diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2')
158 files changed, 0 insertions, 18744 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java deleted file mode 100644 index 69240f1d5e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaAnnotationDefinitionProvider.java +++ /dev/null @@ -1,176 +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.core.internal.jpa2; - -import java.util.List; -import org.eclipse.jpt.core.JpaAnnotationDefinitionProvider; -import org.eclipse.jpt.core.internal.AbstractJpaAnnotationDefintionProvider; -import org.eclipse.jpt.core.internal.jpa2.resource.java.Access2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.AssociationOverride2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.AssociationOverrides2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.Cacheable2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.CollectionTable2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.ElementCollection2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapKeyClass2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapKeyColumn2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapKeyEnumerated2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapKeyJoinColumn2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapKeyJoinColumns2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapKeyTemporal2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.MapsId2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.NamedQueries2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.NamedQuery2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.OrderColumn2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.jpa2.resource.java.SequenceGenerator2_0AnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.AttributeOverrideAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.AttributeOverridesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.BasicAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.ColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.DiscriminatorColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.DiscriminatorValueAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EmbeddableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EmbeddedAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EmbeddedIdAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EntityAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.EnumeratedAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.GeneratedValueAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.IdAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.IdClassAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.InheritanceAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.JoinColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.JoinColumnsAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.JoinTableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.LobAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.ManyToManyAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.ManyToOneAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.MapKeyAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.MappedSuperclassAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueriesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.NamedNativeQueryAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.OneToManyAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.OneToOneAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.OrderByAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.PrimaryKeyJoinColumnsAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.SecondaryTableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.SecondaryTablesAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TableAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TableGeneratorAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TemporalAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.TransientAnnotationDefinition; -import org.eclipse.jpt.core.internal.resource.java.VersionAnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; - -/** - * Support for existing JPA 1.0 annotations, new JPA 2.0 annotations, and - * augmented support for annotations changed from 1.0 to 2.0 - */ -public class Generic2_0JpaAnnotationDefinitionProvider - extends AbstractJpaAnnotationDefintionProvider -{ - // singleton - private static final JpaAnnotationDefinitionProvider INSTANCE = - new Generic2_0JpaAnnotationDefinitionProvider(); - - - /** - * Return the singleton - */ - public static JpaAnnotationDefinitionProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private Generic2_0JpaAnnotationDefinitionProvider() { - super(); - } - - - @Override - protected void addTypeAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(Access2_0AnnotationDefinition.instance()); - definitions.add(AssociationOverride2_0AnnotationDefinition.instance()); - definitions.add(AssociationOverrides2_0AnnotationDefinition.instance()); - definitions.add(AttributeOverrideAnnotationDefinition.instance()); - definitions.add(AttributeOverridesAnnotationDefinition.instance()); - definitions.add(Cacheable2_0AnnotationDefinition.instance()); - definitions.add(DiscriminatorColumnAnnotationDefinition.instance()); - definitions.add(DiscriminatorValueAnnotationDefinition.instance()); - definitions.add(EmbeddableAnnotationDefinition.instance()); - definitions.add(EntityAnnotationDefinition.instance()); - definitions.add(IdClassAnnotationDefinition.instance()); - definitions.add(InheritanceAnnotationDefinition.instance()); - definitions.add(MappedSuperclassAnnotationDefinition.instance()); - definitions.add(NamedQuery2_0AnnotationDefinition.instance()); - definitions.add(NamedQueries2_0AnnotationDefinition.instance()); - definitions.add(NamedNativeQueryAnnotationDefinition.instance()); - definitions.add(NamedNativeQueriesAnnotationDefinition.instance()); - definitions.add(PrimaryKeyJoinColumnAnnotationDefinition.instance()); - definitions.add(PrimaryKeyJoinColumnsAnnotationDefinition.instance()); - definitions.add(SecondaryTableAnnotationDefinition.instance()); - definitions.add(SecondaryTablesAnnotationDefinition.instance()); - definitions.add(SequenceGenerator2_0AnnotationDefinition.instance()); - definitions.add(TableAnnotationDefinition.instance()); - definitions.add(TableGeneratorAnnotationDefinition.instance()); - } - - @Override - protected void addTypeMappingAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(EmbeddableAnnotationDefinition.instance()); - definitions.add(EntityAnnotationDefinition.instance()); - definitions.add(MappedSuperclassAnnotationDefinition.instance()); - } - - @Override - protected void addAttributeAnnotationDefinitionsTo(List<AnnotationDefinition> definitions) { - definitions.add(Access2_0AnnotationDefinition.instance()); - definitions.add(AssociationOverride2_0AnnotationDefinition.instance()); - definitions.add(AssociationOverrides2_0AnnotationDefinition.instance()); - definitions.add(AttributeOverrideAnnotationDefinition.instance()); - definitions.add(AttributeOverridesAnnotationDefinition.instance()); - definitions.add(BasicAnnotationDefinition.instance()); - definitions.add(CollectionTable2_0AnnotationDefinition.instance()); - definitions.add(ColumnAnnotationDefinition.instance()); - definitions.add(ElementCollection2_0AnnotationDefinition.instance()); - definitions.add(EmbeddedAnnotationDefinition.instance()); - definitions.add(EmbeddedIdAnnotationDefinition.instance()); - definitions.add(EnumeratedAnnotationDefinition.instance()); - definitions.add(GeneratedValueAnnotationDefinition.instance()); - definitions.add(IdAnnotationDefinition.instance()); - definitions.add(JoinColumnAnnotationDefinition.instance()); - definitions.add(JoinColumnsAnnotationDefinition.instance()); - definitions.add(JoinTableAnnotationDefinition.instance()); - definitions.add(LobAnnotationDefinition.instance()); - definitions.add(ManyToManyAnnotationDefinition.instance()); - definitions.add(ManyToOneAnnotationDefinition.instance()); - definitions.add(MapsId2_0AnnotationDefinition.instance()); - definitions.add(MapKeyAnnotationDefinition.instance()); - definitions.add(MapKeyClass2_0AnnotationDefinition.instance()); - definitions.add(MapKeyColumn2_0AnnotationDefinition.instance()); - definitions.add(MapKeyEnumerated2_0AnnotationDefinition.instance()); - definitions.add(MapKeyJoinColumn2_0AnnotationDefinition.instance()); - definitions.add(MapKeyJoinColumns2_0AnnotationDefinition.instance()); - definitions.add(MapKeyTemporal2_0AnnotationDefinition.instance()); - definitions.add(OneToManyAnnotationDefinition.instance()); - definitions.add(OneToOneAnnotationDefinition.instance()); - definitions.add(OrderByAnnotationDefinition.instance()); - definitions.add(OrderColumn2_0AnnotationDefinition.instance()); - definitions.add(PrimaryKeyJoinColumnAnnotationDefinition.instance()); - definitions.add(PrimaryKeyJoinColumnsAnnotationDefinition.instance()); - definitions.add(SequenceGenerator2_0AnnotationDefinition.instance()); - definitions.add(TableGeneratorAnnotationDefinition.instance()); - definitions.add(TemporalAnnotationDefinition.instance()); - definitions.add(TransientAnnotationDefinition.instance()); - definitions.add(VersionAnnotationDefinition.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformFactory.java deleted file mode 100644 index d3f3bf9a9f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformFactory.java +++ /dev/null @@ -1,60 +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.core.internal.jpa2; - -import org.eclipse.jpt.core.JpaFacet; -import org.eclipse.jpt.core.JpaPlatform; -import org.eclipse.jpt.core.JpaPlatformFactory; -import org.eclipse.jpt.core.JpaPlatformVariation; -import org.eclipse.jpt.core.internal.GenericJpaAnnotationProvider; -import org.eclipse.jpt.core.internal.GenericJpaPlatform; -import org.eclipse.jpt.core.internal.GenericJpaPlatformFactory.SimpleVersion; - -/** - * All the state in the JPA platform should be "static" (i.e. unchanging once - * it is initialized). - */ -public class Generic2_0JpaPlatformFactory - implements JpaPlatformFactory -{ - /** - * zero-argument constructor - */ - public Generic2_0JpaPlatformFactory() { - super(); - } - - - public JpaPlatform buildJpaPlatform(String id) { - return new GenericJpaPlatform( - id, - this.buildJpaVersion(), - new GenericJpaFactory2_0(), - new GenericJpaAnnotationProvider(Generic2_0JpaAnnotationDefinitionProvider.instance()), - Generic2_0JpaPlatformProvider.instance(), - this.buildJpaPlatformVariation()); - } - - private JpaPlatform.Version buildJpaVersion() { - return new SimpleVersion(JpaFacet.VERSION_2_0.getVersionString()); - } - - protected JpaPlatformVariation buildJpaPlatformVariation() { - return new JpaPlatformVariation() { - //table_per_class inheritance support is optional in the 2.0 spec - public Supported getTablePerConcreteClassInheritanceIsSupported() { - return Supported.MAYBE; - } - public boolean isJoinTableOverridable() { - return true; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java deleted file mode 100644 index fba0cd6952..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/Generic2_0JpaPlatformProvider.java +++ /dev/null @@ -1,153 +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.core.internal.jpa2; - -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.jpt.core.JpaPlatformProvider; -import org.eclipse.jpt.core.JpaResourceModelProvider; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.ResourceDefinition; -import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition; -import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition; -import org.eclipse.jpt.core.internal.AbstractJpaPlatformProvider; -import org.eclipse.jpt.core.internal.JarResourceModelProvider; -import org.eclipse.jpt.core.internal.JavaResourceModelProvider; -import org.eclipse.jpt.core.internal.OrmResourceModelProvider; -import org.eclipse.jpt.core.internal.PersistenceResourceModelProvider; -import org.eclipse.jpt.core.internal.context.java.JavaBasicMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaEmbeddableDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaEmbeddedIdMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaEmbeddedMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaEntityDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaManyToManyMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaManyToOneMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaMappedSuperclassDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaOneToManyMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaOneToOneMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaTransientMappingDefinition; -import org.eclipse.jpt.core.internal.context.java.JavaVersionMappingDefinition; -import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmXmlDefinition; -import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericPersistenceXmlDefinition; -import org.eclipse.jpt.core.internal.jpa2.context.java.JavaElementCollectionMappingDefinition2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.JavaIdMappingDefinition2_0; -import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmXml2_0Definition; -import org.eclipse.jpt.core.internal.jpa2.context.persistence.Generic2_0PersistenceXmlDefinition; - -/** - * All the state in the JPA platform should be "static" (i.e. unchanging once - * it is initialized). - */ -public class Generic2_0JpaPlatformProvider - extends AbstractJpaPlatformProvider -{ - // singleton - private static final JpaPlatformProvider INSTANCE = - new Generic2_0JpaPlatformProvider(); - - - /** - * Return the singleton - */ - public static JpaPlatformProvider instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private Generic2_0JpaPlatformProvider() { - super(); - } - - - // ********** resource models ********** - - public JpaResourceType getMostRecentSupportedResourceType(IContentType contentType) { - if (contentType.equals(JptCorePlugin.JAVA_SOURCE_CONTENT_TYPE)) { - return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE; - } - else if (contentType.equals(JptCorePlugin.JAR_CONTENT_TYPE)) { - return JptCorePlugin.JAR_RESOURCE_TYPE; - } - else if (contentType.equals(JptCorePlugin.PERSISTENCE_XML_CONTENT_TYPE)) { - return JptCorePlugin.PERSISTENCE_XML_2_0_RESOURCE_TYPE; - } - else if (contentType.equals(JptCorePlugin.ORM_XML_CONTENT_TYPE)) { - return JptCorePlugin.ORM_XML_2_0_RESOURCE_TYPE; - } - else { - throw new IllegalArgumentException(contentType.toString()); - } - } - - @Override - protected JpaResourceModelProvider[] buildResourceModelProviders() { - // order should not be important here - return new JpaResourceModelProvider[] { - JavaResourceModelProvider.instance(), - JarResourceModelProvider.instance(), - PersistenceResourceModelProvider.instance(), - OrmResourceModelProvider.instance()}; - } - - - // ********** Java type mappings ********** - - @Override - protected JavaTypeMappingDefinition[] buildNonNullJavaTypeMappingDefinitions() { - // order determined by analyzing order that reference implementation (eclipselink) uses - return new JavaTypeMappingDefinition[] { - JavaEntityDefinition.instance(), - JavaEmbeddableDefinition.instance(), - JavaMappedSuperclassDefinition.instance()}; - } - - - // ********** Java attribute mappings ********** - - @Override - protected JavaAttributeMappingDefinition[] buildNonNullDefaultJavaAttributeMappingDefinitions() { - // order determined by analyzing order that reference implementation (eclipselink) uses - return new JavaAttributeMappingDefinition[] { - JavaEmbeddedMappingDefinition.instance(), - JavaBasicMappingDefinition.instance()}; - } - - @Override - protected JavaAttributeMappingDefinition[] buildNonNullSpecifiedJavaAttributeMappingDefinitions() { - // order determined by analyzing order that reference implementation (eclipselink) uses - return new JavaAttributeMappingDefinition[] { - JavaTransientMappingDefinition.instance(), - JavaElementCollectionMappingDefinition2_0.instance(), - JavaIdMappingDefinition2_0.instance(), - JavaVersionMappingDefinition.instance(), - JavaBasicMappingDefinition.instance(), - JavaEmbeddedMappingDefinition.instance(), - JavaEmbeddedIdMappingDefinition.instance(), - JavaManyToManyMappingDefinition.instance(), - JavaManyToOneMappingDefinition.instance(), - JavaOneToManyMappingDefinition.instance(), - JavaOneToOneMappingDefinition.instance()}; - } - - - // ********** Mapping Files ********** - - @Override - protected ResourceDefinition[] buildResourceDefinitions() { - return new ResourceDefinition[] { - GenericPersistenceXmlDefinition.instance(), - Generic2_0PersistenceXmlDefinition.instance(), - GenericOrmXmlDefinition.instance(), - GenericOrmXml2_0Definition.instance()}; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java deleted file mode 100644 index 726704938b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaDatabaseIdentifierAdapter.java +++ /dev/null @@ -1,80 +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.core.internal.jpa2; - -import java.util.Iterator; - -import org.eclipse.jpt.core.JpaDataSource; -import org.eclipse.jpt.core.context.JpaRootContextNode; -import org.eclipse.jpt.core.context.persistence.Persistence; -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.context.persistence.PersistenceXml; -import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.db.DatabaseIdentifierAdapter; - -/** - * Conversions are determined by the <code>delimited-identifiers</code> - * flag in <code>orm.xml</code>. - * <p> - * Assume we are in a JPA 2.0-compatible project. - */ -public class GenericJpaDatabaseIdentifierAdapter - implements DatabaseIdentifierAdapter -{ - private final JpaDataSource dataSource; - - public GenericJpaDatabaseIdentifierAdapter(JpaDataSource dataSource) { - super(); - this.dataSource = dataSource; - } - - /** - * If the flag is set, "identifiers" are treated as "names". - */ - public String convertIdentifierToName(String identifier, DefaultCallback defaultCallback) { - return this.getDefaultDelimitedIdentifiers() ? identifier : defaultCallback.convertIdentifierToName(identifier); - } - - /** - * If the flag is set, "names" are treated as "identifiers". - */ - public String convertNameToIdentifier(String name, DefaultCallback defaultCallback) { - return this.getDefaultDelimitedIdentifiers() ? name : defaultCallback.convertNameToIdentifier(name); - } - - protected boolean getDefaultDelimitedIdentifiers() { - PersistenceUnit2_0 pu = this.getPersistenceUnit(); - return (pu != null) && pu.getDefaultDelimitedIdentifiers(); - } - - protected PersistenceUnit2_0 getPersistenceUnit() { - Persistence p = this.getPersistence(); - if (p == null) { - return null; - } - Iterator<PersistenceUnit> units = this.getPersistence().persistenceUnits(); - return (PersistenceUnit2_0) (units.hasNext() ? units.next() : null); - } - - protected Persistence getPersistence() { - PersistenceXml pxml = this.getPersistenceXml(); - return (pxml == null) ? null : pxml.getPersistence(); - } - - protected PersistenceXml getPersistenceXml() { - // TODO this null check can be removed if the data source is moved to the persistence unit; - // the root context node can be null during construction; - // this shouldn't be a problem since the default-delimiters flag - // is recalculated during the initial, post-project construction, "update" - JpaRootContextNode rcn = this.dataSource.getJpaProject().getRootContextNode(); - return (rcn == null) ? null : rcn.getPersistenceXml(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java deleted file mode 100644 index b9ce8bf3b5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericJpaFactory2_0.java +++ /dev/null @@ -1,191 +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.core.internal.jpa2; - -import org.eclipse.jpt.core.JpaProject; -import org.eclipse.jpt.core.JpaProject.Config; -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer; -import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference; -import org.eclipse.jpt.core.context.java.JavaBaseColumn.Owner; -import org.eclipse.jpt.core.context.java.JavaColumn; -import org.eclipse.jpt.core.context.java.JavaEmbeddable; -import org.eclipse.jpt.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.core.context.java.JavaNamedColumn; -import org.eclipse.jpt.core.context.java.JavaNamedQuery; -import org.eclipse.jpt.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.context.java.JavaPersistentType; -import org.eclipse.jpt.core.context.java.JavaSequenceGenerator; -import org.eclipse.jpt.core.internal.AbstractJpaFactory; -import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaAssociationOverrideContainer; -import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaColumn; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaAssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaCacheable2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaCollectionTable2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaDerivedIdentity2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaEmbeddable2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaManyToOneMapping2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaNamedQuery2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaOneToManyMapping2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaOneToOneMapping2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaOrderColumn2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaOrphanRemoval2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaPersistentAttribute2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaPersistentType2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaSequenceGenerator2_0; -import org.eclipse.jpt.core.internal.jpa2.context.java.VirtualAssociationOverride2_0Annotation; -import org.eclipse.jpt.core.jpa2.JpaProject2_0; -import org.eclipse.jpt.core.jpa2.context.MetamodelSourceType; -import org.eclipse.jpt.core.jpa2.context.java.JavaCacheable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaEmbeddedMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrderColumn2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrderable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - - -/** - * Central class that allows extenders to easily replace implementations of - * various Dali interfaces. - */ -public class GenericJpaFactory2_0 - extends AbstractJpaFactory -{ - - public GenericJpaFactory2_0() { - super(); - } - - // ********** Core Model ********** - - @Override - public JpaProject buildJpaProject(Config config) { - if ( ! (config instanceof JpaProject2_0.Config)) { - throw new IllegalArgumentException("config must be 2.0-compatible: " + config); //$NON-NLS-1$ - } - return super.buildJpaProject(config); - } - - @Override - public MetamodelSourceType.Synchronizer buildMetamodelSynchronizer(MetamodelSourceType sourceType) { - return new GenericMetamodelSynchronizer(sourceType); - } - - - // ********** Java Context Model ********** - - @Override - public JavaPersistentType buildJavaPersistentType(PersistentType.Owner owner, JavaResourcePersistentType jrpt) { - return new GenericJavaPersistentType2_0(owner, jrpt); - } - - @Override - public JavaPersistentAttribute buildJavaPersistentAttribute(PersistentType parent, JavaResourcePersistentAttribute jrpa) { - return new GenericJavaPersistentAttribute2_0(parent, jrpa); - } - - @Override - public JavaEmbeddable buildJavaEmbeddable(JavaPersistentType parent) { - return new GenericJavaEmbeddable2_0(parent); - } - - @Override - public JavaSequenceGenerator buildJavaSequenceGenerator(JavaJpaContextNode parent) { - return new GenericJavaSequenceGenerator2_0(parent); - } - - //The 2.0 JPA spec supports association overrides on an embedded mapping while the 1.0 spec did not - @Override - public JavaAssociationOverrideContainer buildJavaAssociationOverrideContainer(JavaEmbeddedMapping2_0 parent, JavaAssociationOverrideContainer.Owner owner) { - return new GenericJavaAssociationOverrideContainer(parent, owner); - } - - @Override - public JavaAssociationOverrideRelationshipReference buildJavaAssociationOverrideRelationshipReference(JavaAssociationOverride parent) { - return new GenericJavaAssociationOverrideRelationshipReference2_0(parent); - } - - @Override - public AssociationOverrideAnnotation buildJavaVirtualAssociationOverrideAnnotation(JavaResourcePersistentMember jrpm, String name, JoiningStrategy joiningStrategy) { - return new VirtualAssociationOverride2_0Annotation(jrpm, name, joiningStrategy); - } - - @Override - public JavaDerivedIdentity2_0 buildJavaDerivedIdentity(JavaSingleRelationshipMapping2_0 parent) { - return new GenericJavaDerivedIdentity2_0(parent); - } - - @Override - public JavaElementCollectionMapping2_0 buildJavaElementCollectionMapping2_0(JavaPersistentAttribute parent) { - return new GenericJavaElementCollectionMapping2_0(parent); - } - - @Override - public JavaCacheable2_0 buildJavaCacheable(JavaCacheableHolder2_0 parent) { - return new GenericJavaCacheable2_0(parent); - } - - @Override - public JavaOrphanRemovable2_0 buildJavaOrphanRemoval(JavaOrphanRemovalHolder2_0 parent) { - return new GenericJavaOrphanRemoval2_0(parent); - } - - @Override - public JavaNamedQuery buildJavaNamedQuery(JavaJpaContextNode parent) { - return new GenericJavaNamedQuery2_0(parent); - } - - @Override - public JavaCollectionTable2_0 buildJavaCollectionTable(JavaElementCollectionMapping2_0 parent, Table.Owner owner) { - return new GenericJavaCollectionTable2_0(parent, owner); - } - - @Override - public JavaOrderColumn2_0 buildJavaOrderColumn(JavaOrderable2_0 parent, JavaNamedColumn.Owner owner) { - return new GenericJavaOrderColumn2_0(parent, owner); - } - - @Override - public JavaColumn buildJavaMapKeyColumn(JavaJpaContextNode parent, Owner owner) { - return new GenericJavaColumn(parent, owner); - } - - @Override - public JavaManyToOneMapping buildJavaManyToOneMapping(JavaPersistentAttribute parent) { - return new GenericJavaManyToOneMapping2_0(parent); - } - - @Override - public JavaOneToManyMapping buildJavaOneToManyMapping(JavaPersistentAttribute parent) { - return new GenericJavaOneToManyMapping2_0(parent); - } - - @Override - public JavaOneToOneMapping buildJavaOneToOneMapping(JavaPersistentAttribute parent) { - return new GenericJavaOneToOneMapping2_0(parent); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericMetamodelSynchronizer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericMetamodelSynchronizer.java deleted file mode 100644 index 8dc8d64205..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/GenericMetamodelSynchronizer.java +++ /dev/null @@ -1,432 +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.core.internal.jpa2; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Collection; -import java.util.Date; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IPackageFragmentRoot; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.jpa2.JpaProject2_0; -import org.eclipse.jpt.core.jpa2.context.AttributeMapping2_0; -import org.eclipse.jpt.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.core.jpa2.context.MetamodelSourceType; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.JavaResourcePersistentType2_0; -import org.eclipse.jpt.core.utility.BodySourceWriter; -import org.eclipse.jpt.utility.internal.ClassName; -import org.eclipse.jpt.utility.internal.SimpleStack; -import org.eclipse.jpt.utility.internal.StringTools; - -import com.ibm.icu.text.DateFormat; -import com.ibm.icu.text.SimpleDateFormat; - -/** - * For now, the "synchronization" is simple brute-force: we generate the source - * code and then compare it with what is already present in the file. - * If the new source is different, we replace the file contents; otherwise, we - * leave the file unchanged. - */ -@SuppressWarnings("nls") -public class GenericMetamodelSynchronizer - implements MetamodelSourceType.Synchronizer -{ - protected final MetamodelSourceType sourceType; - - - public GenericMetamodelSynchronizer(MetamodelSourceType sourceType) { - super(); - this.sourceType = sourceType; - } - - public IFile getFile() { - return (IFile) this.getPackageFragment().getCompilationUnit(this.getFileName()).getResource(); - } - - - // ********** synchronize ********** - - public void synchronize(Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - try { - this.synchronize_(memberTypeTree); - } catch (JavaModelException ex) { - JptCorePlugin.log(ex); - } - } - - protected void synchronize_(Map<String, Collection<MetamodelSourceType>> memberTypeTree) throws JavaModelException { - IPackageFragment pkg = this.getPackageFragment(); - String fileName = this.getFileName(); - - ICompilationUnit compilationUnit = pkg.getCompilationUnit(fileName); - if (compilationUnit.exists()) { - // overwrite existing file if it has changed (ignoring the timestamp) - String newSource = this.buildSource(compilationUnit, memberTypeTree); - if (newSource != null) { - pkg.createCompilationUnit(fileName, newSource, true, null); // true=force - } - } else { - // write a new file, creating the package folders if necessary - if ( ! pkg.exists()) { - this.getSourceFolder().createPackageFragment(pkg.getElementName(), true, null); // true=force - } - pkg.createCompilationUnit(fileName, this.buildSource(memberTypeTree), false, null); // false=no force - } - } - - /** - * pre-condition: the compilation unit exists - * - * return null if the old source is not to be replaced - */ - protected String buildSource(ICompilationUnit compilationUnit, Map<String, Collection<MetamodelSourceType>> memberTypeTree) throws JavaModelException { - IFile file = (IFile) compilationUnit.getResource(); - JavaResourcePersistentType2_0 genType = this.getJpaProject().getGeneratedMetamodelTopLevelType(file); - if (genType == null) { - return null; // the file exists, but its source is not a generated metamodel top-level class - } - - String oldSource = compilationUnit.getSource(); - int oldLength = oldSource.length(); - - String newSource = this.buildSource(memberTypeTree); - int newLength = newSource.length(); - if (newLength != oldLength) { - return newSource; - } - - String date = genType.getGeneratedAnnotation().getDate(); // if we get here, this will be non-empty - int dateBegin = oldSource.indexOf(date); - if (dateBegin == -1) { - return null; // hmmm... - } - int dateEnd = dateBegin + date.length(); - if (dateEnd > oldLength) { - return null; // hmmm... - } - - if (newSource.regionMatches(0, oldSource, 0, dateBegin) && - newSource.regionMatches(dateEnd, oldSource, dateEnd, oldLength - dateEnd)) { - return null; - } - return newSource; - } - - - // ********** package/file ********** - - protected IPackageFragment getPackageFragment() { - return this.getSourceFolder().getPackageFragment(this.getPackageName()); - } - - protected IPackageFragmentRoot getSourceFolder() { - return this.getJpaProject().getMetamodelPackageFragmentRoot(); - } - - protected JpaProject2_0 getJpaProject() { - return (JpaProject2_0) this.sourceType.getJpaProject(); - } - - protected String getPackageName() { - return this.buildPackageName(this.sourceType.getName()); - } - - protected String buildPackageName(String topLevelSourceTypeName) { - return this.buildPackageName_(ClassName.getPackageName(topLevelSourceTypeName)); - } - - // TODO - protected String buildPackageName_(String sourcePackageName) { - // the default is to store the metamodel class in the same package as the source type - return sourcePackageName; - } - - protected String getFileName() { - return ClassName.getSimpleName(this.getClassName()) + ".java"; - } - - protected String getClassName() { - return this.buildClassName(this.sourceType.getName()); - } - - protected String buildClassName(Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - return this.buildClassName(this.sourceType.getName(), memberTypeTree); - } - - protected String buildClassName(String sourceTypeName, Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - String current = sourceTypeName; - SimpleStack<String> stack = new SimpleStack<String>(); - - while (true) { - stack.push(ClassName.getSimpleName(current)); - String declaringTypeName = this.getDeclaringTypeName(current, memberTypeTree); - if (declaringTypeName == null) { - break; - } - current = declaringTypeName; - } - - StringBuilder sb = new StringBuilder(sourceTypeName.length() + 10); - sb.append(this.buildPackageName(current)); - while ( ! stack.isEmpty()) { - sb.append('.'); - sb.append(this.buildSimpleClassName(stack.pop())); - } - return sb.toString(); - } - - protected String buildClassName(String topLevelSourceTypeName) { - return this.buildPackageName(topLevelSourceTypeName) + '.' + this.buildSimpleClassName(ClassName.getSimpleName(topLevelSourceTypeName)); - } - - protected String getSimpleClassName() { - return this.buildSimpleClassName(ClassName.getSimpleName(this.sourceType.getName())); - } - - // TODO - protected String buildSimpleClassName(String simpleSourceTypeName) { - // the default is to simply append an underscore to the source type name - return simpleSourceTypeName + '_'; - } - - - // ********** source code ********** - - /** - * build the "body" source first; then build the "package" and "imports" source - * and concatenate the "body" source to it - */ - protected String buildSource(Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - // build the body source first so we can gather up the import statements - BodySourceWriter bodySourceWriter = this.buildBodySourceWriter(memberTypeTree); - - StringWriter sw = new StringWriter(bodySourceWriter.getLength() + 2000); - PrintWriter pw = new PrintWriter(sw); - this.printPackageAndImportsOn(pw, bodySourceWriter); - pw.print(bodySourceWriter.getSource()); - return sw.toString(); - } - - protected BodySourceWriter buildBodySourceWriter(Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - BodySourceWriter pw = new BodySourceWriter(this.getPackageName(), this.getClassName()); - this.printBodySourceOn(pw, memberTypeTree); - return pw; - } - - public void printBodySourceOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - this.printClassDeclarationOn(pw, memberTypeTree); - pw.print(" {"); - pw.println(); - - pw.indent(); - boolean attributesPrinted = this.printAttributesOn(pw); - this.printMemberTypesOn(pw, memberTypeTree, attributesPrinted); - pw.undent(); - - pw.print('}'); - pw.println(); // EOF - } - - - // ********** class declaration ********** - - protected void printClassDeclarationOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - boolean topLevel = this.sourceTypeIsTopLevel(memberTypeTree); - if (topLevel) { - this.printGeneratedAnnotationOn(pw); - } - if (this.sourceType.isManaged()) { - this.printStaticMetamodelAnnotationOn(pw); - } - - pw.print("public "); - if ( ! topLevel) { - pw.print("static "); - } - pw.print("class "); - pw.print(this.getSimpleClassName()); // this is always the simple name - PersistentType superPersistentType = this.sourceType.getSuperPersistentType(); - if (superPersistentType != null) { - pw.print(" extends "); - pw.printTypeDeclaration(this.buildClassName(superPersistentType.getName(), memberTypeTree)); - } - } - - /** - * Return whether the source type is a top level type. - * This can be inferred from the specified member type tree. - */ - protected boolean sourceTypeIsTopLevel(Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - return this.sourceTypeIsTopLevel(this.sourceType.getName(), memberTypeTree); - } - - /** - * Return whether the specified source type is a top level type. - * This can be inferred from the specified member type tree. - */ - protected boolean sourceTypeIsTopLevel(String sourceTypeName, Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - return this.getDeclaringTypeName(sourceTypeName, memberTypeTree) == null; - } - - /** - * Return the name of the specified source type's declaring type, as - * implied by the specified member type tree. Return null if the source - * type is a top-level type. - */ - protected String getDeclaringTypeName(String sourceTypeName, Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - int lastPeriod = sourceTypeName.lastIndexOf('.'); - if (lastPeriod == -1) { - return null; // default package top-level type - } - String declaringTypeName = sourceTypeName.substring(0, lastPeriod); - return (memberTypeTree.get(declaringTypeName) == null) ? null : declaringTypeName; - } - - protected void printGeneratedAnnotationOn(BodySourceWriter pw) { - pw.printAnnotation("javax.annotation.Generated"); - pw.print('('); - pw.print("value="); - pw.printStringLiteral(JavaResourcePersistentType2_0.METAMODEL_GENERATED_ANNOTATION_VALUE); - pw.print(", "); - pw.print("date="); - pw.printStringLiteral(format(new Date())); - pw.print(')'); - pw.println(); - } - - protected void printStaticMetamodelAnnotationOn(BodySourceWriter pw) { - pw.printAnnotation(JPA2_0.STATIC_METAMODEL); - pw.print('('); - pw.printTypeDeclaration(this.sourceType.getName()); - pw.print(".class"); - pw.print(')'); - pw.println(); - } - - /** - * {@link SimpleDateFormat} is not thread-safe. - */ - protected static synchronized String format(Date date) { - return DATE_FORMAT.format(date); - } - /** - * Recommended date format is ISO 8601. - * @see javax.annotation.Generated - */ - private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); - - - // ********** attributes ********** - - /** - * Return whether any attributes were printed. - */ - protected boolean printAttributesOn(BodySourceWriter pw) { - boolean printed = false; - for (Iterator<PersistentAttribute> stream = this.sourceType.attributes(); stream.hasNext(); ) { - this.printAttributeOn(stream.next(), pw); - printed = true; - } - return printed; - } - - protected void printAttributeOn(PersistentAttribute persistentAttribute, BodySourceWriter pw) { - AttributeMapping attributeMapping = persistentAttribute.getMapping(); - if (attributeMapping != null) { // probably shouldn't be null? - this.printAttributeMappingOn(attributeMapping, pw); - } - } - - protected void printAttributeMappingOn(AttributeMapping attributeMapping, BodySourceWriter pw) { - MetamodelField field = ((AttributeMapping2_0) attributeMapping).getMetamodelField(); - if (field != null) { - this.printFieldOn(field, pw); - } - } - - protected void printFieldOn(MetamodelField field, BodySourceWriter pw) { - for (String modifier : field.getModifiers()) { - pw.print(modifier); - pw.print(' '); - } - pw.printTypeDeclaration(field.getTypeName()); - pw.print('<'); - for (Iterator<String> stream = field.getTypeArgumentNames().iterator(); stream.hasNext(); ) { - pw.printTypeDeclaration(stream.next()); - if (stream.hasNext()) { - pw.print(", "); - } - } - pw.print('>'); - pw.print(' '); - pw.print(field.getName()); - pw.print(';'); - pw.println(); - } - - - // ********** member types ********** - - protected void printMemberTypesOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType>> memberTypeTree, boolean attributesPrinted) { - Collection<MetamodelSourceType> memberTypes = memberTypeTree.get(this.sourceType.getName()); - if (memberTypes != null) { - if (attributesPrinted) { - pw.println(); - } - for (Iterator<MetamodelSourceType> stream = memberTypes.iterator(); stream.hasNext(); ) { - stream.next().printBodySourceOn(pw, memberTypeTree); - if (stream.hasNext()) { - pw.println(); - } - } - } - } - - - // ********** package and imports ********** - - protected void printPackageAndImportsOn(PrintWriter pw, BodySourceWriter bodySourceWriter) { - if (this.getPackageName().length() != 0) { - pw.print("package "); - pw.print(this.getPackageName()); - pw.print(';'); - pw.println(); - pw.println(); - } - - for (String import_ : bodySourceWriter.getImports()) { - pw.print("import "); - pw.print(import_); - pw.print(';'); - pw.println(); - } - pw.println(); - } - - - // ********** misc ********** - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.sourceType.getName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/CollectionTableValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/CollectionTableValidator.java deleted file mode 100644 index cdbe70b90a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/CollectionTableValidator.java +++ /dev/null @@ -1,57 +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.core.internal.jpa2.context; - -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.core.internal.jpa1.context.AbstractTableValidator; -import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.jpa2.context.CollectionTable2_0; - -public class CollectionTableValidator extends AbstractTableValidator -{ - public CollectionTableValidator(CollectionTable2_0 table, TableTextRangeResolver textRangeResolver) { - super(table, textRangeResolver); - } - - public CollectionTableValidator(PersistentAttribute persistentAttribute, CollectionTable2_0 table, TableTextRangeResolver textRangeResolver) { - super(persistentAttribute, table, textRangeResolver); - } - - @Override - protected String getUnresolvedCatalogMessage() { - return JpaValidationMessages.COLLECTION_TABLE_UNRESOLVED_CATALOG; - } - - @Override - protected String getVirtualAttributeUnresolvedCatalogMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_CATALOG; - } - - @Override - protected String getUnresolvedSchemaMessage() { - return JpaValidationMessages.COLLECTION_TABLE_UNRESOLVED_SCHEMA; - } - - @Override - protected String getVirtualAttributeUnresolvedSchemaMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_SCHEMA; - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.COLLECTION_TABLE_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_COLLECTION_TABLE_UNRESOLVED_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/OrderColumnValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/OrderColumnValidator.java deleted file mode 100644 index 0a967fc06f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/OrderColumnValidator.java +++ /dev/null @@ -1,43 +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.core.internal.jpa2.context; - -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.jpa1.context.AbstractNamedColumnValidator; -import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.jpa2.context.OrderColumn2_0; - -public class OrderColumnValidator extends AbstractNamedColumnValidator -{ - public OrderColumnValidator( - OrderColumn2_0 column, - NamedColumnTextRangeResolver textRangeResolver) { - super(column, textRangeResolver); - } - - public OrderColumnValidator( - PersistentAttribute persistentAttribute, - OrderColumn2_0 column, - NamedColumnTextRangeResolver textRangeResolver) { - super(persistentAttribute, column, textRangeResolver); - } - - @Override - protected String getUnresolvedNameMessage() { - return JpaValidationMessages.ORDER_COLUMN_UNRESOLVED_NAME; - } - - @Override - protected String getVirtualAttributeUnresolvedNameMessage() { - return JpaValidationMessages.VIRTUAL_ATTRIBUTE_ORDER_COLUMN_UNRESOLVED_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/SimpleMetamodelField.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/SimpleMetamodelField.java deleted file mode 100644 index 4615c38895..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/SimpleMetamodelField.java +++ /dev/null @@ -1,107 +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.core.internal.jpa2.context; - -import org.eclipse.jpt.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * Straightforward implementation. - */ -public class SimpleMetamodelField - implements MetamodelField -{ - protected final Iterable<String> modifiers; - protected final String typeName; - protected final Iterable<String> typeArgumentNames; - protected final String name; - - public SimpleMetamodelField( - Iterable<String> modifiers, - String typeName, - Iterable<String> typeArgumentNames, - String name - ) { - super(); - if (modifiers == null) { - throw new NullPointerException(); - } - if (typeName == null) { - throw new NullPointerException(); - } - if (typeArgumentNames == null) { - throw new NullPointerException(); - } - if (name == null) { - throw new NullPointerException(); - } - this.modifiers = modifiers; - this.typeName = typeName; - this.typeArgumentNames = typeArgumentNames; - this.name = name; - } - - public Iterable<String> getModifiers() { - return this.modifiers; - } - - public String getTypeName() { - return this.typeName; - } - - public Iterable<String> getTypeArgumentNames() { - return this.typeArgumentNames; - } - - public String getName() { - return this.name; - } - - @Override - public int hashCode() { - return CollectionTools.hashCode(this.modifiers) ^ - this.typeName.hashCode() ^ - CollectionTools.hashCode(this.typeArgumentNames) ^ - this.name.hashCode(); - } - - @Override - public boolean equals(Object o) { - if ( ! (o instanceof MetamodelField)) { - return false; - } - MetamodelField other = (MetamodelField) o; - return CollectionTools.elementsAreEqual(this.getModifiers(), other.getModifiers()) && - this.getTypeName().equals(other.getTypeName()) && - CollectionTools.elementsAreEqual(this.getTypeArgumentNames(), other.getTypeArgumentNames()) && - this.getName().equals(other.getName()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (String modifier : this.modifiers) { - sb.append(modifier); - sb.append(' '); - } - sb.append(this.typeName); - sb.append('<'); - for (String typeArgumentName : this.typeArgumentNames) { - sb.append(typeArgumentName); - sb.append(", "); //$NON-NLS-1$ - } - sb.setLength(sb.length() - 2); - sb.append('>'); - sb.append(' '); - sb.append(this.name); - return sb.toString(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java deleted file mode 100644 index 3b0a9ebffd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java +++ /dev/null @@ -1,1475 +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.core.internal.jpa2.context.java; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Vector; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AssociationOverride; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.AttributeOverride; -import org.eclipse.jpt.core.context.BaseColumn; -import org.eclipse.jpt.core.context.BaseOverride; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.context.Converter; -import org.eclipse.jpt.core.context.Embeddable; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.FetchType; -import org.eclipse.jpt.core.context.Fetchable; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumn.Owner; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer; -import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer; -import org.eclipse.jpt.core.context.java.JavaBaseColumn; -import org.eclipse.jpt.core.context.java.JavaColumn; -import org.eclipse.jpt.core.context.java.JavaConverter; -import org.eclipse.jpt.core.context.java.JavaOverrideContainer; -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.MappingTools; -import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaAttributeMapping; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator; -import org.eclipse.jpt.core.internal.jpa1.context.CollectionTableTableDescriptionProvider; -import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider; -import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideValidator; -import org.eclipse.jpt.core.internal.jpa1.context.MapKeyColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator; -import org.eclipse.jpt.core.internal.jpa2.context.CollectionTableValidator; -import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.jpa2.JpaFactory2_0; -import org.eclipse.jpt.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.core.jpa2.context.CollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrderable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0; -import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.MapKeyAnnotation; -import org.eclipse.jpt.core.resource.java.TemporalAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - - -public abstract class AbstractJavaElementCollectionMapping2_0 - extends AbstractJavaAttributeMapping<ElementCollection2_0Annotation> - implements JavaElementCollectionMapping2_0 -{ - protected String specifiedTargetClass; - protected String defaultTargetClass; - protected String fullyQualifiedTargetClass; - protected PersistentType resolvedTargetType; - protected Embeddable resolvedTargetEmbeddable; - protected Entity resolvedTargetEntity; - - protected FetchType specifiedFetch; - - protected final JavaOrderable2_0 orderable; - - protected final JavaCollectionTable2_0 collectionTable; - - protected Type valueType; - - protected final JavaColumn valueColumn; - - protected JavaConverter valueConverter; - - protected final JavaConverter nullConverter; - - protected final JavaAttributeOverrideContainer valueAttributeOverrideContainer; - - protected final JavaAssociationOverrideContainer valueAssociationOverrideContainer; - - protected Type keyType; - - //MapKey is not supported by the spec, so this is only for EclipseLink - //In the generic case we can handle this with validation and not showing the UI widgets - protected String specifiedMapKey; - protected boolean noMapKey = false; - protected boolean pkMapKey = false; - protected boolean customMapKey = false; - - protected String specifiedMapKeyClass; - protected String defaultMapKeyClass; - protected String fullyQualifiedMapKeyClass; - protected PersistentType resolvedMapKeyType; - protected Embeddable resolvedMapKeyEmbeddable; - protected Entity resolvedMapKeyEntity; - - protected final JavaColumn mapKeyColumn; - - protected final JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer; - - protected AbstractJavaElementCollectionMapping2_0(JavaPersistentAttribute parent) { - super(parent); - this.orderable = getJpaFactory().buildJavaOrderable(this, buildOrderableOwner()); - this.collectionTable = getJpaFactory().buildJavaCollectionTable(this, new CollectionTableOwner()); - this.valueColumn = getJpaFactory().buildJavaColumn(parent, new ValueColumnOwner()); - this.nullConverter = getJpaFactory().buildJavaNullConverter(this); - this.valueConverter = this.nullConverter; - this.valueAttributeOverrideContainer = this.getJpaFactory().buildJavaAttributeOverrideContainer(this, new ValueAttributeOverrideContainerOwner()); - this.valueAssociationOverrideContainer = this.getJpaFactory().buildJavaAssociationOverrideContainer(this, new ValueAssociationOverrideContainerOwner()); - this.mapKeyColumn = getJpaFactory().buildJavaMapKeyColumn(parent, new MapKeyColumnOwner()); - this.mapKeyAttributeOverrideContainer = this.getJpaFactory().buildJavaAttributeOverrideContainer(this, new MapKeyAttributeOverrideContainerOwner()); - } - - @Override - protected JpaFactory2_0 getJpaFactory() { - return (JpaFactory2_0) super.getJpaFactory(); - } - - @Override - protected void initialize() { - super.initialize(); - this.specifiedFetch = this.getResourceFetch(); - this.orderable.initialize(); - this.defaultTargetClass = this.buildDefaultTargetClass(); - this.specifiedTargetClass = this.getResourceTargetClass(); - this.fullyQualifiedTargetClass = this.buildFullyQualifiedTargetClass(); - this.resolvedTargetType = this.buildResolvedTargetType(); - this.resolvedTargetEmbeddable = this.buildResolvedTargetEmbeddable(); - this.resolvedTargetEntity = this.buildResolvedTargetEntity(); - this.initializeCollectionTable(); - this.initializeValueType(); - this.initializeValueColumn(); - this.initializeValueConverter(); - this.valueAttributeOverrideContainer.initialize(getResourcePersistentAttribute()); - this.valueAssociationOverrideContainer.initialize(getResourcePersistentAttribute()); - this.defaultMapKeyClass = this.buildDefaultMapKeyClass(); - this.specifiedMapKeyClass = this.getResourceMapKeyClass(); - this.fullyQualifiedMapKeyClass = this.buildFullyQualifiedMapKeyClass(); - this.resolvedMapKeyType = this.buildResolvedMapKeyType(); - this.resolvedMapKeyEmbeddable = this.buildResolvedMapKeyEmbeddable(); - this.resolvedMapKeyEntity = this.buildResolvedMapKeyEntity(); - this.initializeKeyType(); - this.initializeMapKey(); - this.initializeMapKeyColumn(); - this.mapKeyAttributeOverrideContainer.initialize(getResourcePersistentAttribute()); - } - - @Override - protected void update() { - super.update(); - this.setSpecifiedFetch_(this.getResourceFetch()); - this.orderable.update(); - this.setDefaultTargetClass(this.buildDefaultTargetClass()); - this.setSpecifiedTargetClass_(this.getResourceTargetClass()); - this.setFullyQualifiedTargetClass(this.buildFullyQualifiedTargetClass()); - this.resolvedTargetType = this.buildResolvedTargetType();//no need for change notification, use resolved target embeddable change notification instead? - this.setResolvedTargetEmbeddable(this.buildResolvedTargetEmbeddable()); - this.updateCollectionTable(); - this.updateValueType(); - this.updateValueColumn(); - this.updateValueConverter(); - this.valueAttributeOverrideContainer.update(getResourcePersistentAttribute()); - this.valueAssociationOverrideContainer.update(getResourcePersistentAttribute()); - this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass()); - this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass()); - this.setFullyQualifiedMapKeyClass(this.buildFullyQualifiedMapKeyClass()); - this.resolvedMapKeyType = this.buildResolvedMapKeyType();//no need for change notification, use resolved target embeddable change notification instead? - this.setResolvedMapKeyEmbeddable(this.buildResolvedMapKeyEmbeddable()); - this.setResolvedMapKeyEntity(this.buildResolvedMapKeyEntity()); - this.updateKeyType(); - this.updateMapKey(); - this.updateMapKeyColumn(); - this.mapKeyAttributeOverrideContainer.update(getResourcePersistentAttribute()); - } - - @Override - public void postUpdate() { - super.postUpdate(); - this.valueAssociationOverrideContainer.postUpdate(); - } - - public Entity getEntity() { - return getTypeMapping().getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY ? (Entity) getTypeMapping() : null; - } - - //************** JavaAttributeMapping implementation *************** - - public String getKey() { - return MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY; - } - - public String getAnnotationName() { - return ElementCollection2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected void addSupportingAnnotationNamesTo(Vector<String> names) { - super.addSupportingAnnotationNamesTo(names); - names.add(JPA.ASSOCIATION_OVERRIDE); - names.add(JPA.ASSOCIATION_OVERRIDES); - names.add(JPA.ATTRIBUTE_OVERRIDE); - names.add(JPA.ATTRIBUTE_OVERRIDES); - names.add(JPA2_0.COLLECTION_TABLE); - names.add(JPA.COLUMN); - names.add(JPA.ENUMERATED); - names.add(JPA.LOB); - names.add(JPA.MAP_KEY); - names.add(JPA2_0.MAP_KEY_CLASS); - names.add(JPA2_0.MAP_KEY_COLUMN); - names.add(JPA2_0.MAP_KEY_ENUMERATED); - names.add(JPA2_0.MAP_KEY_JOIN_COLUMN); - names.add(JPA2_0.MAP_KEY_JOIN_COLUMNS); - names.add(JPA2_0.MAP_KEY_TEMPORAL); - names.add(JPA.ORDER_BY); - names.add(JPA2_0.ORDER_COLUMN); - names.add(JPA.TEMPORAL); - } - - // ********** target class ********** - - public String getTargetClass() { - return (this.specifiedTargetClass != null) ? this.specifiedTargetClass : this.defaultTargetClass; - } - - public String getSpecifiedTargetClass() { - return this.specifiedTargetClass; - } - - public void setSpecifiedTargetClass(String targetClass) { - String old = this.specifiedTargetClass; - this.specifiedTargetClass = targetClass; - this.mappingAnnotation.setTargetClass(targetClass); - this.firePropertyChanged(SPECIFIED_TARGET_CLASS_PROPERTY, old, targetClass); - } - - protected void setSpecifiedTargetClass_(String targetClass) { - String old = this.specifiedTargetClass; - this.specifiedTargetClass = targetClass; - this.firePropertyChanged(SPECIFIED_TARGET_CLASS_PROPERTY, old, targetClass); - } - - protected String getResourceTargetClass() { - return this.mappingAnnotation.getTargetClass(); - } - - public String getDefaultTargetClass() { - return this.defaultTargetClass; - } - - protected void setDefaultTargetClass(String targetClass) { - String old = this.defaultTargetClass; - this.defaultTargetClass = targetClass; - this.firePropertyChanged(DEFAULT_TARGET_CLASS_PROPERTY, old, targetClass); - } - - protected String buildDefaultTargetClass() { - return this.getPersistentAttribute().getMultiReferenceTargetTypeName(); - } - - public String getFullyQualifiedTargetClass() { - return this.fullyQualifiedTargetClass; - } - - protected void setFullyQualifiedTargetClass(String targetClass) { - String old = this.fullyQualifiedTargetClass; - this.fullyQualifiedTargetClass = targetClass; - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_CLASS_PROPERTY, old, targetClass); - } - - protected String buildFullyQualifiedTargetClass() { - return (this.specifiedTargetClass == null) ? - this.defaultTargetClass : - this.mappingAnnotation.getFullyQualifiedTargetClassName(); - } - - public Embeddable getResolvedTargetEmbeddable() { - return this.resolvedTargetEmbeddable; - } - - protected void setResolvedTargetEmbeddable(Embeddable embeddable) { - Embeddable old = this.resolvedTargetEmbeddable; - this.resolvedTargetEmbeddable = embeddable; - this.firePropertyChanged(RESOLVED_TARGET_EMBEDDABLE_PROPERTY, old, embeddable); - } - - public PersistentType getResolvedTargetType() { - return this.resolvedTargetType; - } - - protected PersistentType buildResolvedTargetType() { - return (this.fullyQualifiedTargetClass == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedTargetClass); - } - - protected Embeddable buildResolvedTargetEmbeddable() { - if (this.resolvedTargetType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedTargetType.getMapping(); - return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null; - } - - protected Entity buildResolvedTargetEntity() { - if (this.resolvedTargetType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedTargetType.getMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - - public char getTargetClassEnclosingTypeSeparator() { - return '.'; - } - - // *************** Fetch *************** - - public FetchType getFetch() { - return (this.getSpecifiedFetch() == null) ? this.getDefaultFetch() : this.getSpecifiedFetch(); - } - - public FetchType getDefaultFetch() { - return DEFAULT_FETCH_TYPE; - } - - public FetchType getSpecifiedFetch() { - return this.specifiedFetch; - } - - public void setSpecifiedFetch(FetchType newSpecifiedFetch) { - FetchType oldFetch = this.specifiedFetch; - this.specifiedFetch = newSpecifiedFetch; - this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(newSpecifiedFetch)); - firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch); - } - - /** - * internal setter used only for updating from the resource model. - * There were problems with InvalidThreadAccess exceptions in the UI - * when you set a value from the UI and the annotation doesn't exist yet. - * Adding the annotation causes an update to occur and then the exception. - */ - protected void setSpecifiedFetch_(FetchType newSpecifiedFetch) { - FetchType oldFetch = this.specifiedFetch; - this.specifiedFetch = newSpecifiedFetch; - firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch); - } - - protected FetchType getResourceFetch() { - return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch()); - } - - // ********** collection table ********** - - public JavaCollectionTable2_0 getCollectionTable() { - return this.collectionTable; - } - - protected void initializeCollectionTable() { - this.collectionTable.initialize(getCollectionTableAnnotation()); - } - - protected void updateCollectionTable() { - this.collectionTable.update(getCollectionTableAnnotation()); - } - - public CollectionTable2_0Annotation getCollectionTableAnnotation() { - return (CollectionTable2_0Annotation) this.getResourcePersistentAttribute(). - getNonNullAnnotation(CollectionTable2_0Annotation.ANNOTATION_NAME); - } - - // ***************** value column ************** - - public JavaColumn getValueColumn() { - return this.valueColumn; - } - - protected void initializeValueColumn() { - this.valueColumn.initialize(getColumnAnnotation()); - } - - protected void updateValueColumn() { - getValueColumn().update(getColumnAnnotation()); - } - - public ColumnAnnotation getColumnAnnotation() { - return (ColumnAnnotation) this.getResourcePersistentAttribute().getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME); - } - - - // ************ value converter ************ - - public JavaConverter getConverter() { - return this.valueConverter; - } - - protected String getValueConverterType() { - return this.valueConverter.getType(); - } - - public void setConverter(String converterType) { - if (this.valuesAreEqual(getValueConverterType(), converterType)) { - return; - } - JavaConverter oldConverter = this.valueConverter; - JavaConverter newConverter = buildConverter(converterType); - this.valueConverter = this.nullConverter; - if (oldConverter != null) { - oldConverter.removeFromResourceModel(); - } - this.valueConverter = newConverter; - if (newConverter != null) { - newConverter.addToResourceModel(); - } - firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter); - } - - protected void setConverter(JavaConverter newConverter) { - JavaConverter oldConverter = this.valueConverter; - this.valueConverter = newConverter; - firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter); - } - - - protected void initializeValueConverter() { - this.valueConverter = this.buildConverter(this.getResourceConverterType()); - } - - protected void updateValueConverter() { - if (this.valuesAreEqual(getResourceConverterType(), getValueConverterType())) { - getConverter().update(this.getResourcePersistentAttribute()); - } - else { - JavaConverter javaConverter = buildConverter(getResourceConverterType()); - setConverter(javaConverter); - } - } - - protected JavaConverter buildConverter(String converterType) { - if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) { - return this.nullConverter; - } - if (this.valuesAreEqual(converterType, Converter.ENUMERATED_CONVERTER)) { - return getJpaFactory().buildJavaEnumeratedConverter(this, this.getResourcePersistentAttribute()); - } - if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) { - return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute()); - } - return null; - } - - protected String getResourceConverterType() { - if (this.getResourcePersistentAttribute().getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME) != null) { - return Converter.ENUMERATED_CONVERTER; - } - if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) { - return Converter.TEMPORAL_CONVERTER; - } - return Converter.NO_CONVERTER; - } - - - // ********** overrides ********** - - public JavaAttributeOverrideContainer getValueAttributeOverrideContainer() { - return this.valueAttributeOverrideContainer; - } - - public JavaAssociationOverrideContainer getValueAssociationOverrideContainer() { - return this.valueAssociationOverrideContainer; - } - - - // ***************** map key column ************** - - public JavaColumn getMapKeyColumn() { - return this.mapKeyColumn; - } - - protected void initializeMapKeyColumn() { - this.mapKeyColumn.initialize(getMapKeyColumnAnnotation()); - } - - protected void updateMapKeyColumn() { - getMapKeyColumn().update(getMapKeyColumnAnnotation()); - } - - public MapKeyColumn2_0Annotation getMapKeyColumnAnnotation() { - return (MapKeyColumn2_0Annotation) this.getResourcePersistentAttribute().getNonNullAnnotation(MapKeyColumn2_0Annotation.ANNOTATION_NAME); - } - - public JavaAttributeOverrideContainer getMapKeyAttributeOverrideContainer() { - return this.mapKeyAttributeOverrideContainer; - } - - // ********** ordering ********** - - public JavaOrderable2_0 getOrderable() { - return this.orderable; - } - - protected Orderable2_0.Owner buildOrderableOwner() { - return new Orderable2_0.Owner() { - public String getTableName() { - return getCollectionTable().getName(); - } - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - return getCollectionTable().getDbTable(); - } - }; - } - - - public Type getValueType() { - return this.valueType; - } - - protected void setValueType(Type newValueType) { - Type old = this.valueType; - this.valueType = newValueType; - firePropertyChanged(VALUE_TYPE_PROPERTY, old, newValueType); - } - - protected void initializeValueType() { - this.valueType = this.buildValueType(); - } - - protected void updateValueType() { - this.setValueType(this.buildValueType()); - } - - protected Type buildValueType() { - if (getResolvedTargetEmbeddable() != null) { - return Type.EMBEDDABLE_TYPE; - } - else if (this.resolvedTargetEntity != null) { - return Type.ENTITY_TYPE; - } - else if (getTargetClass() == null) { - return Type.NO_TYPE; - } - return Type.BASIC_TYPE; - } - - public Type getKeyType() { - return this.keyType; - } - - protected void setKeyType(Type newKeyType) { - Type old = this.keyType; - this.keyType = newKeyType; - firePropertyChanged(KEY_TYPE_PROPERTY, old, newKeyType); - } - - protected void initializeKeyType() { - this.keyType = this.buildKeyType(); - } - - protected void updateKeyType() { - this.setKeyType(this.buildKeyType()); - } - - protected Type buildKeyType() { - if (getResolvedMapKeyEmbeddable() != null) { - return Type.EMBEDDABLE_TYPE; - } - if (getResolvedMapKeyEntity() != null) { - return Type.ENTITY_TYPE; - } - else if (getMapKeyClass() == null) { - return Type.NO_TYPE; - } - return Type.BASIC_TYPE; - } - - // ********** map key ********** - - public String getMapKey() { - if (this.noMapKey) { - return null; - } - if (this.pkMapKey) { - return null;//the target is either embeddable or basic, so a key will have to be specified - } - if (this.customMapKey) { - return this.specifiedMapKey; - } - throw new IllegalStateException("unknown map key"); //$NON-NLS-1$ - } - - public String getSpecifiedMapKey() { - return this.specifiedMapKey; - } - - public void setSpecifiedMapKey(String mapKey) { - String old = this.specifiedMapKey; - this.specifiedMapKey = mapKey; - MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation(); - if (mapKey == null) { - if (mapKeyAnnotation != null) { - this.removeMapKeyAnnotation(); - } - } else { - if (mapKeyAnnotation == null) { - mapKeyAnnotation = this.addMapKeyAnnotation(); - } - mapKeyAnnotation.setName(mapKey); - } - this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey); - } - - protected void setSpecifiedMapKey_(String mapKey) { - String old = this.specifiedMapKey; - this.specifiedMapKey = mapKey; - this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey); - } - - protected void initializeMapKey() { - MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation(); - if (mapKeyAnnotation == null) { - this.noMapKey = true; - } else { - this.specifiedMapKey = mapKeyAnnotation.getName(); - if (this.specifiedMapKey == null) { - this.pkMapKey = true; - } else { - this.customMapKey = true; - } - } - } - - protected void updateMapKey() { - MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation(); - if (mapKeyAnnotation == null) { - this.setSpecifiedMapKey_(null); - this.setNoMapKey_(true); - this.setPkMapKey_(false); - this.setCustomMapKey_(false); - } else { - String mk = mapKeyAnnotation.getName(); - this.setSpecifiedMapKey_(mk); - this.setNoMapKey_(false); - this.setPkMapKey_(mk == null); - this.setCustomMapKey_(mk != null); - } - } - - protected MapKeyAnnotation getMapKeyAnnotation() { - return (MapKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyAnnotation.ANNOTATION_NAME); - } - - protected MapKeyAnnotation addMapKeyAnnotation() { - return (MapKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME); - } - - protected void removeMapKeyAnnotation() { - this.getResourcePersistentAttribute().removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME); - } - - protected boolean mapKeyNameTouches(int pos, CompilationUnit astRoot) { - MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation(); - return (mapKeyAnnotation != null) && mapKeyAnnotation.nameTouches(pos, astRoot); - } - - - // ********** no map key ********** - - public boolean isNoMapKey() { - return this.noMapKey; - } - - public void setNoMapKey(boolean noMapKey) { - boolean old = this.noMapKey; - this.noMapKey = noMapKey; - if (noMapKey) { - if (this.getMapKeyAnnotation() != null) { - this.removeMapKeyAnnotation(); - } - } else { - // the 'noMapKey' flag is cleared as a - // side-effect of setting the other flags, - // via a call to #setNoMapKey_(boolean) - } - this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey); - } - - protected void setNoMapKey_(boolean noMapKey) { - boolean old = this.noMapKey; - this.noMapKey = noMapKey; - this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey); - } - - - // ********** pk map key ********** - - public boolean isPkMapKey() { - return this.pkMapKey; - } - - public void setPkMapKey(boolean pkMapKey) { - boolean old = this.pkMapKey; - this.pkMapKey = pkMapKey; - MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation(); - if (pkMapKey) { - if (mapKeyAnnotation == null) { - this.addMapKeyAnnotation(); - } else { - mapKeyAnnotation.setName(null); - } - } else { - // the 'pkMapKey' flag is cleared as a - // side-effect of setting the other flags, - // via a call to #setPkMapKey_(boolean) - } - this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey); - } - - protected void setPkMapKey_(boolean pkMapKey) { - boolean old = this.pkMapKey; - this.pkMapKey = pkMapKey; - this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey); - } - - - // ********** custom map key ********** - - public boolean isCustomMapKey() { - return this.customMapKey; - } - - public void setCustomMapKey(boolean customMapKey) { - boolean old = this.customMapKey; - this.customMapKey = customMapKey; - if (customMapKey) { - this.setSpecifiedMapKey(""); //$NON-NLS-1$ - } else { - // the 'customMapKey' flag is cleared as a - // side-effect of setting the other flags, - // via a call to #setCustomMapKey_(boolean) - } - this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey); - } - - protected void setCustomMapKey_(boolean customMapKey) { - boolean old = this.customMapKey; - this.customMapKey = customMapKey; - this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey); - } - - // *************** map key class ************* - - public String getMapKeyClass() { - return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass; - } - - public String getSpecifiedMapKeyClass() { - return this.specifiedMapKeyClass; - } - - public void setSpecifiedMapKeyClass(String mapKeyClass) { - String old = this.specifiedMapKeyClass; - this.specifiedMapKeyClass = mapKeyClass; - MapKeyClass2_0Annotation mapKeyClassAnnotation = this.getMapKeyClassAnnotation(); - if (mapKeyClass == null) { - if (mapKeyClassAnnotation != null) { - this.removeMapKeyClassAnnotation(); - } - } else { - if (mapKeyClassAnnotation == null) { - mapKeyClassAnnotation = this.addMapKeyClassAnnotation(); - } - mapKeyClassAnnotation.setValue(mapKeyClass); - } - - this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected void setSpecifiedMapKeyClass_(String mapKeyClass) { - String old = this.specifiedMapKeyClass; - this.specifiedMapKeyClass = mapKeyClass; - this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected String getResourceMapKeyClass() { - MapKeyClass2_0Annotation annotation = getMapKeyClassAnnotation(); - return annotation == null ? null : annotation.getValue(); - } - - public String getDefaultMapKeyClass() { - return this.defaultMapKeyClass; - } - - protected void setDefaultMapKeyClass(String mapKeyClass) { - String old = this.defaultMapKeyClass; - this.defaultMapKeyClass = mapKeyClass; - this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected String buildDefaultMapKeyClass() { - return this.getPersistentAttribute().getMultiReferenceMapKeyTypeName(); - } - - public String getFullyQualifiedMapKeyClass() { - return this.fullyQualifiedMapKeyClass; - } - - protected void setFullyQualifiedMapKeyClass(String mapKeyClass) { - String old = this.fullyQualifiedMapKeyClass; - this.fullyQualifiedMapKeyClass = mapKeyClass; - this.firePropertyChanged(FULLY_QUALIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected String buildFullyQualifiedMapKeyClass() { - return (this.specifiedMapKeyClass == null) ? - this.defaultMapKeyClass : - this.getMapKeyClassAnnotation().getFullyQualifiedClassName(); - } - - public char getMapKeyClassEnclosingTypeSeparator() { - return '.'; - } - - protected MapKeyClass2_0Annotation getMapKeyClassAnnotation() { - return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME); - } - - protected MapKeyClass2_0Annotation addMapKeyClassAnnotation() { - return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME); - } - - protected void removeMapKeyClassAnnotation() { - this.getResourcePersistentAttribute().removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME); - } - - public Embeddable getResolvedMapKeyEmbeddable() { - return this.resolvedMapKeyEmbeddable; - } - - protected void setResolvedMapKeyEmbeddable(Embeddable embeddable) { - Embeddable old = this.resolvedMapKeyEmbeddable; - this.resolvedMapKeyEmbeddable = embeddable; - this.firePropertyChanged(RESOLVED_MAP_KEY_EMBEDDABLE_PROPERTY, old, embeddable); - } - - public Entity getResolvedMapKeyEntity() { - return this.resolvedMapKeyEntity; - } - - protected void setResolvedMapKeyEntity(Entity entity) { - Entity old = this.resolvedMapKeyEntity; - this.resolvedMapKeyEntity = entity; - this.firePropertyChanged(RESOLVED_MAP_KEY_ENTITY_PROPERTY, old, entity); - } - - public PersistentType getResolvedMapKeyType() { - return getResolvedMapKeyEmbeddable() == null ? null : getResolvedMapKeyEmbeddable().getPersistentType(); - } - - protected PersistentType buildResolvedMapKeyType() { - return (this.fullyQualifiedMapKeyClass == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedMapKeyClass); - } - - protected Embeddable buildResolvedMapKeyEmbeddable() { - if (this.resolvedMapKeyType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedMapKeyType.getMapping(); - return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null; - } - - protected Entity buildResolvedMapKeyEntity() { - if (this.resolvedMapKeyType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedMapKeyType.getMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - - - // ********** Java completion proposals ********** - - @Override - public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.getCollectionTable().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.getValueColumn().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = getConverter().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.getOrderable().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.getValueAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.getValueAssociationOverrideContainer().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (this.mapKeyNameTouches(pos, astRoot)) { - return this.javaCandidateMapKeyNames(filter); - } - result = this.getMapKeyColumn().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.getMapKeyAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } -// result = this.getMapKeyAssociationOverrideContainer().javaCompletionProposals(pos, filter, astRoot); -// if (result != null) { -// return result; -// } - return null; - } - - protected Iterator<String> javaCandidateMapKeyNames(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals(this.candidateMapKeyNames(filter)); - } - - protected Iterator<String> candidateMapKeyNames(Filter<String> filter) { - return new FilteringIterator<String>(this.candidateMapKeyNames(), filter); - } - - public Iterator<String> candidateMapKeyNames() { - return this.allTargetEmbeddableAttributeNames(); - } - - public Iterator<String> allTargetEmbeddableAttributeNames() { - return new CompositeIterator<String>( - new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEmbeddableAttributeMappings()) { - @Override - protected Iterator<String> transform(AttributeMapping mapping) { - return mapping.allMappingNames(); - } - }); - } - - @Override - public Iterator<String> allMappingNames() { - return new CompositeIterator<String>(this.getName(), this.allEmbeddableAttributeMappingNames()); - } - - protected Iterator<String> allEmbeddableAttributeMappingNames() { - return this.embeddableOverrideableMappingNames( - new Transformer<AttributeMapping, Iterator<String>>() { - public Iterator<String> transform(AttributeMapping mapping) { - return mapping.allMappingNames(); - } - } - ); - } - - protected Iterator<AttributeMapping> allTargetEmbeddableAttributeMappings() { - return (this.resolvedTargetEmbeddable != null) ? - this.resolvedTargetEmbeddable.allAttributeMappings() : - EmptyIterator.<AttributeMapping> instance(); - } - - protected Iterator<AttributeMapping> embeddableAttributeMappings() { - Embeddable targetEmbeddable = getResolvedTargetEmbeddable(); - if (targetEmbeddable != null && targetEmbeddable != getPersistentAttribute().getOwningTypeMapping()) { - return targetEmbeddable.attributeMappings(); - } - return EmptyIterator.instance(); - } - - @Override - public Iterator<String> allOverrideableAttributeMappingNames() { - return this.embeddableOverrideableAttributeMappingNames(); - } - - protected Iterator<String> embeddableOverrideableAttributeMappingNames() { - return this.embeddableOverrideableMappingNames( - new Transformer<AttributeMapping, Iterator<String>>() { - public Iterator<String> transform(AttributeMapping mapping) { - return mapping.allOverrideableAttributeMappingNames(); - } - } - ); - } - - @Override - public Iterator<String> allOverrideableAssociationMappingNames() { - return this.embeddableOverrideableAssociationMappingNames(); - } - - protected Iterator<String> embeddableOverrideableAssociationMappingNames() { - return this.embeddableOverrideableMappingNames( - new Transformer<AttributeMapping, Iterator<String>>() { - public Iterator<String> transform(AttributeMapping mapping) { - return mapping.allOverrideableAssociationMappingNames(); - } - } - ); - } - - protected Iterator<String> embeddableOverrideableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) { - return new TransformationIterator<String, String>( - new CompositeIterator<String>( - new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer))) - { - @Override - protected String transform(String next) { - return getName() + '.' + next; - } - }; - } - - @Override - public AttributeMapping resolveAttributeMapping(String name) { - AttributeMapping resolvedMapping = super.resolveAttributeMapping(name); - if (resolvedMapping != null) { - return resolvedMapping; - } - int dotIndex = name.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(name.substring(0, dotIndex))) { - for (AttributeMapping attributeMapping : CollectionTools.iterable(embeddableAttributeMappings())) { - resolvedMapping = attributeMapping.resolveAttributeMapping(name.substring(dotIndex + 1)); - if (resolvedMapping != null) { - return resolvedMapping; - } - } - } - } - return null; - } - - @Override - public Column resolveOverriddenColumn(String attributeName) { - int dotIndex = attributeName.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(attributeName.substring(0, dotIndex))) { - attributeName = attributeName.substring(dotIndex + 1); - AttributeOverride override = getValueAttributeOverrideContainer().getAttributeOverrideNamed(attributeName); - if (override != null && !override.isVirtual()) { - return override.getColumn(); - } - if (this.getResolvedTargetEmbeddable() == null) { - return null; - } - return this.getResolvedTargetEmbeddable().resolveOverriddenColumn(attributeName); - } - } - return null; - } - - // ********** metamodel ********** - @Override - protected String getMetamodelFieldTypeName() { - return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldTypeName(); - } - - @Override - public String getMetamodelTypeName() { - return (this.fullyQualifiedTargetClass != null) ? this.fullyQualifiedTargetClass : MetamodelField.DEFAULT_TYPE_NAME; - } - - @Override - protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) { - this.addMetamodelFieldMapKeyTypeArgumentNameTo(typeArgumentNames); - super.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames); - } - - protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) { - String keyTypeName = ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName(); - if (keyTypeName != null) { - typeArgumentNames.add(keyTypeName); - } - } - - public String getMetamodelFieldMapKeyTypeName() { - return MappingTools.getMetamodelFieldMapKeyTypeName(this); - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.validateTargetClass(messages, astRoot); - this.validateMapKeyClass(messages, astRoot); - this.getOrderable().validate(messages, reporter, astRoot); - this.getCollectionTable().validate(messages, reporter, astRoot); - this.validateValue(messages, reporter, astRoot); - this.validateMapKey(messages, reporter, astRoot); - } - - protected void validateValue(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - //TODO should we handle validation when the type is embeddable, but a value column is specified, or things like that if that is invalid? - if (getValueType() == Type.BASIC_TYPE) { - this.getValueColumn().validate(messages, reporter, astRoot); - this.getConverter().validate(messages, reporter, astRoot); - } - else if (getValueType() == Type.EMBEDDABLE_TYPE) { - this.getValueAttributeOverrideContainer().validate(messages, reporter, astRoot); - this.getValueAssociationOverrideContainer().validate(messages, reporter, astRoot); - } - } - - protected void validateMapKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - if (getMapKey() != null) { - //TODO validate that the map key refers to an existing attribute - return; - } - if (getKeyType() == Type.BASIC_TYPE) { - this.getMapKeyColumn().validate(messages, reporter, astRoot); - //validate map key converter - } - else if (getKeyType() == Type.ENTITY_TYPE) { - //validate map key join columns - } - else if (getKeyType() == Type.EMBEDDABLE_TYPE) { - getMapKeyAttributeOverrideContainer().validate(messages, reporter, astRoot); - //getMapKeyAssociationOverrideContainer().validate(messages, reporter, astRoot); - } - } - - protected void validateTargetClass(List<IMessage> messages, CompilationUnit astRoot) { - if (this.getTargetClass() == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - new String[0], - this, - this.getValidationTextRange(astRoot) - ) - ); - } - //TODO this does not give an error for unmapped, unlisted types that aren't basic - bug 310464 - if (this.resolvedTargetType != null) { - if (getResolvedTargetEmbeddable() == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - new String[] {this.getTargetClass()}, - this, - this.getTargetClassTextRange(astRoot) - ) - ); - } - } - } - - protected void validateMapKeyClass(List<IMessage> messages, CompilationUnit astRoot) { - if (!getPersistentAttribute().getJpaContainer().isMap()) { - return; - } - if (this.getMapKeyClass() == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - new String[0], - this, - this.getValidationTextRange(astRoot) - ) - ); - } - } - - protected TextRange getTargetClassTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.mappingAnnotation.getTargetClassTextRange(astRoot), astRoot); - } - - protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) { - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); - } - - - protected class CollectionTableOwner implements Table.Owner { - public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) { - return new CollectionTableValidator((CollectionTable2_0) table, textRangeResolver); - } - } - - protected abstract class ColumnOwner implements JavaBaseColumn.Owner { - public String getDefaultTableName() { - return getCollectionTable().getName(); - } - - public TypeMapping getTypeMapping() { - return AbstractJavaElementCollectionMapping2_0.this.getTypeMapping(); - } - - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - if (getCollectionTable().getName() != null && getCollectionTable().getName().equals(tableName)) { - return AbstractJavaElementCollectionMapping2_0.this.getCollectionTable().getDbTable(); - } - return null; - } - - /** - * If there is a specified table name it needs to be the same - * the default table name. the table is always the collection table - */ - public boolean tableNameIsInvalid(String tableName) { - return !StringTools.stringsAreEqual(getDefaultTableName(), tableName); - } - - public java.util.Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return AbstractJavaElementCollectionMapping2_0.this.getValidationTextRange(astRoot); - } - } - - protected class ValueColumnOwner extends ColumnOwner { - public String getDefaultColumnName() { - return AbstractJavaElementCollectionMapping2_0.this.getName(); - } - - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } - - protected class MapKeyColumnOwner extends ColumnOwner { - public String getDefaultColumnName() { - return AbstractJavaElementCollectionMapping2_0.this.getName() + "_KEY"; //$NON-NLS-1$ - } - - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new MapKeyColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } - - // ********** override container owners ********** - - protected abstract class OverrideContainerOwner - implements JavaOverrideContainer.Owner - { - public TypeMapping getTypeMapping() { - return AbstractJavaElementCollectionMapping2_0.this.getTypeMapping(); - } - - public String getDefaultTableName() { - return AbstractJavaElementCollectionMapping2_0.this.getCollectionTable().getName(); - } - - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - return AbstractJavaElementCollectionMapping2_0.this.getCollectionTable().getDbTable(); - } - - public java.util.Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - /** - * If there is a specified table name it needs to be the same - * the default table name. the table is always the collection table - */ - public boolean tableNameIsInvalid(String tableName) { - return !StringTools.stringsAreEqual(getDefaultTableName(), tableName); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return AbstractJavaElementCollectionMapping2_0.this.getValidationTextRange(astRoot); - } - } - - protected class ValueAssociationOverrideContainerOwner - extends OverrideContainerOwner - implements JavaAssociationOverrideContainer.Owner - { - public TypeMapping getOverridableTypeMapping() { - return AbstractJavaElementCollectionMapping2_0.this.getResolvedTargetEmbeddable(); - } - - public Iterator<String> allOverridableNames() { - TypeMapping typeMapping = getOverridableTypeMapping(); - return (typeMapping == null) ? - EmptyIterator.<String>instance() - : typeMapping.allOverridableAssociationNames(); - } - - public RelationshipReference resolveRelationshipReference(String associationOverrideName) { - return MappingTools.resolveRelationshipReference(getOverridableTypeMapping(), associationOverrideName); - } - - public String getPossiblePrefix() { - return "value."; //$NON-NLS-1$ - } - - public String getWritePrefix() { - return getPersistentAttribute().getJpaContainer().isMap() ? this.getPossiblePrefix() : null; - } - - //return false if the override is prefixed with "key.", these will be part of the MapKeyAttributeOverrideContainer. - //a prefix of "value." or no prefix at all is relevant. If the type is not a Map then return true since all attribute overrides - //need to apply to the value. - public boolean isRelevant(String overrideName) { - if (getKeyType() != Type.EMBEDDABLE_TYPE) { - return true; - } - return !overrideName.startsWith("key."); //$NON-NLS-1$ - } - - public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) { - return new AssociationOverrideValidator((AssociationOverride) override, (AssociationOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinColumnValidator((AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) columnOwner, (JoinColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - - public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - } - - //********** AttributeOverrideContainer.Owner implementation ********* - - protected class ValueAttributeOverrideContainerOwner - extends OverrideContainerOwner - implements JavaAttributeOverrideContainer.Owner - { - public TypeMapping getOverridableTypeMapping() { - return AbstractJavaElementCollectionMapping2_0.this.getResolvedTargetEmbeddable(); - } - - public Iterator<String> allOverridableNames() { - TypeMapping typeMapping = getOverridableTypeMapping(); - return (typeMapping == null) ? - EmptyIterator.<String>instance() - : typeMapping.allOverridableAttributeNames(); - } - - public Column resolveOverriddenColumn(String attributeOverrideName) { - return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName); - } - - public String getPossiblePrefix() { - return "value."; //$NON-NLS-1$ - } - - public String getWritePrefix() { - return getPersistentAttribute().getJpaContainer().isMap() ? this.getPossiblePrefix() : null; - } - - //return false if the override is prefixed with "key.", these will be part of the MapKeyAttributeOverrideContainer. - //a prefix of "value." or no prefix at all is relevant. If the type is not a Map then return true since all attribute overrides - //need to apply to the value. - public boolean isRelevant(String overrideName) { - if (getKeyType() != Type.EMBEDDABLE_TYPE) { - return true; - } - return !overrideName.startsWith("key."); //$NON-NLS-1$ - } - - public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) { - return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { - return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } - - - protected class MapKeyAttributeOverrideContainerOwner - extends OverrideContainerOwner - implements JavaAttributeOverrideContainer.Owner - { - public TypeMapping getOverridableTypeMapping() { - return AbstractJavaElementCollectionMapping2_0.this.getResolvedMapKeyEmbeddable(); - } - - public Iterator<String> allOverridableNames() { - TypeMapping typeMapping = getOverridableTypeMapping(); - return (typeMapping == null) ? - EmptyIterator.<String>instance() - : typeMapping.allOverridableAttributeNames(); - } - - public String getPossiblePrefix() { - return "key."; //$NON-NLS-1$ - } - - public String getWritePrefix() { - return this.getPossiblePrefix(); - } - - //the only relevant overrides are those that start with "key.", no prefix will be a value attribute override - public boolean isRelevant(String overrideName) { - if (getValueType() != Type.EMBEDDABLE_TYPE) { - return true; - } - return overrideName.startsWith("key."); //$NON-NLS-1$ - } - - public Column resolveOverriddenColumn(String attributeOverrideName) { - return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName); - } - - public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) { - return new MapKeyAttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { - return new MapKeyAttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/AbstractJavaIdMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/AbstractJavaIdMappingDefinition2_0.java deleted file mode 100644 index 6ae03e083d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/AbstractJavaIdMappingDefinition2_0.java +++ /dev/null @@ -1,42 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaIdMappingDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation; -import org.eclipse.jpt.core.resource.java.OneToOneAnnotation; - -public abstract class AbstractJavaIdMappingDefinition2_0 - extends AbstractJavaIdMappingDefinition -{ - protected AbstractJavaIdMappingDefinition2_0() { - super(); - } - - - @Override - public boolean testSpecified(JavaPersistentAttribute persistentAttribute) { - return super.testSpecified(persistentAttribute) && ! testDerivedId(persistentAttribute); - } - - /** - * Return whether the Id annotation, if present, is used as a supporting annotation for - * 1-1 or M-1 mapping, rather than as a primary mapping annotation - */ - protected boolean testDerivedId(JavaPersistentAttribute persistentAttribute) { - JavaResourcePersistentAttribute resourceAttribute = - persistentAttribute.getResourcePersistentAttribute(); - return resourceAttribute.getAnnotation(OneToOneAnnotation.ANNOTATION_NAME) != null - || resourceAttribute.getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME) != null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaAssociationOverrideRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaAssociationOverrideRelationshipReference2_0.java deleted file mode 100644 index 668e0127f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaAssociationOverrideRelationshipReference2_0.java +++ /dev/null @@ -1,123 +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.core.internal.jpa2.context.java; - -import java.util.Iterator; -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.AssociationOverrideRelationshipReference; -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaAssociationOverrideRelationshipReference; -import org.eclipse.jpt.core.jpa2.context.AssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaAssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaJoinTableInAssociationOverrideJoiningStrategy2_0; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaAssociationOverrideRelationshipReference2_0 extends AbstractJavaAssociationOverrideRelationshipReference - implements JavaAssociationOverrideRelationshipReference2_0 -{ - - protected final JavaJoinTableInAssociationOverrideJoiningStrategy2_0 joinTableJoiningStrategy; - - public GenericJavaAssociationOverrideRelationshipReference2_0(JavaAssociationOverride parent) { - super(parent); - this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy(); - } - - public void initializeFrom(AssociationOverrideRelationshipReference oldAssociationOverride) { - if (oldAssociationOverride.getJoinColumnJoiningStrategy().hasSpecifiedJoinColumns()) { - getJoinColumnJoiningStrategy().initializeFrom(oldAssociationOverride.getJoinColumnJoiningStrategy()); - } - else { - getJoinTableJoiningStrategy().initializeFrom(((AssociationOverrideRelationshipReference2_0) oldAssociationOverride).getJoinTableJoiningStrategy()); - } - } - - protected JavaJoinTableInAssociationOverrideJoiningStrategy2_0 buildJoinTableJoiningStrategy() { - return new GenericJavaJoinTableInAssociationOverrideJoiningStrategy2_0(this); - } - - @Override - public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - return null; - } - - @Override - protected void initializeJoiningStrategies(AssociationOverrideAnnotation associationOverride) { - super.initializeJoiningStrategies(associationOverride); - this.joinTableJoiningStrategy.initialize((AssociationOverride2_0Annotation) associationOverride); - } - - @Override - protected void updateJoiningStrategies(AssociationOverrideAnnotation associationOverride) { - super.updateJoiningStrategies(associationOverride); - this.joinTableJoiningStrategy.update((AssociationOverride2_0Annotation) associationOverride); - } - - @Override - protected JoiningStrategy calculatePredominantJoiningStrategy() { - if (this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns()) { - return this.joinColumnJoiningStrategy; - } - return this.joinTableJoiningStrategy; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.joinTableJoiningStrategy.validate(messages, reporter, astRoot); - } - - - // **************** join columns ******************************************* - - public JavaJoinTableInAssociationOverrideJoiningStrategy2_0 getJoinTableJoiningStrategy() { - return this.joinTableJoiningStrategy; - } - - public boolean usesJoinTableJoiningStrategy() { - return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy; - } - - public void setJoinTableJoiningStrategy() { - this.joinTableJoiningStrategy.addStrategy(); - this.joinColumnJoiningStrategy.removeStrategy(); - } - - public void unsetJoinTableJoiningStrategy() { - this.joinTableJoiningStrategy.removeStrategy(); - } - - public boolean mayHaveDefaultJoinTable() { - return getAssociationOverride().isVirtual() && this.usesJoinTableJoiningStrategy(); - } - - @Override - public void setJoinColumnJoiningStrategy() { - super.setJoinColumnJoiningStrategy(); - this.joinTableJoiningStrategy.removeStrategy(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java deleted file mode 100644 index e21fb8be65..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java +++ /dev/null @@ -1,135 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.java.JavaCacheable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0; -import org.eclipse.jpt.core.jpa2.resource.java.Cacheable2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -public class GenericJavaCacheable2_0 - extends AbstractJavaJpaContextNode - implements JavaCacheable2_0 -{ - protected boolean defaultCacheable; - protected Boolean specifiedCacheable; - - protected JavaResourcePersistentType resourcePersistentType; - - public GenericJavaCacheable2_0(JavaCacheableHolder2_0 parent) { - super(parent); - } - - @Override - public JavaCacheableHolder2_0 getParent() { - return (JavaCacheableHolder2_0) super.getParent(); - } - - protected String getCacheableAnnotationName() { - return Cacheable2_0Annotation.ANNOTATION_NAME; - } - - protected Cacheable2_0Annotation getResourceCacheable() { - return (Cacheable2_0Annotation) this.resourcePersistentType.getAnnotation(getCacheableAnnotationName()); - } - - protected void addResourceCacheable() { - this.resourcePersistentType.addAnnotation(getCacheableAnnotationName()); - } - - protected void removeResourceCacheable() { - this.resourcePersistentType.removeAnnotation(getCacheableAnnotationName()); - } - - protected boolean calculateDefaultCacheable() { - return getParent().calculateDefaultCacheable(); - } - - public boolean isCacheable() { - return this.specifiedCacheable != null ? this.specifiedCacheable.booleanValue() : this.defaultCacheable; - } - - public boolean isDefaultCacheable() { - return this.defaultCacheable; - } - - protected void setDefaultCacheable(boolean newDefaultCacheable) { - boolean oldDefaultCacheable = this.defaultCacheable; - this.defaultCacheable = newDefaultCacheable; - firePropertyChanged(DEFAULT_CACHEABLE_PROPERTY, oldDefaultCacheable, newDefaultCacheable); - } - - public Boolean getSpecifiedCacheable() { - return this.specifiedCacheable; - } - - public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) { - if (this.specifiedCacheable == newSpecifiedCacheable) { - return; - } - Boolean oldSpecifiedCacheable = this.specifiedCacheable; - this.specifiedCacheable = newSpecifiedCacheable; - - if (newSpecifiedCacheable != null) { - if (getResourceCacheable() == null) { - addResourceCacheable(); - } - if (newSpecifiedCacheable.booleanValue()) { - if (getResourceCacheable().getValue() == Boolean.FALSE) { - getResourceCacheable().setValue(null); - } - } - else { - getResourceCacheable().setValue(Boolean.FALSE); - } - } - else { - removeResourceCacheable(); - } - firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable); - } - - protected void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) { - Boolean oldSpecifiedCacheable = this.specifiedCacheable; - this.specifiedCacheable = newSpecifiedCacheable; - firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable); - } - - public void initialize(JavaResourcePersistentType jrpt) { - this.resourcePersistentType = jrpt; - Cacheable2_0Annotation resourceCacheable = this.getResourceCacheable(); - this.specifiedCacheable = this.specifiedCacheable(resourceCacheable); - } - - public void update(JavaResourcePersistentType jrpt) { - this.resourcePersistentType = jrpt; - Cacheable2_0Annotation resourceCacheable = this.getResourceCacheable(); - this.setSpecifiedCacheable_(this.specifiedCacheable(resourceCacheable)); - this.setDefaultCacheable(this.calculateDefaultCacheable()); - } - - private Boolean specifiedCacheable(Cacheable2_0Annotation resourceCacheable) { - if (resourceCacheable == null) { - return null; - } - if (resourceCacheable.getValue() == null) { //@Cacheable is equivalent to @Cacheable(true) - return Boolean.TRUE; - } - return resourceCacheable.getValue(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - Cacheable2_0Annotation resourceCacheable = this.getResourceCacheable(); - return resourceCacheable == null ? null : resourceCacheable.getTextRange(astRoot); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaCollectionTable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaCollectionTable2_0.java deleted file mode 100644 index 99e5b283d4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaCollectionTable2_0.java +++ /dev/null @@ -1,183 +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.core.internal.jpa2.context.java; - -import java.util.Iterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.BaseJoinColumn; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.java.JavaJoinColumn; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.MappingTools; -import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.jpa1.context.CollectionTableTableDescriptionProvider; -import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaReferenceTable; -import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -/** - * Java collection table - */ -public class GenericJavaCollectionTable2_0 - extends GenericJavaReferenceTable - implements JavaCollectionTable2_0 -{ - - public GenericJavaCollectionTable2_0(JavaElementCollectionMapping2_0 parent, Owner owner) { - super(parent, owner); - } - - @Override - protected JavaJoinColumn.Owner buildJoinColumnOwner() { - return new JoinColumnOwner(); - } - - @Override - public JavaElementCollectionMapping2_0 getParent() { - return (JavaElementCollectionMapping2_0) super.getParent(); - } - - public PersistentAttribute getPersistentAttribute() { - return getParent().getPersistentAttribute(); - } - - public void initialize(CollectionTable2_0Annotation collectionTable) { - super.initialize(collectionTable); - } - - public void update(CollectionTable2_0Annotation collectionTable) { - super.update(collectionTable); - } - - // ********** AbstractJavaTable implementation ********** - - @Override - protected String getAnnotationName() { - return CollectionTable2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected String buildDefaultName() { - return MappingTools.buildCollectionTableDefaultName(getParent()); - } - - @Override - protected CollectionTable2_0Annotation getAnnotation() { - return this.getParent().getCollectionTableAnnotation(); - } - - - - // ********** validation ********** - - public boolean shouldValidateAgainstDatabase() { - return getParent().shouldValidateAgainstDatabase(); - } - - - // ********** join column owner adapter ********** - - /** - * owner for "back-pointer" JoinColumns; - * these point at the source/owning entity - */ - protected class JoinColumnOwner - implements JavaJoinColumn.Owner - { - protected JoinColumnOwner() { - super(); - } - - //***** NamedColumn.Owner implementation ******* - public TypeMapping getTypeMapping() { - return GenericJavaCollectionTable2_0.this.getParent().getTypeMapping(); - } - - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - String collectionTableName = GenericJavaCollectionTable2_0.this.getName(); - return (collectionTableName == null) ? null : (collectionTableName.equals(tableName)) ? GenericJavaCollectionTable2_0.this.getDbTable() : null; - } - - public String getDefaultColumnName() { - //built in MappingTools.buildJoinColumnDefaultName() - return null; - } - - //***** JavaNamedColumn.Owner implementation ******* - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return GenericJavaCollectionTable2_0.this.getValidationTextRange(astRoot); - } - - //***** BaseColumn.Owner implementation ******* - /** - * by default, the join column is, obviously, in the collection table - */ - public String getDefaultTableName() { - return GenericJavaCollectionTable2_0.this.getName(); - } - - - //***** BaseJoinColumn.Owner implementation ******* - public org.eclipse.jpt.db.Table getReferencedColumnDbTable() { - return getTypeMapping().getPrimaryDbTable(); - } - - public boolean isVirtual(BaseJoinColumn joinColumn) { - return GenericJavaCollectionTable2_0.this.defaultJoinColumn == joinColumn; - } - - //***** JoinColumn.Owner implementation ******* - /** - * If there is a specified table name it needs to be the same - * the default table name. the table is always the collection table - */ - public boolean tableNameIsInvalid(String tableName) { - return !StringTools.stringsAreEqual(getDefaultTableName(), tableName); - } - - /** - * the join column can only be on the collection table itself - */ - public Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - public Entity getRelationshipTarget() { - return GenericJavaCollectionTable2_0.this.getParent().getEntity(); - } - - public String getAttributeName() { - return null; //I *think* this is correct - //return GenericJavaCollectionTable2_0.this.getParent().getName(); - } - - public PersistentAttribute getPersistentAttribute() { - return GenericJavaCollectionTable2_0.this.getParent().getPersistentAttribute(); - } - - public int joinColumnsSize() { - return GenericJavaCollectionTable2_0.this.joinColumnsSize(); - } - - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new JoinColumnValidator((JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaDerivedIdentity2_0.java deleted file mode 100644 index 67f5312ad3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaDerivedIdentity2_0.java +++ /dev/null @@ -1,191 +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.core.internal.jpa2.context.java; - -import java.util.Iterator; -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.DerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaMapsIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaDerivedIdentity2_0 extends AbstractJavaJpaContextNode - implements JavaDerivedIdentity2_0 -{ - // cache the strategy for property change notification - protected DerivedIdentityStrategy2_0 cachedPredominantDerivedIdentityStrategy; - - protected JavaIdDerivedIdentityStrategy2_0 idDerivedIdentityStrategy; - - protected JavaMapsIdDerivedIdentityStrategy2_0 mapsIdDerivedIdentityStrategy; - - - public GenericJavaDerivedIdentity2_0(JavaSingleRelationshipMapping2_0 parent) { - super(parent); - this.idDerivedIdentityStrategy = buildIdDerivedIdentityStrategy(); - this.mapsIdDerivedIdentityStrategy = buildMapsIdDerivedIdentityStrategy(); - } - - - protected JavaIdDerivedIdentityStrategy2_0 buildIdDerivedIdentityStrategy() { - return new GenericJavaIdDerivedIdentityStrategy2_0(this); - } - - protected JavaMapsIdDerivedIdentityStrategy2_0 buildMapsIdDerivedIdentityStrategy() { - return new GenericJavaMapsIdDerivedIdentityStrategy2_0(this); - } - - @Override - public JavaSingleRelationshipMapping2_0 getParent() { - return (JavaSingleRelationshipMapping2_0) super.getParent(); - } - - public JavaSingleRelationshipMapping2_0 getMapping() { - return getParent(); - } - - - // **************** predominant joining strategy *************************** - - public DerivedIdentityStrategy2_0 getPredominantDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy; - } - - protected void setPredominantJoiningStrategy() { - setPredominantJoiningStrategy(calculatePredominantDerivedIdentityStrategy()); - } - - protected void setPredominantJoiningStrategy(DerivedIdentityStrategy2_0 newStrategy) { - DerivedIdentityStrategy2_0 oldStrategy = this.cachedPredominantDerivedIdentityStrategy; - this.cachedPredominantDerivedIdentityStrategy = newStrategy; - firePropertyChanged(PREDOMINANT_DERIVED_IDENTITY_STRATEGY_PROPERTY, oldStrategy, newStrategy); - } - - - // **************** resource -> context ************************************ - - public void initialize() { - this.idDerivedIdentityStrategy.initialize(); - this.mapsIdDerivedIdentityStrategy.initialize(); - this.cachedPredominantDerivedIdentityStrategy = calculatePredominantDerivedIdentityStrategy(); - } - - public void update() { - this.idDerivedIdentityStrategy.update(); - this.mapsIdDerivedIdentityStrategy.update(); - setPredominantJoiningStrategy(calculatePredominantDerivedIdentityStrategy()); - } - - protected DerivedIdentityStrategy2_0 calculatePredominantDerivedIdentityStrategy() { - if (this.mapsIdDerivedIdentityStrategy.isSpecified()) { - return this.mapsIdDerivedIdentityStrategy; - } - else if (this.idDerivedIdentityStrategy.isSpecified()) { - return this.idDerivedIdentityStrategy; - } - else { - return null; - } - } - - - // **************** no strategy ******************************************* - - public void setNullDerivedIdentityStrategy() { - this.mapsIdDerivedIdentityStrategy.removeStrategy(); - this.idDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean usesNullDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy == null; - } - - - // **************** maps id strategy ************************************** - - public JavaMapsIdDerivedIdentityStrategy2_0 getMapsIdDerivedIdentityStrategy() { - return this.mapsIdDerivedIdentityStrategy; - } - - public void setMapsIdDerivedIdentityStrategy() { - this.mapsIdDerivedIdentityStrategy.addStrategy(); - this.idDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public void unsetMapsIdDerivedIdentityStrategy() { - this.mapsIdDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean usesMapsIdDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy == this.mapsIdDerivedIdentityStrategy; - } - - - // **************** id strategy ******************************************* - - public JavaIdDerivedIdentityStrategy2_0 getIdDerivedIdentityStrategy() { - return this.idDerivedIdentityStrategy; - } - - public void setIdDerivedIdentityStrategy() { - this.idDerivedIdentityStrategy.addStrategy(); - this.mapsIdDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public void unsetIdDerivedIdentityStrategy() { - this.idDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean usesIdDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy == this.idDerivedIdentityStrategy; - } - - - // **************** java completion *************************************** - - @Override - public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot); - if (result == null) { - result = this.mapsIdDerivedIdentityStrategy.javaCompletionProposals(pos, filter, astRoot); - } - if (result == null) { - result = this.idDerivedIdentityStrategy.javaCompletionProposals(pos, filter, astRoot); - } - return result; - } - - - // **************** validation ******************************************** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return getMapping().getValidationTextRange(astRoot); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - this.idDerivedIdentityStrategy.validate(messages, reporter, astRoot); - this.mapsIdDerivedIdentityStrategy.validate(messages, reporter, astRoot); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java deleted file mode 100644 index 43cfc4038d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaElementCollectionMapping2_0.java +++ /dev/null @@ -1,22 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; - - -public class GenericJavaElementCollectionMapping2_0 - extends AbstractJavaElementCollectionMapping2_0 -{ - public GenericJavaElementCollectionMapping2_0(JavaPersistentAttribute parent) { - super(parent); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaEmbeddable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaEmbeddable2_0.java deleted file mode 100644 index 4e9bd8353c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaEmbeddable2_0.java +++ /dev/null @@ -1,43 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.java.JavaPersistentType; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaEmbeddable; -import org.eclipse.jpt.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.utility.internal.ArrayTools; - - -public class GenericJavaEmbeddable2_0 - extends AbstractJavaEmbeddable -{ - public GenericJavaEmbeddable2_0(JavaPersistentType parent) { - super(parent); - } - - @Override - public boolean attributeMappingKeyAllowed(String attributeMappingKey) { - return ArrayTools.contains(ALLOWED_ATTRIBUTE_MAPPING_KEYS, attributeMappingKey); - } - - public static final String[] ALLOWED_ATTRIBUTE_MAPPING_KEYS = - new String[] { - MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY, - MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, - MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, - MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, - MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, - MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY, - MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY, - MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY - }; - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java deleted file mode 100644 index a53f2f67c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java +++ /dev/null @@ -1,126 +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.core.internal.jpa2.context.java; - -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.resource.java.IdAnnotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaIdDerivedIdentityStrategy2_0 - extends AbstractJavaJpaContextNode - implements JavaIdDerivedIdentityStrategy2_0 -{ - protected boolean value; - - - public GenericJavaIdDerivedIdentityStrategy2_0(JavaDerivedIdentity2_0 parent) { - super(parent); - } - - - public JavaDerivedIdentity2_0 getDerivedIdentity() { - return (JavaDerivedIdentity2_0) super.getParent(); - } - - public JavaSingleRelationshipMapping2_0 getMapping() { - return getDerivedIdentity().getMapping(); - } - - protected JavaResourcePersistentAttribute getResourceAttribute() { - return getMapping().getPersistentAttribute().getResourcePersistentAttribute(); - } - - protected IdAnnotation getAnnotation() { - return (IdAnnotation) getResourceAttribute().getAnnotation(JPA.ID); - } - - protected boolean getResourceValue() { - return getAnnotation() != null; - } - - protected void addAnnotation() { - getResourceAttribute().addAnnotation(JPA.ID); - } - - protected void removeAnnotation() { - getResourceAttribute().removeAnnotation(JPA.ID); - } - - public boolean getValue() { - return this.value; - } - - public void setValue(boolean newValue) { - if (this.value == newValue) { - return; - } - boolean oldValue = this.value; - this.value = newValue; - - if (newValue) { - addAnnotation(); - } - else { - removeAnnotation(); - } - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - protected void setValue_(boolean newValue) { - boolean oldValue = this.value; - this.value = newValue; - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public boolean isSpecified() { - return getAnnotation() != null; - } - - public void addStrategy() { - if (getAnnotation() == null) { - addAnnotation(); - } - } - - public void removeStrategy() { - if (getAnnotation() != null) { - removeAnnotation(); - } - } - - public void initialize() { - this.value = getResourceValue(); - } - - public void update() { - this.setValue_(getResourceValue()); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - IdAnnotation annotation = this.getAnnotation(); - return annotation == null ? null : annotation.getTextRange(astRoot); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - // no validation rules - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaJoinTableInAssociationOverrideJoiningStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaJoinTableInAssociationOverrideJoiningStrategy2_0.java deleted file mode 100644 index 2485182458..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaJoinTableInAssociationOverrideJoiningStrategy2_0.java +++ /dev/null @@ -1,98 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumn.Owner; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJoinTableJoiningStrategy; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinTableValidator; -import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider; -import org.eclipse.jpt.core.jpa2.context.java.JavaAssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaJoinTableInAssociationOverrideJoiningStrategy2_0; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; - -public class GenericJavaJoinTableInAssociationOverrideJoiningStrategy2_0 - extends AbstractJavaJoinTableJoiningStrategy - implements JavaJoinTableInAssociationOverrideJoiningStrategy2_0 -{ - protected transient AssociationOverride2_0Annotation associationOverrideAnnotation; - - public GenericJavaJoinTableInAssociationOverrideJoiningStrategy2_0(JavaAssociationOverrideRelationshipReference2_0 parent) { - super(parent); - } - - public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinTableValidator(getRelationshipReference().getAssociationOverride(), (JoinTable) table, textRangeResolver); - } - - public boolean isOverridableAssociation() { - return false; - } - - @Override - public JavaAssociationOverrideRelationshipReference2_0 getRelationshipReference() { - return (JavaAssociationOverrideRelationshipReference2_0) super.getRelationshipReference(); - } - - public boolean shouldValidateAgainstDatabase() { - return getRelationshipReference().getTypeMapping().shouldValidateAgainstDatabase(); - } - - // **************** join table ********************************************* - - public JoinTableAnnotation getAnnotation() { - return this.associationOverrideAnnotation.getNonNullJoinTable(); - } - @Override - protected JoinTableAnnotation addAnnotation() { - return this.associationOverrideAnnotation.addJoinTable(); - } - - @Override - protected void removeAnnotation() { - this.associationOverrideAnnotation.removeJoinTable(); - } - - - public void initialize(AssociationOverride2_0Annotation associationOverride) { - this.associationOverrideAnnotation = associationOverride; - super.initialize(); - } - - public void update(AssociationOverride2_0Annotation associationOverride) { - this.associationOverrideAnnotation = associationOverride; - super.update(); - } - - - // **************** validation ********************************************* - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getRelationshipReference().getValidationTextRange(astRoot); - } - - public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinColumnValidator(this.getRelationshipReference().getAssociationOverride(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider()); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideInverseJoinColumnValidator(this.getRelationshipReference().getAssociationOverride(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0.java deleted file mode 100644 index 48057b5bd5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaManyToOneMapping2_0.java +++ /dev/null @@ -1,29 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaManyToOneMapping; -import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneRelationshipReference2_0; - - -public class GenericJavaManyToOneMapping2_0 - extends AbstractJavaManyToOneMapping -{ - public GenericJavaManyToOneMapping2_0(JavaPersistentAttribute parent) { - super(parent); - } - - @Override - protected JavaManyToOneRelationshipReference2_0 buildRelationshipReference() { - return new GenericJavaManyToOneRelationshipReference2_0(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaManyToOneRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaManyToOneRelationshipReference2_0.java deleted file mode 100644 index cbc931c043..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaManyToOneRelationshipReference2_0.java +++ /dev/null @@ -1,40 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaManyToOneRelationshipReference; -import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinTableJoiningStrategy; -import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneMapping2_0; - -public class GenericJavaManyToOneRelationshipReference2_0 - extends AbstractJavaManyToOneRelationshipReference -{ - - public GenericJavaManyToOneRelationshipReference2_0(JavaManyToOneMapping2_0 parent) { - super(parent); - } - - @Override - protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() { - return new GenericJavaJoinTableJoiningStrategy(this); - } - - @Override - protected JoiningStrategy calculatePredominantJoiningStrategy() { - if (this.joinTableJoiningStrategy.getJoinTable() != null) { - return this.joinTableJoiningStrategy; - } - return this.joinColumnJoiningStrategy; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java deleted file mode 100644 index 3ec591b63c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java +++ /dev/null @@ -1,299 +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.core.internal.jpa2.context.java; - -import java.util.Iterator; -import java.util.List; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.Embeddable; -import org.eclipse.jpt.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages; -import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaMapsIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapsId2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.Filter; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericJavaMapsIdDerivedIdentityStrategy2_0 - extends AbstractJavaJpaContextNode - implements JavaMapsIdDerivedIdentityStrategy2_0 -{ - protected String specifiedValue; - - protected String defaultValue; - - - public GenericJavaMapsIdDerivedIdentityStrategy2_0(JavaDerivedIdentity2_0 parent) { - super(parent); - } - - - public JavaDerivedIdentity2_0 getDerivedIdentity() { - return (JavaDerivedIdentity2_0) super.getParent(); - } - - public JavaSingleRelationshipMapping2_0 getMapping() { - return getDerivedIdentity().getMapping(); - } - - protected JavaResourcePersistentAttribute getResourceAttribute() { - return getMapping().getPersistentAttribute().getResourcePersistentAttribute(); - } - - protected MapsId2_0Annotation getAnnotation() { - return (MapsId2_0Annotation) getResourceAttribute().getNonNullAnnotation(JPA2_0.MAPS_ID); - } - - protected MapsId2_0Annotation getAnnotationOrNull() { - return (MapsId2_0Annotation) getResourceAttribute().getAnnotation(JPA2_0.MAPS_ID); - } - - protected String getResourceValue() { - return getAnnotation().getValue(); - } - - protected String calculateDefaultValue() { - Iterable<AttributeMapping> validAttributeMappings = - new FilteringIterable<AttributeMapping>( - CollectionTools.collection(getMapping().getPersistentAttribute().getOwningTypeMapping().allAttributeMappings())) { - @Override - protected boolean accept(AttributeMapping o) { - return StringTools.stringsAreEqual(o.getKey(), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY) - || StringTools.stringsAreEqual(o.getKey(), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); - } - }; - if (CollectionTools.size(validAttributeMappings) == 1) { - return validAttributeMappings.iterator().next().getName(); - } - return null; - } - - protected void addAnnotation() { - getResourceAttribute().addAnnotation(JPA2_0.MAPS_ID); - } - - protected void removeAnnotation() { - getResourceAttribute().removeAnnotation(JPA2_0.MAPS_ID); - } - - public String getSpecifiedValue() { - return this.specifiedValue; - } - - public void setSpecifiedValue(String newValue) { - if (StringTools.stringsAreEqual(this.specifiedValue, newValue)) { - return; - } - String oldValue = this.specifiedValue; - this.specifiedValue = newValue; - getAnnotation().setValue(newValue); - firePropertyChanged(SPECIFIED_VALUE_PROPERTY, oldValue, newValue); - } - - protected void setSpecifiedValue_(String newValue) { - String oldValue = this.specifiedValue; - this.specifiedValue = newValue; - firePropertyChanged(SPECIFIED_VALUE_PROPERTY, oldValue, newValue); - } - - public boolean usesDefaultValue() { - return true; - } - - public String getDefaultValue() { - return this.defaultValue; - } - - protected void setDefaultValue_(String newValue) { - if (StringTools.stringsAreEqual(this.defaultValue, newValue)) { - return; - } - String oldValue = this.defaultValue; - this.defaultValue = newValue; - firePropertyChanged(SPECIFIED_VALUE_PROPERTY, oldValue, newValue); - } - - public String getValue() { - return (this.specifiedValue != null) ? this.specifiedValue : this.defaultValue; - } - - public Iterable<String> getSortedValueChoices() { - return CollectionTools.sort( - new TransformationIterable<AttributeMapping, String>(getAllAttributeMappingChoices()) { - @Override - protected String transform(AttributeMapping o) { - return o.getName(); - } - }); - } - - public Iterable<AttributeMapping> getAllAttributeMappingChoices() { - return new CompositeIterable<AttributeMapping>( - getAttributeMappingChoiceIterables( - CollectionTools.collection(getMapping().getPersistentAttribute().getOwningTypeMapping().allAttributeMappings()))); - } - - protected Iterable<Iterable<AttributeMapping>> getAttributeMappingChoiceIterables(Iterable<AttributeMapping> availableMappings) { - return new TransformationIterable<AttributeMapping, Iterable<AttributeMapping>>(availableMappings) { - @Override - protected Iterable<AttributeMapping> transform(AttributeMapping o) { - if (StringTools.stringsAreEqual(o.getKey(), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)) { - return getEmbeddedIdMappingChoiceIterable((EmbeddedIdMapping) o); - } - return new SingleElementIterable<AttributeMapping>(o); - } - }; - } - - protected Iterable<AttributeMapping> getEmbeddedIdMappingChoiceIterable(EmbeddedIdMapping mapping) { - Embeddable embeddable = mapping.getTargetEmbeddable(); - if (embeddable == null) { - return new SingleElementIterable<AttributeMapping>(mapping); - } - return new CompositeIterable<AttributeMapping>( - mapping, - CollectionTools.collection(embeddable.allAttributeMappings())); - } - - public AttributeMapping getResolvedAttributeMappingValue() { - if (getValue() != null) { - for (AttributeMapping each : getAllAttributeMappingChoices()) { - if (each.getName().equals(getValue())) { - return each; - } - } - } - return null; - } - - public boolean isSpecified() { - return getAnnotationOrNull() != null; - } - - public void addStrategy() { - if (getAnnotationOrNull() == null) { - addAnnotation(); - } - } - - public void removeStrategy() { - if (getAnnotationOrNull() != null) { - removeAnnotation(); - } - } - - public void initialize() { - this.specifiedValue = getResourceValue(); - this.defaultValue = calculateDefaultValue(); - } - - public void update() { - this.setSpecifiedValue_(getResourceValue()); - this.setDefaultValue_(calculateDefaultValue()); - } - - @Override - public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { - Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot); - if (result != null) { - return result; - } - if (getAnnotation().valueTouches(pos, astRoot)) { - result = sortedJavaValueChoices(filter); - } - return result; - } - - protected Iterator<String> sortedJavaValueChoices(Filter<String> filter) { - return StringTools.convertToJavaStringLiterals( - new FilteringIterator<String>(getSortedValueChoices(), filter)); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getAnnotation().getTextRange(astRoot); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - super.validate(messages, reporter, astRoot); - validateMapsId(messages, reporter, astRoot); - } - - protected void validateMapsId(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { - // shortcut out if maps id is not even used - if (! getDerivedIdentity().usesMapsIdDerivedIdentityStrategy()) { - return; - } - - // test whether value can be resolved - AttributeMapping attributeMappingValue = getResolvedAttributeMappingValue(); - if (attributeMappingValue == null) { - // if value is not specified, use that message - if (getSpecifiedValue() == null) { - messages.add(buildMessage(JpaValidationMessages.MAPS_ID_VALUE_NOT_SPECIFIED, null, astRoot)); - } - else { - messages.add(buildMessage(JpaValidationMessages.MAPS_ID_VALUE_NOT_RESOLVED, new String[] {getValue()}, astRoot)); - } - } - - // test whether attribute mapping is allowable - if (attributeMappingValue != null) { - if (! CollectionTools.contains(getValidAttributeMappingChoices(), attributeMappingValue)) { - messages.add(buildMessage(JpaValidationMessages.MAPS_ID_VALUE_INVALID, new String[] {getValue()}, astRoot)); - } - } - } - - protected Iterable<AttributeMapping> getValidAttributeMappingChoices() { - return new CompositeIterable<AttributeMapping>( - getAttributeMappingChoiceIterables( - new FilteringIterable<AttributeMapping>( - CollectionTools.collection(getMapping().getPersistentAttribute().getOwningTypeMapping().allAttributeMappings())) { - @Override - protected boolean accept(AttributeMapping o) { - return StringTools.stringsAreEqual(o.getKey(), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY) - || StringTools.stringsAreEqual(o.getKey(), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); - } - })); - } - - protected IMessage buildMessage(String msgID, String[] params, CompilationUnit astRoot) { - PersistentAttribute attribute = getDerivedIdentity().getMapping().getPersistentAttribute(); - String attributeDesc = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName()); - - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - msgID, - ArrayTools.add(params, 0, attributeDesc), - this, - this.getValidationTextRange(astRoot)); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java deleted file mode 100644 index dfb4303377..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java +++ /dev/null @@ -1,92 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaQuery; -import org.eclipse.jpt.core.jpa2.context.LockModeType2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaNamedQuery2_0; -import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; - -/** - * GenericJavaNamedQuery2_0 - */ -public class GenericJavaNamedQuery2_0 extends AbstractJavaQuery - implements JavaNamedQuery2_0 -{ - protected LockModeType2_0 specifiedLockMode; - protected LockModeType2_0 defaultLockMode; - - public GenericJavaNamedQuery2_0(JavaJpaContextNode parent) { - super(parent); - } - - // ********** NamedQuery2_0 implementation ********** - - public LockModeType2_0 getLockMode() { - return (this.specifiedLockMode != null) ? this.specifiedLockMode : this.defaultLockMode; - } - - public LockModeType2_0 getSpecifiedLockMode() { - return this.specifiedLockMode; - } - - public void setSpecifiedLockMode(LockModeType2_0 lockMode) { - LockModeType2_0 old = this.specifiedLockMode; - this.specifiedLockMode = lockMode; - this.getResourceQuery().setLockMode(LockModeType2_0.toJavaResourceModel(lockMode)); - this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode); - } - - protected void setSpecifiedLockMode_(LockModeType2_0 lockMode) { - LockModeType2_0 old = this.specifiedLockMode; - this.specifiedLockMode = lockMode; - this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode); - } - - public LockModeType2_0 getDefaultLockMode() { - return this.defaultLockMode; - } - - protected void setDefaultLockMode(LockModeType2_0 lockMode) { - LockModeType2_0 old = this.defaultLockMode; - this.defaultLockMode = lockMode; - firePropertyChanged(DEFAULT_LOCK_MODE_PROPERTY, old, lockMode); - } - - protected LockModeType2_0 buildDefaultLockMode() { - return LockModeType2_0.NONE; - } - - // ********** resource => context ********** - - public void initialize(NamedQueryAnnotation resourceQuery) { - super.initialize(resourceQuery); - this.defaultLockMode = this.buildDefaultLockMode(); - this.specifiedLockMode = this.getResourceQueryLockMode(resourceQuery); - } - - public void update(NamedQueryAnnotation resourceQuery) { - super.update(resourceQuery); - this.setSpecifiedLockMode_(this.getResourceQueryLockMode(resourceQuery)); - } - - @Override - protected NamedQuery2_0Annotation getResourceQuery() { - return (NamedQuery2_0Annotation) super.getResourceQuery(); - } - - protected LockModeType2_0 getResourceQueryLockMode(NamedQueryAnnotation resourceQuery) { - return LockModeType2_0.fromJavaResourceModel( - ((NamedQuery2_0Annotation)resourceQuery).getLockMode()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0.java deleted file mode 100644 index 075d3b4d7e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyMapping2_0.java +++ /dev/null @@ -1,30 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.context.java.JavaRelationshipReference; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaOneToManyMapping; -import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation; - - -public class GenericJavaOneToManyMapping2_0 - extends AbstractJavaOneToManyMapping<OneToMany2_0Annotation> -{ - public GenericJavaOneToManyMapping2_0(JavaPersistentAttribute parent) { - super(parent); - } - - - @Override - protected JavaRelationshipReference buildRelationshipReference() { - return new GenericJavaOneToManyRelationshipReference2_0(this); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java deleted file mode 100644 index 66a2234118..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToManyRelationshipReference2_0.java +++ /dev/null @@ -1,41 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy; -import org.eclipse.jpt.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaOneToManyRelationshipReference; - -public class GenericJavaOneToManyRelationshipReference2_0 - extends AbstractJavaOneToManyRelationshipReference -{ - - public GenericJavaOneToManyRelationshipReference2_0(JavaOneToManyMapping parent) { - super(parent); - } - - @Override - protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() { - return new GenericJavaTargetForiegnKeyJoinColumnJoiningStrategy(this); - } - - @Override - protected JoiningStrategy calculatePredominantJoiningStrategy() { - if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) { - return this.mappedByJoiningStrategy; - } - else if (this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns()) { - return this.joinColumnJoiningStrategy; - } - return this.joinTableJoiningStrategy; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0.java deleted file mode 100644 index de4b0059c2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToOneMapping2_0.java +++ /dev/null @@ -1,29 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaOneToOneMapping; -import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneRelationshipReference2_0; - - -public class GenericJavaOneToOneMapping2_0 - extends AbstractJavaOneToOneMapping -{ - public GenericJavaOneToOneMapping2_0(JavaPersistentAttribute parent) { - super(parent); - } - - @Override - protected JavaOneToOneRelationshipReference2_0 buildRelationshipReference() { - return new GenericJavaOneToOneRelationshipReference2_0(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToOneRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToOneRelationshipReference2_0.java deleted file mode 100644 index 60878540a5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOneToOneRelationshipReference2_0.java +++ /dev/null @@ -1,45 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy; -import org.eclipse.jpt.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaOneToOneRelationshipReference; -import org.eclipse.jpt.core.internal.context.java.GenericJavaJoinTableJoiningStrategy; - -public class GenericJavaOneToOneRelationshipReference2_0 - extends AbstractJavaOneToOneRelationshipReference -{ - - public GenericJavaOneToOneRelationshipReference2_0(JavaOneToOneMapping parent) { - super(parent); - } - - @Override - protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() { - return new GenericJavaJoinTableJoiningStrategy(this); - } - - @Override - protected JoiningStrategy calculatePredominantJoiningStrategy() { - if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) { - return this.mappedByJoiningStrategy; - } - else if (this.primaryKeyJoinColumnJoiningStrategy.primaryKeyJoinColumnsSize() > 0) { - return this.primaryKeyJoinColumnJoiningStrategy; - } - else if (this.joinTableJoiningStrategy.getJoinTable() != null) { - return this.joinTableJoiningStrategy; - } - return this.joinColumnJoiningStrategy; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOrderColumn2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOrderColumn2_0.java deleted file mode 100644 index b80807365c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOrderColumn2_0.java +++ /dev/null @@ -1,178 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.BaseColumn; -import org.eclipse.jpt.core.context.java.JavaNamedColumn; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaNamedColumn; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrderColumn2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrderable2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - - -public class GenericJavaOrderColumn2_0 - extends AbstractJavaNamedColumn<OrderColumn2_0Annotation> - implements JavaOrderColumn2_0 -{ - protected Boolean specifiedNullable; - - protected Boolean specifiedInsertable; - - protected Boolean specifiedUpdatable; - - - public GenericJavaOrderColumn2_0(JavaOrderable2_0 parent, JavaNamedColumn.Owner owner) { - super(parent, owner); - } - - protected OrderColumn2_0Annotation getNonNullOrderColumnAnnotation(JavaResourcePersistentAttribute resource) { - return (OrderColumn2_0Annotation) resource.getNonNullAnnotation(OrderColumn2_0Annotation.ANNOTATION_NAME); - } - - public void initialize(JavaResourcePersistentAttribute resource) { - this.initialize(getNonNullOrderColumnAnnotation(resource)); - } - - @Override - public void initialize(OrderColumn2_0Annotation column) { - super.initialize(column); - this.specifiedNullable = this.getResourceNullable(column); - this.specifiedInsertable = this.getResourceInsertable(column); - this.specifiedUpdatable = this.getResourceUpdatable(column); - } - - public void update(JavaResourcePersistentAttribute resource) { - this.update(getNonNullOrderColumnAnnotation(resource)); - } - - @Override - public void update(OrderColumn2_0Annotation column) { - super.update(column); - this.setSpecifiedNullable_(this.getResourceNullable(column)); - this.setSpecifiedInsertable_(this.getResourceInsertable(column)); - this.setSpecifiedUpdatable_(this.getResourceUpdatable(column)); - } - - @Override - public JavaOrderable2_0 getParent() { - return (JavaOrderable2_0) super.getParent(); - } - - @Override - public String getTable() { - return getParent().getDefaultTableName(); - } - - public boolean isNullable() { - return (this.getSpecifiedNullable() == null) ? this.isDefaultNullable() : this.getSpecifiedNullable().booleanValue(); - } - - public boolean isDefaultNullable() { - return BaseColumn.DEFAULT_NULLABLE; - } - - public Boolean getSpecifiedNullable() { - return this.specifiedNullable; - } - - public void setSpecifiedNullable(Boolean newSpecifiedNullable) { - Boolean oldSpecifiedNullable = this.specifiedNullable; - this.specifiedNullable = newSpecifiedNullable; - this.getResourceColumn().setNullable(newSpecifiedNullable); - firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable); - } - - /** - * internal setter used only for updating from the resource model. - * There were problems with InvalidThreadAccess exceptions in the UI - * when you set a value from the UI and the annotation doesn't exist yet. - * Adding the annotation causes an update to occur and then the exception. - */ - protected void setSpecifiedNullable_(Boolean newSpecifiedNullable) { - Boolean oldSpecifiedNullable = this.specifiedNullable; - this.specifiedNullable = newSpecifiedNullable; - firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable); - } - - protected Boolean getResourceNullable(OrderColumn2_0Annotation column) { - return column.getNullable(); - } - - public boolean isInsertable() { - return (this.getSpecifiedInsertable() == null) ? this.isDefaultInsertable() : this.getSpecifiedInsertable().booleanValue(); - } - - public boolean isDefaultInsertable() { - return BaseColumn.DEFAULT_INSERTABLE; - } - - public Boolean getSpecifiedInsertable() { - return this.specifiedInsertable; - } - - public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) { - Boolean oldSpecifiedInsertable = this.specifiedInsertable; - this.specifiedInsertable = newSpecifiedInsertable; - this.getResourceColumn().setInsertable(newSpecifiedInsertable); - firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable); - } - - /** - * internal setter used only for updating from the resource model. - * There were problems with InvalidThreadAccess exceptions in the UI - * when you set a value from the UI and the annotation doesn't exist yet. - * Adding the annotation causes an update to occur and then the exception. - */ - protected void setSpecifiedInsertable_(Boolean newSpecifiedInsertable) { - Boolean oldSpecifiedInsertable = this.specifiedInsertable; - this.specifiedInsertable = newSpecifiedInsertable; - firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable); - } - - protected Boolean getResourceInsertable(OrderColumn2_0Annotation column) { - return column.getInsertable(); - } - - public boolean isUpdatable() { - return (this.getSpecifiedUpdatable() == null) ? this.isDefaultUpdatable() : this.getSpecifiedUpdatable().booleanValue(); - } - - public boolean isDefaultUpdatable() { - return BaseColumn.DEFAULT_UPDATABLE; - } - - public Boolean getSpecifiedUpdatable() { - return this.specifiedUpdatable; - } - - public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) { - Boolean oldSpecifiedUpdatable = this.specifiedUpdatable; - this.specifiedUpdatable = newSpecifiedUpdatable; - this.getResourceColumn().setUpdatable(newSpecifiedUpdatable); - firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable); - } - - /** - * internal setter used only for updating from the resource model. - * There were problems with InvalidThreadAccess exceptions in the UI - * when you set a value from the UI and the annotation doesn't exist yet. - * Adding the annotation causes an update to occur and then the exception. - */ - protected void setSpecifiedUpdatable_(Boolean newSpecifiedUpdatable) { - Boolean oldSpecifiedUpdatable = this.specifiedUpdatable; - this.specifiedUpdatable = newSpecifiedUpdatable; - firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable); - } - - protected Boolean getResourceUpdatable(OrderColumn2_0Annotation column) { - return column.getUpdatable(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java deleted file mode 100644 index 8587f04505..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java +++ /dev/null @@ -1,109 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OrphanRemovable2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * GenericJavaOrphanRemoval2_0 - */ -public class GenericJavaOrphanRemoval2_0 - extends AbstractJavaJpaContextNode - implements JavaOrphanRemovable2_0 -{ - protected boolean defaultOrphanRemoval; - protected Boolean specifiedOrphanRemoval; - - protected JavaResourcePersistentAttribute resourcePersistentAttribute; - - public GenericJavaOrphanRemoval2_0(JavaOrphanRemovalHolder2_0 parent) { - super(parent); - } - - @Override - public JavaOrphanRemovalHolder2_0 getParent() { - return (JavaOrphanRemovalHolder2_0) super.getParent(); - } - - protected String getAnnotationName() { - return ((JavaAttributeMapping)getParent()).getAnnotationName(); - } - - protected OrphanRemovable2_0Annotation getResourceOrphanRemovable() { - return (OrphanRemovable2_0Annotation) this.resourcePersistentAttribute.getAnnotation(this.getAnnotationName()); - } - - // ********** OrphanRemovable2_0 implementation ********** - - public boolean isOrphanRemoval() { - return this.specifiedOrphanRemoval != null ? this.specifiedOrphanRemoval.booleanValue() : this.defaultOrphanRemoval; - } - - public Boolean getSpecifiedOrphanRemoval() { - return this.specifiedOrphanRemoval; - } - - public boolean isDefaultOrphanRemoval() { - return this.defaultOrphanRemoval; - } - - protected void setDefaultOrphanRemoval(boolean newDefaultOrphanRemoval) { - boolean old = this.defaultOrphanRemoval; - this.defaultOrphanRemoval = newDefaultOrphanRemoval; - this.firePropertyChanged(DEFAULT_ORPHAN_REMOVAL_PROPERTY, old, newDefaultOrphanRemoval); - } - - public void setSpecifiedOrphanRemoval(Boolean newOrphanRemoval) { - Boolean old = this.specifiedOrphanRemoval; - this.specifiedOrphanRemoval = newOrphanRemoval; - this.getResourceOrphanRemovable().setOrphanRemoval(newOrphanRemoval); - this.firePropertyChanged(SPECIFIED_ORPHAN_REMOVAL_PROPERTY, old, newOrphanRemoval); - } - - protected void setSpecifiedOrphanRemoval_(Boolean newSpecifiedOrphanRemoval) { - Boolean old = this.specifiedOrphanRemoval; - this.specifiedOrphanRemoval = newSpecifiedOrphanRemoval; - this.firePropertyChanged(SPECIFIED_ORPHAN_REMOVAL_PROPERTY, old, newSpecifiedOrphanRemoval); - } - - // ********** initialize/update ********** - - public void initialize(JavaResourcePersistentAttribute jrpa) { - this.resourcePersistentAttribute = jrpa; - OrphanRemovable2_0Annotation resource = this.getResourceOrphanRemovable(); - this.specifiedOrphanRemoval = this.getSpecifiedOrphanRemovalFrom(resource); - } - - public void update(JavaResourcePersistentAttribute jrpa) { - this.resourcePersistentAttribute = jrpa; - OrphanRemovable2_0Annotation resource = this.getResourceOrphanRemovable(); - this.setSpecifiedOrphanRemoval_(this.getSpecifiedOrphanRemovalFrom(resource)); - } - - private Boolean getSpecifiedOrphanRemovalFrom(OrphanRemovable2_0Annotation resource) { - return (resource == null) ? null : resource.getOrphanRemoval(); - } - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - // TODO - return null; - } - - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java deleted file mode 100644 index 57ca824b24..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentAttribute2_0.java +++ /dev/null @@ -1,79 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.AccessType; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaPersistentAttribute; -import org.eclipse.jpt.core.internal.jpa1.context.GenericPersistentAttributeValidator; -import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * JPA 2.0 Java persistent attribute - */ -public class GenericJavaPersistentAttribute2_0 - extends AbstractJavaPersistentAttribute - implements JavaPersistentAttribute2_0 -{ - protected AccessType specifiedAccess; - - - public GenericJavaPersistentAttribute2_0(PersistentType parent, JavaResourcePersistentAttribute resourcePersistentAttribute) { - super(parent, resourcePersistentAttribute); - this.specifiedAccess = this.buildSpecifiedAccess(); - } - - - // ********** AccessHolder implementation ********** - - public AccessType getSpecifiedAccess() { - return this.specifiedAccess; - } - - /** - * Don't support changing to specified access on a java persistent attribute, this - * involves a larger process of moving the annotations to the corresponding field/property - * which may or may not exist or might need to be created. - */ - public void setSpecifiedAccess(AccessType specifiedAccess) { - throw new UnsupportedOperationException(); - } - - protected void setSpecifiedAccess_(AccessType specifiedAccess) { - AccessType old = this.specifiedAccess; - this.specifiedAccess = specifiedAccess; - this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, specifiedAccess); - } - - protected AccessType buildSpecifiedAccess() { - Access2_0Annotation accessAnnotation = - (Access2_0Annotation) this.resourcePersistentAttribute. - getAnnotation(Access2_0Annotation.ANNOTATION_NAME); - return accessAnnotation == null ? null : AccessType.fromJavaResourceModel(accessAnnotation.getValue()); - } - - @Override - public void update() { - super.update(); - this.setSpecifiedAccess_(this.buildSpecifiedAccess()); - } - - - // ********** validation ********** - - @Override - protected JptValidator buildAttibuteValidator(CompilationUnit astRoot) { - return new GenericPersistentAttributeValidator(this, this, buildTextRangeResolver(astRoot)); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentType2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentType2_0.java deleted file mode 100644 index 46939ff675..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaPersistentType2_0.java +++ /dev/null @@ -1,148 +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.core.internal.jpa2.context.java; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jpt.core.context.AccessType; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaPersistentType; -import org.eclipse.jpt.core.jpa2.JpaFactory2_0; -import org.eclipse.jpt.core.jpa2.context.MetamodelSourceType; -import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentType2_0; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.BodySourceWriter; - -/** - * JPA 2.0 Java persistent type. - * Support for specified access and metamodel generation. - */ -public class GenericJavaPersistentType2_0 - extends AbstractJavaPersistentType - implements JavaPersistentType2_0 -{ - protected String declaringTypeName; - - protected final MetamodelSourceType.Synchronizer metamodelSynchronizer; - - - public GenericJavaPersistentType2_0(PersistentType.Owner parent, JavaResourcePersistentType jrpt) { - super(parent, jrpt); - this.metamodelSynchronizer = this.buildMetamodelSynchronizer(); - } - - @Override - protected void initialize(JavaResourcePersistentType jrpt) { - super.initialize(jrpt); - this.declaringTypeName = this.buildDeclaringTypeName(); - } - - protected MetamodelSourceType.Synchronizer buildMetamodelSynchronizer() { - return ((JpaFactory2_0) this.getJpaFactory()).buildMetamodelSynchronizer(this); - } - - @Override - public void update() { - super.update(); - this.setDeclaringTypeName(this.buildDeclaringTypeName()); - } - - - // ********** access ********** - - protected Access2_0Annotation getAccessAnnotation() { - return (Access2_0Annotation) this.resourcePersistentType.getNonNullAnnotation(this.getAccessAnnotationName()); - } - - protected String getAccessAnnotationName() { - return Access2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected AccessType buildSpecifiedAccess() { - return AccessType.fromJavaResourceModel(this.getAccessAnnotation().getValue()); - } - - public void setSpecifiedAccess(AccessType specifiedAccess) { - AccessType old = this.specifiedAccess; - this.specifiedAccess = specifiedAccess; - this.getAccessAnnotation().setValue(AccessType.toJavaResourceModel(specifiedAccess)); - this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, specifiedAccess); - } - - protected void setSpecifiedAccess_(AccessType specifiedAccess) { - AccessType old = this.specifiedAccess; - this.specifiedAccess = specifiedAccess; - this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, specifiedAccess); - } - - @Override - protected Iterator<JavaResourcePersistentAttribute> resourceAttributes() { - return (this.specifiedAccess == null) ? - super.resourceAttributes() : - this.resourcePersistentType.persistableAttributes(AccessType.toJavaResourceModel(this.specifiedAccess)); - } - - @Override - public void updateAccess() { - super.updateAccess(); - this.setSpecifiedAccess_(this.buildSpecifiedAccess()); - } - - - // ********** declaring type name ********** - - public String getDeclaringTypeName() { - return this.declaringTypeName; - } - - protected void setDeclaringTypeName(String declaringTypeName) { - String old = this.declaringTypeName; - this.declaringTypeName = declaringTypeName; - this.firePropertyChanged(DECLARING_TYPE_NAME_PROPERTY, old, declaringTypeName); - } - - protected String buildDeclaringTypeName() { - return this.resourcePersistentType.getDeclaringTypeName(); - } - - - // ********** metamodel ********** - - public IFile getMetamodelFile() { - return this.metamodelSynchronizer.getFile(); - } - - public void initializeMetamodel() { - // do nothing - probably shouldn't be called... - } - - public boolean isManaged() { - return true; - } - - public void synchronizeMetamodel(Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - this.metamodelSynchronizer.synchronize(memberTypeTree); - } - - public void printBodySourceOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType>> memberTypeTree) { - this.metamodelSynchronizer.printBodySourceOn(pw, memberTypeTree); - } - - public void disposeMetamodel() { - // do nothing - probably shouldn't be called... - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0.java deleted file mode 100644 index 242ab12a17..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0.java +++ /dev/null @@ -1,139 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaSequenceGenerator; -import org.eclipse.jpt.core.jpa2.context.SequenceGenerator2_0; -import org.eclipse.jpt.core.jpa2.resource.java.SequenceGenerator2_0Annotation; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; - -/** - * Generic2_0JavaSequenceGenerator - */ -public class GenericJavaSequenceGenerator2_0 extends AbstractJavaSequenceGenerator - implements SequenceGenerator2_0 -{ - protected String specifiedCatalog; - protected String defaultCatalog; - - protected String specifiedSchema; - protected String defaultSchema; - - public GenericJavaSequenceGenerator2_0(JavaJpaContextNode parent) { - super(parent); - } - - // ********** catalog ********** - - @Override - public String getCatalog() { - return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog; - } - - public String getSpecifiedCatalog() { - return this.specifiedCatalog; - } - - public void setSpecifiedCatalog(String catalog) { - String old = this.specifiedCatalog; - this.specifiedCatalog = catalog; - this.getResourceGenerator().setCatalog(catalog); - this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, 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; - firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog); - } - - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - // ********** schema ********** - - @Override - public String getSchema() { - return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema; - } - - public String getSpecifiedSchema() { - return this.specifiedSchema; - } - - public void setSpecifiedSchema(String schema) { - String old = this.specifiedSchema; - this.specifiedSchema = schema; - this.getResourceGenerator().setSchema(schema); - this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, 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(); - } - - // ********** resource => context ********** - - @Override - public void initialize(SequenceGeneratorAnnotation resourceSequenceGenerator) { - super.initialize(resourceSequenceGenerator); - SequenceGenerator2_0Annotation resource = (SequenceGenerator2_0Annotation) resourceSequenceGenerator; - - this.defaultCatalog = this.buildDefaultCatalog(); - this.specifiedCatalog = resource.getCatalog(); - this.defaultSchema = this.buildDefaultSchema(); - this.specifiedSchema = resource.getSchema(); - } - - @Override - public void update(SequenceGeneratorAnnotation resourceSequenceGenerator) { - super.update(resourceSequenceGenerator); - SequenceGenerator2_0Annotation resource = (SequenceGenerator2_0Annotation) resourceSequenceGenerator; - - this.setDefaultCatalog(this.buildDefaultCatalog()); - this.setSpecifiedCatalog_(resource.getCatalog()); - this.setDefaultSchema(this.buildDefaultSchema()); - this.setSpecifiedSchema_(resource.getSchema()); - } - - @Override - protected SequenceGenerator2_0Annotation getResourceGenerator() { - return (SequenceGenerator2_0Annotation) super.getResourceGenerator(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaTargetForiegnKeyJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaTargetForiegnKeyJoinColumnJoiningStrategy.java deleted file mode 100644 index 1241c2ab88..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/GenericJavaTargetForiegnKeyJoinColumnJoiningStrategy.java +++ /dev/null @@ -1,45 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy; - -public class GenericJavaTargetForiegnKeyJoinColumnJoiningStrategy - extends AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy -{ - - public GenericJavaTargetForiegnKeyJoinColumnJoiningStrategy(JavaJoinColumnEnabledRelationshipReference parent) { - super(parent); - } - - public TypeMapping getRelationshipSource() { - RelationshipMapping relationshipMapping = getRelationshipMapping(); - return relationshipMapping == null ? null : relationshipMapping.getResolvedTargetEntity(); - } - - public TypeMapping getRelationshipTarget() { - return getRelationshipMapping().getTypeMapping(); - } - - @Override - protected Entity getRelationshipTargetEntity() { - TypeMapping relationshipTarget = getRelationshipTarget(); - return relationshipTarget.getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY ? (Entity) relationshipTarget : null; - } - - public boolean isTargetForeignKeyRelationship() { - return true; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java deleted file mode 100644 index 3a276373a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/JavaElementCollectionMappingDefinition2_0.java +++ /dev/null @@ -1,57 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.JpaFactory; -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition; -import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaAttributeMappingDefinition; -import org.eclipse.jpt.core.jpa2.JpaFactory2_0; -import org.eclipse.jpt.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation; - -public class JavaElementCollectionMappingDefinition2_0 - extends AbstractJavaAttributeMappingDefinition -{ - // singleton - private static final JavaElementCollectionMappingDefinition2_0 INSTANCE = - new JavaElementCollectionMappingDefinition2_0(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private JavaElementCollectionMappingDefinition2_0() { - super(); - } - - public String getKey() { - return MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY; - } - - public String getAnnotationName() { - return ElementCollection2_0Annotation.ANNOTATION_NAME; - } - - public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) { - return ((JpaFactory2_0) factory).buildJavaElementCollectionMapping2_0(parent); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java deleted file mode 100644 index d8948bc5ad..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/JavaIdMappingDefinition2_0.java +++ /dev/null @@ -1,37 +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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition; - -public class JavaIdMappingDefinition2_0 - extends AbstractJavaIdMappingDefinition2_0 -{ - // singleton - private static final JavaIdMappingDefinition2_0 INSTANCE = - new JavaIdMappingDefinition2_0(); - - - /** - * Return the singleton. - */ - public static JavaAttributeMappingDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private JavaIdMappingDefinition2_0() { - super(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaCacheable2_0.java deleted file mode 100644 index 7110530551..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaCacheable2_0.java +++ /dev/null @@ -1,56 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.java.JavaCacheable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -public class NullJavaCacheable2_0 - extends AbstractJavaJpaContextNode - implements JavaCacheable2_0 -{ - public NullJavaCacheable2_0(JavaCacheableHolder2_0 parent) { - super(parent); - } - - public Boolean getSpecifiedCacheable() { - return null; - } - - public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) { - throw new UnsupportedOperationException(); - } - - public boolean isCacheable() { - return false; - } - - public boolean isDefaultCacheable() { - return false; - } - - public void initialize(JavaResourcePersistentType jrpt) { - //no-op - } - - public void update(JavaResourcePersistentType jrpt) { - //no-op - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java deleted file mode 100644 index 96e0f78fea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java +++ /dev/null @@ -1,90 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.DerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.IdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.MapsIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.utility.TextRange; - -public class NullJavaDerivedIdentity2_0 - extends AbstractJavaJpaContextNode - implements JavaDerivedIdentity2_0 -{ - public NullJavaDerivedIdentity2_0(JavaSingleRelationshipMapping2_0 parent) { - super(parent); - } - - - public JavaSingleRelationshipMapping2_0 getMapping() { - return (JavaSingleRelationshipMapping2_0) getParent(); - } - - public void initialize() { - // no op - } - - public void update() { - // no op - } - - public DerivedIdentityStrategy2_0 getPredominantDerivedIdentityStrategy() { - return null; - } - - public MapsIdDerivedIdentityStrategy2_0 getMapsIdDerivedIdentityStrategy() { - return null; - } - - public boolean usesMapsIdDerivedIdentityStrategy() { - return false; - } - - public void setMapsIdDerivedIdentityStrategy() { - // no op - } - - public void unsetMapsIdDerivedIdentityStrategy() { - // no op - } - - public IdDerivedIdentityStrategy2_0 getIdDerivedIdentityStrategy() { - return null; - } - - public boolean usesIdDerivedIdentityStrategy() { - return false; - } - - public void setIdDerivedIdentityStrategy() { - // no op - } - - public void unsetIdDerivedIdentityStrategy() { - // no op - } - - public boolean usesNullDerivedIdentityStrategy() { - return true; - } - - public void setNullDerivedIdentityStrategy() { - // no op - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java deleted file mode 100644 index 9be228255c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java +++ /dev/null @@ -1,234 +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.core.internal.jpa2.context.java; - -import java.util.Iterator; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.java.JavaColumn; -import org.eclipse.jpt.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.resource.java.ColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.db.Column; -import org.eclipse.jpt.db.Table; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - - -public class NullJavaMapKeyColumn2_0 - extends AbstractJavaJpaContextNode - implements JavaColumn -{ - - public NullJavaMapKeyColumn2_0(JavaJpaContextNode parent) { - super(parent); - } - - public void initialize(JavaResourcePersistentAttribute resource) { - //no-op - } - - public void update(JavaResourcePersistentAttribute resource) { - //no-op - } - - public void initialize(ColumnAnnotation resourceColumn) { - //no-op - } - - public void update(ColumnAnnotation resourceColumn) { - //no-op - } - - public String getName() { - return null; - } - - public String getSpecifiedName() { - return null; - } - - public void setSpecifiedName(String newSpecifiedName) { - throw new UnsupportedOperationException(); - } - - public String getDefaultName() { - return null; - } - - public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean isNullable() { - return false; - } - - public boolean isDefaultNullable() { - return false; - } - - public Boolean getSpecifiedNullable() { - return null; - } - - public void setSpecifiedNullable(Boolean newSpecifiedNullable) { - throw new UnsupportedOperationException(); - } - - public boolean isInsertable() { - return false; - } - - public boolean isDefaultInsertable() { - return false; - } - - public Boolean getSpecifiedInsertable() { - return null; - } - - public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) { - throw new UnsupportedOperationException(); - } - - public boolean isUpdatable() { - return false; - } - - public boolean isDefaultUpdatable() { - return false; - } - - public Boolean getSpecifiedUpdatable() { - return null; - } - - public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) { - throw new UnsupportedOperationException(); - } - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; - } - - public int getDefaultLength() { - return 0; - } - - public int getDefaultPrecision() { - return 0; - } - - public int getDefaultScale() { - return 0; - } - - public int getLength() { - return 0; - } - - public int getPrecision() { - return 0; - } - - public int getScale() { - return 0; - } - - public Integer getSpecifiedLength() { - return null; - } - - public Integer getSpecifiedPrecision() { - return null; - } - - public Integer getSpecifiedScale() { - return null; - } - - public void setSpecifiedLength(Integer newSpecifiedLength) { - throw new UnsupportedOperationException(); - } - - public void setSpecifiedPrecision(Integer newSpecifiedPrecision) { - throw new UnsupportedOperationException(); - } - - public void setSpecifiedScale(Integer newSpecifiedScale) { - throw new UnsupportedOperationException(); - } - - public Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - public String getDefaultTable() { - return null; - } - - public String getSpecifiedTable() { - return null; - } - - public String getTable() { - return null; - } - - public void setSpecifiedTable(String value) { - throw new UnsupportedOperationException(); - } - - public Boolean getSpecifiedUnique() { - return null; - } - - public void setSpecifiedUnique(Boolean newSpecifiedUnique) { - throw new UnsupportedOperationException(); - } - - public boolean isDefaultUnique() { - return false; - } - - public boolean isUnique() { - return false; - } - - public String getColumnDefinition() { - return null; - } - - public void setColumnDefinition(String value) { - throw new UnsupportedOperationException(); - } - - public boolean tableNameIsInvalid() { - return false; - } - - public TextRange getTableTextRange(CompilationUnit astRoot) { - return null; - } - - public Column getDbColumn() { - return null; - } - - public Table getDbTable() { - return null; - } - - public boolean isResolved() { - return false; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaOrderColumn2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaOrderColumn2_0.java deleted file mode 100644 index b46cca3ba4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaOrderColumn2_0.java +++ /dev/null @@ -1,91 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.context.java.JavaJpaContextNode; -import org.eclipse.jpt.core.context.java.JavaNamedColumn; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaNamedColumn; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrderColumn2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - - -public class NullJavaOrderColumn2_0 - extends AbstractJavaNamedColumn<OrderColumn2_0Annotation> - implements JavaOrderColumn2_0 -{ - - public NullJavaOrderColumn2_0(JavaJpaContextNode parent, JavaNamedColumn.Owner owner) { - super(parent, owner); - } - - public void initialize(JavaResourcePersistentAttribute resource) { - //no-op - } - - public void update(JavaResourcePersistentAttribute resource) { - //no-op - } - - public boolean isNullable() { - return false; - } - - public boolean isDefaultNullable() { - return false; - } - - public Boolean getSpecifiedNullable() { - return null; - } - - public void setSpecifiedNullable(Boolean newSpecifiedNullable) { - throw new UnsupportedOperationException(); - } - - public boolean isInsertable() { - return false; - } - - public boolean isDefaultInsertable() { - return false; - } - - public Boolean getSpecifiedInsertable() { - return null; - } - - public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) { - throw new UnsupportedOperationException(); - } - - public boolean isUpdatable() { - return false; - } - - public boolean isDefaultUpdatable() { - return false; - } - - public Boolean getSpecifiedUpdatable() { - return null; - } - - public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) { - throw new UnsupportedOperationException(); - } - - @Override - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java deleted file mode 100644 index 03633a8565..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java +++ /dev/null @@ -1,64 +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.core.internal.jpa2.context.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.context.java.AbstractJavaJpaContextNode; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * NullJavaOrphanRemoval2_0 - */ -public class NullJavaOrphanRemoval2_0 - extends AbstractJavaJpaContextNode - implements JavaOrphanRemovable2_0 -{ - // ********** constructor ********** - public NullJavaOrphanRemoval2_0(JavaOrphanRemovalHolder2_0 parent) { - super(parent); - } - - // ********** OrphanRemovable2_0 implementation ********** - - public boolean isOrphanRemoval() { - return false; - } - - public Boolean getSpecifiedOrphanRemoval() { - return null; - } - - public boolean isDefaultOrphanRemoval() { - return false; - } - - public void setSpecifiedOrphanRemoval(Boolean newSpecifiedOrphanRemoval) { - throw new UnsupportedOperationException(); - } - - // ********** JavaOrphanRemovable2_0 implementation ********** - - public void initialize(JavaResourcePersistentAttribute jrpa) { - // do nothing - } - - public void update(JavaResourcePersistentAttribute jrpa) { - // do nothing - } - - // ********** validation ********** - - public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/VirtualAssociationOverride2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/VirtualAssociationOverride2_0Annotation.java deleted file mode 100644 index 122c3f6bc3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/VirtualAssociationOverride2_0Annotation.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.core.internal.jpa2.context.java; - -import org.eclipse.jpt.core.context.JoinTableJoiningStrategy; -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.internal.context.java.VirtualAssociationOverrideAnnotation; -import org.eclipse.jpt.core.internal.resource.java.NullJoinTableAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; - -/** - * javax.persistence.AssociationOverride - */ -public final class VirtualAssociationOverride2_0Annotation - extends VirtualAssociationOverrideAnnotation - implements AssociationOverride2_0Annotation -{ - - private final JoinTableAnnotation joinTable; - - public VirtualAssociationOverride2_0Annotation(JavaResourcePersistentMember parent, String name, JoiningStrategy joiningStrategy) { - super(parent, name, joiningStrategy); - this.joinTable = this.buildJoinTable(); - } - - protected JoinTableAnnotation buildJoinTable() { - if (this.joiningStrategy instanceof JoinTableJoiningStrategy) { - return new VirtualAssociationOverrideJoinTableAnnotation(this, ((JoinTableJoiningStrategy)this.joiningStrategy).getJoinTable()); - } - return new NullJoinTableAnnotation(this); - } - - // ***** join table - - public JoinTableAnnotation getJoinTable() { - return this.joinTable; - } - - public JoinTableAnnotation getNonNullJoinTable() { - return this.joinTable; - } - - public JoinTableAnnotation addJoinTable() { - throw new UnsupportedOperationException(); - } - - public void removeJoinTable() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/VirtualAssociationOverrideJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/VirtualAssociationOverrideJoinTableAnnotation.java deleted file mode 100644 index 62b0475fd2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/java/VirtualAssociationOverrideJoinTableAnnotation.java +++ /dev/null @@ -1,133 +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.core.internal.jpa2.context.java; - -import java.util.ListIterator; -import java.util.Vector; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.internal.context.java.VirtualAssociationOverrideJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.resource.java.NullJoinTableAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.utility.internal.CollectionTools; - -public final class VirtualAssociationOverrideJoinTableAnnotation extends NullJoinTableAnnotation - implements JoinTableAnnotation -{ - private JoinTable joinTable; //TODO uniqueConstraints - - private final Vector<JoinColumnAnnotation> joinColumns; - - private final Vector<JoinColumnAnnotation> inverseJoinColumns; - - public VirtualAssociationOverrideJoinTableAnnotation(AssociationOverride2_0Annotation parent, JoinTable joinTable) { - super(parent); - this.joinTable = joinTable; - this.joinColumns = this.buildJoinColumns(); - this.inverseJoinColumns = this.buildInverseJoinColumns(); - } - - @Override - protected JoinTableAnnotation addAnnotation() { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildJoinColumns() { - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(this.joinTable.joinColumnsSize()); - for (JoinColumn joinColumn : CollectionTools.iterable(this.joinTable.joinColumns())) { - result.add(new VirtualAssociationOverrideJoinColumnAnnotation(this, joinColumn)); - } - return result; - } - - private Vector<JoinColumnAnnotation> buildInverseJoinColumns() { - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(this.joinTable.inverseJoinColumnsSize()); - for (JoinColumn joinColumn : CollectionTools.iterable(this.joinTable.inverseJoinColumns())) { - result.add(new VirtualAssociationOverrideJoinColumnAnnotation(this, joinColumn)); - } - return result; - } - - @Override - public String getName() { - return this.joinTable.getSpecifiedName(); - } - - @Override - public void setName(String name) { - throw new UnsupportedOperationException(); - } - - @Override - public String getCatalog() { - return this.joinTable.getCatalog(); - } - - @Override - public void setCatalog(String catalog) { - throw new UnsupportedOperationException(); - } - - @Override - public String getSchema() { - return this.joinTable.getSchema(); - } - - @Override - public void setSchema(String schema) { - throw new UnsupportedOperationException(); - } - - // ***** join columns - @Override - public ListIterator<JoinColumnAnnotation> joinColumns() { - return this.joinColumns.listIterator(); - } - - @Override - public JoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.elementAt(index); - } - - @Override - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - @Override - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - // ***** inverse join columns - @Override - public ListIterator<JoinColumnAnnotation> inverseJoinColumns() { - return this.inverseJoinColumns.listIterator(); - } - - @Override - public JoinColumnAnnotation inverseJoinColumnAt(int index) { - return this.inverseJoinColumns.elementAt(index); - } - - @Override - public int indexOfInverseJoinColumn(JoinColumnAnnotation joinColumn) { - return this.inverseJoinColumns.indexOf(joinColumn); - } - - @Override - public int inverseJoinColumnsSize() { - return this.inverseJoinColumns.size(); - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java deleted file mode 100644 index 960fad85b8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java +++ /dev/null @@ -1,1566 +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.core.internal.jpa2.context.orm; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.emf.common.util.EList; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AssociationOverride; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.AttributeOverride; -import org.eclipse.jpt.core.context.BaseColumn; -import org.eclipse.jpt.core.context.BaseOverride; -import org.eclipse.jpt.core.context.Column; -import org.eclipse.jpt.core.context.Converter; -import org.eclipse.jpt.core.context.Embeddable; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.FetchType; -import org.eclipse.jpt.core.context.Fetchable; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoinColumn.Owner; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.core.context.PersistentType; -import org.eclipse.jpt.core.context.RelationshipReference; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer; -import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.core.context.orm.OrmAttributeOverrideContainer; -import org.eclipse.jpt.core.context.orm.OrmColumn; -import org.eclipse.jpt.core.context.orm.OrmConverter; -import org.eclipse.jpt.core.context.orm.OrmOverrideContainer; -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.MappingTools; -import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver; -import org.eclipse.jpt.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmAttributeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAttributeOverrideColumn; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator; -import org.eclipse.jpt.core.internal.jpa1.context.CollectionTableTableDescriptionProvider; -import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider; -import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideValidator; -import org.eclipse.jpt.core.internal.jpa1.context.MapKeyColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator; -import org.eclipse.jpt.core.internal.jpa2.context.CollectionTableValidator; -import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.core.jpa2.context.CollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.MetamodelField; -import org.eclipse.jpt.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.core.jpa2.context.PersistentAttribute2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrderable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory; -import org.eclipse.jpt.core.resource.orm.Attributes; -import org.eclipse.jpt.core.resource.orm.MapKey; -import org.eclipse.jpt.core.resource.orm.OrmFactory; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.core.resource.orm.XmlClassReference; -import org.eclipse.jpt.core.resource.orm.XmlCollectionTable; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlElementCollection; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.utility.internal.iterables.EmptyIterable; -import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; -import org.eclipse.text.edits.ReplaceEdit; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - - -public abstract class AbstractOrmElementCollectionMapping2_0<T extends XmlElementCollection> - extends AbstractOrmAttributeMapping<T> - implements OrmElementCollectionMapping2_0 -{ - - protected String specifiedTargetClass; - protected String defaultTargetClass; - protected PersistentType resolvedTargetType; - protected Embeddable resolvedTargetEmbeddable; - - protected FetchType specifiedFetch; - - protected final OrmOrderable2_0 orderable; - - protected final OrmCollectionTable2_0 collectionTable; - - protected Type valueType; - - protected final OrmColumn valueColumn; - - protected OrmConverter valueConverter; - - protected final OrmConverter nullValueConverter; - - protected final OrmAttributeOverrideContainer valueAttributeOverrideContainer; - - protected final OrmAssociationOverrideContainer valueAssociationOverrideContainer; - - protected Type keyType; - - protected String specifiedMapKey; - protected boolean noMapKey = false; - protected boolean pkMapKey = false; - protected boolean customMapKey = false; - - protected String specifiedMapKeyClass; - protected String defaultMapKeyClass; - protected PersistentType resolvedMapKeyType; - protected Embeddable resolvedMapKeyEmbeddable; - protected Entity resolvedMapKeyEntity; - - protected final OrmColumn mapKeyColumn; - - protected final OrmAttributeOverrideContainer mapKeyAttributeOverrideContainer; - - protected AbstractOrmElementCollectionMapping2_0(OrmPersistentAttribute parent, T resourceMapping) { - super(parent, resourceMapping); - this.specifiedFetch = this.getResourceFetch(); - this.orderable = getXmlContextNodeFactory().buildOrmOrderable(this, buildOrderableOwner()); - this.specifiedTargetClass = getResourceTargetClass(); - this.defaultTargetClass = buildDefaultTargetClass(); - this.resolvedTargetType = this.resolveTargetType(); - this.resolvedTargetEmbeddable = resolveTargetEmbeddable(); - this.collectionTable = getXmlContextNodeFactory().buildOrmCollectionTable(this, new CollectionTableOwner(), getResourceCollectionTable()); - this.valueType = this.buildValueType(); - this.valueColumn = getXmlContextNodeFactory().buildOrmColumn(this, new ValueColumnOwner()); - this.nullValueConverter = this.getXmlContextNodeFactory().buildOrmNullConverter(this); - this.valueConverter = this.buildConverter(this.getResourceConverterType()); - this.valueAssociationOverrideContainer = buildValueAssociationOverrideContainer(); - this.valueAttributeOverrideContainer = buildValueAttributeOverrideContainer(); - this.resolvedMapKeyType = this.resolveMapKeyType(); - this.resolvedMapKeyEmbeddable = this.resolveMapKeyEmbeddable(); - this.resolvedMapKeyEntity = this.resolveMapKeyEntity(); - this.initializeMapKey(); - this.defaultMapKeyClass = this.buildDefaultMapKeyClass(); - this.specifiedMapKeyClass = this.getResourceMapKeyClass(); - this.mapKeyColumn = getXmlContextNodeFactory().buildOrmColumn(this, new MapKeyColumnOwner()); - this.mapKeyAttributeOverrideContainer = this.buildMapKeyAttributeOverrideContainer(); - } - - @Override - public void update() { - super.update(); - this.setSpecifiedTargetClass_(this.getResourceTargetClass()); - this.setDefaultTargetClass(this.buildDefaultTargetClass()); - this.resolvedTargetType = this.resolveTargetType(); - this.setResolvedTargetEmbeddable(this.resolveTargetEmbeddable()); - this.setSpecifiedFetch_(this.getResourceFetch()); - this.orderable.update(); - this.collectionTable.update(); - this.setValueType(buildValueType()); - this.valueColumn.update(getResourceColumn()); - this.valueAttributeOverrideContainer.update(); - this.valueAssociationOverrideContainer.update(); - this.updateValueConverter(); - this.resolvedMapKeyType = this.resolveMapKeyType();//no need for change notification, use resolved target embeddable change notification instead? - this.setResolvedMapKeyEmbeddable(this.resolveMapKeyEmbeddable()); - this.setResolvedMapKeyEntity(this.resolveMapKeyEntity()); - this.setKeyType(buildKeyType()); - this.updateMapKey(); - this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass()); - this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass()); - this.mapKeyColumn.update(getResourceMapKeyColumn()); - this.mapKeyAttributeOverrideContainer.update(); - } - - @Override - public void postUpdate() { - super.postUpdate(); - this.valueAssociationOverrideContainer.postUpdate(); - } - - @Override - protected OrmXml2_0ContextNodeFactory getXmlContextNodeFactory() { - return super.getXmlContextNodeFactory(); - } - - public Entity getEntity() { - return getTypeMapping().getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY ? (Entity) getTypeMapping() : null; - } - - - //************* AttributeMapping implementation *************** - - public String getKey() { - return MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY; - } - - //************* OrmAttributeMapping implementation *************** - public void initializeOn(OrmAttributeMapping newMapping) { - newMapping.initializeFromOrmAttributeMapping(this); - } - - public int getXmlSequence() { - return 75; - } - - public void addToResourceModel(Attributes resourceAttributes) { - resourceAttributes.getElementCollections().add(this.resourceAttributeMapping); - } - - public void removeFromResourceModel(Attributes resourceAttributes) { - resourceAttributes.getElementCollections().remove(this.resourceAttributeMapping); - } - - - // **************** target class ****************************************** - - public char getTargetClassEnclosingTypeSeparator() { - return '$'; - } - - public String getTargetClass() { - return (this.specifiedTargetClass != null) ? this.specifiedTargetClass : this.defaultTargetClass; - } - - public String getSpecifiedTargetClass() { - return this.specifiedTargetClass; - } - - public void setSpecifiedTargetClass(String targetClass) { - String old = this.specifiedTargetClass; - this.specifiedTargetClass = targetClass; - this.resourceAttributeMapping.setTargetClass(targetClass); - this.firePropertyChanged(SPECIFIED_TARGET_CLASS_PROPERTY, old, targetClass); - } - - protected void setSpecifiedTargetClass_(String targetClass) { - String old = this.specifiedTargetClass; - this.specifiedTargetClass = targetClass; - this.firePropertyChanged(SPECIFIED_TARGET_CLASS_PROPERTY, old, targetClass); - } - - public String getDefaultTargetClass() { - return this.defaultTargetClass; - } - - protected void setDefaultTargetClass(String targetClass) { - String old = this.defaultTargetClass; - this.defaultTargetClass = targetClass; - this.firePropertyChanged(DEFAULT_TARGET_CLASS_PROPERTY, old, targetClass); - } - - public Embeddable getResolvedTargetEmbeddable() { - return this.resolvedTargetEmbeddable; - } - - protected void setResolvedTargetEmbeddable(Embeddable targetEmbeddable) { - Embeddable old = this.resolvedTargetEmbeddable; - this.resolvedTargetEmbeddable = targetEmbeddable; - this.firePropertyChanged(RESOLVED_TARGET_EMBEDDABLE_PROPERTY, old, targetEmbeddable); - } - - public PersistentType getResolvedTargetType() { - return this.resolvedTargetType; - } - - protected String getResourceTargetClass() { - return this.resourceAttributeMapping.getTargetClass(); - } - - protected String buildDefaultTargetClass() { - if (this.getJavaPersistentAttribute() != null) { - return this.getJavaPersistentAttribute().getMultiReferenceTargetTypeName(); - } - return null; - } - - protected PersistentType resolveTargetType() { - return this.resolvePersistentType(this.getTargetClass()); - } - - protected Embeddable resolveTargetEmbeddable() { - if (this.resolvedTargetType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedTargetType.getMapping(); - return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null; - } - - //************* Fetchable ************* - - public FetchType getFetch() { - return (this.getSpecifiedFetch() == null) ? this.getDefaultFetch() : this.getSpecifiedFetch(); - } - - public FetchType getDefaultFetch() { - return DEFAULT_FETCH_TYPE; - } - - public FetchType getSpecifiedFetch() { - return this.specifiedFetch; - } - - public void setSpecifiedFetch(FetchType newSpecifiedFetch) { - FetchType oldFetch = this.specifiedFetch; - this.specifiedFetch = newSpecifiedFetch; - this.resourceAttributeMapping.setFetch(FetchType.toOrmResourceModel(newSpecifiedFetch)); - firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch); - } - - protected void setSpecifiedFetch_(FetchType newSpecifiedFetch) { - FetchType oldFetch = this.specifiedFetch; - this.specifiedFetch = newSpecifiedFetch; - firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch); - } - - protected FetchType getResourceFetch() { - return FetchType.fromOrmResourceModel(this.resourceAttributeMapping.getFetch()); - } - - // **************** collection table *********************************************** - - public OrmCollectionTable2_0 getCollectionTable() { - return this.collectionTable; - } - - public XmlCollectionTable getResourceCollectionTable() { - return this.resourceAttributeMapping.getCollectionTable(); - } - - - // ************** value column ******************************************** - - public OrmColumn getValueColumn() { - return this.valueColumn; - } - - protected XmlColumn getResourceColumn() { - return this.resourceAttributeMapping.getColumn(); - } - - - // *********** value converter ************* - - public OrmConverter getConverter() { - return this.valueConverter; - } - - protected String getConverterType() { - return this.valueConverter.getType(); - } - - public void setConverter(String converterType) { - if (this.valuesAreEqual(getConverterType(), converterType)) { - return; - } - OrmConverter oldConverter = this.valueConverter; - OrmConverter newConverter = buildConverter(converterType); - this.valueConverter = this.nullValueConverter; - if (oldConverter != null) { - oldConverter.removeFromResourceModel(); - } - this.valueConverter = newConverter; - if (newConverter != null) { - newConverter.addToResourceModel(); - } - firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter); - } - - protected void setConverter(OrmConverter newConverter) { - OrmConverter oldConverter = this.valueConverter; - this.valueConverter = newConverter; - firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter); - } - - protected OrmConverter buildConverter(String converterType) { - if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) { - return this.nullValueConverter; - } - if (this.valuesAreEqual(converterType, Converter.ENUMERATED_CONVERTER)) { - return getXmlContextNodeFactory().buildOrmEnumeratedConverter(this, this.resourceAttributeMapping); - } - if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) { - return getXmlContextNodeFactory().buildOrmTemporalConverter(this, this.resourceAttributeMapping); - } - if (this.valuesAreEqual(converterType, Converter.LOB_CONVERTER)) { - return getXmlContextNodeFactory().buildOrmLobConverter(this, this.resourceAttributeMapping); - } - return null; - } - - protected String getResourceConverterType() { - if (this.resourceAttributeMapping.getEnumerated() != null) { - return Converter.ENUMERATED_CONVERTER; - } - else if (this.resourceAttributeMapping.getTemporal() != null) { - return Converter.TEMPORAL_CONVERTER; - } - else if (this.resourceAttributeMapping.isLob()) { - return Converter.LOB_CONVERTER; - } - - return Converter.NO_CONVERTER; - } - - protected void updateValueConverter() { - if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) { - getConverter().update(); - } - else { - setConverter(buildConverter(getResourceConverterType())); - } - } - - - public Type getValueType() { - return this.valueType; - } - - protected void setValueType(Type newValueType) { - Type old = this.valueType; - this.valueType = newValueType; - firePropertyChanged(VALUE_TYPE_PROPERTY, old, newValueType); - } - - protected Type buildValueType() { - if (getResolvedTargetEmbeddable() != null) { - return Type.EMBEDDABLE_TYPE; - } - else if (getTargetClass() == null) { - return Type.NO_TYPE; - } - return Type.BASIC_TYPE; - } - - public Type getKeyType() { - return this.keyType; - } - - protected void setKeyType(Type newKeyType) { - Type old = this.keyType; - this.keyType = newKeyType; - firePropertyChanged(KEY_TYPE_PROPERTY, old, newKeyType); - } - - protected Type buildKeyType() { - if (getResolvedMapKeyEmbeddable() != null) { - return Type.EMBEDDABLE_TYPE; - } - if (getResolvedMapKeyEntity() != null) { - return Type.ENTITY_TYPE; - } - else if (getMapKeyClass() == null) { - return Type.NO_TYPE; - } - return Type.BASIC_TYPE; - } - - // ************** value column ******************************************** - - public OrmColumn getMapKeyColumn() { - return this.mapKeyColumn; - } - - protected XmlColumn getResourceMapKeyColumn() { - return this.resourceAttributeMapping.getMapKeyColumn(); - } - - // **************** ordering *********************************************** - - public OrmOrderable2_0 getOrderable() { - return this.orderable; - } - - protected Orderable2_0.Owner buildOrderableOwner() { - return new Orderable2_0.Owner() { - public String getTableName() { - return getCollectionTable().getName(); - } - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - return getCollectionTable().getDbTable(); - } - }; - } - - - // **************** overrides *********************************************** - - public OrmAttributeOverrideContainer getValueAttributeOverrideContainer() { - return this.valueAttributeOverrideContainer; - } - - protected OrmAttributeOverrideContainer buildValueAttributeOverrideContainer() { - return getXmlContextNodeFactory().buildOrmAttributeOverrideContainer(this, new ValueAttributeOverrideContainerOwner()); - } - - protected JavaAttributeOverride getJavaValueAttributeOverrideNamed(String attributeName) { - if (getJavaElementCollectionMapping() != null) { - return getJavaElementCollectionMapping().getValueAttributeOverrideContainer().getAttributeOverrideNamed(attributeName); - } - return null; - } - - public OrmAssociationOverrideContainer getValueAssociationOverrideContainer() { - return this.valueAssociationOverrideContainer; - } - - protected OrmAssociationOverrideContainer buildValueAssociationOverrideContainer() { - return getXmlContextNodeFactory().buildOrmAssociationOverrideContainer(this, new ValueAssociationOverrideContainerOwner()); - } - - protected JavaAssociationOverride getJavaValueAssociationOverrideNamed(String attributeName) { - if (getJavaElementCollectionMapping() != null) { - return getJavaElementCollectionMapping().getValueAssociationOverrideContainer().getAssociationOverrideNamed(attributeName); - } - return null; - } - - protected JavaElementCollectionMapping2_0 getJavaElementCollectionMapping() { - if (this.getJavaPersistentAttribute() == null) { - return null; - } - AttributeMapping javaAttributeMapping = this.getJavaPersistentAttribute().getMapping(); - if (javaAttributeMapping.getKey() == MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY) { - return ((JavaElementCollectionMapping2_0) javaAttributeMapping); - } - return null; - } - - public OrmAttributeOverrideContainer getMapKeyAttributeOverrideContainer() { - return this.mapKeyAttributeOverrideContainer; - } - - protected OrmAttributeOverrideContainer buildMapKeyAttributeOverrideContainer() { - return getXmlContextNodeFactory().buildOrmAttributeOverrideContainer(this, new MapKeyAttributeOverrideContainerOwner()); - } - - protected JavaAttributeOverride getJavaMapKeyAttributeOverrideNamed(String attributeName) { - if (getJavaElementCollectionMapping() != null) { - return getJavaElementCollectionMapping().getMapKeyAttributeOverrideContainer().getAttributeOverrideNamed(attributeName); - } - return null; - } - - // **************** map key ************************************************ - - public String getMapKey() { - if (this.noMapKey) { - return null; - } - if (this.pkMapKey) { - return null;//the target is either embeddable or basic, so a key will have to be specified - } - if (this.customMapKey) { - return this.specifiedMapKey; - } - throw new IllegalStateException("unknown map key"); //$NON-NLS-1$ - } - - public String getSpecifiedMapKey() { - return this.specifiedMapKey; - } - - public void setSpecifiedMapKey(String mapKey) { - String old = this.specifiedMapKey; - this.specifiedMapKey = mapKey; - if (this.attributeValueHasChanged(old, mapKey)) { - MapKey xmlMapKey = this.getXmlMapKey(); - if (mapKey == null) { - if (xmlMapKey != null) { - this.removeXmlMapKey(); - } - } else { - if (xmlMapKey == null) { - xmlMapKey = this.addXmlMapKey(); - } - xmlMapKey.setName(mapKey); - } - } - this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey); - } - - protected void setSpecifiedMapKey_(String mapKey) { - String old = this.specifiedMapKey; - this.specifiedMapKey = mapKey; - this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey); - } - - protected void initializeMapKey() { - MapKey xmlMapKey = this.getXmlMapKey(); - if (xmlMapKey == null) { - this.noMapKey = true; - } else { - this.specifiedMapKey = xmlMapKey.getName(); - if (this.specifiedMapKey == null) { - this.pkMapKey = true; - } else { - this.customMapKey = true; - } - } - } - - protected void updateMapKey() { - MapKey xmlMapKey = this.getXmlMapKey(); - if (xmlMapKey == null) { - this.setSpecifiedMapKey_(null); - this.setNoMapKey_(true); - this.setPkMapKey_(false); - this.setCustomMapKey_(false); - } else { - String mk = xmlMapKey.getName(); - this.setSpecifiedMapKey_(mk); - this.setNoMapKey_(false); - this.setPkMapKey_(mk == null); - this.setCustomMapKey_(mk != null); - } - } - - protected MapKey getXmlMapKey() { - return this.resourceAttributeMapping.getMapKey(); - } - - protected MapKey addXmlMapKey() { - MapKey mapKey = OrmFactory.eINSTANCE.createMapKey(); - this.resourceAttributeMapping.setMapKey(mapKey); - return mapKey; - } - - protected void removeXmlMapKey() { - this.resourceAttributeMapping.setMapKey(null); - } - - public Iterator<String> candidateMapKeyNames() { - return this.allTargetEmbeddableAttributeNames(); - } - - public Iterator<String> allTargetEmbeddableAttributeNames() { - return new CompositeIterator<String>( - new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEmbeddableAttributeMappings()) { - @Override - protected Iterator<String> transform(AttributeMapping mapping) { - return mapping.allMappingNames(); - } - }); - } - - protected Iterator<String> allEmbeddableAttributeMappingNames() { - return this.embeddableOverrideableMappingNames( - new Transformer<AttributeMapping, Iterator<String>>() { - public Iterator<String> transform(AttributeMapping mapping) { - return mapping.allMappingNames(); - } - } - ); - } - - @Override - public Iterator<String> allMappingNames() { - return new CompositeIterator<String>(this.getName(), this.allEmbeddableAttributeMappingNames()); - } - - protected Iterator<AttributeMapping> allTargetEmbeddableAttributeMappings() { - return (this.resolvedTargetEmbeddable != null) ? - this.resolvedTargetEmbeddable.allAttributeMappings() : - EmptyIterator.<AttributeMapping> instance(); - } - - protected Iterator<AttributeMapping> embeddableAttributeMappings() { - Embeddable targetEmbeddable = getResolvedTargetEmbeddable(); - if (targetEmbeddable != null && targetEmbeddable != getPersistentAttribute().getOwningTypeMapping()) { - return targetEmbeddable.attributeMappings(); - } - return EmptyIterator.instance(); - } - - @Override - public Iterator<String> allOverrideableAttributeMappingNames() { - return this.embeddableOverrideableAttributeMappingNames(); - } - - protected Iterator<String> embeddableOverrideableAttributeMappingNames() { - return this.embeddableOverrideableMappingNames( - new Transformer<AttributeMapping, Iterator<String>>() { - public Iterator<String> transform(AttributeMapping mapping) { - return mapping.allOverrideableAttributeMappingNames(); - } - } - ); - } - - @Override - public Iterator<String> allOverrideableAssociationMappingNames() { - return this.embeddableOverrideableAssociationMappingNames(); - } - - protected Iterator<String> embeddableOverrideableAssociationMappingNames() { - return this.embeddableOverrideableMappingNames( - new Transformer<AttributeMapping, Iterator<String>>() { - public Iterator<String> transform(AttributeMapping mapping) { - return mapping.allOverrideableAssociationMappingNames(); - } - } - ); - } - - protected Iterator<String> embeddableOverrideableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) { - return new TransformationIterator<String, String>( - new CompositeIterator<String>( - new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer))) - { - @Override - protected String transform(String next) { - return getName() + '.' + next; - } - }; - } - - - @Override - public Column resolveOverriddenColumn(String attributeName) { - if (getName() == null) { - return null; - } - int dotIndex = attributeName.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(attributeName.substring(0, dotIndex))) { - attributeName = attributeName.substring(dotIndex + 1); - AttributeOverride override = getValueAttributeOverrideContainer().getAttributeOverrideNamed(attributeName); - if (override != null && !override.isVirtual()) { - return override.getColumn(); - } - if (this.getResolvedTargetEmbeddable() == null) { - return null; - } - return this.getResolvedTargetEmbeddable().resolveOverriddenColumn(attributeName); - } - } - return null; - } - - protected Iterator<String> embeddableAttributeMappingNames() { - return new TransformationIterator<String, String>( - new CompositeIterator<String>( - new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings()) { - @Override - protected Iterator<String> transform(AttributeMapping mapping) { - return mapping.allMappingNames(); - } - } - ) - ) { - @Override - protected String transform(String next) { - return getName() + '.' + next; - } - }; - } - - @Override - public AttributeMapping resolveAttributeMapping(String attributeName) { - if (getName() == null) { - return null; - } - AttributeMapping resolvedMapping = super.resolveAttributeMapping(attributeName); - if (resolvedMapping != null) { - return resolvedMapping; - } - int dotIndex = attributeName.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(attributeName.substring(0, dotIndex))) { - for (AttributeMapping attributeMapping : CollectionTools.iterable(embeddableAttributeMappings())) { - resolvedMapping = attributeMapping.resolveAttributeMapping(attributeName.substring(dotIndex + 1)); - if (resolvedMapping != null) { - return resolvedMapping; - } - } - } - } - return null; - } - - @Override - public RelationshipReference resolveRelationshipReference(String attributeName) { - if (getName() == null) { - return null; - } - int dotIndex = attributeName.indexOf('.'); - if (dotIndex != -1) { - if (getName().equals(attributeName.substring(0, dotIndex))) { - attributeName = attributeName.substring(dotIndex + 1); - AssociationOverride override = getValueAssociationOverrideContainer().getAssociationOverrideNamed(attributeName); - if (override != null && !override.isVirtual()) { - return override.getRelationshipReference(); - } - if (this.getResolvedTargetEmbeddable() == null) { - return null; - } - return this.getResolvedTargetEmbeddable().resolveRelationshipReference(attributeName); - } - } - return null; - } - - // **************** no map key *********************************************** - - public boolean isNoMapKey() { - return this.noMapKey; - } - - public void setNoMapKey(boolean noMapKey) { - boolean old = this.noMapKey; - this.noMapKey = noMapKey; - if (noMapKey) { - if (this.getXmlMapKey() != null) { - this.removeXmlMapKey(); - } - } - this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey); - } - - protected void setNoMapKey_(boolean noMapKey) { - boolean old = this.noMapKey; - this.noMapKey = noMapKey; - this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey); - } - - - // **************** pk map key *********************************************** - - public boolean isPkMapKey() { - return this.pkMapKey; - } - - public void setPkMapKey(boolean pkMapKey) { - boolean old = this.pkMapKey; - this.pkMapKey = pkMapKey; - MapKey xmlMapKey = this.getXmlMapKey(); - if (pkMapKey) { - if (xmlMapKey == null) { - this.addXmlMapKey(); - } else { - xmlMapKey.setName(null); - } - } - this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey); - } - - protected void setPkMapKey_(boolean pkMapKey) { - boolean old = this.pkMapKey; - this.pkMapKey = pkMapKey; - this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey); - } - - - // **************** custom map key *********************************************** - - public boolean isCustomMapKey() { - return this.customMapKey; - } - - public void setCustomMapKey(boolean customMapKey) { - boolean old = this.customMapKey; - this.customMapKey = customMapKey; - if (customMapKey) { - this.setSpecifiedMapKey(""); //$NON-NLS-1$ - } - this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey); - } - - protected void setCustomMapKey_(boolean customMapKey) { - boolean old = this.customMapKey; - this.customMapKey = customMapKey; - this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey); - } - - // **************** map key class ****************************************** - - public char getMapKeyClassEnclosingTypeSeparator() { - return '$'; - } - - public String getMapKeyClass() { - return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass; - } - - public String getSpecifiedMapKeyClass() { - return this.specifiedMapKeyClass; - } - - public void setSpecifiedMapKeyClass(String mapKeyClass) { - String old = this.specifiedMapKeyClass; - this.specifiedMapKeyClass = mapKeyClass; - if (this.attributeValueHasChanged(old, mapKeyClass)) { - XmlClassReference xmlMapKeyClass = this.getXmlMapKeyClass(); - if (mapKeyClass == null) { - if (xmlMapKeyClass != null) { - this.removeXmlMapKeyClass(); - } - } else { - if (xmlMapKeyClass == null) { - xmlMapKeyClass = this.addXmlMapKeyClass(); - } - xmlMapKeyClass.setClassName(mapKeyClass); - } - } - this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected void setSpecifiedMapKeyClass_(String mapKeyClass) { - String old = this.specifiedMapKeyClass; - this.specifiedMapKeyClass = mapKeyClass; - this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected XmlClassReference getXmlMapKeyClass() { - return this.resourceAttributeMapping.getMapKeyClass(); - } - - protected XmlClassReference addXmlMapKeyClass() { - XmlClassReference mapKeyClass = OrmFactory.eINSTANCE.createXmlClassReference(); - this.resourceAttributeMapping.setMapKeyClass(mapKeyClass); - return mapKeyClass; - } - - protected void removeXmlMapKeyClass() { - this.resourceAttributeMapping.setMapKeyClass(null); - } - - public String getDefaultMapKeyClass() { - return this.defaultMapKeyClass; - } - - protected void setDefaultMapKeyClass(String mapKeyClass) { - String old = this.defaultMapKeyClass; - this.defaultMapKeyClass = mapKeyClass; - this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass); - } - - protected String getResourceMapKeyClass() { - XmlClassReference mapKeyClass = this.resourceAttributeMapping.getMapKeyClass(); - return mapKeyClass == null ? null : mapKeyClass.getClassName(); - } - - protected String buildDefaultMapKeyClass() { - if (this.getJavaPersistentAttribute() != null) { - return this.getJavaPersistentAttribute().getMultiReferenceMapKeyTypeName(); - } - return null; - } - - - public Embeddable getResolvedMapKeyEmbeddable() { - return this.resolvedMapKeyEmbeddable; - } - - protected void setResolvedMapKeyEmbeddable(Embeddable embeddable) { - Embeddable old = this.resolvedMapKeyEmbeddable; - this.resolvedMapKeyEmbeddable = embeddable; - this.firePropertyChanged(RESOLVED_MAP_KEY_EMBEDDABLE_PROPERTY, old, embeddable); - } - - public Entity getResolvedMapKeyEntity() { - return this.resolvedMapKeyEntity; - } - - protected void setResolvedMapKeyEntity(Entity entity) { - Entity old = this.resolvedMapKeyEntity; - this.resolvedMapKeyEntity = entity; - this.firePropertyChanged(RESOLVED_MAP_KEY_ENTITY_PROPERTY, old, entity); - } - - public PersistentType getResolvedMapKeyType() { - return getResolvedMapKeyEmbeddable() == null ? null : getResolvedMapKeyEmbeddable().getPersistentType(); - } - - protected PersistentType resolveMapKeyType() { - return this.resolvePersistentType(this.getMapKeyClass()); - } - - protected Embeddable resolveMapKeyEmbeddable() { - if (this.resolvedMapKeyType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedMapKeyType.getMapping(); - return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null; - } - - protected Entity resolveMapKeyEntity() { - if (this.resolvedMapKeyType == null) { - return null; - } - TypeMapping typeMapping = this.resolvedMapKeyType.getMapping(); - return (typeMapping instanceof Entity) ? (Entity) typeMapping : null; - } - - - // ********** metamodel ********** - @Override - protected String getMetamodelFieldTypeName() { - return ((PersistentAttribute2_0) getPersistentAttribute()).getMetamodelContainerFieldTypeName(); - } - - @Override - public String getMetamodelTypeName() { - if (this.valueType == Type.BASIC_TYPE) { - return getTargetClass(); - } - if (this.resolvedTargetType == null) { - return MetamodelField.DEFAULT_TYPE_NAME; - } - String targetTypeName = this.resolvedTargetType.getName(); - return (targetTypeName != null) ? targetTypeName : MetamodelField.DEFAULT_TYPE_NAME; - } - - @Override - protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) { - this.addMetamodelFieldMapKeyTypeArgumentNameTo(typeArgumentNames); - super.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames); - } - - protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) { - String keyTypeName = ((PersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName(); - if (keyTypeName != null) { - typeArgumentNames.add(keyTypeName); - } - } - - public String getMetamodelFieldMapKeyTypeName() { - return MappingTools.getMetamodelFieldMapKeyTypeName(this); - } - - - //*********** refactoring *********** - - @SuppressWarnings("unchecked") - @Override - public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) { - return new CompositeIterable<ReplaceEdit>( - super.createRenameTypeEdits(originalType, newName), - this.createMapKeyClassRenameTypeEdits(originalType, newName), - this.createTargetClassRenameTypeEdits(originalType, newName), - this.createConverterRenameTypeEdits(originalType, newName)); - } - - protected Iterable<ReplaceEdit> createMapKeyClassRenameTypeEdits(IType originalType, String newName) { - if (this.specifiedMapKeyClass != null) { - String originalName = originalType.getFullyQualifiedName('.'); - if (this.resolvedMapKeyType != null && this.resolvedMapKeyType.isFor(originalName)) { - return new SingleElementIterable<ReplaceEdit>(this.createRenameMapKeyClassEdit(originalType, newName)); - } - } - return EmptyIterable.instance(); - } - - protected ReplaceEdit createRenameMapKeyClassEdit(IType originalType, String newName) { - return this.resourceAttributeMapping.createRenameMapKeyClassEdit(originalType, newName); - } - - protected Iterable<ReplaceEdit> createTargetClassRenameTypeEdits(IType originalType, String newName) { - if (this.specifiedTargetClass != null) { - String originalName = originalType.getFullyQualifiedName('.'); - if (this.resolvedTargetType != null && this.resolvedTargetType.isFor(originalName)) { - return new SingleElementIterable<ReplaceEdit>(this.resourceAttributeMapping.createRenameTargetClassEdit(originalType, newName)); - } - } - return EmptyIterable.instance(); - } - - protected Iterable<ReplaceEdit> createConverterRenameTypeEdits(IType originalType, String newName) { - if (getConverter() != null) { - return getConverter().createRenameTypeEdits(originalType, newName); - } - return EmptyIterable.instance(); - } - - @SuppressWarnings("unchecked") - @Override - public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - return new CompositeIterable<ReplaceEdit>( - super.createMoveTypeEdits(originalType, newPackage), - this.createMapKeyClassMoveTypeEdits(originalType, newPackage), - this.createTargetClassMoveTypeEdits(originalType, newPackage), - this.createConverterMoveTypeEdits(originalType, newPackage)); - } - - protected Iterable<ReplaceEdit> createMapKeyClassMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - if (this.specifiedMapKeyClass != null) { - String originalName = originalType.getFullyQualifiedName('.'); - if (this.resolvedMapKeyType != null && this.resolvedMapKeyType.isFor(originalName)) { - return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenamePackageEdit(newPackage.getElementName())); - } - } - return EmptyIterable.instance(); - } - - protected Iterable<ReplaceEdit> createTargetClassMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - if (this.specifiedTargetClass != null) { - String originalName = originalType.getFullyQualifiedName('.'); - if (this.resolvedTargetType != null && this.resolvedTargetType.isFor(originalName)) { - return new SingleElementIterable<ReplaceEdit>(this.resourceAttributeMapping.createRenameTargetClassPackageEdit(newPackage.getElementName())); - } - } - return EmptyIterable.instance(); - } - - protected Iterable<ReplaceEdit> createConverterMoveTypeEdits(IType originalType, IPackageFragment newPackage) { - if (getConverter() != null) { - return getConverter().createMoveTypeEdits(originalType, newPackage); - } - return EmptyIterable.instance(); - } - - @SuppressWarnings("unchecked") - @Override - public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) { - return new CompositeIterable<ReplaceEdit>( - super.createRenamePackageEdits(originalPackage, newName), - this.createMapKeyClassRenamePackageEdits(originalPackage, newName), - this.createTargetClassRenamePackageEdits(originalPackage, newName), - this.createConverterRenamePackageEdits(originalPackage, newName)); - } - - protected Iterable<ReplaceEdit> createMapKeyClassRenamePackageEdits(IPackageFragment originalPackage, String newName) { - if (this.specifiedMapKeyClass != null) { - if (this.resolvedMapKeyType != null && this.resolvedMapKeyType.isIn(originalPackage)) { - return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenamePackageEdit(newName)); - } - } - return EmptyIterable.instance(); - } - - protected ReplaceEdit createMapKeyClassRenamePackageEdit(String newName) { - return this.resourceAttributeMapping.createRenameMapKeyClassPackageEdit(newName); - } - - protected Iterable<ReplaceEdit> createTargetClassRenamePackageEdits(IPackageFragment originalPackage, String newName) { - if (this.specifiedTargetClass != null) { - if (this.resolvedTargetType != null && this.resolvedTargetType.isIn(originalPackage)) { - return new SingleElementIterable<ReplaceEdit>(this.resourceAttributeMapping.createRenameTargetClassPackageEdit(newName)); - } - } - return EmptyIterable.instance(); - } - - protected Iterable<ReplaceEdit> createConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) { - if (getConverter() != null) { - return getConverter().createRenamePackageEdits(originalPackage, newName); - } - return EmptyIterable.instance(); - } - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.validateTargetClass(messages); - this.validateMapKeyClass(messages); - this.getOrderable().validate(messages, reporter); - this.getCollectionTable().validate(messages, reporter); - this.validateValue(messages, reporter); - this.validateMapKey(messages, reporter); - } - - public void validateValue(List<IMessage> messages, IReporter reporter) { - //TODO should we handle validation when the type is embeddable, but a value column is specified, or things like that if that is invalid? - if (getValueType() == Type.BASIC_TYPE) { - this.getValueColumn().validate(messages, reporter); - this.getConverter().validate(messages, reporter); - } - if (getValueType() == Type.EMBEDDABLE_TYPE) { - this.getValueAttributeOverrideContainer().validate(messages, reporter); - this.getValueAssociationOverrideContainer().validate(messages, reporter); - } - } - - public void validateMapKey(List<IMessage> messages, IReporter reporter) { - if (getMapKey() != null) { - //TODO validate that the map key refers to an existing attribute - return; - } - if (getKeyType() == Type.BASIC_TYPE) { - this.getMapKeyColumn().validate(messages, reporter); - //validate map key converter - } - else if (getKeyType() == Type.ENTITY_TYPE) { - //validate map key join columns - } - else if (getKeyType() == Type.EMBEDDABLE_TYPE) { - this.getMapKeyAttributeOverrideContainer().validate(messages, reporter); - //validate map key association overrides - } - } - - protected void validateTargetClass(List<IMessage> messages) { - if (getTargetClass() == null) { - if (getPersistentAttribute().isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - new String[] {this.getName()}, - this, - this.getValidationTextRange() - ) - ); - } - else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - new String[0], - this, - this.getValidationTextRange() - ) - ); - } - } - //TODO this does not give an error for unmapped, unlisted types that aren't basic - bug 310464 - if (this.resolvedTargetType != null) { - if (getResolvedTargetEmbeddable() == null) { - if (getPersistentAttribute().isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - new String[] {this.getName(), this.getTargetClass()}, - this, - this.getValidationTextRange() - ) - ); - } - else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - new String[] {this.getTargetClass(), this.getName()}, - this, - this.getTargetClassTextRange() - ) - ); - } - } - } - } - - protected void validateMapKeyClass(List<IMessage> messages) { - if (getJavaPersistentAttribute() != null && !getJavaPersistentAttribute().getJpaContainer().isMap()) { - return; - } - if (getMapKeyClass() == null) { - if (getPersistentAttribute().isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - new String[] {this.getName()}, - this, - this.getValidationTextRange() - ) - ); - } - else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - new String[0], - this, - this.getValidationTextRange() - ) - ); - } - } - } - - protected TextRange getTargetClassTextRange() { - return this.resourceAttributeMapping.getTargetClassTextRange(); - } - - protected class CollectionTableOwner implements Table.Owner { - public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) { - return new CollectionTableValidator(getPersistentAttribute(), (CollectionTable2_0) table, textRangeResolver); - } - } - - protected abstract class ColumnOwner implements OrmColumn.Owner { - public String getDefaultTableName() { - return getCollectionTable().getName(); - } - - public TypeMapping getTypeMapping() { - return AbstractOrmElementCollectionMapping2_0.this.getTypeMapping(); - } - - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - if (getCollectionTable().getName().equals(tableName)) { - return AbstractOrmElementCollectionMapping2_0.this.getCollectionTable().getDbTable(); - } - return null; - } - - public java.util.Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - /** - * If there is a specified table name it needs to be the same - * the default table name. the table is always the collection table - */ - public boolean tableNameIsInvalid(String tableName) { - return !StringTools.stringsAreEqual(getDefaultTableName(), tableName); - } - - public TextRange getValidationTextRange() { - return AbstractOrmElementCollectionMapping2_0.this.getValidationTextRange(); - } - } - - protected class ValueColumnOwner extends ColumnOwner { - - public XmlColumn getResourceColumn() { - return AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.getColumn(); - } - - public void addResourceColumn() { - AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.setColumn(OrmFactory.eINSTANCE.createXmlColumn()); - } - - public void removeResourceColumn() { - AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.setColumn(null); - } - - public String getDefaultColumnName() { - return AbstractOrmElementCollectionMapping2_0.this.getName(); - } - - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new NamedColumnValidator(getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } - - protected class MapKeyColumnOwner extends ColumnOwner { - - public XmlColumn getResourceColumn() { - return AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.getMapKeyColumn(); - } - - public void addResourceColumn() { - AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.setMapKeyColumn(OrmFactory.eINSTANCE.createXmlColumn()); - } - - public void removeResourceColumn() { - AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.setMapKeyColumn(null); - } - - public String getDefaultColumnName() { - return AbstractOrmElementCollectionMapping2_0.this.getName() + "_KEY"; //$NON-NLS-1$ - } - - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new MapKeyColumnValidator(getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } - - protected abstract class OverrideContainerOwner implements OrmOverrideContainer.Owner { - public OrmTypeMapping getTypeMapping() { - return AbstractOrmElementCollectionMapping2_0.this.getTypeMapping(); - } - - public String getDefaultTableName() { - return AbstractOrmElementCollectionMapping2_0.this.getCollectionTable().getName(); - } - - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - return AbstractOrmElementCollectionMapping2_0.this.getCollectionTable().getDbTable(); - } - - public java.util.Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - /** - * If there is a specified table name it needs to be the same - * the default table name. the table is always the collection table - */ - public boolean tableNameIsInvalid(String tableName) { - return !StringTools.stringsAreEqual(getDefaultTableName(), tableName); - } - } - - protected class ValueAssociationOverrideContainerOwner - extends OverrideContainerOwner - implements OrmAssociationOverrideContainer.Owner - { - public TypeMapping getOverridableTypeMapping() { - return AbstractOrmElementCollectionMapping2_0.this.getResolvedTargetEmbeddable(); - } - - public Iterator<String> allOverridableNames() { - TypeMapping typeMapping = getOverridableTypeMapping(); - return (typeMapping == null) ? - EmptyIterator.<String>instance() - : typeMapping.allOverridableAssociationNames(); - } - - public EList<XmlAssociationOverride> getResourceAssociationOverrides() { - return AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.getAssociationOverrides(); - } - - public RelationshipReference resolveRelationshipReference(String associationOverrideName) { - if (getPersistentAttribute().isVirtual() && !getTypeMapping().isMetadataComplete()) { - JavaAssociationOverride javaAssociationOverride = getJavaValueAssociationOverrideNamed(associationOverrideName); - if (javaAssociationOverride != null && !javaAssociationOverride.isVirtual()) { - return javaAssociationOverride.getRelationshipReference(); - } - } - return MappingTools.resolveRelationshipReference(getOverridableTypeMapping(), associationOverrideName); - } - - public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { - return new AssociationOverrideJoinColumnValidator(getPersistentAttribute(), (AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) columnOwner, (JoinColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - - public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) { - return new AssociationOverrideValidator(getPersistentAttribute(), (AssociationOverride) override, (AssociationOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public TextRange getValidationTextRange() { - return AbstractOrmElementCollectionMapping2_0.this.getValidationTextRange(); - } - } - - - //********** OrmAttributeOverrideContainer.Owner implementation ********* - - protected class ValueAttributeOverrideContainerOwner - extends OverrideContainerOwner - implements OrmAttributeOverrideContainer.Owner - { - public TypeMapping getOverridableTypeMapping() { - return AbstractOrmElementCollectionMapping2_0.this.getResolvedTargetEmbeddable(); - } - - public Iterator<String> allOverridableNames() { - TypeMapping typeMapping = getOverridableTypeMapping(); - return (typeMapping == null) ? - EmptyIterator.<String>instance() - : typeMapping.allOverridableAttributeNames(); - } - - public EList<XmlAttributeOverride> getResourceAttributeOverrides() { - return AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.getAttributeOverrides(); - } - - public Column resolveOverriddenColumn(String attributeOverrideName) { - if (getPersistentAttribute().isVirtual() && !getTypeMapping().isMetadataComplete()) { - JavaAttributeOverride javaAttributeOverride = getJavaValueAttributeOverrideNamed(attributeOverrideName); - if (javaAttributeOverride != null && !javaAttributeOverride.isVirtual()) { - return javaAttributeOverride.getColumn(); - } - } - return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName); - } - - public XmlColumn buildVirtualXmlColumn(Column overridableColumn, String attributeName, boolean isMetadataComplete) { - return new VirtualXmlAttributeOverrideColumn(overridableColumn); - } - - public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) { - return new AttributeOverrideValidator(getPersistentAttribute(), (AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { - return new AttributeOverrideColumnValidator(getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - - public TextRange getValidationTextRange() { - return AbstractOrmElementCollectionMapping2_0.this.getValidationTextRange(); - } - } - - - protected class MapKeyAttributeOverrideContainerOwner - extends OverrideContainerOwner - implements OrmAttributeOverrideContainer.Owner - { - public TypeMapping getOverridableTypeMapping() { - return AbstractOrmElementCollectionMapping2_0.this.getResolvedMapKeyEmbeddable(); - } - - public Iterator<String> allOverridableNames() { - TypeMapping typeMapping = getOverridableTypeMapping(); - return (typeMapping == null) ? - EmptyIterator.<String>instance() - : typeMapping.allOverridableAttributeNames(); - } - - public EList<XmlAttributeOverride> getResourceAttributeOverrides() { - return AbstractOrmElementCollectionMapping2_0.this.resourceAttributeMapping.getMapKeyAttributeOverrides(); - } - - public Column resolveOverriddenColumn(String attributeOverrideName) { - if (getPersistentAttribute().isVirtual() && !getTypeMapping().isMetadataComplete()) { - JavaAttributeOverride javaAttributeOverride = getJavaMapKeyAttributeOverrideNamed(attributeOverrideName); - if (javaAttributeOverride != null && !javaAttributeOverride.isVirtual()) { - return javaAttributeOverride.getColumn(); - } - } - return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName); - } - - public XmlColumn buildVirtualXmlColumn(Column overridableColumn, String attributeName, boolean isMetadataComplete) { - return new VirtualXmlAttributeOverrideColumn(overridableColumn); - } - - public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) { - return new MapKeyAttributeOverrideValidator(getPersistentAttribute(), (AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); - } - - public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { - return new MapKeyAttributeOverrideColumnValidator(getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - - public TextRange getValidationTextRange() { - return AbstractOrmElementCollectionMapping2_0.this.getValidationTextRange(); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmAssociationOverrideRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmAssociationOverrideRelationshipReference2_0.java deleted file mode 100644 index 5bec62c9cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmAssociationOverrideRelationshipReference2_0.java +++ /dev/null @@ -1,128 +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.core.internal.jpa2.context.orm; - -import java.util.List; -import org.eclipse.jpt.core.context.AssociationOverrideRelationshipReference; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.JoinColumn.Owner; -import org.eclipse.jpt.core.context.orm.OrmAssociationOverride; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmAssociationOverrideRelationshipReference; -import org.eclipse.jpt.core.jpa2.context.AssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmAssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmJoinTableInAssociationOverrideJoiningStrategy2_0; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmAssociationOverrideRelationshipReference2_0 extends AbstractOrmAssociationOverrideRelationshipReference - implements OrmAssociationOverrideRelationshipReference2_0 -{ - - protected OrmJoinTableInAssociationOverrideJoiningStrategy2_0 joinTableJoiningStrategy; - - // cache the strategy for property change notification - protected JoiningStrategy cachedPredominantJoiningStrategy; - - public GenericOrmAssociationOverrideRelationshipReference2_0(OrmAssociationOverride parent, XmlAssociationOverride xao) { - super(parent, xao); - } - - protected OrmJoinTableInAssociationOverrideJoiningStrategy2_0 buildJoinTableJoiningStrategy(XmlAssociationOverride xao) { - return new GenericOrmJoinTableInAssociationOverrideJoiningStrategy2_0(this, xao); - } - - @Override - public void initializeFrom(AssociationOverrideRelationshipReference oldAssociationOverride) { - if (oldAssociationOverride.getJoinColumnJoiningStrategy().hasSpecifiedJoinColumns()) { - getJoinColumnJoiningStrategy().initializeFrom(oldAssociationOverride.getJoinColumnJoiningStrategy()); - } - else { - getJoinTableJoiningStrategy().initializeFrom(((AssociationOverrideRelationshipReference2_0) oldAssociationOverride).getJoinTableJoiningStrategy()); - } - } - - @Override - protected void initializeJoiningStrategies(org.eclipse.jpt.core.resource.orm.XmlAssociationOverride xao) { - super.initializeJoiningStrategies(xao); - this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy(xao); - } - - @Override - protected void updateJoiningStrategies(org.eclipse.jpt.core.resource.orm.XmlAssociationOverride xao) { - super.updateJoiningStrategies(xao); - this.joinTableJoiningStrategy.update(xao); - } - - @Override - protected JoiningStrategy calculatePredominantJoiningStrategy() { - if (this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns()) { - return this.joinColumnJoiningStrategy; - } - return this.joinTableJoiningStrategy; - } - - - // ********** validation ********** - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.joinTableJoiningStrategy.validate(messages, reporter); - } - - - // **************** join table ******************************************* - - - public OrmJoinTableInAssociationOverrideJoiningStrategy2_0 getJoinTableJoiningStrategy() { - return this.joinTableJoiningStrategy; - } - - public boolean usesJoinTableJoiningStrategy() { - return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy; - } - - public void setJoinTableJoiningStrategy() { - this.joinTableJoiningStrategy.addStrategy(); - this.joinColumnJoiningStrategy.removeStrategy(); - } - - public void unsetJoinTableJoiningStrategy() { - this.joinTableJoiningStrategy.removeStrategy(); - } - - public boolean mayHaveDefaultJoinTable() { - return getAssociationOverride().isVirtual() && this.usesJoinTableJoiningStrategy(); - } - - @Override - public void setJoinColumnJoiningStrategy() { - super.setJoinColumnJoiningStrategy(); - this.joinTableJoiningStrategy.removeStrategy(); - } - - public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return getAssociationOverride().getOwner().buildJoinTableJoinColumnValidator(getAssociationOverride(), column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return getAssociationOverride().getOwner().buildJoinTableInverseJoinColumnValidator(getAssociationOverride(), column, owner, textRangeResolver); - } - - public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) { - return getAssociationOverride().getOwner().buildTableValidator(getAssociationOverride(), table, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java deleted file mode 100644 index da3d2fcb2a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java +++ /dev/null @@ -1,92 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheableHolder2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlCacheable_2_0; -import org.eclipse.jpt.core.utility.TextRange; - -public class GenericOrmCacheable2_0 extends AbstractOrmXmlContextNode - implements OrmCacheable2_0 -{ - protected final XmlCacheable_2_0 resource; - - protected boolean defaultCacheable; - - protected Boolean specifiedCacheable; - - - public GenericOrmCacheable2_0(OrmCacheableHolder2_0 parent, XmlCacheable_2_0 resource) { - super(parent); - this.resource = resource; - this.specifiedCacheable = this.getResourceCacheable(); - } - - @Override - public OrmCacheableHolder2_0 getParent() { - return (OrmCacheableHolder2_0) super.getParent(); - } - - public boolean isCacheable() { - return (this.specifiedCacheable != null) ? this.specifiedCacheable.booleanValue() : this.defaultCacheable; - } - - public boolean isDefaultCacheable() { - return this.defaultCacheable; - } - - protected void setDefaultCacheable(boolean newDefaultCacheable) { - boolean oldDefaultCacheable = this.defaultCacheable; - this.defaultCacheable = newDefaultCacheable; - firePropertyChanged(DEFAULT_CACHEABLE_PROPERTY, oldDefaultCacheable, newDefaultCacheable); - } - - public Boolean getSpecifiedCacheable() { - return this.specifiedCacheable; - } - - public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) { - Boolean oldSpecifiedCacheable = this.specifiedCacheable; - this.specifiedCacheable = newSpecifiedCacheable; - this.resource.setCacheable(newSpecifiedCacheable); - firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable); - } - - protected void setSpecifiedCacheable_(Boolean newSpecifiedCacheable) { - Boolean oldSpecifiedCacheable = this.specifiedCacheable; - this.specifiedCacheable = newSpecifiedCacheable; - firePropertyChanged(SPECIFIED_CACHEABLE_PROPERTY, oldSpecifiedCacheable, newSpecifiedCacheable); - } - - - // **************** initialize/update ************************************** - - public void update() { - setSpecifiedCacheable_(this.getResourceCacheable()); - setDefaultCacheable(this.calculateDefaultCacheable()); - } - - protected Boolean getResourceCacheable() { - return this.resource.getCacheable(); - } - - protected boolean calculateDefaultCacheable() { - return getParent().calculateDefaultCacheable(); - } - - - // **************** validation ************************************** - - public TextRange getValidationTextRange() { - return this.resource.getCacheableTextRange(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmCollectionTable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmCollectionTable2_0.java deleted file mode 100644 index a95750afc3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmCollectionTable2_0.java +++ /dev/null @@ -1,195 +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.core.internal.jpa2.context.orm; - -import java.util.Iterator; -import org.eclipse.jpt.core.context.BaseJoinColumn; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.NamedColumn; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.orm.OrmJoinColumn; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.MappingTools; -import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.jpa1.context.CollectionTableTableDescriptionProvider; -import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator; -import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmReferenceTable; -import org.eclipse.jpt.core.jpa2.context.CollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0; -import org.eclipse.jpt.core.resource.orm.OrmFactory; -import org.eclipse.jpt.core.resource.orm.XmlCollectionTable; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -/** - * orm.xml collection table - */ -public class GenericOrmCollectionTable2_0 - extends GenericOrmReferenceTable - implements OrmCollectionTable2_0 -{ - - public GenericOrmCollectionTable2_0(OrmElementCollectionMapping2_0 parent, Owner owner, XmlCollectionTable xmlCollectionTable) { - super(parent, owner); - this.initialize(xmlCollectionTable); - } - - @Override - protected OrmJoinColumn.Owner buildJoinColumnOwner() { - return new JoinColumnOwner(); - } - - public void initializeFrom(CollectionTable2_0 oldCollectionTable) { - super.initializeFrom(oldCollectionTable); - } - - // ********** AbstractOrmTable implementation ********** - - public PersistentAttribute getPersistentAttribute() { - return getParent().getPersistentAttribute(); - } - - @Override - public OrmElementCollectionMapping2_0 getParent() { - return (OrmElementCollectionMapping2_0) super.getParent(); - } - - @Override - protected String buildDefaultName() { - return MappingTools.buildCollectionTableDefaultName(getParent()); - } - - @Override - protected XmlCollectionTable getResourceTable() { - return this.getParent().getResourceAttributeMapping().getCollectionTable(); - } - - @Override - protected XmlCollectionTable addResourceTable() { - XmlCollectionTable xmlCollectionTable = OrmFactory.eINSTANCE.createXmlCollectionTable(); - getParent().getResourceAttributeMapping().setCollectionTable(xmlCollectionTable); - return xmlCollectionTable; - } - - @Override - protected void removeResourceTable() { - getParent().getResourceAttributeMapping().setCollectionTable(null); - } - - - // ********** validation ********** - - public boolean shouldValidateAgainstDatabase() { - return getParent().shouldValidateAgainstDatabase(); - } - - - // ********** join column owner adapters ********** - - /** - * owner for "back-pointer" JoinColumns; - * these point at the source/owning entity - */ - protected class JoinColumnOwner - implements OrmJoinColumn.Owner - { - protected JoinColumnOwner() { - super(); - } - public TypeMapping getTypeMapping() { - return GenericOrmCollectionTable2_0.this.getParent().getTypeMapping(); - } - - public PersistentAttribute getPersistentAttribute() { - return GenericOrmCollectionTable2_0.this.getParent().getPersistentAttribute(); - } - - /** - * the default table name is always valid and a specified table name - * is prohibited (which will be handled elsewhere) - */ - public boolean tableNameIsInvalid(String tableName) { - return false; - } - - public Iterator<String> candidateTableNames() { - return EmptyIterator.instance(); - } - - /** - * the join column can only be on the collection table itself - */ - public boolean tableIsAllowed() { - return false; - } - - public org.eclipse.jpt.db.Table getDbTable(String tableName) { - String collectionTableName = GenericOrmCollectionTable2_0.this.getName(); - return (collectionTableName == null) ? null : (collectionTableName.equals(tableName)) ? GenericOrmCollectionTable2_0.this.getDbTable() : null; - } - - /** - * by default, the join column is, obviously, in the collection table; - * not sure whether it can be anywhere else... - */ - public String getDefaultTableName() { - return GenericOrmCollectionTable2_0.this.getName(); - } - - public TextRange getValidationTextRange() { - return GenericOrmCollectionTable2_0.this.getValidationTextRange(); - } - - public Entity getRelationshipTarget() { - return GenericOrmCollectionTable2_0.this.getParent().getEntity(); - } - - public String getAttributeName() { - //TODO - return null; //I *think* this is correct -// //return GenericJavaCollectionTable2_0.this.getParent().getName(); -// Entity targetEntity = GenericOrmCollectionTable2_0.this.getRelationshipMapping().getResolvedTargetEntity(); -// if (targetEntity == null) { -// return null; -// } -// for (PersistentAttribute each : CollectionTools.iterable(targetEntity.getPersistentType().allAttributes())) { -// if (each.getMapping().isOwnedBy(getRelationshipMapping())) { -// return each.getName(); -// } -// } -// return null; - } - - public org.eclipse.jpt.db.Table getReferencedColumnDbTable() { - return getTypeMapping().getPrimaryDbTable(); - } - - public boolean isVirtual(BaseJoinColumn joinColumn) { - return GenericOrmCollectionTable2_0.this.defaultJoinColumn == joinColumn; - } - - public String getDefaultColumnName() { - //built in MappingTools.buildJoinColumnDefaultName() - return null; - } - - public int joinColumnsSize() { - return GenericOrmCollectionTable2_0.this.joinColumnsSize(); - } - - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new JoinColumnValidator(getPersistentAttribute(), (JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java deleted file mode 100644 index 61647b4f06..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java +++ /dev/null @@ -1,178 +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.core.internal.jpa2.context.orm; - -import java.util.List; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.DerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmMapsIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlSingleRelationshipMapping_2_0; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmDerivedIdentity2_0 - extends AbstractOrmXmlContextNode - implements OrmDerivedIdentity2_0 -{ - protected XmlSingleRelationshipMapping_2_0 resource; - - // cache the strategy for property change notification - protected DerivedIdentityStrategy2_0 cachedPredominantDerivedIdentityStrategy; - - protected OrmIdDerivedIdentityStrategy2_0 idDerivedIdentityStrategy; - - protected OrmMapsIdDerivedIdentityStrategy2_0 mapsIdDerivedIdentityStrategy; - - - public GenericOrmDerivedIdentity2_0( - OrmSingleRelationshipMapping2_0 parent, XmlSingleRelationshipMapping_2_0 resource) { - super(parent); - this.resource = resource; - this.idDerivedIdentityStrategy = buildIdDerivedIdentityStrategy(); - this.mapsIdDerivedIdentityStrategy = buildMapsIdDerivedIdentityStrategy(); - this.cachedPredominantDerivedIdentityStrategy = calculatePredominantDerivedIdentityStrategy(); - } - - - protected OrmIdDerivedIdentityStrategy2_0 buildIdDerivedIdentityStrategy() { - return new GenericOrmIdDerivedIdentityStrategy2_0(this, resource); - } - - protected OrmMapsIdDerivedIdentityStrategy2_0 buildMapsIdDerivedIdentityStrategy() { - return new GenericOrmMapsIdDerivedIdentityStrategy2_0(this, resource); - } - - public OrmSingleRelationshipMapping2_0 getMapping() { - return (OrmSingleRelationshipMapping2_0) getParent(); - } - - - // **************** predominant joining strategy *************************** - - public DerivedIdentityStrategy2_0 getPredominantDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy; - } - - protected void setPredominantJoiningStrategy() { - setPredominantJoiningStrategy(calculatePredominantDerivedIdentityStrategy()); - } - - protected void setPredominantJoiningStrategy(DerivedIdentityStrategy2_0 newStrategy) { - DerivedIdentityStrategy2_0 oldStrategy = this.cachedPredominantDerivedIdentityStrategy; - this.cachedPredominantDerivedIdentityStrategy = newStrategy; - firePropertyChanged(PREDOMINANT_DERIVED_IDENTITY_STRATEGY_PROPERTY, oldStrategy, newStrategy); - } - - - // **************** resource -> context ************************************ - - public void update() { - this.idDerivedIdentityStrategy.update(); - this.mapsIdDerivedIdentityStrategy.update(); - setPredominantJoiningStrategy(calculatePredominantDerivedIdentityStrategy()); - } - - protected DerivedIdentityStrategy2_0 calculatePredominantDerivedIdentityStrategy() { - if (this.mapsIdDerivedIdentityStrategy.isSpecified()) { - return this.mapsIdDerivedIdentityStrategy; - } - else if (this.idDerivedIdentityStrategy.isSpecified()) { - return this.idDerivedIdentityStrategy; - } - else { - return null; - } - } - - - // **************** no strategy ******************************************* - - public void setNullDerivedIdentityStrategy() { - this.mapsIdDerivedIdentityStrategy.removeStrategy(); - this.idDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean usesNullDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy == null; - } - - - // **************** maps id strategy ************************************** - - public OrmMapsIdDerivedIdentityStrategy2_0 getMapsIdDerivedIdentityStrategy() { - return this.mapsIdDerivedIdentityStrategy; - } - - public void setMapsIdDerivedIdentityStrategy() { - this.mapsIdDerivedIdentityStrategy.addStrategy(); - this.idDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public void unsetMapsIdDerivedIdentityStrategy() { - this.mapsIdDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean usesMapsIdDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy == this.mapsIdDerivedIdentityStrategy; - } - - - // **************** id strategy ******************************************* - - public OrmIdDerivedIdentityStrategy2_0 getIdDerivedIdentityStrategy() { - return this.idDerivedIdentityStrategy; - } - - public void setIdDerivedIdentityStrategy() { - this.idDerivedIdentityStrategy.addStrategy(); - this.mapsIdDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public void unsetIdDerivedIdentityStrategy() { - this.idDerivedIdentityStrategy.removeStrategy(); - setPredominantJoiningStrategy(); - } - - public boolean usesIdDerivedIdentityStrategy() { - return this.cachedPredominantDerivedIdentityStrategy == this.idDerivedIdentityStrategy; - } - - - // **************** morphing ********************************************** - - public void initializeFrom(OrmDerivedIdentity2_0 oldDerivedIdentity) { - this.mapsIdDerivedIdentityStrategy.initializeFrom(oldDerivedIdentity.getMapsIdDerivedIdentityStrategy()); - this.idDerivedIdentityStrategy.initializeFrom(oldDerivedIdentity.getIdDerivedIdentityStrategy()); - this.cachedPredominantDerivedIdentityStrategy = calculatePredominantDerivedIdentityStrategy(); - } - - - // **************** validation ******************************************** - - public TextRange getValidationTextRange() { - return getMapping().getValidationTextRange(); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - this.idDerivedIdentityStrategy.validate(messages, reporter); - this.mapsIdDerivedIdentityStrategy.validate(messages, reporter); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java deleted file mode 100644 index bb61f67178..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmElementCollectionMapping2_0.java +++ /dev/null @@ -1,24 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.resource.orm.XmlElementCollection; - - -public class GenericOrmElementCollectionMapping2_0 - extends AbstractOrmElementCollectionMapping2_0<XmlElementCollection> -{ - - public GenericOrmElementCollectionMapping2_0(OrmPersistentAttribute parent, XmlElementCollection resourceMapping) { - super(parent, resourceMapping); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmEmbeddable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmEmbeddable2_0.java deleted file mode 100644 index 0c73b1073a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmEmbeddable2_0.java +++ /dev/null @@ -1,31 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmEmbeddable; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaEmbeddable2_0; -import org.eclipse.jpt.core.resource.orm.XmlEmbeddable; -import org.eclipse.jpt.utility.internal.ArrayTools; - - -public class GenericOrmEmbeddable2_0 - extends AbstractOrmEmbeddable -{ - public GenericOrmEmbeddable2_0(OrmPersistentType parent, XmlEmbeddable resourceMapping) { - super(parent, resourceMapping); - } - - @Override - public boolean attributeMappingKeyAllowed(String attributeMappingKey) { - return ArrayTools.contains(GenericJavaEmbeddable2_0.ALLOWED_ATTRIBUTE_MAPPING_KEYS, attributeMappingKey); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java deleted file mode 100644 index 63943de42a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java +++ /dev/null @@ -1,102 +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.core.internal.jpa2.context.orm; - -import java.util.List; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlDerivedId_2_0; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmIdDerivedIdentityStrategy2_0 - extends AbstractOrmXmlContextNode - implements OrmIdDerivedIdentityStrategy2_0 -{ - protected XmlDerivedId_2_0 resource; - - protected boolean value; - - - public GenericOrmIdDerivedIdentityStrategy2_0( - OrmDerivedIdentity2_0 parent, XmlDerivedId_2_0 resource) { - super(parent); - this.resource = resource; - this.value = getResourceToContextValue(); - } - - - public OrmDerivedIdentity2_0 getDerivedIdentity() { - return (OrmDerivedIdentity2_0) getParent(); - } - - public OrmSingleRelationshipMapping2_0 getMapping() { - return getDerivedIdentity().getMapping(); - } - - public boolean getValue() { - return this.value; - } - - public void setValue(boolean newValue) { - boolean oldValue = this.value; - this.value = newValue; - this.resource.setId(getContextToResourceValue()); - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - protected void setValue_(boolean newValue) { - boolean oldValue = this.value; - this.value = newValue; - firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - public void update() { - setValue_(getResourceToContextValue()); - } - - protected boolean getResourceToContextValue() { - return (resource.getId() == null) ? false : resource.getId().booleanValue(); - } - - protected Boolean getContextToResourceValue() { - return (this.value) ? Boolean.TRUE : null; - } - - public boolean isSpecified() { - return Boolean.TRUE.equals(this.resource.getId()); - } - - public void addStrategy() { - this.resource.setId(true); - } - - public void removeStrategy() { - this.resource.setId(null); - } - - public void initializeFrom(OrmIdDerivedIdentityStrategy2_0 oldStrategy) { - setValue(oldStrategy.getValue()); - } - - public TextRange getValidationTextRange() { - return this.resource.getIdTextRange(); - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - // no validation rules - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmJoinTableInAssociationOverrideJoiningStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmJoinTableInAssociationOverrideJoiningStrategy2_0.java deleted file mode 100644 index efb52a0665..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmJoinTableInAssociationOverrideJoiningStrategy2_0.java +++ /dev/null @@ -1,90 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.TableTextRangeResolver; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmJoinTableJoiningStrategy; -import org.eclipse.jpt.core.jpa2.context.orm.OrmAssociationOverrideRelationshipReference2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmJoinTableInAssociationOverrideJoiningStrategy2_0; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.core.resource.orm.XmlJoinTable; -import org.eclipse.jpt.core.utility.TextRange; - -public class GenericOrmJoinTableInAssociationOverrideJoiningStrategy2_0 - extends AbstractOrmJoinTableJoiningStrategy - implements OrmJoinTableInAssociationOverrideJoiningStrategy2_0 -{ - protected transient XmlAssociationOverride resourceAssociationOverride; - - public GenericOrmJoinTableInAssociationOverrideJoiningStrategy2_0(OrmAssociationOverrideRelationshipReference2_0 parent, XmlAssociationOverride xao) { - super(parent); - this.resourceAssociationOverride = xao; - this.initialize(); - } - - @Override - public OrmAssociationOverrideRelationshipReference2_0 getParent() { - return (OrmAssociationOverrideRelationshipReference2_0) super.getParent(); - } - - public boolean isOverridableAssociation() { - return false; - } - - @Override - public OrmAssociationOverrideRelationshipReference2_0 getRelationshipReference() { - return (OrmAssociationOverrideRelationshipReference2_0) super.getRelationshipReference(); - } - - public boolean shouldValidateAgainstDatabase() { - return getRelationshipReference().getTypeMapping().shouldValidateAgainstDatabase(); - } - - // **************** join table ********************************************* - - @Override - protected void setResourceJoinTable(XmlJoinTable resourceJoinTable) { - this.resourceAssociationOverride.setJoinTable(resourceJoinTable); - } - - public XmlJoinTable getResourceJoinTable() { - return this.resourceAssociationOverride.getJoinTable(); - } - - public void removeResourceJoinTable() { - this.resourceAssociationOverride.setJoinTable(null); - } - - public void update(XmlAssociationOverride resourceAssociationOverride) { - this.resourceAssociationOverride = resourceAssociationOverride; - super.update(); - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.resourceAssociationOverride.getValidationTextRange(); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); - } - - public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return getRelationshipReference().buildJoinTableJoinColumnValidator(column, owner, textRangeResolver); - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - return getRelationshipReference().buildJoinTableInverseJoinColumnValidator(column, owner, textRangeResolver); - } - - public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) { - return getRelationshipReference().buildTableValidator(table, textRangeResolver); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0.java deleted file mode 100644 index 93265e500c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmManyToOneMapping2_0.java +++ /dev/null @@ -1,28 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmManyToOneMapping; -import org.eclipse.jpt.core.jpa2.context.orm.OrmManyToOneRelationshipReference2_0; -import org.eclipse.jpt.core.resource.orm.XmlManyToOne; - -public class GenericOrmManyToOneMapping2_0 - extends AbstractOrmManyToOneMapping<XmlManyToOne> -{ - public GenericOrmManyToOneMapping2_0(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) { - super(parent, resourceMapping); - } - - @Override - protected OrmManyToOneRelationshipReference2_0 buildRelationshipReference() { - return new GenericOrmManyToOneRelationshipReference2_0(this, this.resourceAttributeMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmManyToOneRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmManyToOneRelationshipReference2_0.java deleted file mode 100644 index 72ee3ac0cf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmManyToOneRelationshipReference2_0.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmJoinTable; -import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference; -import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.core.context.orm.OrmRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmManyToOneRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinTableJoiningStrategy; -import org.eclipse.jpt.core.resource.orm.XmlManyToOne; - -public class GenericOrmManyToOneRelationshipReference2_0 - extends AbstractOrmManyToOneRelationshipReference -{ - - public GenericOrmManyToOneRelationshipReference2_0( - OrmManyToOneMapping parent, XmlManyToOne resource) { - super(parent, resource); - } - - @Override - protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() { - return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping()); - } - - @Override - public void initializeOn(OrmRelationshipReference newRelationshipReference) { - super.initializeOn(newRelationshipReference); - newRelationshipReference.initializeFromJoinTableEnabledRelationshipReference(this); - } - - @Override - public void initializeFromJoinTableEnabledRelationshipReference( - OrmJoinTableEnabledRelationshipReference oldRelationshipReference) { - super.initializeFromJoinTableEnabledRelationshipReference(oldRelationshipReference); - OrmJoinTable oldTable = - oldRelationshipReference.getJoinTableJoiningStrategy().getJoinTable(); - if (oldTable != null) { - this.joinTableJoiningStrategy.addJoinTable().initializeFrom(oldTable); - } - } - - @Override - protected OrmJoiningStrategy calculatePredominantJoiningStrategy() { - if (this.joinTableJoiningStrategy.getJoinTable() != null){ - return this.joinTableJoiningStrategy; - } - return this.joinColumnJoiningStrategy; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java deleted file mode 100644 index fa2dd6e7c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java +++ /dev/null @@ -1,227 +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.core.internal.jpa2.context.orm; - -import java.util.List; -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.Embeddable; -import org.eclipse.jpt.core.context.EmbeddedIdMapping; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages; -import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages; -import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; -import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmMapsIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlMapsId_2_0; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.ArrayTools; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.Tools; -import org.eclipse.jpt.utility.internal.iterables.CompositeIterable; -import org.eclipse.jpt.utility.internal.iterables.FilteringIterable; -import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable; -import org.eclipse.jpt.utility.internal.iterables.TransformationIterable; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.validation.internal.provisional.core.IMessage; -import org.eclipse.wst.validation.internal.provisional.core.IReporter; - -public class GenericOrmMapsIdDerivedIdentityStrategy2_0 - extends AbstractOrmXmlContextNode - implements OrmMapsIdDerivedIdentityStrategy2_0 -{ - protected XmlMapsId_2_0 resource; - - protected String value; - - - public GenericOrmMapsIdDerivedIdentityStrategy2_0( - OrmDerivedIdentity2_0 parent, XmlMapsId_2_0 resource) { - super(parent); - this.resource = resource; - this.value = this.resource.getMapsId(); - } - - - public OrmDerivedIdentity2_0 getDerivedIdentity() { - return (OrmDerivedIdentity2_0) getParent(); - } - - public OrmSingleRelationshipMapping2_0 getMapping() { - return getDerivedIdentity().getMapping(); - } - - public String getSpecifiedValue() { - return this.value; - } - - public void setSpecifiedValue(String newValue) { - String oldValue = this.value; - this.value = newValue; - this.resource.setMapsId(this.value); - firePropertyChanged(SPECIFIED_VALUE_PROPERTY, oldValue, newValue); - } - - protected void setSpecifiedValue_(String newValue) { - String oldValue = this.value; - this.value = newValue; - firePropertyChanged(SPECIFIED_VALUE_PROPERTY, oldValue, newValue); - } - - public boolean usesDefaultValue() { - return false; - } - - public String getDefaultValue() { - // there is no way to have default values in xml - return null; - } - - public String getValue() { - // there is never a default value - return this.value; - } - - public Iterable<String> getSortedValueChoices() { - return CollectionTools.sort( - new TransformationIterable<AttributeMapping, String>(getAllAttributeMappingChoices()) { - @Override - protected String transform(AttributeMapping o) { - return o.getName(); - } - }); - } - - public Iterable<AttributeMapping> getAllAttributeMappingChoices() { - return new CompositeIterable<AttributeMapping>( - getAttributeMappingChoiceIterables( - CollectionTools.collection(getMapping().getPersistentAttribute().getOwningTypeMapping().allAttributeMappings()))); - } - - protected Iterable<Iterable<AttributeMapping>> getAttributeMappingChoiceIterables(Iterable<AttributeMapping> availableMappings) { - return new TransformationIterable<AttributeMapping, Iterable<AttributeMapping>>(availableMappings) { - @Override - protected Iterable<AttributeMapping> transform(AttributeMapping o) { - if (StringTools.stringsAreEqual(o.getKey(), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)) { - return getEmbeddedIdMappingChoiceIterable((EmbeddedIdMapping) o); - } - else { - return new SingleElementIterable(o); - } - } - }; - } - - protected Iterable<AttributeMapping> getEmbeddedIdMappingChoiceIterable(EmbeddedIdMapping mapping) { - Embeddable embeddable = mapping.getTargetEmbeddable(); - if (embeddable == null) { - return new SingleElementIterable(mapping); - } - else { - return new CompositeIterable<AttributeMapping>( - mapping, - CollectionTools.collection(embeddable.allAttributeMappings())); - } - } - - public AttributeMapping getResolvedAttributeMappingValue() { - if (getValue() != null) { - for (AttributeMapping each : getAllAttributeMappingChoices()) { - if (Tools.valuesAreEqual(each.getName(), getValue())) { - return each; - } - } - } - return null; - } - - public boolean isSpecified() { - return this.resource.getMapsId() != null; - } - - public void addStrategy() { - this.resource.setMapsId(""); - } - - public void removeStrategy() { - this.resource.setMapsId(null); - } - - public void update() { - setSpecifiedValue_(this.resource.getMapsId()); - } - - public void initializeFrom(OrmMapsIdDerivedIdentityStrategy2_0 oldStrategy) { - setSpecifiedValue(oldStrategy.getSpecifiedValue()); - } - - public TextRange getValidationTextRange() { - TextRange textRange = this.resource.getMapsIdTextRange(); - return (textRange == null) ? getDerivedIdentity().getValidationTextRange() : textRange; - } - - @Override - public void validate(List<IMessage> messages, IReporter reporter) { - super.validate(messages, reporter); - validateMapsId(messages, reporter); - } - - protected void validateMapsId(List<IMessage> messages, IReporter reporter) { - // shortcut out if maps id is not even used - if (! getDerivedIdentity().usesMapsIdDerivedIdentityStrategy()) { - return; - } - - // test whether value can be resolved - AttributeMapping attributeMappingValue = getResolvedAttributeMappingValue(); - if (attributeMappingValue == null) { - // there is no defaulting, so only use the 'resolved' error, even if the value is empty string - messages.add(buildMessage(JpaValidationMessages.MAPS_ID_VALUE_NOT_RESOLVED, new String[] {getValue()})); - } - - // test whether attribute mapping is allowable - if (attributeMappingValue != null) { - if (! CollectionTools.contains(getValidAttributeMappingChoices(), attributeMappingValue)) { - messages.add(buildMessage(JpaValidationMessages.MAPS_ID_VALUE_INVALID, new String[] {getValue()})); - } - } - } - - protected Iterable<AttributeMapping> getValidAttributeMappingChoices() { - return new CompositeIterable<AttributeMapping>( - getAttributeMappingChoiceIterables( - new FilteringIterable<AttributeMapping>( - CollectionTools.collection(getMapping().getPersistentAttribute().getOwningTypeMapping().allAttributeMappings())) { - @Override - protected boolean accept(AttributeMapping o) { - return StringTools.stringsAreEqual(o.getKey(), MappingKeys.ID_ATTRIBUTE_MAPPING_KEY) - || StringTools.stringsAreEqual(o.getKey(), MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY); - } - })); - } - - protected IMessage buildMessage(String msgID, String[] params) { - String attributeDescString; - PersistentAttribute attribute = getDerivedIdentity().getMapping().getPersistentAttribute(); - if (attribute.isVirtual()) { - attributeDescString = NLS.bind(JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC, attribute.getName()); - } - else { - attributeDescString = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName()); - } - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, msgID, ArrayTools.add(params, 0, attributeDescString), this, getValidationTextRange()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java deleted file mode 100644 index 51f36abc89..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmNamedQuery2_0.java +++ /dev/null @@ -1,88 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmQuery; -import org.eclipse.jpt.core.jpa2.context.LockModeType2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmNamedQuery2_0; -import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; - -/** - * GenericOrmNamedQuery2_0 - */ -public class GenericOrmNamedQuery2_0 extends AbstractOrmQuery<XmlNamedQuery> - implements OrmNamedQuery2_0 -{ - protected LockModeType2_0 specifiedLockMode; - protected LockModeType2_0 defaultLockMode; - - // ********** constructor ********** - public GenericOrmNamedQuery2_0(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) { - super(parent, resourceNamedQuery); - } - - // ********** NamedQuery2_0 implementation ********** - - public LockModeType2_0 getLockMode() { - return (this.specifiedLockMode != null) ? this.specifiedLockMode : this.defaultLockMode; - } - - public LockModeType2_0 getSpecifiedLockMode() { - return this.specifiedLockMode; - } - - public void setSpecifiedLockMode(LockModeType2_0 lockMode) { - LockModeType2_0 old = this.specifiedLockMode; - this.specifiedLockMode = lockMode; - this.getResourceQuery().setLockMode(LockModeType2_0.toOrmResourceModel(lockMode)); - this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode); - } - - public void setSpecifiedLockMode_(LockModeType2_0 lockMode) { - LockModeType2_0 old = this.specifiedLockMode; - this.specifiedLockMode = lockMode; - this.firePropertyChanged(SPECIFIED_LOCK_MODE_PROPERTY, old, lockMode); - } - - public LockModeType2_0 getDefaultLockMode() { - return this.defaultLockMode; - } - - protected void setDefaultLockMode(LockModeType2_0 lockMode) { - LockModeType2_0 old = this.defaultLockMode; - this.defaultLockMode = lockMode; - this.firePropertyChanged(DEFAULT_LOCK_MODE_PROPERTY, old, lockMode); - } - - protected LockModeType2_0 buildDefaultLockMode() { - return LockModeType2_0.NONE; - } - - // ********** resource => context ********** - - @Override - protected void initialize(XmlNamedQuery xmlQuery) { - super.initialize(xmlQuery); - this.defaultLockMode = this.buildDefaultLockMode(); - this.specifiedLockMode = this.getResourceLockModeOf(xmlQuery); - } - - @Override - public void update(XmlNamedQuery xmlQuery) { - super.update(xmlQuery); - this.setSpecifiedLockMode_(this.getResourceLockModeOf(xmlQuery)); - } - - private LockModeType2_0 getResourceLockModeOf(XmlNamedQuery xmlQuery) { - return LockModeType2_0.fromOrmResourceModel(xmlQuery.getLockMode()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0.java deleted file mode 100644 index 22e11bc0a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyMapping2_0.java +++ /dev/null @@ -1,30 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmOneToManyMapping; -import org.eclipse.jpt.core.resource.orm.XmlOneToMany; - - -public class GenericOrmOneToManyMapping2_0 extends AbstractOrmOneToManyMapping<XmlOneToMany> -{ - - public GenericOrmOneToManyMapping2_0(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) { - super(parent, resourceMapping); - } - - @Override - protected OrmRelationshipReference buildRelationshipReference() { - return new GenericOrmOneToManyRelationshipReference2_0(this, this.resourceAttributeMapping); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java deleted file mode 100644 index 1ca049aad8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToManyRelationshipReference2_0.java +++ /dev/null @@ -1,80 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.AttributeMapping; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.orm.OrmJoinColumn; -import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.context.orm.OrmJoinColumnJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.core.context.orm.OrmRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmOneToManyRelationshipReference; -import org.eclipse.jpt.core.resource.orm.XmlOneToMany; -import org.eclipse.jpt.utility.internal.CollectionTools; - -public class GenericOrmOneToManyRelationshipReference2_0 - extends AbstractOrmOneToManyRelationshipReference -{ - public GenericOrmOneToManyRelationshipReference2_0( - OrmOneToManyMapping parent, XmlOneToMany resource) { - - super(parent, resource); - } - - @Override - protected OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() { - return new GenericOrmTargetForiegnKeyJoinColumnJoiningStrategy(this, getResourceMapping()); - } - - @Override - public void initializeOn(OrmRelationshipReference newRelationshipReference) { - super.initializeOn(newRelationshipReference); - newRelationshipReference.initializeFromJoinColumnEnabledRelationshipReference(this); - } - - @Override - public void initializeFromJoinColumnEnabledRelationshipReference( - OrmJoinColumnEnabledRelationshipReference oldRelationshipReference) { - super.initializeFromJoinColumnEnabledRelationshipReference(oldRelationshipReference); - int index = 0; - for (JoinColumn joinColumn : - CollectionTools.iterable( - oldRelationshipReference.getJoinColumnJoiningStrategy().specifiedJoinColumns())) { - OrmJoinColumn newJoinColumn = this.joinColumnJoiningStrategy.addSpecifiedJoinColumn(index++); - newJoinColumn.initializeFrom(joinColumn); - } - } - - @Override - protected OrmJoiningStrategy calculatePredominantJoiningStrategy() { - if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) { - return this.mappedByJoiningStrategy; - } - else if (this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns()) { - return this.joinColumnJoiningStrategy; - } - else { - return this.joinTableJoiningStrategy; - } - } - - - // **************** mapped by ********************************************** - - @Override - public boolean mayBeMappedBy(AttributeMapping mappedByMapping) { - return super.mayBeMappedBy(mappedByMapping) || - mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0.java deleted file mode 100644 index ea22084522..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToOneMapping2_0.java +++ /dev/null @@ -1,31 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmOneToOneMapping; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToOneRelationshipReference2_0; -import org.eclipse.jpt.core.resource.orm.XmlOneToOne; - - -public class GenericOrmOneToOneMapping2_0 - extends AbstractOrmOneToOneMapping<XmlOneToOne> -{ - - // ********** constructor ********** - public GenericOrmOneToOneMapping2_0(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) { - super(parent, resourceMapping); - } - - @Override - protected OrmOneToOneRelationshipReference2_0 buildRelationshipReference() { - return new GenericOrmOneToOneRelationshipReference2_0(this, this.resourceAttributeMapping); - } -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToOneRelationshipReference2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToOneRelationshipReference2_0.java deleted file mode 100644 index 2a894d51fc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOneToOneRelationshipReference2_0.java +++ /dev/null @@ -1,70 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.orm.OrmJoinTable; -import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference; -import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.core.context.orm.OrmRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmOneToOneRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.GenericOrmJoinTableJoiningStrategy; -import org.eclipse.jpt.core.resource.orm.XmlOneToOne; - -public class GenericOrmOneToOneRelationshipReference2_0 - extends AbstractOrmOneToOneRelationshipReference -{ - - - public GenericOrmOneToOneRelationshipReference2_0( - OrmOneToOneMapping parent, XmlOneToOne resource) { - super(parent, resource); - } - - - @Override - protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() { - return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping()); - } - - @Override - public void initializeOn(OrmRelationshipReference newRelationshipReference) { - super.initializeOn(newRelationshipReference); - newRelationshipReference.initializeFromJoinTableEnabledRelationshipReference(this); - // no other primary key reference as of yet, so no initialization based on pk join columns - } - - @Override - public void initializeFromJoinTableEnabledRelationshipReference( - OrmJoinTableEnabledRelationshipReference oldRelationshipReference) { - super.initializeFromJoinTableEnabledRelationshipReference(oldRelationshipReference); - OrmJoinTable oldTable = - oldRelationshipReference.getJoinTableJoiningStrategy().getJoinTable(); - if (oldTable != null) { - this.joinTableJoiningStrategy.addJoinTable().initializeFrom(oldTable); - } - } - - @Override - protected OrmJoiningStrategy calculatePredominantJoiningStrategy() { - if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) { - return this.mappedByJoiningStrategy; - } - else if (this.primaryKeyJoinColumnJoiningStrategy.primaryKeyJoinColumnsSize() > 0) { - return this.primaryKeyJoinColumnJoiningStrategy; - } - else if (this.joinTableJoiningStrategy.getJoinTable() != null){ - return this.joinTableJoiningStrategy; - } - return this.joinColumnJoiningStrategy; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOrderColumn2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOrderColumn2_0.java deleted file mode 100644 index d2aeb22eed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOrderColumn2_0.java +++ /dev/null @@ -1,218 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.BaseColumn; -import org.eclipse.jpt.core.context.PersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmNamedColumn; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmNamedColumn; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrderColumn2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrderable2_0; -import org.eclipse.jpt.core.resource.orm.OrmFactory; -import org.eclipse.jpt.core.resource.orm.XmlOrderColumn; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrderable_2_0; - - -public class GenericOrmOrderColumn2_0 - extends AbstractOrmNamedColumn<XmlOrderColumn> - implements OrmOrderColumn2_0 -{ - protected Boolean specifiedNullable; - - protected Boolean specifiedInsertable; - - protected Boolean specifiedUpdatable; - - protected XmlOrderable_2_0 xmlOrderable; - - public GenericOrmOrderColumn2_0(OrmOrderable2_0 parent, OrmNamedColumn.Owner owner) { - super(parent, owner); - } - - @Override - public OrmOrderable2_0 getParent() { - return (OrmOrderable2_0) super.getParent(); - } - - protected PersistentAttribute getPersistentAttribute() { - return getParent().getParent().getPersistentAttribute(); - } - - @Override - public String getTable() { - return getParent().getDefaultTableName(); - } - - @Override - public XmlOrderColumn getResourceColumn() { - return this.xmlOrderable.getOrderColumn(); - } - - @Override - protected void addResourceColumn() { - this.xmlOrderable.setOrderColumn(OrmFactory.eINSTANCE.createXmlOrderColumn()); - } - - @Override - protected void removeResourceColumn() { - this.xmlOrderable.setOrderColumn(null); - } - - public boolean isResourceSpecified() { - return getResourceColumn() != null; - } - - @Override - protected void removeResourceColumnIfFeaturesUnset() { - //override to do nothing - //don't want to remove the order-column element if it's features are all set to null - } - - public boolean isNullable() { - return (this.getSpecifiedNullable() == null) ? this.isDefaultNullable() : this.getSpecifiedNullable().booleanValue(); - } - - public boolean isDefaultNullable() { - return BaseColumn.DEFAULT_NULLABLE; - } - - public Boolean getSpecifiedNullable() { - return this.specifiedNullable; - } - - public void setSpecifiedNullable(Boolean newSpecifiedNullable) { - Boolean oldSpecifiedNullable = this.specifiedNullable; - this.specifiedNullable = newSpecifiedNullable; - if (this.valuesAreDifferent(oldSpecifiedNullable, newSpecifiedNullable)) { - if (this.getResourceColumn() != null) { - this.getResourceColumn().setNullable(newSpecifiedNullable); - this.removeResourceColumnIfFeaturesUnset(); - } - else if (newSpecifiedNullable != null) { - addResourceColumn(); - getResourceColumn().setNullable(newSpecifiedNullable); - } - } - firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable); - } - - protected void setSpecifiedNullable_(Boolean newSpecifiedNullable) { - Boolean oldSpecifiedNullable = this.specifiedNullable; - this.specifiedNullable = newSpecifiedNullable; - firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable); - } - - public boolean isInsertable() { - return (this.getSpecifiedInsertable() == null) ? this.isDefaultInsertable() : this.getSpecifiedInsertable().booleanValue(); - } - - public boolean isDefaultInsertable() { - return BaseColumn.DEFAULT_INSERTABLE; - } - - public Boolean getSpecifiedInsertable() { - return this.specifiedInsertable; - } - - public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) { - Boolean oldSpecifiedInsertable = this.specifiedInsertable; - this.specifiedInsertable = newSpecifiedInsertable; - if (this.valuesAreDifferent(oldSpecifiedInsertable, newSpecifiedInsertable)) { - if (this.getResourceColumn() != null) { - this.getResourceColumn().setInsertable(newSpecifiedInsertable); - this.removeResourceColumnIfFeaturesUnset(); - } - else if (newSpecifiedInsertable != null) { - addResourceColumn(); - getResourceColumn().setInsertable(newSpecifiedInsertable); - } - } - firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable); - } - - protected void setSpecifiedInsertable_(Boolean newSpecifiedInsertable) { - Boolean oldSpecifiedInsertable = this.specifiedInsertable; - this.specifiedInsertable = newSpecifiedInsertable; - firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable); - } - - public boolean isUpdatable() { - return (this.getSpecifiedUpdatable() == null) ? this.isDefaultUpdatable() : this.getSpecifiedUpdatable().booleanValue(); - } - - public boolean isDefaultUpdatable() { - return BaseColumn.DEFAULT_UPDATABLE; - } - - public Boolean getSpecifiedUpdatable() { - return this.specifiedUpdatable; - } - - public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) { - Boolean oldSpecifiedUpdatable = this.specifiedUpdatable; - this.specifiedUpdatable = newSpecifiedUpdatable; - if (this.valuesAreDifferent(oldSpecifiedUpdatable, newSpecifiedUpdatable)) { - if (this.getResourceColumn() != null) { - this.getResourceColumn().setUpdatable(newSpecifiedUpdatable); - this.removeResourceColumnIfFeaturesUnset(); - } - else if (newSpecifiedUpdatable != null) { - addResourceColumn(); - getResourceColumn().setUpdatable(newSpecifiedUpdatable); - } - } - firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable); - } - - protected void setSpecifiedUpdatable_(Boolean newSpecifiedUpdatable) { - Boolean oldSpecifiedUpdatable = this.specifiedUpdatable; - this.specifiedUpdatable = newSpecifiedUpdatable; - firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable); - } - - public void initialize(XmlOrderable_2_0 xmlOrderable) { - this.xmlOrderable = xmlOrderable; - this.initialize(this.getResourceColumn()); - } - - public void update(XmlOrderable_2_0 xmlOrderable) { - this.xmlOrderable = xmlOrderable; - this.update(this.getResourceColumn()); - } - - @Override - protected void initialize(XmlOrderColumn column) { - super.initialize(column); - this.specifiedNullable = this.getResourceNullable(column); - this.specifiedUpdatable = this.getResourceUpdatable(column); - this.specifiedInsertable = this.getResourceInsertable(column); - } - - @Override - protected void update(XmlOrderColumn column) { - super.update(column); - setSpecifiedNullable_(this.getResourceNullable(column)); - setSpecifiedUpdatable_(this.getResourceUpdatable(column)); - setSpecifiedInsertable_(this.getResourceInsertable(column)); - } - - protected Boolean getResourceNullable(XmlOrderColumn column) { - return column == null ? null : column.getNullable(); - } - - protected Boolean getResourceUpdatable(XmlOrderColumn column) { - return column == null ? null : column.getUpdatable(); - } - - - protected Boolean getResourceInsertable(XmlOrderColumn column) { - return column == null ? null : column.getInsertable(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java deleted file mode 100644 index 2402b9381a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java +++ /dev/null @@ -1,82 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrphanRemovable_2_0; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * GenericOrmOrphanRemoval2_0 - */ -public class GenericOrmOrphanRemoval2_0 extends AbstractOrmXmlContextNode - implements OrmOrphanRemovable2_0 -{ - protected final XmlOrphanRemovable_2_0 resource; - protected boolean defaultOrphanRemoval; - protected Boolean specifiedOrphanRemoval; - - // ********** constructor ********** - public GenericOrmOrphanRemoval2_0(OrmOrphanRemovalHolder2_0 parent, XmlOrphanRemovable_2_0 resource) { - super(parent); - this.resource = resource; - this.specifiedOrphanRemoval = this.getResourceOrphanRemoval(); - } - - @Override - public OrmOrphanRemovalHolder2_0 getParent() { - return (OrmOrphanRemovalHolder2_0) super.getParent(); - } - - // ********** OrphanRemovable2_0 implementation ********** - - public boolean isOrphanRemoval() { - return (this.specifiedOrphanRemoval != null) ? this.specifiedOrphanRemoval.booleanValue() : this.defaultOrphanRemoval; - } - - public Boolean getSpecifiedOrphanRemoval() { - return this.specifiedOrphanRemoval; - } - - public boolean isDefaultOrphanRemoval() { - return this.defaultOrphanRemoval; - } - - public void setSpecifiedOrphanRemoval(Boolean newSpecifiedOrphanRemoval) { - Boolean old = this.specifiedOrphanRemoval; - this.specifiedOrphanRemoval = newSpecifiedOrphanRemoval; - this.resource.setOrphanRemoval(newSpecifiedOrphanRemoval); - this.firePropertyChanged(SPECIFIED_ORPHAN_REMOVAL_PROPERTY, old, newSpecifiedOrphanRemoval); - } - - protected void setSpecifiedOrphanRemoval_(Boolean newSpecifiedOrphanRemoval) { - Boolean old = this.specifiedOrphanRemoval; - this.specifiedOrphanRemoval = newSpecifiedOrphanRemoval; - this.firePropertyChanged(SPECIFIED_ORPHAN_REMOVAL_PROPERTY, old, newSpecifiedOrphanRemoval); - } - - // ********** initialize/update ********** - public void update() { - this.setSpecifiedOrphanRemoval_(this.getResourceOrphanRemoval()); - } - - // ********** validation ********** - public TextRange getValidationTextRange() { - // TODO - return null; - } - - protected Boolean getResourceOrphanRemoval() { - return this.resource.getOrphanRemoval(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0.java deleted file mode 100644 index baef20f457..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmPersistentAttribute2_0.java +++ /dev/null @@ -1,66 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.AccessType; -import org.eclipse.jpt.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.core.internal.context.JptValidator; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmPersistentAttribute; -import org.eclipse.jpt.core.internal.jpa1.context.GenericPersistentAttributeValidator; -import org.eclipse.jpt.core.resource.orm.XmlAccessHolder; -import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; - - -public class GenericOrmPersistentAttribute2_0 - extends AbstractOrmPersistentAttribute -{ - - protected AccessType specifiedAccess; - - public GenericOrmPersistentAttribute2_0(OrmPersistentType parent, Owner owner, XmlAttributeMapping resourceMapping) { - super(parent, owner, resourceMapping); - this.specifiedAccess = getResourceAccess(); - } - - public AccessType getSpecifiedAccess() { - return this.specifiedAccess; - } - - public void setSpecifiedAccess(AccessType newSpecifiedAccess) { - AccessType oldAccess = this.specifiedAccess; - this.specifiedAccess = newSpecifiedAccess; - ((XmlAccessHolder) this.getResourceAttributeMapping()).setAccess(AccessType.toOrmResourceModel(newSpecifiedAccess)); - firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, oldAccess, newSpecifiedAccess); - } - - protected void setSpecifiedAccess_(AccessType newSpecifiedAccess) { - AccessType oldAccess = this.specifiedAccess; - this.specifiedAccess = newSpecifiedAccess; - firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, oldAccess, newSpecifiedAccess); - } - - @Override - public void update() { - super.update(); - setSpecifiedAccess_(getResourceAccess()); - } - - protected AccessType getResourceAccess() { - return AccessType.fromOrmResourceModel(((XmlAccessHolder) getResourceAttributeMapping()).getAccess()); - } - - - // ********** validation ********** - - @Override - protected JptValidator buildAttibuteValidator() { - return new GenericPersistentAttributeValidator(this, getJavaPersistentAttribute(), buildTextRangeResolver()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmSequenceGenerator2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmSequenceGenerator2_0.java deleted file mode 100644 index b130cdc8db..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmSequenceGenerator2_0.java +++ /dev/null @@ -1,131 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmSequenceGenerator; -import org.eclipse.jpt.core.jpa2.context.orm.OrmSequenceGenerator2_0; -import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; - -/** - * Generic2_0OrmSequenceGenerator - */ -public class GenericOrmSequenceGenerator2_0 extends AbstractOrmSequenceGenerator - implements OrmSequenceGenerator2_0 -{ - protected String specifiedCatalog; - protected String defaultCatalog; - - protected String specifiedSchema; - protected String defaultSchema; - - public GenericOrmSequenceGenerator2_0(XmlContextNode parent, XmlSequenceGenerator resourceSequenceGenerator) { - super(parent, resourceSequenceGenerator); - } - - // ********** catalog ********** - - @Override - public String getCatalog() { - return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog; - } - - public String getSpecifiedCatalog() { - return this.specifiedCatalog; - } - - public void setSpecifiedCatalog(String catalog) { - String old = this.specifiedCatalog; - this.specifiedCatalog = catalog; - this.getResourceGenerator().setCatalog(catalog); - this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, 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; - firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog); - } - - protected String buildDefaultCatalog() { - return this.getContextDefaultCatalog(); - } - - // ********** schema ********** - - @Override - public String getSchema() { - return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema; - } - - public String getSpecifiedSchema() { - return this.specifiedSchema; - } - - public void setSpecifiedSchema(String schema) { - String old = this.specifiedSchema; - this.specifiedSchema = schema; - this.getResourceGenerator().setSchema(schema); - this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, 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(); - } - - // ********** resource => context ********** - - @Override - protected void initialize(XmlSequenceGenerator xmlResource) { - super.initialize(xmlResource); - - this.defaultCatalog = this.buildDefaultCatalog(); - this.specifiedCatalog = xmlResource.getCatalog(); - this.defaultSchema = this.buildDefaultSchema(); - this.specifiedSchema = xmlResource.getSchema(); - } - - @Override - public void update(XmlSequenceGenerator xmlResource) { - super.update(xmlResource); - - this.setDefaultCatalog(this.buildDefaultCatalog()); - this.setSpecifiedCatalog_(xmlResource.getCatalog()); - this.setDefaultSchema(this.buildDefaultSchema()); - this.setSpecifiedSchema_(xmlResource.getSchema()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmTargetForiegnKeyJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmTargetForiegnKeyJoinColumnJoiningStrategy.java deleted file mode 100644 index 9724c2b7bb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmTargetForiegnKeyJoinColumnJoiningStrategy.java +++ /dev/null @@ -1,49 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.MappingKeys; -import org.eclipse.jpt.core.context.Entity; -import org.eclipse.jpt.core.context.RelationshipMapping; -import org.eclipse.jpt.core.context.TypeMapping; -import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy; -import org.eclipse.jpt.core.resource.orm.XmlJoinColumnsMapping; - -public class GenericOrmTargetForiegnKeyJoinColumnJoiningStrategy - extends AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy -{ - - public GenericOrmTargetForiegnKeyJoinColumnJoiningStrategy( - OrmJoinColumnEnabledRelationshipReference parent, - XmlJoinColumnsMapping resource) { - super(parent, resource); - } - - public TypeMapping getRelationshipSource() { - RelationshipMapping relationshipMapping = getRelationshipMapping(); - return relationshipMapping == null ? null : relationshipMapping.getResolvedTargetEntity(); - } - - public TypeMapping getRelationshipTarget() { - return getRelationshipMapping().getTypeMapping(); - } - - @Override - protected Entity getRelationshipTargetEntity() { - TypeMapping relationshipTarget = getRelationshipTarget(); - return relationshipTarget.getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY ? (Entity) relationshipTarget : null; - } - - public boolean isTargetForeignKeyRelationship() { - return true; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java deleted file mode 100644 index 176a0cccf4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0ContextNodeFactory.java +++ /dev/null @@ -1,220 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.Table; -import org.eclipse.jpt.core.context.XmlContextNode; -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping; -import org.eclipse.jpt.core.context.java.JavaIdMapping; -import org.eclipse.jpt.core.context.java.JavaManyToManyMapping; -import org.eclipse.jpt.core.context.java.JavaManyToOneMapping; -import org.eclipse.jpt.core.context.java.JavaOneToManyMapping; -import org.eclipse.jpt.core.context.java.JavaOneToOneMapping; -import org.eclipse.jpt.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.core.context.orm.OrmAssociationOverride; -import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer; -import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideRelationshipReference; -import org.eclipse.jpt.core.context.orm.OrmEmbeddable; -import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping; -import org.eclipse.jpt.core.context.orm.OrmNamedQuery; -import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping; -import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping; -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer.Owner; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNodeFactory; -import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmAssociationOverrideContainer; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaEmbeddedMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaManyToManyMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneMapping2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheableHolder2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCollectionTable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmEmbeddedMapping2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.core.resource.orm.XmlBasic; -import org.eclipse.jpt.core.resource.orm.XmlCollectionTable; -import org.eclipse.jpt.core.resource.orm.XmlElementCollection; -import org.eclipse.jpt.core.resource.orm.XmlEmbedded; -import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId; -import org.eclipse.jpt.core.resource.orm.XmlId; -import org.eclipse.jpt.core.resource.orm.XmlManyToMany; -import org.eclipse.jpt.core.resource.orm.XmlManyToOne; -import org.eclipse.jpt.core.resource.orm.XmlNamedQuery; -import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlOneToMany; -import org.eclipse.jpt.core.resource.orm.XmlOneToOne; -import org.eclipse.jpt.core.resource.orm.XmlTransient; -import org.eclipse.jpt.core.resource.orm.XmlVersion; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlCacheable_2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrphanRemovable_2_0; -import org.eclipse.jpt.core.resource.orm.v2_0.XmlSingleRelationshipMapping_2_0; - -public class GenericOrmXml2_0ContextNodeFactory extends AbstractOrmXmlContextNodeFactory -{ - - @Override - public OrmEmbeddable buildOrmEmbeddable(OrmPersistentType parent, org.eclipse.jpt.core.resource.orm.XmlEmbeddable resourceMapping) { - return new GenericOrmEmbeddable2_0(parent, resourceMapping); - } - - @Override - public OrmPersistentAttribute buildOrmPersistentAttribute(OrmPersistentType parent, OrmPersistentAttribute.Owner owner, org.eclipse.jpt.core.resource.orm.XmlAttributeMapping resourceMapping) { - return new GenericOrmPersistentAttribute2_0(parent, owner, resourceMapping); - } - - @Override - public OrmAssociationOverrideRelationshipReference buildOrmAssociationOverrideRelationshipReference(OrmAssociationOverride parent, org.eclipse.jpt.core.resource.orm.XmlAssociationOverride associationOverride) { - return new GenericOrmAssociationOverrideRelationshipReference2_0(parent, associationOverride); - } - - @Override - public OrmSequenceGenerator buildOrmSequenceGenerator(XmlContextNode parent, org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator resourceSequenceGenerator) { - return new GenericOrmSequenceGenerator2_0(parent, resourceSequenceGenerator); - } - - @Override - public OrmAssociationOverrideContainer buildOrmAssociationOverrideContainer( - OrmEmbeddedMapping2_0 parent, - Owner owner) { - - return new GenericOrmAssociationOverrideContainer(parent, owner); - } - - @Override - public OrmDerivedIdentity2_0 buildOrmDerivedIdentity( - OrmSingleRelationshipMapping2_0 parent, XmlSingleRelationshipMapping_2_0 resource) { - return new GenericOrmDerivedIdentity2_0(parent, resource); - } - - @Override - public OrmElementCollectionMapping2_0 buildOrmElementCollectionMapping2_0( - OrmPersistentAttribute parent, XmlElementCollection resourceMapping) { - - return new GenericOrmElementCollectionMapping2_0(parent, resourceMapping); - } - - @Override - public OrmCacheable2_0 buildOrmCacheable(OrmCacheableHolder2_0 parent, XmlCacheable_2_0 resource) { - return new GenericOrmCacheable2_0(parent, resource); - } - - @Override - public OrmOrphanRemovable2_0 buildOrmOrphanRemoval(OrmOrphanRemovalHolder2_0 parent, XmlOrphanRemovable_2_0 resource) { - return new GenericOrmOrphanRemoval2_0(parent, resource); - } - - @Override - public OrmNamedQuery buildOrmNamedQuery(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) { - return new GenericOrmNamedQuery2_0(parent, resourceNamedQuery); - } - - @Override - public OrmCollectionTable2_0 buildOrmCollectionTable(OrmElementCollectionMapping2_0 parent, Table.Owner owner, XmlCollectionTable resource) { - return new GenericOrmCollectionTable2_0(parent, owner, resource); - } - - @Override - public OrmOneToManyMapping buildOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) { - return new GenericOrmOneToManyMapping2_0(parent, resourceMapping); - } - - @Override - public OrmManyToOneMapping buildOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) { - return new GenericOrmManyToOneMapping2_0(parent, resourceMapping); - } - - @Override - public OrmOneToOneMapping buildOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) { - return new GenericOrmOneToOneMapping2_0(parent, resourceMapping); - } - - // ********** ORM Virtual Resource Model ********** - - @Override - public XmlAssociationOverride buildVirtualXmlAssociationOverride(String name, OrmTypeMapping parent, JoiningStrategy joiningStrategy) { - return new VirtualXmlAssociationOverride2_0(name, parent, joiningStrategy); - } - - @Override - public XmlBasic buildVirtualXmlBasic(OrmTypeMapping ormTypeMapping, JavaBasicMapping javaBasicMapping) { - return new VirtualXmlBasic2_0(ormTypeMapping, javaBasicMapping); - } - - @Override - public XmlId buildVirtualXmlId(OrmTypeMapping ormTypeMapping, JavaIdMapping javaIdMapping) { - return new VirtualXmlId2_0(ormTypeMapping, javaIdMapping); - } - - @Override - public XmlEmbeddedId buildVirtualXmlEmbeddedId(OrmTypeMapping ormTypeMapping, JavaEmbeddedIdMapping javaEmbeddedIdMapping) { - return new VirtualXmlEmbeddedId2_0(ormTypeMapping, javaEmbeddedIdMapping); - } - - @Override - public XmlEmbedded buildVirtualXmlEmbedded(OrmTypeMapping ormTypeMapping, JavaEmbeddedMapping javaEmbeddedMapping) { - return new VirtualXmlEmbedded2_0(ormTypeMapping, (JavaEmbeddedMapping2_0) javaEmbeddedMapping); - } - - @Override - public XmlManyToMany buildVirtualXmlManyToMany(OrmTypeMapping ormTypeMapping, JavaManyToManyMapping javaManyToManyMapping) { - return new VirtualXmlManyToMany2_0(ormTypeMapping, (JavaManyToManyMapping2_0) javaManyToManyMapping); - } - - @Override - public XmlManyToOne buildVirtualXmlManyToOne(OrmTypeMapping ormTypeMapping, JavaManyToOneMapping javaManyToOneMapping) { - return new VirtualXmlManyToOne2_0(ormTypeMapping, (JavaManyToOneMapping2_0) javaManyToOneMapping); - } - - @Override - public XmlOneToMany buildVirtualXmlOneToMany(OrmTypeMapping ormTypeMapping, JavaOneToManyMapping javaOneToManyMapping) { - return new VirtualXmlOneToMany2_0(ormTypeMapping, (JavaOneToManyMapping2_0) javaOneToManyMapping); - } - - @Override - public XmlOneToOne buildVirtualXmlOneToOne(OrmTypeMapping ormTypeMapping, JavaOneToOneMapping javaOneToOneMapping) { - return new VirtualXmlOneToOne2_0(ormTypeMapping, (JavaOneToOneMapping2_0) javaOneToOneMapping); - } - - @Override - public XmlTransient buildVirtualXmlTransient(OrmTypeMapping ormTypeMapping, JavaTransientMapping javaTransientMapping) { - return new VirtualXmlTransient2_0(ormTypeMapping, javaTransientMapping); - } - - @Override - public XmlVersion buildVirtualXmlVersion(OrmTypeMapping ormTypeMapping, JavaVersionMapping javaVersionMapping) { - return new VirtualXmlVersion2_0(ormTypeMapping, javaVersionMapping); - } - - @Override - public XmlNullAttributeMapping buildVirtualXmlNullAttributeMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping) { - return new VirtualXmlNullAttributeMapping2_0(ormTypeMapping, javaAttributeMapping); - } - - @Override - public XmlElementCollection buildVirtualXmlElementCollection2_0(OrmTypeMapping ormTypeMapping, JavaElementCollectionMapping2_0 javaMapping) { - return new VirtualXmlElementCollection2_0(ormTypeMapping, javaMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0Definition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0Definition.java deleted file mode 100644 index 181bfa4df9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/GenericOrmXml2_0Definition.java +++ /dev/null @@ -1,107 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.orm.NullOrmAttributeMappingDefinition; -import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition; -import org.eclipse.jpt.core.context.orm.OrmTypeMappingDefinition; -import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory; -import org.eclipse.jpt.core.context.orm.OrmXmlDefinition; -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmBasicMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmEmbeddableDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmEmbeddedIdMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmEmbeddedMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmEntityDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmIdMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmManyToManyMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmManyToOneMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmMappedSuperclassDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmOneToManyMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmOneToOneMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmTransientMappingDefinition; -import org.eclipse.jpt.core.internal.context.orm.OrmVersionMappingDefinition; -import org.eclipse.jpt.core.resource.orm.OrmFactory; - -public class GenericOrmXml2_0Definition - extends AbstractOrmXmlDefinition -{ - // singleton - private static final OrmXmlDefinition INSTANCE = - new GenericOrmXml2_0Definition(); - - - /** - * Return the singleton - */ - public static OrmXmlDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private GenericOrmXml2_0Definition() { - super(); - } - - - public EFactory getResourceNodeFactory() { - return OrmFactory.eINSTANCE; - } - - @Override - protected OrmXmlContextNodeFactory buildContextNodeFactory() { - return new GenericOrmXml2_0ContextNodeFactory(); - } - - public JpaResourceType getResourceType() { - return JptCorePlugin.ORM_XML_2_0_RESOURCE_TYPE; - } - - - // ********** ORM type mappings ********** - - @Override - protected OrmTypeMappingDefinition[] buildOrmTypeMappingDefinitions() { - // order should not matter here, but we'll use the same order as for java - // (@see {@link Generic2_0JpaPlatformProvider}) - return new OrmTypeMappingDefinition[] { - OrmEntityDefinition.instance(), - OrmEmbeddableDefinition.instance(), - OrmMappedSuperclassDefinition.instance()}; - } - - - // ********** ORM attribute mappings ********** - - @Override - protected OrmAttributeMappingDefinition[] buildOrmAttributeMappingDefinitions() { - // order should not matter here, but we'll use the same order as for java - // (@see {@link Generic2_0JpaPlatformProvider}) - return new OrmAttributeMappingDefinition[] { - OrmTransientMappingDefinition.instance(), - OrmElementCollectionMapping2_0Definition.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.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java deleted file mode 100644 index 9bcf898ae8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java +++ /dev/null @@ -1,49 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheableHolder2_0; -import org.eclipse.jpt.core.utility.TextRange; - -public class NullOrmCacheable2_0 - extends AbstractOrmXmlContextNode - implements OrmCacheable2_0 -{ - public NullOrmCacheable2_0(OrmCacheableHolder2_0 parent) { - super(parent); - } - - public boolean isCacheable() { - return false; - } - - public boolean isDefaultCacheable() { - return false; - } - - public Boolean getSpecifiedCacheable() { - return null; - } - - public void setSpecifiedCacheable(Boolean newSpecifiedCacheable) { - throw new UnsupportedOperationException(); - } - - public void update() { - //no-op - } - - public TextRange getValidationTextRange() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java deleted file mode 100644 index ca5f71be79..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java +++ /dev/null @@ -1,88 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.DerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmMapsIdDerivedIdentityStrategy2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0; -import org.eclipse.jpt.core.utility.TextRange; - -public class NullOrmDerivedIdentity2_0 extends AbstractXmlContextNode - implements OrmDerivedIdentity2_0 -{ - public NullOrmDerivedIdentity2_0(OrmSingleRelationshipMapping2_0 parent) { - super(parent); - } - - - public OrmSingleRelationshipMapping2_0 getMapping() { - return (OrmSingleRelationshipMapping2_0) getParent(); - } - - public void update() { - // no op - } - - public DerivedIdentityStrategy2_0 getPredominantDerivedIdentityStrategy() { - return null; - } - - public OrmMapsIdDerivedIdentityStrategy2_0 getMapsIdDerivedIdentityStrategy() { - return null; - } - - public boolean usesMapsIdDerivedIdentityStrategy() { - return false; - } - - public void setMapsIdDerivedIdentityStrategy() { - // no op - } - - public void unsetMapsIdDerivedIdentityStrategy() { - // no op - } - - public OrmIdDerivedIdentityStrategy2_0 getIdDerivedIdentityStrategy() { - return null; - } - - public boolean usesIdDerivedIdentityStrategy() { - return false; - } - - public void setIdDerivedIdentityStrategy() { - // no op - } - - public void unsetIdDerivedIdentityStrategy() { - // no op - } - - public boolean usesNullDerivedIdentityStrategy() { - return true; - } - - public void setNullDerivedIdentityStrategy() { - // no op - } - - public void initializeFrom(OrmDerivedIdentity2_0 oldDerivedIdentity) { - // no op - } - - public TextRange getValidationTextRange() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java deleted file mode 100644 index 9c90fa5da1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java +++ /dev/null @@ -1,52 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * NullOrmOrphanRemovable2_0 - */ -public class NullOrmOrphanRemoval2_0 - extends AbstractOrmXmlContextNode - implements OrmOrphanRemovable2_0 -{ - public NullOrmOrphanRemoval2_0(OrmOrphanRemovalHolder2_0 parent) { - super(parent); - } - - public boolean isDefaultOrphanRemoval() { - return false; - } - - public boolean isOrphanRemoval() { - return false; - } - - public Boolean getSpecifiedOrphanRemoval() { - return null; - } - - public void setSpecifiedOrphanRemoval(Boolean newSpecifiedOrphanRemoval) { - throw new UnsupportedOperationException(); - } - - public void update() { - // do nothing - } - - public TextRange getValidationTextRange() { - return null; - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/OrmElementCollectionMapping2_0Definition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/OrmElementCollectionMapping2_0Definition.java deleted file mode 100644 index 66c9a0556e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/OrmElementCollectionMapping2_0Definition.java +++ /dev/null @@ -1,75 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.core.context.orm.OrmAttributeMapping; -import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition; -import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory; -import org.eclipse.jpt.core.jpa2.MappingKeys2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory; -import org.eclipse.jpt.core.resource.orm.OrmPackage; -import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlElementCollection; -import org.eclipse.jpt.core.resource.xml.EmfTools; - -public class OrmElementCollectionMapping2_0Definition - implements OrmAttributeMappingDefinition -{ - // singleton - private static final OrmAttributeMappingDefinition INSTANCE = - new OrmElementCollectionMapping2_0Definition(); - - - /** - * Return the singleton - */ - public static OrmAttributeMappingDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private OrmElementCollectionMapping2_0Definition() { - super(); - } - - - public String getKey() { - return MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY; - } - - public XmlAttributeMapping buildResourceMapping(EFactory factory) { - return EmfTools.create( - factory, - OrmPackage.eINSTANCE.getXmlElementCollection(), - XmlElementCollection.class); - } - - public OrmAttributeMapping buildContextMapping( - OrmPersistentAttribute parent, - XmlAttributeMapping resourceMapping, - OrmXmlContextNodeFactory factory) { - return ((OrmXml2_0ContextNodeFactory) factory).buildOrmElementCollectionMapping2_0(parent, (XmlElementCollection) resourceMapping); - } - - public XmlAttributeMapping buildVirtualResourceMapping( - OrmTypeMapping ormTypeMapping, - JavaAttributeMapping javaAttributeMapping, - OrmXmlContextNodeFactory factory) { - return ((OrmXml2_0ContextNodeFactory) factory).buildVirtualXmlElementCollection2_0(ormTypeMapping, (JavaElementCollectionMapping2_0) javaAttributeMapping); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClassReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClassReference.java deleted file mode 100644 index 375ee49628..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualMapKeyClassReference.java +++ /dev/null @@ -1,33 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionMapping2_0; -import org.eclipse.jpt.core.resource.orm.XmlClassReference; - -public class VirtualMapKeyClassReference extends XmlClassReference -{ - JavaCollectionMapping2_0 javaCollectionMapping; - - public VirtualMapKeyClassReference(JavaCollectionMapping2_0 collectionMapping) { - super(); - this.javaCollectionMapping = collectionMapping; - } - - @Override - public String getClassName() { - return this.javaCollectionMapping.getFullyQualifiedMapKeyClass(); - } - - @Override - public void setClassName(String newClassName) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlAssociationOverride2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlAssociationOverride2_0.java deleted file mode 100644 index a4e66fee61..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlAssociationOverride2_0.java +++ /dev/null @@ -1,74 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jpt.core.context.JoinTable; -import org.eclipse.jpt.core.context.JoinTableJoiningStrategy; -import org.eclipse.jpt.core.context.JoiningStrategy; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAssociationOverride; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlJoinTable; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.core.resource.orm.XmlJoinTable; - -public class VirtualXmlAssociationOverride2_0 extends XmlAssociationOverride -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JoiningStrategy joiningStrategy; - - protected final VirtualXmlAssociationOverride virtualXmlAssociationOverride; - - public VirtualXmlAssociationOverride2_0(String name, OrmTypeMapping ormTypeMapping, JoiningStrategy joiningStrategy) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.joiningStrategy = joiningStrategy; - this.virtualXmlAssociationOverride = new VirtualXmlAssociationOverride(name, ormTypeMapping, joiningStrategy); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getName() { - return this.virtualXmlAssociationOverride.getName(); - } - - @Override - public void setName(String value) { - this.virtualXmlAssociationOverride.setName(value); - } - - @Override - public EList<XmlJoinColumn> getJoinColumns() { - return this.virtualXmlAssociationOverride.getJoinColumns(); - } - - @Override - public XmlJoinTable getJoinTable() { - if (this.joiningStrategy instanceof JoinTableJoiningStrategy) { - JoinTable joinTable = ((JoinTableJoiningStrategy) this.joiningStrategy).getJoinTable(); - if (joinTable != null) { - return new VirtualXmlJoinTable( - this.ormTypeMapping, - joinTable); - } - } - return null; - } - - @Override - public void setJoinTable(XmlJoinTable newJoinTable) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlBasic2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlBasic2_0.java deleted file mode 100644 index ed7ac05655..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlBasic2_0.java +++ /dev/null @@ -1,150 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.java.JavaBasicMapping; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlBasic; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.EnumType; -import org.eclipse.jpt.core.resource.orm.FetchType; -import org.eclipse.jpt.core.resource.orm.TemporalType; -import org.eclipse.jpt.core.resource.orm.XmlBasic; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.utility.TextRange; -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlBasic2_0 extends XmlBasic -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaBasicMapping javaAttributeMapping; - - protected final VirtualXmlBasic virtualXmlBasic; - - public VirtualXmlBasic2_0(OrmTypeMapping ormTypeMapping, JavaBasicMapping javaBasicMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaBasicMapping; - this.virtualXmlBasic = new VirtualXmlBasic(ormTypeMapping, javaBasicMapping); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlBasic.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlBasic.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlBasic.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlBasic.getNameTextRange(); - } - - @Override - public XmlColumn getColumn() { - return this.virtualXmlBasic.getColumn(); - } - - @Override - public void setColumn(XmlColumn value) { - this.virtualXmlBasic.setColumn(value); - } - - @Override - public FetchType getFetch() { - return this.virtualXmlBasic.getFetch(); - } - - @Override - public void setFetch(FetchType newFetch) { - this.virtualXmlBasic.setFetch(newFetch); - } - - @Override - public Boolean getOptional() { - return this.virtualXmlBasic.getOptional(); - } - - @Override - public void setOptional(Boolean newOptional) { - this.virtualXmlBasic.setOptional(newOptional); - } - - @Override - public boolean isLob() { - return this.virtualXmlBasic.isLob(); - } - - @Override - public void setLob(boolean newLob) { - this.virtualXmlBasic.setLob(newLob); - } - - @Override - public TextRange getLobTextRange() { - return this.virtualXmlBasic.getLobTextRange(); - } - - @Override - public TemporalType getTemporal() { - return this.virtualXmlBasic.getTemporal(); - } - - @Override - public void setTemporal(TemporalType setTemporal){ - this.virtualXmlBasic.setTemporal(setTemporal); - } - - @Override - public TextRange getTemporalTextRange() { - return this.virtualXmlBasic.getTemporalTextRange(); - } - - @Override - public EnumType getEnumerated() { - return this.virtualXmlBasic.getEnumerated(); - } - - @Override - public void setEnumerated(EnumType setEnumerated) { - this.virtualXmlBasic.setEnumerated(setEnumerated); - } - - @Override - public TextRange getEnumeratedTextRange() { - return null; - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlCascadeType2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlCascadeType2_0.java deleted file mode 100644 index 33caed6a85..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlCascadeType2_0.java +++ /dev/null @@ -1,89 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.internal.context.orm.VirtualCascadeType; -import org.eclipse.jpt.core.jpa2.context.Cascade2_0; -import org.eclipse.jpt.core.resource.orm.CascadeType; - -public class VirtualXmlCascadeType2_0 - extends CascadeType -{ - protected Cascade2_0 javaCascade; - - protected final VirtualCascadeType virtualXmlCascadeType1_0; - - - public VirtualXmlCascadeType2_0(Cascade2_0 javaCascade) { - super(); - this.javaCascade = javaCascade; - this.virtualXmlCascadeType1_0 = new VirtualCascadeType(javaCascade); - } - - - @Override - public boolean isCascadeDetach() { - return this.javaCascade.isDetach(); - } - - @Override - public void setCascadeDetach(boolean newCascadeDetach) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - - // **************** JPA 1.0 functionality ********************************* - - @Override - public boolean isCascadeAll() { - return this.virtualXmlCascadeType1_0.isCascadeAll(); - } - - @Override - public void setCascadeAll(boolean value) { - this.virtualXmlCascadeType1_0.setCascadeAll(value); - } - - @Override - public boolean isCascadeMerge() { - return this.virtualXmlCascadeType1_0.isCascadeMerge(); - } - - @Override - public void setCascadeMerge(boolean value) { - this.virtualXmlCascadeType1_0.setCascadeMerge(value); - } - - @Override - public boolean isCascadePersist() { - return this.virtualXmlCascadeType1_0.isCascadePersist(); - } - - @Override - public void setCascadePersist(boolean value) { - this.virtualXmlCascadeType1_0.setCascadePersist(value); - } - - @Override - public boolean isCascadeRefresh() { - return this.virtualXmlCascadeType1_0.isCascadeRefresh(); - } - - @Override - public void setCascadeRefresh(boolean value) { - this.setCascadeRefresh(value); - } - - @Override - public boolean isCascadeRemove() { - return this.virtualXmlCascadeType1_0.isCascadeRemove(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlCollectionTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlCollectionTable.java deleted file mode 100644 index 18b149712c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlCollectionTable.java +++ /dev/null @@ -1,127 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.UniqueConstraint; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlJoinColumn; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlUniqueConstraint; -import org.eclipse.jpt.core.jpa2.context.CollectionTable2_0; -import org.eclipse.jpt.core.resource.orm.OrmPackage; -import org.eclipse.jpt.core.resource.orm.XmlCollectionTable; -import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; - -public class VirtualXmlCollectionTable - extends XmlCollectionTable -{ - protected OrmTypeMapping ormTypeMapping; - - protected CollectionTable2_0 collectionTable; - - - public VirtualXmlCollectionTable(OrmTypeMapping ormTypeMapping, CollectionTable2_0 collectionTable) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.collectionTable = collectionTable; - } - - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getName() { - if (this.isOrmMetadataComplete()) { - return this.collectionTable.getDefaultName(); - } - return this.collectionTable.getName(); - } - - @Override - public void setName(String value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getCatalog() { - if (this.isOrmMetadataComplete()) { - return this.collectionTable.getDefaultCatalog(); - } - return this.collectionTable.getCatalog(); - } - - @Override - public void setCatalog(String value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getSchema() { - if (this.isOrmMetadataComplete()) { - return this.collectionTable.getDefaultSchema(); - } - return this.collectionTable.getSchema(); - } - - @Override - public void setSchema(String value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - //VirtualXmlJoinTable is rebuilt every time, so just rebuilding the joinColumns list as well - @Override - public EList<XmlJoinColumn> getJoinColumns() { - EList<XmlJoinColumn> joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_COLLECTION_TABLE__JOIN_COLUMNS); - if (this.collectionTable == null || isOrmMetadataComplete()) { - return joinColumns; - } - for (JoinColumn joinColumn : CollectionTools.iterable(this.collectionTable.specifiedJoinColumns())) { - XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, isOrmMetadataComplete()); - joinColumns.add(xmlJoinColumn); - } - return joinColumns; - } - - @Override - public EList<XmlUniqueConstraint> getUniqueConstraints() { - EList<XmlUniqueConstraint> xmlUniqueConstraints = new EObjectContainmentEList<XmlUniqueConstraint>(XmlUniqueConstraint.class, this, OrmPackage.XML_COLLECTION_TABLE__UNIQUE_CONSTRAINTS); - if (this.collectionTable == null || isOrmMetadataComplete()) { - return xmlUniqueConstraints; - } - for (UniqueConstraint uniqueConstraint : CollectionTools.iterable(this.collectionTable.uniqueConstraints())) { - XmlUniqueConstraint xmlUniqueConstraint = new VirtualXmlUniqueConstraint(uniqueConstraint, isOrmMetadataComplete()); - xmlUniqueConstraints.add(xmlUniqueConstraint); - } - - return xmlUniqueConstraints; - } - - @Override - public TextRange getNameTextRange() { - return null; - } - - @Override - public TextRange getCatalogTextRange() { - return null; - } - - @Override - public TextRange getSchemaTextRange() { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java deleted file mode 100644 index 7c41ccf44c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlElementCollection2_0.java +++ /dev/null @@ -1,286 +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.core.internal.jpa2.context.orm; - -import java.util.ListIterator; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.jpt.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualMapKey; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAttributeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAttributeOverride; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlColumn; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlOrderColumn; -import org.eclipse.jpt.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.FetchType; -import org.eclipse.jpt.core.resource.orm.MapKey; -import org.eclipse.jpt.core.resource.orm.OrmPackage; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.core.resource.orm.XmlClassReference; -import org.eclipse.jpt.core.resource.orm.XmlCollectionTable; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlElementCollection; -import org.eclipse.jpt.core.resource.orm.XmlOrderColumn; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * VirtualXmlElementCollection2_0 is an implementation of XmlElementCollection used when there is - * no tag in the orm.xml and an underlying java element collection exists. - */ -public class VirtualXmlElementCollection2_0 extends XmlElementCollection -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaElementCollectionMapping2_0 javaAttributeMapping; - - protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping; - - protected final MapKey mapKey; - - protected final XmlClassReference mapKeyClass; - - protected final VirtualXmlOrderColumn orderColumn; - - protected final VirtualXmlCollectionTable collectionTable; - - protected final VirtualXmlColumn valueColumn; - - protected final VirtualXmlColumn mapKeyColumn; - - public VirtualXmlElementCollection2_0( - OrmTypeMapping ormTypeMapping, JavaElementCollectionMapping2_0 javaMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaMapping; - this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaMapping); - this.mapKey = new VirtualMapKey(javaMapping); - this.mapKeyClass = new VirtualMapKeyClassReference(javaMapping); - this.orderColumn = new VirtualXmlOrderColumn( - ((Orderable2_0) this.javaAttributeMapping.getOrderable()).getOrderColumn(), - this.ormTypeMapping); - this.collectionTable = new VirtualXmlCollectionTable( - this.ormTypeMapping, - this.javaAttributeMapping.getCollectionTable()); - this.valueColumn = new VirtualXmlColumn(ormTypeMapping, javaMapping.getValueColumn()); - this.mapKeyColumn = new VirtualXmlColumn(ormTypeMapping, javaMapping.getMapKeyColumn()); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlAttributeMapping.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlAttributeMapping.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlAttributeMapping.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlAttributeMapping.getNameTextRange(); - } - - @Override - public FetchType getFetch() { - if (this.isOrmMetadataComplete()) { - return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getDefaultFetch()); - } - return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getFetch()); - } - - @Override - public void setFetch(FetchType newFetch) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - - @Override - public String getTargetClass() { - if (this.isOrmMetadataComplete()) { - return this.javaAttributeMapping.getDefaultTargetClass(); - } - return this.javaAttributeMapping.getFullyQualifiedTargetClass(); - } - - @Override - public void setTargetClass(String value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public TextRange getTargetClassTextRange() { - return null; - } - - - @Override - public XmlCollectionTable getCollectionTable() { - return this.collectionTable; - } - - @Override - public void setCollectionTable(XmlCollectionTable value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlColumn getColumn() { - return this.valueColumn; - } - - @Override - public void setColumn(XmlColumn newColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlColumn getMapKeyColumn() { - return this.mapKeyColumn; - } - - @Override - public void setMapKeyColumn(XmlColumn newMapKeyColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public EList<XmlAttributeOverride> getAttributeOverrides() { - EList<XmlAttributeOverride> attributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_ELEMENT_COLLECTION__ATTRIBUTE_OVERRIDES); - ListIterator<JavaAttributeOverride> javaAttributeOverrides; - if (!this.isOrmMetadataComplete()) { - javaAttributeOverrides = this.javaAttributeMapping.getValueAttributeOverrideContainer().attributeOverrides(); - } - else { - javaAttributeOverrides = this.javaAttributeMapping.getValueAttributeOverrideContainer().virtualAttributeOverrides(); - } - for (JavaAttributeOverride javaAttributeOverride : CollectionTools.iterable(javaAttributeOverrides)) { - XmlColumn xmlColumn = new VirtualXmlColumn(this.ormTypeMapping, javaAttributeOverride.getColumn()); - XmlAttributeOverride xmlAttributeOverride = new VirtualXmlAttributeOverride(javaAttributeOverride.getName(), xmlColumn); - attributeOverrides.add(xmlAttributeOverride); - } - return attributeOverrides; - } - - @Override - public EList<XmlAssociationOverride> getAssociationOverrides() { - EList<XmlAssociationOverride> associationOverrides = new EObjectContainmentEList<XmlAssociationOverride>(XmlAssociationOverride.class, this, OrmPackage.XML_ELEMENT_COLLECTION__ASSOCIATION_OVERRIDES); - ListIterator<JavaAssociationOverride> javaAssociationOverrides; - if (!this.isOrmMetadataComplete()) { - javaAssociationOverrides = this.javaAttributeMapping.getValueAssociationOverrideContainer().associationOverrides(); - } - else { - javaAssociationOverrides = this.javaAttributeMapping.getValueAssociationOverrideContainer().virtualAssociationOverrides(); - } - for (JavaAssociationOverride javaAssociationOverride : CollectionTools.iterable(javaAssociationOverrides)) { - XmlAssociationOverride xmlAssociationOverride = new VirtualXmlAssociationOverride2_0(javaAssociationOverride.getName(), this.ormTypeMapping, javaAssociationOverride.getRelationshipReference().getPredominantJoiningStrategy()); - associationOverrides.add(xmlAssociationOverride); - } - return associationOverrides; - } - - @Override - public MapKey getMapKey() { - if (this.isOrmMetadataComplete()) { - return null; - } - if (this.javaAttributeMapping.isNoMapKey()) { - return null; - } - return this.mapKey; - } - - @Override - public void setMapKey(MapKey value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlClassReference getMapKeyClass() { - if (this.isOrmMetadataComplete()) { - return null; - } - return this.mapKeyClass; - } - - @Override - public void setMapKeyClass(XmlClassReference newMapKeyClass) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getOrderBy() { - if (this.isOrmMetadataComplete()) { - return null; - } - return this.javaAttributeMapping.getOrderable().getSpecifiedOrderBy(); - } - - @Override - public void setOrderBy(String value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlOrderColumn getOrderColumn() { - if (((Orderable2_0) this.javaAttributeMapping.getOrderable()).isOrderColumnOrdering()) { - return this.orderColumn; - } - return null; - } - - @Override - public void setOrderColumn(XmlOrderColumn newOrderColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public EList<XmlAttributeOverride> getMapKeyAttributeOverrides() { - EList<XmlAttributeOverride> attributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_ELEMENT_COLLECTION__MAP_KEY_ATTRIBUTE_OVERRIDES); - ListIterator<JavaAttributeOverride> javaAttributeOverrides; - if (!this.isOrmMetadataComplete()) { - javaAttributeOverrides = this.javaAttributeMapping.getMapKeyAttributeOverrideContainer().attributeOverrides(); - } - else { - javaAttributeOverrides = this.javaAttributeMapping.getMapKeyAttributeOverrideContainer().virtualAttributeOverrides(); - } - for (JavaAttributeOverride javaAttributeOverride : CollectionTools.iterable(javaAttributeOverrides)) { - XmlColumn xmlColumn = new VirtualXmlColumn(this.ormTypeMapping, javaAttributeOverride.getColumn()); - XmlAttributeOverride xmlAttributeOverride = new VirtualXmlAttributeOverride(javaAttributeOverride.getName(), xmlColumn); - attributeOverrides.add(xmlAttributeOverride); - } - return attributeOverrides; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlEmbedded2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlEmbedded2_0.java deleted file mode 100644 index e4b8d33cf9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlEmbedded2_0.java +++ /dev/null @@ -1,102 +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.core.internal.jpa2.context.orm; - -import java.util.ListIterator; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.jpt.core.context.java.JavaAssociationOverride; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlEmbedded; -import org.eclipse.jpt.core.jpa2.context.java.JavaEmbeddedMapping2_0; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.OrmPackage; -import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride; -import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.core.resource.orm.XmlEmbedded; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlEmbedded2_0 extends XmlEmbedded -{ - - protected OrmTypeMapping ormTypeMapping; - - protected final JavaEmbeddedMapping2_0 javaAttributeMapping; - - protected final VirtualXmlEmbedded virtualXmlEmbedded; - - public VirtualXmlEmbedded2_0(OrmTypeMapping ormTypeMapping, JavaEmbeddedMapping2_0 javaEmbeddedMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaEmbeddedMapping; - this.virtualXmlEmbedded = new VirtualXmlEmbedded(ormTypeMapping, javaEmbeddedMapping); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlEmbedded.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlEmbedded.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlEmbedded.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlEmbedded.getNameTextRange(); - } - - @Override - public EList<XmlAttributeOverride> getAttributeOverrides() { - return this.virtualXmlEmbedded.getAttributeOverrides(); - } - - @Override - public EList<XmlAssociationOverride> getAssociationOverrides() { - EList<XmlAssociationOverride> associationOverrides = new EObjectContainmentEList<XmlAssociationOverride>(XmlAssociationOverride.class, this, OrmPackage.XML_ELEMENT_COLLECTION__ASSOCIATION_OVERRIDES); - ListIterator<JavaAssociationOverride> javaAssociationOverrides; - if (!this.isOrmMetadataComplete()) { - javaAssociationOverrides = this.javaAttributeMapping.getAssociationOverrideContainer().associationOverrides(); - } - else { - javaAssociationOverrides = this.javaAttributeMapping.getAssociationOverrideContainer().virtualAssociationOverrides(); - } - for (JavaAssociationOverride javaAssociationOverride : CollectionTools.iterable(javaAssociationOverrides)) { - XmlAssociationOverride xmlAssociationOverride = new VirtualXmlAssociationOverride2_0(javaAssociationOverride.getName(), this.ormTypeMapping, javaAssociationOverride.getRelationshipReference().getPredominantJoiningStrategy()); - associationOverrides.add(xmlAssociationOverride); - } - return associationOverrides; - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlEmbeddedId2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlEmbeddedId2_0.java deleted file mode 100644 index 4fed9661b6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlEmbeddedId2_0.java +++ /dev/null @@ -1,75 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlEmbeddedId; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlEmbeddedId2_0 extends XmlEmbeddedId -{ - - protected OrmTypeMapping ormTypeMapping; - - protected final JavaEmbeddedIdMapping javaAttributeMapping; - - protected final VirtualXmlEmbeddedId virtualXmlEmbeddedId; - - public VirtualXmlEmbeddedId2_0(OrmTypeMapping ormTypeMapping, JavaEmbeddedIdMapping javaEmbeddedIdMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaEmbeddedIdMapping; - this.virtualXmlEmbeddedId = new VirtualXmlEmbeddedId(ormTypeMapping, javaEmbeddedIdMapping); - } - - @Override - public String getMappingKey() { - return this.virtualXmlEmbeddedId.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlEmbeddedId.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlEmbeddedId.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlEmbeddedId.getNameTextRange(); - } - - @Override - public EList<XmlAttributeOverride> getAttributeOverrides() { - return this.virtualXmlEmbeddedId.getAttributeOverrides(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlId2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlId2_0.java deleted file mode 100644 index 710664c2b6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlId2_0.java +++ /dev/null @@ -1,171 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.java.JavaIdMapping; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlId; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.EnumType; -import org.eclipse.jpt.core.resource.orm.TemporalType; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue; -import org.eclipse.jpt.core.resource.orm.XmlId; -import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; -import org.eclipse.jpt.core.resource.orm.XmlTableGenerator; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlId2_0 extends XmlId -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaIdMapping javaAttributeMapping; - - protected final VirtualXmlId virtualXmlId; - - protected final VirtualXmlSequenceGenerator2_0 virtualSequenceGenerator; - - public VirtualXmlId2_0(OrmTypeMapping ormTypeMapping, JavaIdMapping javaIdMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaIdMapping; - this.virtualXmlId = new VirtualXmlId(ormTypeMapping, javaIdMapping); - this.virtualSequenceGenerator = new VirtualXmlSequenceGenerator2_0(javaIdMapping.getGeneratorContainer(), this.isOrmMetadataComplete()); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlId.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlId.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlId.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlId.getNameTextRange(); - } - - @Override - public XmlColumn getColumn() { - return this.virtualXmlId.getColumn(); - } - - @Override - public void setColumn(XmlColumn value) { - this.virtualXmlId.setColumn(value); - } - - @Override - public TemporalType getTemporal() { - return this.virtualXmlId.getTemporal(); - } - - @Override - public void setTemporal(TemporalType newTemporal){ - this.virtualXmlId.setTemporal(newTemporal); - } - - @Override - public TextRange getTemporalTextRange() { - return this.virtualXmlId.getTemporalTextRange(); - } - - @Override - public XmlGeneratedValue getGeneratedValue() { - return this.virtualXmlId.getGeneratedValue(); - } - - @Override - public void setGeneratedValue(XmlGeneratedValue value) { - this.virtualXmlId.setGeneratedValue(value); - } - - @Override - public XmlSequenceGenerator getSequenceGenerator() { - if (this.isOrmMetadataComplete()) { - return null; - } - if (this.javaAttributeMapping.getGeneratorContainer().getSequenceGenerator() != null) { - return this.virtualSequenceGenerator; - } - return null; - } - - @Override - public void setSequenceGenerator(XmlSequenceGenerator value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlTableGenerator getTableGenerator() { - return this.virtualXmlId.getTableGenerator(); - } - - @Override - public void setTableGenerator(XmlTableGenerator value) { - this.virtualXmlId.setTableGenerator(value); - } - - @Override - public EnumType getEnumerated() { - return this.virtualXmlId.getEnumerated(); - } - - @Override - public void setEnumerated(EnumType value) { - this.virtualXmlId.setEnumerated(value); - } - - @Override - public TextRange getEnumeratedTextRange() { - return this.virtualXmlId.getEnumeratedTextRange(); - } - - @Override - public boolean isLob() { - return this.virtualXmlId.isLob(); - } - - @Override - public void setLob(boolean value) { - this.virtualXmlId.setLob(value); - } - - @Override - public TextRange getLobTextRange() { - return this.virtualXmlId.getLobTextRange(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java deleted file mode 100644 index 6a5ed68540..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToMany2_0.java +++ /dev/null @@ -1,246 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 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.core.internal.jpa2.context.orm; - -import java.util.ListIterator; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.jpt.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAttributeOverride; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlColumn; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlManyToMany; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlOrderColumn; -import org.eclipse.jpt.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaManyToManyMapping2_0; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.CascadeType; -import org.eclipse.jpt.core.resource.orm.FetchType; -import org.eclipse.jpt.core.resource.orm.MapKey; -import org.eclipse.jpt.core.resource.orm.OrmPackage; -import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.core.resource.orm.XmlClassReference; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlJoinTable; -import org.eclipse.jpt.core.resource.orm.XmlManyToMany; -import org.eclipse.jpt.core.resource.orm.XmlOrderColumn; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlManyToMany2_0 - extends XmlManyToMany -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaManyToManyMapping2_0 javaAttributeMapping; - - protected final VirtualXmlManyToMany virtualXmlManyToMany; - - protected final VirtualXmlCascadeType2_0 virtualXmlCascadeType; - - protected final XmlClassReference mapKeyClass; - - protected VirtualXmlOrderColumn orderColumn; - - protected final VirtualXmlColumn mapKeyColumn; - - - public VirtualXmlManyToMany2_0( - OrmTypeMapping ormTypeMapping, JavaManyToManyMapping2_0 javaManyToManyMapping) { - - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaManyToManyMapping; - this.virtualXmlManyToMany = new VirtualXmlManyToMany(ormTypeMapping, javaManyToManyMapping); - this.virtualXmlCascadeType = new VirtualXmlCascadeType2_0(javaManyToManyMapping.getCascade()); - this.mapKeyClass = new VirtualMapKeyClassReference(javaManyToManyMapping); - this.orderColumn = new VirtualXmlOrderColumn( - ((Orderable2_0) this.javaAttributeMapping.getOrderable()).getOrderColumn(), - this.ormTypeMapping); - this.mapKeyColumn = new VirtualXmlColumn(ormTypeMapping, javaManyToManyMapping.getMapKeyColumn()); - } - - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlManyToMany.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlManyToMany.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlManyToMany.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlManyToMany.getNameTextRange(); - } - - @Override - public FetchType getFetch() { - return this.virtualXmlManyToMany.getFetch(); - } - - @Override - public void setFetch(FetchType newFetch) { - this.virtualXmlManyToMany.setFetch(newFetch); - } - - @Override - public CascadeType getCascade() { - if (isOrmMetadataComplete()) { - return null; - } - return this.virtualXmlCascadeType; - } - - @Override - public void setCascade(CascadeType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlJoinTable getJoinTable() { - return this.virtualXmlManyToMany.getJoinTable(); - } - - @Override - public void setJoinTable(XmlJoinTable value) { - this.virtualXmlManyToMany.setJoinTable(value); - } - - @Override - public String getTargetEntity() { - return this.virtualXmlManyToMany.getTargetEntity(); - } - - @Override - public void setTargetEntity(String value) { - this.virtualXmlManyToMany.setTargetEntity(value); - } - - @Override - public String getMappedBy() { - return this.virtualXmlManyToMany.getMappedBy(); - } - - @Override - public void setMappedBy(String value) { - this.virtualXmlManyToMany.setMappedBy(value); - } - - - @Override - public MapKey getMapKey() { - return this.virtualXmlManyToMany.getMapKey(); - } - - @Override - public void setMapKey(MapKey value) { - this.virtualXmlManyToMany.setMapKey(value); - } - - @Override - public XmlClassReference getMapKeyClass() { - if (this.isOrmMetadataComplete()) { - return null; - } - return this.mapKeyClass; - } - - @Override - public void setMapKeyClass(XmlClassReference newMapKeyClass) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlColumn getMapKeyColumn() { - return this.mapKeyColumn; - } - - @Override - public void setMapKeyColumn(XmlColumn newMapKeyColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getOrderBy() { - return this.virtualXmlManyToMany.getOrderBy(); - } - - @Override - public void setOrderBy(String value) { - this.virtualXmlManyToMany.setOrderBy(value); - } - - @Override - public XmlOrderColumn getOrderColumn() { - if (((Orderable2_0) this.javaAttributeMapping.getOrderable()).isOrderColumnOrdering()) { - return this.orderColumn; - } - return null; - } - - @Override - public void setOrderColumn(XmlOrderColumn newOrderColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public TextRange getMappedByTextRange() { - return this.virtualXmlManyToMany.getMappedByTextRange(); - } - - @Override - public TextRange getTargetEntityTextRange() { - return this.virtualXmlManyToMany.getTargetEntityTextRange(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public EList<XmlAttributeOverride> getMapKeyAttributeOverrides() { - EList<XmlAttributeOverride> attributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_MANY_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES); - ListIterator<JavaAttributeOverride> javaAttributeOverrides; - if (!this.isOrmMetadataComplete()) { - javaAttributeOverrides = this.javaAttributeMapping.getMapKeyAttributeOverrideContainer().attributeOverrides(); - } - else { - javaAttributeOverrides = this.javaAttributeMapping.getMapKeyAttributeOverrideContainer().virtualAttributeOverrides(); - } - for (JavaAttributeOverride javaAttributeOverride : CollectionTools.iterable(javaAttributeOverrides)) { - XmlColumn xmlColumn = new VirtualXmlColumn(this.ormTypeMapping, javaAttributeOverride.getColumn()); - XmlAttributeOverride xmlAttributeOverride = new VirtualXmlAttributeOverride(javaAttributeOverride.getName(), xmlColumn); - attributeOverrides.add(xmlAttributeOverride); - } - return attributeOverrides; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToOne2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToOne2_0.java deleted file mode 100644 index c8ce2d0bc0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlManyToOne2_0.java +++ /dev/null @@ -1,184 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlJoinTable; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlManyToOne; -import org.eclipse.jpt.core.jpa2.context.DerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneMapping2_0; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.CascadeType; -import org.eclipse.jpt.core.resource.orm.FetchType; -import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.core.resource.orm.XmlJoinTable; -import org.eclipse.jpt.core.resource.orm.XmlManyToOne; -import org.eclipse.jpt.core.utility.TextRange; - -public class VirtualXmlManyToOne2_0 extends XmlManyToOne -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaManyToOneMapping2_0 javaAttributeMapping; - - protected final VirtualXmlManyToOne virtualXmlManyToOne; - - protected final VirtualXmlCascadeType2_0 virtualXmlCascadeType; - - - public VirtualXmlManyToOne2_0( - OrmTypeMapping ormTypeMapping, - JavaManyToOneMapping2_0 javaManyToOneMapping) { - - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaManyToOneMapping; - this.virtualXmlManyToOne = new VirtualXmlManyToOne(ormTypeMapping, javaManyToOneMapping); - this.virtualXmlCascadeType = new VirtualXmlCascadeType2_0(javaManyToOneMapping.getCascade()); - } - - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlManyToOne.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlManyToOne.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlManyToOne.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlManyToOne.getNameTextRange(); - } - - @Override - public FetchType getFetch() { - return this.virtualXmlManyToOne.getFetch(); - } - - @Override - public void setFetch(FetchType newFetch) { - this.virtualXmlManyToOne.setFetch(newFetch); - } - - @Override - public Boolean getOptional() { - return this.virtualXmlManyToOne.getOptional(); - } - - @Override - public void setOptional(Boolean newOptional) { - this.virtualXmlManyToOne.setOptional(newOptional); - } - - @Override - public EList<XmlJoinColumn> getJoinColumns() { - return this.virtualXmlManyToOne.getJoinColumns(); - } - - @Override - public CascadeType getCascade() { - if (isOrmMetadataComplete()) { - return null; - } - return this.virtualXmlCascadeType; - } - - @Override - public void setCascade(CascadeType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlJoinTable getJoinTable() { - if (this.javaAttributeMapping.getRelationshipReference().getJoinTableJoiningStrategy().getJoinTable() != null) { - return new VirtualXmlJoinTable( - this.ormTypeMapping, - this.javaAttributeMapping.getRelationshipReference(). - getJoinTableJoiningStrategy().getJoinTable()); - } - return null; - } - - @Override - public void setJoinTable(XmlJoinTable value) { - this.virtualXmlManyToOne.setJoinTable(value); - } - - @Override - public String getTargetEntity() { - return this.virtualXmlManyToOne.getTargetEntity(); - } - - @Override - public void setTargetEntity(String value) { - this.virtualXmlManyToOne.setTargetEntity(value); - } - - @Override - public TextRange getTargetEntityTextRange() { - return this.virtualXmlManyToOne.getTargetEntityTextRange(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public Boolean getId() { - if (isOrmMetadataComplete()) { - return null; - } - boolean javaIdValue = this.javaAttributeMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue(); - return (javaIdValue) ? Boolean.TRUE : null; - } - - @Override - public void setId(Boolean newId) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getMapsId() { - if (isOrmMetadataComplete()) { - return null; - } - DerivedIdentity2_0 derivedIdentity = this.javaAttributeMapping.getDerivedIdentity(); - if (derivedIdentity.usesMapsIdDerivedIdentityStrategy()) { - return derivedIdentity.getMapsIdDerivedIdentityStrategy().getValue(); - } - else { - return derivedIdentity.getMapsIdDerivedIdentityStrategy().getSpecifiedValue(); - } - } - - @Override - public void setMapsId(String newMapsId) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlNullAttributeMapping2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlNullAttributeMapping2_0.java deleted file mode 100644 index c95d82fae1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlNullAttributeMapping2_0.java +++ /dev/null @@ -1,71 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.java.JavaAttributeMapping; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlNullAttributeMapping; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; -import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * VirtualVersion is an implementation of Version used when there is - * no tag in the orm.xml and an underlying javaVersionMapping exists. - */ -public class VirtualXmlNullAttributeMapping2_0 extends XmlNullAttributeMapping implements XmlAttributeMapping -{ - - protected OrmTypeMapping ormTypeMapping; - - protected final JavaAttributeMapping javaAttributeMapping; - - protected final VirtualXmlNullAttributeMapping virtualXmlNullAttributeMapping; - - public VirtualXmlNullAttributeMapping2_0(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaAttributeMapping; - this.virtualXmlNullAttributeMapping = new VirtualXmlNullAttributeMapping(ormTypeMapping, javaAttributeMapping); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - public String getMappingKey() { - return this.virtualXmlNullAttributeMapping.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlNullAttributeMapping.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlNullAttributeMapping.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlNullAttributeMapping.getNameTextRange(); - } - - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java deleted file mode 100644 index 5604457304..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToMany2_0.java +++ /dev/null @@ -1,284 +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.core.internal.jpa2.context.orm; - -import java.util.ListIterator; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.util.EObjectContainmentEList; -import org.eclipse.jpt.core.context.JoinColumn; -import org.eclipse.jpt.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlAttributeOverride; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlColumn; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlJoinColumn; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlOneToMany; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlOrderColumn; -import org.eclipse.jpt.core.jpa2.context.OneToManyMapping2_0; -import org.eclipse.jpt.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.CascadeType; -import org.eclipse.jpt.core.resource.orm.FetchType; -import org.eclipse.jpt.core.resource.orm.MapKey; -import org.eclipse.jpt.core.resource.orm.OrmPackage; -import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride; -import org.eclipse.jpt.core.resource.orm.XmlClassReference; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.core.resource.orm.XmlJoinTable; -import org.eclipse.jpt.core.resource.orm.XmlOneToMany; -import org.eclipse.jpt.core.resource.orm.XmlOrderColumn; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlOneToMany2_0 extends XmlOneToMany -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaOneToManyMapping2_0 javaAttributeMapping; - - protected final VirtualXmlOneToMany virtualXmlOneToMany; - - protected final VirtualXmlCascadeType2_0 virtualXmlCascadeType; - - protected final XmlClassReference mapKeyClass; - - protected VirtualXmlOrderColumn orderColumn; - - protected final VirtualXmlColumn mapKeyColumn; - - - public VirtualXmlOneToMany2_0( - OrmTypeMapping ormTypeMapping, JavaOneToManyMapping2_0 javaOneToManyMapping) { - - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaOneToManyMapping; - this.virtualXmlOneToMany = new VirtualXmlOneToMany(ormTypeMapping, javaOneToManyMapping); - this.virtualXmlCascadeType = new VirtualXmlCascadeType2_0(javaOneToManyMapping.getCascade()); - this.mapKeyClass = new VirtualMapKeyClassReference(javaOneToManyMapping); - this.orderColumn = new VirtualXmlOrderColumn( - ((Orderable2_0) this.javaAttributeMapping.getOrderable()).getOrderColumn(), - this.ormTypeMapping); - this.mapKeyColumn = new VirtualXmlColumn(ormTypeMapping, javaOneToManyMapping.getMapKeyColumn()); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlOneToMany.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlOneToMany.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlOneToMany.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlOneToMany.getNameTextRange(); - } - - @Override - public FetchType getFetch() { - return this.virtualXmlOneToMany.getFetch(); - } - - @Override - public void setFetch(FetchType newFetch) { - this.virtualXmlOneToMany.setFetch(newFetch); - } - - @Override - public CascadeType getCascade() { - if (isOrmMetadataComplete()) { - return null; - } - return this.virtualXmlCascadeType; - } - - @Override - public void setCascade(CascadeType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - private JavaOrphanRemovable2_0 getOrphanRemovalOf(OneToManyMapping2_0 oneToManyMapping) { - return ((JavaOrphanRemovalHolder2_0) oneToManyMapping).getOrphanRemoval(); - } - - @Override - public Boolean getOrphanRemoval() { - JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(this.javaAttributeMapping); - if (this.isOrmMetadataComplete()) { - return Boolean.valueOf(mappingsOrphanRemoval.isDefaultOrphanRemoval()); - } - return Boolean.valueOf(mappingsOrphanRemoval.isOrphanRemoval()); - } - - @Override - public void setOrphanRemoval(Boolean newOrphanRemoval) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlJoinTable getJoinTable() { - return this.virtualXmlOneToMany.getJoinTable(); - } - - @Override - public void setJoinTable(XmlJoinTable value) { - this.virtualXmlOneToMany.setJoinTable(value); - } - - @Override - public String getTargetEntity() { - return this.virtualXmlOneToMany.getTargetEntity(); - } - - @Override - public void setTargetEntity(String value) { - this.virtualXmlOneToMany.setTargetEntity(value); - } - - @Override - public String getMappedBy() { - return this.virtualXmlOneToMany.getMappedBy(); - } - - @Override - public void setMappedBy(String value) { - this.virtualXmlOneToMany.setMappedBy(value); - } - - - @Override - public MapKey getMapKey() { - return this.virtualXmlOneToMany.getMapKey(); - } - - @Override - public void setMapKey(MapKey value) { - this.virtualXmlOneToMany.setMapKey(value); - } - - @Override - public XmlClassReference getMapKeyClass() { - if (this.isOrmMetadataComplete()) { - return null; - } - return this.mapKeyClass; - } - - @Override - public void setMapKeyClass(XmlClassReference newMapKeyClass) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlColumn getMapKeyColumn() { - return this.mapKeyColumn; - } - - @Override - public void setMapKeyColumn(XmlColumn newMapKeyColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getOrderBy() { - return this.virtualXmlOneToMany.getOrderBy(); - } - - @Override - public void setOrderBy(String value) { - this.virtualXmlOneToMany.setOrderBy(value); - } - - @Override - public XmlOrderColumn getOrderColumn() { - if (((Orderable2_0) this.javaAttributeMapping.getOrderable()).isOrderColumnOrdering()) { - return this.orderColumn; - } - return null; - } - - @Override - public void setOrderColumn(XmlOrderColumn newOrderColumn) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public TextRange getMappedByTextRange() { - return this.virtualXmlOneToMany.getMappedByTextRange(); - } - - @Override - public TextRange getTargetEntityTextRange() { - return this.virtualXmlOneToMany.getTargetEntityTextRange(); - } - - @Override - public EList<XmlJoinColumn> getJoinColumns() { - EList<XmlJoinColumn> joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_ONE_TO_MANY__JOIN_COLUMNS); - if (isOrmMetadataComplete()) { - return joinColumns; - } - for (JoinColumn joinColumn : - CollectionTools.iterable( - this.javaAttributeMapping.getRelationshipReference(). - getJoinColumnJoiningStrategy().specifiedJoinColumns())) { - XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, isOrmMetadataComplete()); - joinColumns.add(xmlJoinColumn); - } - return joinColumns; - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public EList<XmlAttributeOverride> getMapKeyAttributeOverrides() { - EList<XmlAttributeOverride> attributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_ONE_TO_MANY__MAP_KEY_ATTRIBUTE_OVERRIDES); - ListIterator<JavaAttributeOverride> javaAttributeOverrides; - if (!this.isOrmMetadataComplete()) { - javaAttributeOverrides = this.javaAttributeMapping.getMapKeyAttributeOverrideContainer().attributeOverrides(); - } - else { - javaAttributeOverrides = this.javaAttributeMapping.getMapKeyAttributeOverrideContainer().virtualAttributeOverrides(); - } - for (JavaAttributeOverride javaAttributeOverride : CollectionTools.iterable(javaAttributeOverrides)) { - XmlColumn xmlColumn = new VirtualXmlColumn(this.ormTypeMapping, javaAttributeOverride.getColumn()); - XmlAttributeOverride xmlAttributeOverride = new VirtualXmlAttributeOverride(javaAttributeOverride.getName(), xmlColumn); - attributeOverrides.add(xmlAttributeOverride); - } - return attributeOverrides; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToOne2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToOne2_0.java deleted file mode 100644 index cf8ef49ef4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlOneToOne2_0.java +++ /dev/null @@ -1,225 +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.core.internal.jpa2.context.orm; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlJoinTable; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlOneToOne; -import org.eclipse.jpt.core.jpa2.context.DerivedIdentity2_0; -import org.eclipse.jpt.core.jpa2.context.OneToOneMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneMapping2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0; -import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.CascadeType; -import org.eclipse.jpt.core.resource.orm.FetchType; -import org.eclipse.jpt.core.resource.orm.XmlJoinColumn; -import org.eclipse.jpt.core.resource.orm.XmlJoinTable; -import org.eclipse.jpt.core.resource.orm.XmlOneToOne; -import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn; -import org.eclipse.jpt.core.utility.TextRange; - -public class VirtualXmlOneToOne2_0 extends XmlOneToOne -{ - protected OrmTypeMapping ormTypeMapping; - - protected final JavaOneToOneMapping2_0 javaAttributeMapping; - - protected final VirtualXmlOneToOne virtualXmlOneToOne; - - protected final VirtualXmlCascadeType2_0 virtualXmlCascadeType; - - - public VirtualXmlOneToOne2_0( - OrmTypeMapping ormTypeMapping, - JavaOneToOneMapping2_0 javaOneToOneMapping) { - - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaOneToOneMapping; - this.virtualXmlOneToOne = new VirtualXmlOneToOne(ormTypeMapping, javaOneToOneMapping); - this.virtualXmlCascadeType = new VirtualXmlCascadeType2_0(javaOneToOneMapping.getCascade()); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlOneToOne.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlOneToOne.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlOneToOne.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlOneToOne.getNameTextRange(); - } - - @Override - public FetchType getFetch() { - return this.virtualXmlOneToOne.getFetch(); - } - - @Override - public void setFetch(FetchType newFetch) { - this.virtualXmlOneToOne.setFetch(newFetch); - } - - @Override - public Boolean getOptional() { - return this.virtualXmlOneToOne.getOptional(); - } - - @Override - public void setOptional(Boolean newOptional) { - this.virtualXmlOneToOne.setOptional(newOptional); - } - - @Override - public EList<XmlJoinColumn> getJoinColumns() { - return this.virtualXmlOneToOne.getJoinColumns(); - } - - @Override - public CascadeType getCascade() { - if (isOrmMetadataComplete()) { - return null; - } - return this.virtualXmlCascadeType; - } - - @Override - public void setCascade(CascadeType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - private JavaOrphanRemovable2_0 getOrphanRemovalOf(OneToOneMapping2_0 oneToOneMapping) { - return ((JavaOrphanRemovalHolder2_0) oneToOneMapping).getOrphanRemoval(); - } - - @Override - public Boolean getOrphanRemoval() { - JavaOrphanRemovable2_0 mappingsOrphanRemoval = this.getOrphanRemovalOf(this.javaAttributeMapping); - if (this.isOrmMetadataComplete()) { - return Boolean.valueOf(mappingsOrphanRemoval.isDefaultOrphanRemoval()); - } - return Boolean.valueOf(mappingsOrphanRemoval.isOrphanRemoval()); - } - - @Override - public void setOrphanRemoval(Boolean newOrphanRemoval) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public XmlJoinTable getJoinTable() { - if (this.javaAttributeMapping.getRelationshipReference().getJoinTableJoiningStrategy().getJoinTable() != null) { - return new VirtualXmlJoinTable( - this.ormTypeMapping, - this.javaAttributeMapping.getRelationshipReference(). - getJoinTableJoiningStrategy().getJoinTable()); - } - return null; - } - - @Override - public void setJoinTable(XmlJoinTable value) { - this.virtualXmlOneToOne.setJoinTable(value); - } - - @Override - public String getTargetEntity() { - return this.virtualXmlOneToOne.getTargetEntity(); - } - - @Override - public void setTargetEntity(String value) { - this.virtualXmlOneToOne.setTargetEntity(value); - } - - @Override - public String getMappedBy() { - return this.virtualXmlOneToOne.getMappedBy(); - } - - @Override - public void setMappedBy(String value) { - this.virtualXmlOneToOne.setMappedBy(value); - } - - @Override - public EList<XmlPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() { - return this.virtualXmlOneToOne.getPrimaryKeyJoinColumns(); - } - - @Override - public TextRange getMappedByTextRange() { - return this.virtualXmlOneToOne.getMappedByTextRange(); - } - - @Override - public TextRange getTargetEntityTextRange() { - return this.virtualXmlOneToOne.getTargetEntityTextRange(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public Boolean getId() { - if (isOrmMetadataComplete()) { - return null; - } - boolean javaIdValue = this.javaAttributeMapping.getDerivedIdentity().getIdDerivedIdentityStrategy().getValue(); - return (javaIdValue) ? Boolean.TRUE : null; - } - - @Override - public void setId(Boolean newId) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getMapsId() { - if (isOrmMetadataComplete()) { - return null; - } - DerivedIdentity2_0 derivedIdentity = this.javaAttributeMapping.getDerivedIdentity(); - if (derivedIdentity.usesMapsIdDerivedIdentityStrategy()) { - return derivedIdentity.getMapsIdDerivedIdentityStrategy().getValue(); - } - else { - return derivedIdentity.getMapsIdDerivedIdentityStrategy().getSpecifiedValue(); - } - } - - @Override - public void setMapsId(String newMapsId) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlSequenceGenerator2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlSequenceGenerator2_0.java deleted file mode 100644 index f2637eaf51..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlSequenceGenerator2_0.java +++ /dev/null @@ -1,110 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.java.JavaGeneratorContainer; -import org.eclipse.jpt.core.context.java.JavaSequenceGenerator; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlSequenceGenerator; -import org.eclipse.jpt.core.internal.jpa2.context.java.GenericJavaSequenceGenerator2_0; -import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * Generic2_0VirtualXmlSequenceGenerator - */ -public class VirtualXmlSequenceGenerator2_0 extends XmlSequenceGenerator -{ - protected final JavaGeneratorContainer javaGeneratorHolder; - - protected final boolean metadataComplete; - - protected final VirtualXmlSequenceGenerator virtualXmlSequenceGenerator; - - public VirtualXmlSequenceGenerator2_0(JavaGeneratorContainer javaGeneratorHolder, boolean metadataComplete) { - super(); - this.javaGeneratorHolder = javaGeneratorHolder; - this.metadataComplete = metadataComplete; - this.virtualXmlSequenceGenerator = new VirtualXmlSequenceGenerator(javaGeneratorHolder, metadataComplete); - } - - protected JavaSequenceGenerator getJavaSequenceGenerator() { - return this.javaGeneratorHolder.getSequenceGenerator(); - } - - @Override - public String getCatalog() { - return ((GenericJavaSequenceGenerator2_0)this.getJavaSequenceGenerator()).getCatalog(); - } - - @Override - public void setCatalog(String newCatalog) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public String getSchema() { - return ((GenericJavaSequenceGenerator2_0)this.getJavaSequenceGenerator()).getSchema(); - } - - @Override - public void setSchema(String newSchema) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public Integer getAllocationSize() { - return this.virtualXmlSequenceGenerator.getAllocationSize(); - } - - @Override - public void setAllocationSize(Integer newAllocationSize) { - this.virtualXmlSequenceGenerator.setAllocationSize(newAllocationSize); - } - - @Override - public Integer getInitialValue() { - return this.virtualXmlSequenceGenerator.getInitialValue(); - } - - @Override - public void setInitialValue(Integer newInitialValue) { - this.virtualXmlSequenceGenerator.setInitialValue(newInitialValue); - } - - @Override - public String getName() { - return this.virtualXmlSequenceGenerator.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlSequenceGenerator.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlSequenceGenerator.getNameTextRange(); - } - - @Override - public String getSequenceName() { - return this.virtualXmlSequenceGenerator.getSequenceName(); - } - - @Override - public void setSequenceName(String newSequenceName) { - this.virtualXmlSequenceGenerator.setSequenceName(newSequenceName); - } - - @Override - public boolean isVirtual() { - return this.virtualXmlSequenceGenerator.isVirtual(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlTransient2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlTransient2_0.java deleted file mode 100644 index ade064eea6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlTransient2_0.java +++ /dev/null @@ -1,72 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.java.JavaTransientMapping; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlTransient; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.XmlTransient; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlTransient2_0 extends XmlTransient -{ - - protected OrmTypeMapping ormTypeMapping; - - protected final JavaTransientMapping javaAttributeMapping; - - protected final VirtualXmlTransient virtualXmlTransient; - - public VirtualXmlTransient2_0(OrmTypeMapping ormTypeMapping, JavaTransientMapping javaTransientMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaTransientMapping; - this.virtualXmlTransient = new VirtualXmlTransient(ormTypeMapping, javaTransientMapping); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlTransient.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlTransient.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlTransient.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlTransient.getNameTextRange(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlVersion2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlVersion2_0.java deleted file mode 100644 index 3cc3534bc2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/orm/VirtualXmlVersion2_0.java +++ /dev/null @@ -1,130 +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.core.internal.jpa2.context.orm; - -import org.eclipse.jpt.core.context.java.JavaVersionMapping; -import org.eclipse.jpt.core.context.orm.OrmTypeMapping; -import org.eclipse.jpt.core.internal.context.orm.VirtualXmlVersion; -import org.eclipse.jpt.core.resource.orm.AccessType; -import org.eclipse.jpt.core.resource.orm.EnumType; -import org.eclipse.jpt.core.resource.orm.TemporalType; -import org.eclipse.jpt.core.resource.orm.XmlColumn; -import org.eclipse.jpt.core.resource.orm.XmlVersion; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * VirtualBasic is an implementation of Basic used when there is - * no tag in the orm.xml and an underlying javaBasicMapping exists. - */ -public class VirtualXmlVersion2_0 extends XmlVersion -{ - - protected OrmTypeMapping ormTypeMapping; - - protected final JavaVersionMapping javaAttributeMapping; - - protected final VirtualXmlVersion virtualXmlVersion; - - public VirtualXmlVersion2_0(OrmTypeMapping ormTypeMapping, JavaVersionMapping javaVersionMapping) { - super(); - this.ormTypeMapping = ormTypeMapping; - this.javaAttributeMapping = javaVersionMapping; - this.virtualXmlVersion = new VirtualXmlVersion(ormTypeMapping, javaVersionMapping); - } - - protected boolean isOrmMetadataComplete() { - return this.ormTypeMapping.isMetadataComplete(); - } - - @Override - public String getMappingKey() { - return this.virtualXmlVersion.getMappingKey(); - } - - @Override - public String getName() { - return this.virtualXmlVersion.getName(); - } - - @Override - public void setName(String newName) { - this.virtualXmlVersion.setName(newName); - } - - @Override - public TextRange getNameTextRange() { - return this.virtualXmlVersion.getNameTextRange(); - } - - @Override - public XmlColumn getColumn() { - return this.virtualXmlVersion.getColumn(); - } - - @Override - public void setColumn(XmlColumn value) { - this.virtualXmlVersion.setColumn(value); - } - - @Override - public TemporalType getTemporal() { - return this.virtualXmlVersion.getTemporal(); - } - - @Override - public void setTemporal(TemporalType newTemporal){ - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public EnumType getEnumerated() { - return this.virtualXmlVersion.getEnumerated(); - } - - @Override - public void setEnumerated(EnumType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public boolean isLob() { - return this.virtualXmlVersion.isLob(); - } - - @Override - public void setLob(boolean value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } - - @Override - public TextRange getEnumeratedTextRange() { - return this.virtualXmlVersion.getEnumeratedTextRange(); - } - - @Override - public TextRange getLobTextRange() { - return this.virtualXmlVersion.getLobTextRange(); - } - - @Override - public TextRange getTemporalTextRange() { - return this.virtualXmlVersion.getTemporalTextRange(); - } - - @Override - public AccessType getAccess() { - return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(this.javaAttributeMapping.getPersistentAttribute().getAccess()); - } - - @Override - public void setAccess(AccessType value) { - throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/Generic2_0PersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/Generic2_0PersistenceXmlContextNodeFactory.java deleted file mode 100644 index e810ba8343..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/Generic2_0PersistenceXmlContextNodeFactory.java +++ /dev/null @@ -1,31 +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.core.internal.jpa2.context.persistence; - -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceXmlContextNodeFactory; -import org.eclipse.jpt.core.internal.jpa2.context.persistence.connection.GenericConnection2_0; -import org.eclipse.jpt.core.internal.jpa2.context.persistence.options.GenericOptions2_0; -import org.eclipse.jpt.core.jpa2.context.persistence.connection.JpaConnection2_0; -import org.eclipse.jpt.core.jpa2.context.persistence.options.JpaOptions2_0; - - -public class Generic2_0PersistenceXmlContextNodeFactory extends AbstractPersistenceXmlContextNodeFactory -{ - - public JpaConnection2_0 buildConnection(PersistenceUnit parent) { - return new GenericConnection2_0(parent); - } - - public JpaOptions2_0 buildOptions(PersistenceUnit parent) { - return new GenericOptions2_0(parent); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/Generic2_0PersistenceXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/Generic2_0PersistenceXmlDefinition.java deleted file mode 100644 index 00658ee3ed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/Generic2_0PersistenceXmlDefinition.java +++ /dev/null @@ -1,56 +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.core.internal.jpa2.context.persistence; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.jpt.core.JpaResourceType; -import org.eclipse.jpt.core.JptCorePlugin; -import org.eclipse.jpt.core.context.persistence.PersistenceXmlContextNodeFactory; -import org.eclipse.jpt.core.context.persistence.PersistenceXmlDefinition; -import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceXmlDefinition; -import org.eclipse.jpt.core.resource.persistence.v2_0.PersistenceV2_0Factory; - -public class Generic2_0PersistenceXmlDefinition - extends AbstractPersistenceXmlDefinition -{ - // singleton - private static final PersistenceXmlDefinition INSTANCE = - new Generic2_0PersistenceXmlDefinition(); - - - /** - * Return the singleton - */ - public static PersistenceXmlDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private Generic2_0PersistenceXmlDefinition() { - super(); - } - - - public EFactory getResourceNodeFactory() { - return PersistenceV2_0Factory.eINSTANCE; - } - - @Override - protected PersistenceXmlContextNodeFactory buildContextNodeFactory() { - return new Generic2_0PersistenceXmlContextNodeFactory(); - } - - public JpaResourceType getResourceType() { - return JptCorePlugin.PERSISTENCE_XML_2_0_RESOURCE_TYPE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/connection/GenericConnection2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/connection/GenericConnection2_0.java deleted file mode 100644 index 48f975c8b0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/connection/GenericConnection2_0.java +++ /dev/null @@ -1,194 +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.core.internal.jpa2.context.persistence.connection; - -import java.util.Map; - -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnitProperties; -import org.eclipse.jpt.core.jpa2.context.persistence.connection.JpaConnection2_0; - -/** - * GenericConnection2_0 - */ -public class GenericConnection2_0 extends AbstractPersistenceUnitProperties - implements JpaConnection2_0 -{ - // ********** GenericConnection properties ********** - private String driver; - private String url; - private String user; - private String password; - - - // ********** constructors ********** - public GenericConnection2_0(PersistenceUnit parent) { - super(parent); - } - - // ********** initialization ********** - /** - * Initializes properties with values from the persistence unit. - */ - @Override - protected void initializeProperties() { - this.driver = - this.getStringValue(PERSISTENCE_JDBC_DRIVER); - this.url = - this.getStringValue(PERSISTENCE_JDBC_URL); - this.user = - this.getStringValue(PERSISTENCE_JDBC_USER); - this.password = - this.getStringValue(PERSISTENCE_JDBC_PASSWORD); - } - - // ********** behavior ********** - - public void propertyValueChanged(String propertyName, String newValue) { - if (propertyName.equals(PERSISTENCE_JDBC_DRIVER)) { - this.driverChanged(newValue); - } - else if (propertyName.equals(PERSISTENCE_JDBC_URL)) { - this.urlChanged(newValue); - } - else if (propertyName.equals(PERSISTENCE_JDBC_USER)) { - this.userChanged(newValue); - } - else if (propertyName.equals(PERSISTENCE_JDBC_PASSWORD)) { - this.passwordChanged(newValue); - } - } - - public void propertyRemoved(String propertyName) { - if (propertyName.equals(PERSISTENCE_JDBC_DRIVER)) { - this.driverChanged(null); - } - else if (propertyName.equals(PERSISTENCE_JDBC_URL)) { - this.urlChanged(null); - } - else if (propertyName.equals(PERSISTENCE_JDBC_USER)) { - this.userChanged(null); - } - else if (propertyName.equals(PERSISTENCE_JDBC_PASSWORD)) { - this.passwordChanged(null); - } - } - - /** - * Adds property names key/value pairs, where: - * key = PU property key - * value = property id - */ - @Override - protected void addPropertyNames(Map<String, String> propertyNames) { - propertyNames.put( - PERSISTENCE_JDBC_DRIVER, - DRIVER_PROPERTY); - propertyNames.put( - PERSISTENCE_JDBC_URL, - URL_PROPERTY); - propertyNames.put( - PERSISTENCE_JDBC_USER, - USER_PROPERTY); - propertyNames.put( - PERSISTENCE_JDBC_PASSWORD, - PASSWORD_PROPERTY); - } - - // ********** Driver ********** - public String getDriver() { - return this.driver; - } - - public void setDriver(String newDriver) { - String old = this.driver; - this.driver = newDriver; - this.putProperty(DRIVER_PROPERTY, newDriver); - this.firePropertyChanged(DRIVER_PROPERTY, old, newDriver); - } - - private void driverChanged(String newValue) { - String old = this.driver; - this.driver = newValue; - this.firePropertyChanged(DRIVER_PROPERTY, old, newValue); - } - - public String getDefaultDriver() { - return DEFAULT_JDBC_DRIVER; - } - - // ********** URL ********** - public String getUrl() { - return this.url; - } - - public void setUrl(String newUrl) { - String old = this.url; - this.url = newUrl; - this.putProperty(URL_PROPERTY, newUrl); - this.firePropertyChanged(URL_PROPERTY, old, newUrl); - } - - private void urlChanged(String newValue) { - String old = this.url; - this.url = newValue; - this.firePropertyChanged(URL_PROPERTY, old, newValue); - } - - public String getDefaultUrl() { - return DEFAULT_JDBC_URL; - } - - // ********** User ********** - public String getUser() { - return this.user; - } - - public void setUser(String newUser) { - String old = this.user; - this.user = newUser; - this.putProperty(USER_PROPERTY, newUser); - this.firePropertyChanged(USER_PROPERTY, old, newUser); - } - - private void userChanged(String newValue) { - String old = this.user; - this.user = newValue; - this.firePropertyChanged(USER_PROPERTY, old, newValue); - } - - public String getDefaultUser() { - return DEFAULT_JDBC_USER; - } - - // ********** Password ********** - public String getPassword() { - return this.password; - } - - public void setPassword(String newPassword) { - String old = this.password; - this.password = newPassword; - this.putProperty(PASSWORD_PROPERTY, newPassword); - this.firePropertyChanged(PASSWORD_PROPERTY, old, newPassword); - } - - private void passwordChanged(String newValue) { - String old = this.password; - this.password = newValue; - this.firePropertyChanged(PASSWORD_PROPERTY, old, newValue); - } - - public String getDefaultPassword() { - return DEFAULT_JDBC_PASSWORD; - } - - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/connection/NullConnection2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/connection/NullConnection2_0.java deleted file mode 100644 index 2e7130f1d7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/connection/NullConnection2_0.java +++ /dev/null @@ -1,110 +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.core.internal.jpa2.context.persistence.connection; - -import java.util.Map; -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnitProperties; -import org.eclipse.jpt.core.jpa2.context.persistence.connection.JpaConnection2_0; - -/** - * GenericConnection2_0 - */ -public class NullConnection2_0 extends AbstractPersistenceUnitProperties - implements JpaConnection2_0 -{ - - - // ********** constructors ********** - public NullConnection2_0(PersistenceUnit parent) { - super(parent); - } - - // ********** initialization ********** - /** - * Initializes properties with values from the persistence unit. - */ - @Override - protected void initializeProperties() { - //do nothing - } - - // ********** behavior ********** - - public void propertyValueChanged(String propertyName, String newValue) { - //do nothing - } - - public void propertyRemoved(String propertyName) { - //do nothing - } - - /** - * Adds property names key/value pairs, where: - * key = PU property key - * value = property id - */ - @Override - protected void addPropertyNames(Map<String, String> propertyNames) { - //do nothing - } - - // ********** Driver ********** - public String getDriver() { - return null; - } - - public void setDriver(String newDriver) { - throw new UnsupportedOperationException(); - } - - public String getDefaultDriver() { - return DEFAULT_JDBC_DRIVER; - } - - // ********** URL ********** - public String getUrl() { - return null; - } - - public void setUrl(String newUrl) { - throw new UnsupportedOperationException(); - } - - public String getDefaultUrl() { - return DEFAULT_JDBC_URL; - } - - // ********** User ********** - public String getUser() { - return null; - } - - public void setUser(String newUser) { - throw new UnsupportedOperationException(); - } - - public String getDefaultUser() { - return DEFAULT_JDBC_USER; - } - - // ********** Password ********** - public String getPassword() { - return null; - } - - public void setPassword(String newPassword) { - throw new UnsupportedOperationException(); - } - - public String getDefaultPassword() { - return DEFAULT_JDBC_PASSWORD; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/options/GenericOptions2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/options/GenericOptions2_0.java deleted file mode 100644 index 1d73540371..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/options/GenericOptions2_0.java +++ /dev/null @@ -1,337 +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.core.internal.jpa2.context.persistence.options; - -import java.util.List; -import java.util.ListIterator; -import java.util.Map; - -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnitProperties; -import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0; -import org.eclipse.jpt.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * JPA 2.0 options - */ -public class GenericOptions2_0 extends AbstractPersistenceUnitProperties - implements JpaOptions2_0 -{ - // ********** GenericConnection properties ********** - private Integer lockTimeout; - private Integer queryTimeout; - private List<String> validationGroupPrePersists; - private List<String> validationGroupPreUpdates; - private List<String> validationGroupPreRemoves; - - // ********** constructors ********** - public GenericOptions2_0(PersistenceUnit parent) { - super(parent); - } - - // ********** initialization ********** - /** - * Initializes properties with values from the persistence unit. - */ - @Override - protected void initializeProperties() { - this.lockTimeout = - this.getIntegerValue(PERSISTENCE_LOCK_TIMEOUT); - this.queryTimeout = - this.getIntegerValue(PERSISTENCE_QUERY_TIMEOUT); - - // ValidationMode is initialized with the persistence unit element - this.validationGroupPrePersists = this.getCompositeValue(PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST); - this.validationGroupPreUpdates = this.getCompositeValue(PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE); - this.validationGroupPreRemoves = this.getCompositeValue(PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE); - } - - // ********** behavior ********** - - public void propertyValueChanged(String propertyName, String newValue) { - if (propertyName.equals(PERSISTENCE_LOCK_TIMEOUT)) { - this.lockTimeoutChanged(newValue); - } - else if (propertyName.equals(PERSISTENCE_QUERY_TIMEOUT)) { - this.queryTimeoutChanged(newValue); - } - else if (propertyName.equals(PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST)) { - this.validationGroupPrePersistsChanged(); - } - else if (propertyName.equals(PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE)) { - this.validationGroupPreUpdatesChanged(); - } - else if (propertyName.equals(PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE)) { - this.validationGroupPreRemovesChanged(); - } - } - - public void propertyRemoved(String propertyName) { - if (propertyName.equals(PERSISTENCE_LOCK_TIMEOUT)) { - this.lockTimeoutChanged(null); - } - else if (propertyName.equals(PERSISTENCE_QUERY_TIMEOUT)) { - this.queryTimeoutChanged(null); - } - else if (propertyName.equals(PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST)) { - this.validationGroupPrePersistsChanged(); - } - else if (propertyName.equals(PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE)) { - this.validationGroupPreUpdatesChanged(); - } - else if (propertyName.equals(PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE)) { - this.validationGroupPreRemovesChanged(); - } - } - - /** - * Adds property names key/value pairs, where: - * key = PU property key - * value = property id - */ - @Override - protected void addPropertyNames(Map<String, String> propertyNames) { - propertyNames.put( - PERSISTENCE_LOCK_TIMEOUT, - LOCK_TIMEOUT_PROPERTY); - propertyNames.put( - PERSISTENCE_QUERY_TIMEOUT, - QUERY_TIMEOUT_PROPERTY); - propertyNames.put( - PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST, - VALIDATION_GROUP_PRE_PERSIST_PROPERTY); - propertyNames.put( - PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE, - VALIDATION_GROUP_PRE_UPDATE_PROPERTY); - propertyNames.put( - PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE, - VALIDATION_GROUP_PRE_REMOVE_PROPERTY); - } - - @Override - public PersistenceUnit2_0 getPersistenceUnit() { - return (PersistenceUnit2_0) super.getPersistenceUnit(); - } - - // ********** LockTimeout ********** - public Integer getLockTimeout() { - return this.lockTimeout; - } - - public void setLockTimeout(Integer newLockTimeout) { - Integer old = this.lockTimeout; - this.lockTimeout = newLockTimeout; - this.putProperty(LOCK_TIMEOUT_PROPERTY, newLockTimeout); - this.firePropertyChanged(LOCK_TIMEOUT_PROPERTY, old, newLockTimeout); - } - - private void lockTimeoutChanged(String stringValue) { - Integer newValue = getIntegerValueOf(stringValue); - - Integer old = this.lockTimeout; - this.lockTimeout = newValue; - this.firePropertyChanged(LOCK_TIMEOUT_PROPERTY, old, newValue); - } - - public Integer getDefaultLockTimeout() { - return DEFAULT_LOCK_TIMEOUT; - } - - // ********** QueryTimeout ********** - public Integer getQueryTimeout() { - return this.queryTimeout; - } - - public void setQueryTimeout(Integer newQueryTimeout) { - Integer old = this.queryTimeout; - this.queryTimeout = newQueryTimeout; - this.putProperty(QUERY_TIMEOUT_PROPERTY, newQueryTimeout); - this.firePropertyChanged(QUERY_TIMEOUT_PROPERTY, old, newQueryTimeout); - } - - private void queryTimeoutChanged(String stringValue) { - Integer newValue = getIntegerValueOf(stringValue); - - Integer old = this.queryTimeout; - this.queryTimeout = newValue; - this.firePropertyChanged(QUERY_TIMEOUT_PROPERTY, old, newValue); - } - - public Integer getDefaultQueryTimeout() { - return DEFAULT_QUERY_TIMEOUT; - } - - // ********** ValidationGroupPrePersists ********** - public ListIterator<String> validationGroupPrePersists(){ - return new CloneListIterator<String>(this.validationGroupPrePersists); - } - - public int validationGroupPrePersistsSize(){ - return this.validationGroupPrePersists.size(); - } - - public boolean validationGroupPrePersistExists(String validationGroupPrePersistClassName) { - for (String validationGroupPrePersist : this.validationGroupPrePersists) { - if(validationGroupPrePersist.equals(validationGroupPrePersistClassName)) { - return true; - } - } - return false; - } - - public String addValidationGroupPrePersist(String newPrePersistClassName){ - - if( ! this.validationGroupPrePersistExists(newPrePersistClassName)) { - this.validationGroupPrePersists.add(newPrePersistClassName); - this.putPropertyCompositeValue(VALIDATION_GROUP_PRE_PERSIST_PROPERTY, newPrePersistClassName); - this.fireListChanged(VALIDATION_GROUP_PRE_PERSIST_LIST, this.validationGroupPrePersists); - return newPrePersistClassName; - } - return null; - } - - public void removeValidationGroupPrePersist(String className){ - - if(this.removeValidationGroupPrePersist_(className) != null) { - this.removePropertyCompositeValue(VALIDATION_GROUP_PRE_PERSIST_PROPERTY, className); - this.fireListChanged(VALIDATION_GROUP_PRE_PERSIST_LIST, this.validationGroupPrePersists); - } - } - - private String removeValidationGroupPrePersist_(String className){ - - for ( ListIterator<String> i = this.validationGroupPrePersists(); i.hasNext();) { - String validationGroupPrePersist = i.next(); - if(validationGroupPrePersist.equals(className)) { - this.validationGroupPrePersists.remove(validationGroupPrePersist); - return validationGroupPrePersist; - } - } - return null; - } - - private void validationGroupPrePersistsChanged() { - this.validationGroupPrePersists = this.getCompositeValue(PERSISTENCE_VALIDATION_GROUP_PRE_PERSIST); - this.fireListChanged(VALIDATION_GROUP_PRE_PERSIST_LIST, this.validationGroupPrePersists); - } - - // ********** ValidationGroupPreUpdates ********** - - public ListIterator<String> validationGroupPreUpdates(){ - return new CloneListIterator<String>(this.validationGroupPreUpdates); - } - - public int validationGroupPreUpdatesSize(){ - return this.validationGroupPreUpdates.size(); - } - - public boolean validationGroupPreUpdateExists(String validationGroupPreUpdateClassName) { - - for (String validationGroupPreUpdate : this.validationGroupPreUpdates) { - if(validationGroupPreUpdate.equals(validationGroupPreUpdateClassName)) { - return true; - } - } - return false; - } - - public String addValidationGroupPreUpdate(String newPreUpdateClassName){ - - if( ! this.validationGroupPreUpdateExists(newPreUpdateClassName)) { - this.validationGroupPreUpdates.add(newPreUpdateClassName); - this.putPropertyCompositeValue(VALIDATION_GROUP_PRE_UPDATE_PROPERTY, newPreUpdateClassName); - this.fireListChanged(VALIDATION_GROUP_PRE_UPDATE_LIST, this.validationGroupPreUpdates); - return newPreUpdateClassName; - } - return null; - } - - public void removeValidationGroupPreUpdate(String className){ - - if(this.removeValidationGroupPreUpdate_(className) != null) { - this.removePropertyCompositeValue(VALIDATION_GROUP_PRE_UPDATE_PROPERTY, className); - this.fireListChanged(VALIDATION_GROUP_PRE_UPDATE_LIST, this.validationGroupPreUpdates); - } - } - - private String removeValidationGroupPreUpdate_(String className){ - - for(ListIterator<String> i = this.validationGroupPreUpdates(); i.hasNext();) { - String validationGroupPreUpdate = i.next(); - if(validationGroupPreUpdate.equals(className)) { - this.validationGroupPreUpdates.remove(validationGroupPreUpdate); - return validationGroupPreUpdate; - } - } - return null; - } - - private void validationGroupPreUpdatesChanged() { - this.validationGroupPreUpdates = this.getCompositeValue(PERSISTENCE_VALIDATION_GROUP_PRE_UPDATE); - this.fireListChanged(VALIDATION_GROUP_PRE_UPDATE_LIST, this.validationGroupPreUpdates); - } - - // ********** ValidationGroupPreRemoves ********** - - public ListIterator<String> validationGroupPreRemoves(){ - return new CloneListIterator<String>(this.validationGroupPreRemoves); - } - - public int validationGroupPreRemovesSize(){ - return this.validationGroupPreRemoves.size(); - } - - public boolean validationGroupPreRemoveExists(String validationGroupPreRemoveClassName) { - - for (String validationGroupPreRemove : this.validationGroupPreRemoves) { - if(validationGroupPreRemove.equals(validationGroupPreRemoveClassName)) { - return true; - } - } - return false; - } - - public String addValidationGroupPreRemove(String newPreRemoveClassName){ - - if( ! this.validationGroupPreRemoveExists(newPreRemoveClassName)) { - this.validationGroupPreRemoves.add(newPreRemoveClassName); - this.putPropertyCompositeValue(VALIDATION_GROUP_PRE_REMOVE_PROPERTY, newPreRemoveClassName); - this.fireListChanged(VALIDATION_GROUP_PRE_REMOVE_LIST, this.validationGroupPreRemoves); - return newPreRemoveClassName; - } - return null; - } - - public void removeValidationGroupPreRemove(String className){ - - if(this.removeValidationGroupPreRemove_(className) != null) { - this.removePropertyCompositeValue(VALIDATION_GROUP_PRE_REMOVE_PROPERTY, className); - this.fireListChanged(VALIDATION_GROUP_PRE_REMOVE_LIST, this.validationGroupPreRemoves); - } - } - - private String removeValidationGroupPreRemove_(String className){ - - for(ListIterator<String> i = this.validationGroupPreRemoves(); i.hasNext();) { - String validationGroupPreRemove = i.next(); - if(validationGroupPreRemove.equals(className)) { - this.validationGroupPreRemoves.remove(validationGroupPreRemove); - return validationGroupPreRemove; - } - } - return null; - } - - private void validationGroupPreRemovesChanged() { - this.validationGroupPreRemoves = this.getCompositeValue(PERSISTENCE_VALIDATION_GROUP_PRE_REMOVE); - this.fireListChanged(VALIDATION_GROUP_PRE_REMOVE_LIST, this.validationGroupPreRemoves); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/options/NullOptions2_0.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/options/NullOptions2_0.java deleted file mode 100644 index de1c93dd74..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/context/persistence/options/NullOptions2_0.java +++ /dev/null @@ -1,152 +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.core.internal.jpa2.context.persistence.options; - -import java.util.ListIterator; -import java.util.Map; - -import org.eclipse.jpt.core.context.persistence.PersistenceUnit; -import org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnitProperties; -import org.eclipse.jpt.core.jpa2.context.persistence.options.JpaOptions2_0; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * JPA 2.0 options - */ -public class NullOptions2_0 extends AbstractPersistenceUnitProperties - implements JpaOptions2_0 -{ - - - // ********** constructors ********** - public NullOptions2_0(PersistenceUnit parent) { - super(parent); - } - - // ********** initialization ********** - /** - * Initializes properties with values from the persistence unit. - */ - @Override - protected void initializeProperties() { - //do nothing - } - - // ********** behavior ********** - - public void propertyValueChanged(String propertyName, String newValue) { - //do nothing - } - - public void propertyRemoved(String propertyName) { - //do nothing - } - - /** - * Adds property names key/value pairs, where: - * key = PU property key - * value = property id - */ - @Override - protected void addPropertyNames(Map<String, String> propertyNames) { - //do nothing - } - - // ********** LockTimeout ********** - public Integer getLockTimeout() { - return null; - } - - public void setLockTimeout(Integer newLockTimeout) { - throw new UnsupportedOperationException(); - } - - public Integer getDefaultLockTimeout() { - return DEFAULT_LOCK_TIMEOUT; - } - - // ********** QueryTimeout ********** - public Integer getQueryTimeout() { - return null; - } - - public void setQueryTimeout(Integer newQueryTimeout) { - throw new UnsupportedOperationException(); - } - - public Integer getDefaultQueryTimeout() { - return DEFAULT_QUERY_TIMEOUT; - } - - - // ********** ValidationGroupPrePersists ********** - public ListIterator<String> validationGroupPrePersists() { - return EmptyListIterator.instance(); - } - - public int validationGroupPrePersistsSize() { - return 0; - } - - public boolean validationGroupPrePersistExists(String validationGroupPrePersistClassName) { - return false; - } - - public String addValidationGroupPrePersist(String newValidationGroupPrePersistClassName) { - throw new UnsupportedOperationException(); - } - - public void removeValidationGroupPrePersist(String validationGroupPrePersistClassName) { - throw new UnsupportedOperationException(); - } - - // ********** ValidationGroupPreUpdates ********** - public ListIterator<String> validationGroupPreUpdates() { - return EmptyListIterator.instance(); - } - - public int validationGroupPreUpdatesSize() { - return 0; - } - - public boolean validationGroupPreUpdateExists(String validationGroupPreUpdateClassName) { - return false; - } - - public String addValidationGroupPreUpdate(String newValidationGroupPreUpdateClassName) { - throw new UnsupportedOperationException(); - } - - public void removeValidationGroupPreUpdate(String validationGroupPreUpdateClassName) { - throw new UnsupportedOperationException(); - } - - // ********** ValidationGroupPreRemoves ********** - public ListIterator<String> validationGroupPreRemoves() { - return EmptyListIterator.instance(); - } - - public int validationGroupPreRemovesSize() { - return 0; - } - - public boolean validationGroupPreRemoveExists(String validationGroupPreRemoveClassName) { - return false; - } - - public String addValidationGroupPreRemove(String newValidationGroupPreRemoveClassName) { - throw new UnsupportedOperationException(); - } - - public void removeValidationGroupPreRemove(String validationGroupPreRemoveClassName) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/Access2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/Access2_0AnnotationDefinition.java deleted file mode 100644 index 882463673b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/Access2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryAccess2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceAccess2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Access - */ -public final class Access2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new Access2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private Access2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceAccess2_0Annotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullAccess2_0Annotation((JavaResourcePersistentMember) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAccess2_0Annotation((JavaResourcePersistentMember) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return Access2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/AssociationOverride2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/AssociationOverride2_0AnnotationDefinition.java deleted file mode 100644 index db340bd03f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/AssociationOverride2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryAssociationOverride2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceAssociationOverride2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverride - */ -public final class AssociationOverride2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AssociationOverride2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AssociationOverride2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceAssociationOverride2_0Annotation.buildAssociationOverride((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAssociationOverride2_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AssociationOverrideAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/AssociationOverrides2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/AssociationOverrides2_0AnnotationDefinition.java deleted file mode 100644 index 7a1b956899..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/AssociationOverrides2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryAssociationOverrides2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceAssociationOverrides2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.AssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverrides - */ -public final class AssociationOverrides2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new AssociationOverrides2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private AssociationOverrides2_0AnnotationDefinition() { - super(); - } - - public AssociationOverridesAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceAssociationOverrides2_0Annotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public AssociationOverridesAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryAssociationOverrides2_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return AssociationOverridesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/Cacheable2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/Cacheable2_0AnnotationDefinition.java deleted file mode 100644 index 449589b721..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/Cacheable2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryCacheable2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceCacheable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.Cacheable2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Cacheable - */ -public final class Cacheable2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new Cacheable2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private Cacheable2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceCacheable2_0Annotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryCacheable2_0Annotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return Cacheable2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/CollectionTable2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/CollectionTable2_0AnnotationDefinition.java deleted file mode 100644 index add7b0eb7b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/CollectionTable2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryCollectionTable2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceCollectionTable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.CollectionTable - */ -public final class CollectionTable2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new CollectionTable2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private CollectionTable2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceCollectionTable2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullCollectionTable2_0Annotation(parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryCollectionTable2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return CollectionTable2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/ElementCollection2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/ElementCollection2_0AnnotationDefinition.java deleted file mode 100644 index d2ed5be3dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/ElementCollection2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryElementCollection2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceElementCollection2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.ElementCollection - */ -public final class ElementCollection2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new ElementCollection2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private ElementCollection2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceElementCollection2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryElementCollection2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ElementCollection2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/GeneratedAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/GeneratedAnnotationDefinition.java deleted file mode 100644 index 3d8941b6bc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/GeneratedAnnotationDefinition.java +++ /dev/null @@ -1,64 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryGeneratedAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceGeneratedAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.annotation.Generated - * <p> - * This annotation definition is not really required; it's just here for a bit - * of consistency.... - */ -public final class GeneratedAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final GeneratedAnnotationDefinition INSTANCE = new GeneratedAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static GeneratedAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private GeneratedAnnotationDefinition() { - super(); - } - - public GeneratedAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceGeneratedAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public GeneratedAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return null; - } - - public GeneratedAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryGeneratedAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return GeneratedAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyClass2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyClass2_0AnnotationDefinition.java deleted file mode 100644 index 5c7042aebf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyClass2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapKeyClass2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceMapKeyClass2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKeyClass - */ -public final class MapKeyClass2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyClass2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyClass2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapKeyClass2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyClass2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyClass2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyColumn2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyColumn2_0AnnotationDefinition.java deleted file mode 100644 index 1ef128e751..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyColumn2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceMapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKeyColumn - */ -public final class MapKeyColumn2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyColumn2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyColumn2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapKeyColumn2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullMapKeyColumnAnnotation(parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyColumn2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyColumn2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyEnumerated2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyEnumerated2_0AnnotationDefinition.java deleted file mode 100644 index 602e923870..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyEnumerated2_0AnnotationDefinition.java +++ /dev/null @@ -1,61 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapKeyEnumerated2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceMapKeyEnumerated2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyEnumerated2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKeyTemporal - */ -public final class MapKeyEnumerated2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyEnumerated2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyEnumerated2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapKeyEnumerated2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullMapKeyEnumerated2_0Annotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyEnumerated2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyEnumerated2_0Annotation.ANNOTATION_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyJoinColumn2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyJoinColumn2_0AnnotationDefinition.java deleted file mode 100644 index a63a6fde6a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyJoinColumn2_0AnnotationDefinition.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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapKeyJoinColumn2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyJoinColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKeyJoinColumn - */ -public final class MapKeyJoinColumn2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyJoinColumn2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyJoinColumn2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return SourceMapKeyJoinColumn2_0Annotation.createMapKeyJoinColumn(parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyJoinColumn2_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyJoinColumn2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyJoinColumns2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyJoinColumns2_0AnnotationDefinition.java deleted file mode 100644 index 2369738b96..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyJoinColumns2_0AnnotationDefinition.java +++ /dev/null @@ -1,61 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapKeyJoinColumns2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyJoinColumns2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKeyJoinColumns - */ -public final class MapKeyJoinColumns2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyJoinColumns2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyJoinColumns2_0AnnotationDefinition() { - super(); - } - - public MapKeyJoinColumns2_0Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapKeyJoinColumns2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public MapKeyJoinColumns2_0Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyJoinColumns2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyJoinColumns2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyTemporal2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyTemporal2_0AnnotationDefinition.java deleted file mode 100644 index dc20f1b06b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapKeyTemporal2_0AnnotationDefinition.java +++ /dev/null @@ -1,61 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapKeyTemporal2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceMapKeyTemporal2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyTemporal2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapKeyTemporal - */ -public final class MapKeyTemporal2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapKeyTemporal2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private MapKeyTemporal2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapKeyTemporal2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullMapKeyTemporal2_0Annotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapKeyTemporal2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyTemporal2_0Annotation.ANNOTATION_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapsId2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapsId2_0AnnotationDefinition.java deleted file mode 100644 index c95e94cb49..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/MapsId2_0AnnotationDefinition.java +++ /dev/null @@ -1,65 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryMapsId2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceMapsId2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapsId2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.MapsId - */ -public class MapsId2_0AnnotationDefinition implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new MapsId2_0AnnotationDefinition(); - - - /** - * Return the singleton - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - - /** - * Enforce singleton usage - */ - private MapsId2_0AnnotationDefinition() { - super(); - } - - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceMapsId2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullMapsId2_0Annotation((JavaResourcePersistentMember) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryMapsId2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapsId2_0Annotation.ANNOTATION_NAME; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java deleted file mode 100644 index fe9fe210fc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQueries2_0AnnotationDefinition.java +++ /dev/null @@ -1,61 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryNamedQueries2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceNamedQueries2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.NamedQueriesAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQueries - */ -public class NamedQueries2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedQueries2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedQueries2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceNamedQueries2_0Annotation(parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryNamedQueries2_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedQueriesAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java deleted file mode 100644 index d5eee3db23..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NamedQuery2_0AnnotationDefinition.java +++ /dev/null @@ -1,61 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryNamedQuery2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceNamedQuery2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQuery - */ -public class NamedQuery2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new NamedQuery2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private NamedQuery2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceNamedQuery2_0Annotation(parent, (Type) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryNamedQuery2_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return NamedQueryAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullAccess2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullAccess2_0Annotation.java deleted file mode 100644 index d3990a5aaf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullAccess2_0Annotation.java +++ /dev/null @@ -1,55 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Access - */ -public class NullAccess2_0Annotation - extends NullAnnotation - implements Access2_0Annotation -{ - - protected NullAccess2_0Annotation(JavaResourcePersistentMember parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected Access2_0Annotation addAnnotation() { - return (Access2_0Annotation) super.addAnnotation(); - } - - // ***** value - public AccessType getValue() { - return null; - } - - public void setValue(AccessType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullAssociationOverrideJoinTableAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullAssociationOverrideJoinTableAnnotation.java deleted file mode 100644 index 142f918b92..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullAssociationOverrideJoinTableAnnotation.java +++ /dev/null @@ -1,35 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jpt.core.internal.resource.java.NullJoinTableAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; - -/** - * javax.persistence.JoinTable found in a javax.persistence.AssociationOverride annotation - */ -public class NullAssociationOverrideJoinTableAnnotation - extends NullJoinTableAnnotation -{ - public NullAssociationOverrideJoinTableAnnotation(AssociationOverride2_0Annotation parent) { - super(parent); - } - - private AssociationOverride2_0Annotation getAssociationOverride2_0Annotation() { - return (AssociationOverride2_0Annotation) this.parent; - } - - @Override - protected JoinTableAnnotation addAnnotation() { - return this.getAssociationOverride2_0Annotation().addJoinTable(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullCollectionTable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullCollectionTable2_0Annotation.java deleted file mode 100644 index 6574d3f5d1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullCollectionTable2_0Annotation.java +++ /dev/null @@ -1,70 +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.core.internal.jpa2.resource.java; - -import java.util.ListIterator; - -import org.eclipse.jpt.core.internal.resource.java.NullBaseTableAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -/** - * javax.persistence.CollectionTable - */ -public class NullCollectionTable2_0Annotation - extends NullBaseTableAnnotation - implements CollectionTable2_0Annotation -{ - public NullCollectionTable2_0Annotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected CollectionTable2_0Annotation addAnnotation() { - return (CollectionTable2_0Annotation) super.addAnnotation(); - } - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return EmptyListIterator.instance(); - } - - public int joinColumnsSize() { - return 0; - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return null; - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - throw new UnsupportedOperationException(); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - // the CollectionTable annotation is missing, add both it and a join column at the same time - return this.addAnnotation().addJoinColumn(index); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyColumnAnnotation.java deleted file mode 100644 index cae6ddbfed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyColumnAnnotation.java +++ /dev/null @@ -1,82 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullBaseColumnAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapKeyColumn - */ -public class NullMapKeyColumnAnnotation - extends NullBaseColumnAnnotation - implements MapKeyColumn2_0Annotation -{ - public NullMapKeyColumnAnnotation(JavaResourceNode parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected MapKeyColumn2_0Annotation addAnnotation() { - return (MapKeyColumn2_0Annotation) super.addAnnotation(); - } - - // ***** length - public Integer getLength() { - return null; - } - - public void setLength(Integer length) { - if (length != null) { - this.addAnnotation().setLength(length); - } - } - - public TextRange getLengthTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** scale - public Integer getScale() { - return null; - } - - public void setScale(Integer scale) { - if (scale != null) { - this.addAnnotation().setScale(scale); - } - } - - public TextRange getScaleTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** precision - public Integer getPrecision() { - return null; - } - - public void setPrecision(Integer precision) { - if (precision != null) { - this.addAnnotation().setPrecision(precision); - } - } - - public TextRange getPrecisionTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyEnumerated2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyEnumerated2_0Annotation.java deleted file mode 100644 index 922c7c9efa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyEnumerated2_0Annotation.java +++ /dev/null @@ -1,57 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyEnumerated2_0Annotation; -import org.eclipse.jpt.core.resource.java.EnumType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapKeyEnumerated - */ -public final class NullMapKeyEnumerated2_0Annotation - extends NullAnnotation - implements MapKeyEnumerated2_0Annotation -{ - protected NullMapKeyEnumerated2_0Annotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected MapKeyEnumerated2_0Annotation addAnnotation() { - return (MapKeyEnumerated2_0Annotation) super.addAnnotation(); - } - - - // ********** MapKeyEnumerated2_0Annotation implementation ********** - - // ***** value - public EnumType getValue() { - return null; - } - - public void setValue(EnumType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyTemporal2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyTemporal2_0Annotation.java deleted file mode 100644 index 0d9142feb8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapKeyTemporal2_0Annotation.java +++ /dev/null @@ -1,57 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyTemporal2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.TemporalType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapKeyTemporal - */ -public final class NullMapKeyTemporal2_0Annotation - extends NullAnnotation - implements MapKeyTemporal2_0Annotation -{ - protected NullMapKeyTemporal2_0Annotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected MapKeyTemporal2_0Annotation addAnnotation() { - return (MapKeyTemporal2_0Annotation) super.addAnnotation(); - } - - - // ********** MapKeyTemporal2_0Annotation implementation ********** - - // ***** value - public TemporalType getValue() { - return null; - } - - public void setValue(TemporalType value) { - if (value != null) { - this.addAnnotation().setValue(value); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapsId2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapsId2_0Annotation.java deleted file mode 100644 index 823e0a4577..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullMapsId2_0Annotation.java +++ /dev/null @@ -1,57 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapsId2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapsId - */ -public class NullMapsId2_0Annotation - extends NullAnnotation - implements MapsId2_0Annotation -{ - protected NullMapsId2_0Annotation(JavaResourcePersistentMember parent) { - super(parent); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected MapsId2_0Annotation addAnnotation() { - return (MapsId2_0Annotation) super.addAnnotation(); - } - - public String getValue() { - return null; - } - - public void setValue(String newValue) { - if (newValue != null) { - this.addAnnotation().setValue(newValue); - } - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return null; - } - - public boolean valueTouches(int pos, CompilationUnit astRoot) { - return false; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullOrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullOrderColumn2_0Annotation.java deleted file mode 100644 index c97eaba31b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/NullOrderColumn2_0Annotation.java +++ /dev/null @@ -1,82 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.NullNamedColumnAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OrderColumn - */ -public final class NullOrderColumn2_0Annotation - extends NullNamedColumnAnnotation - implements OrderColumn2_0Annotation -{ - public NullOrderColumn2_0Annotation(JavaResourcePersistentAttribute parent) { - super(parent); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected OrderColumn2_0Annotation addAnnotation() { - return (OrderColumn2_0Annotation) super.addAnnotation(); - } - - // ***** updatable - public Boolean getUpdatable() { - return null; - } - - public void setUpdatable(Boolean updatable) { - if (updatable != null) { - this.addAnnotation().setUpdatable(updatable); - } - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** insertable - public Boolean getInsertable() { - return null; - } - - public void setInsertable(Boolean insertable) { - if (insertable != null) { - this.addAnnotation().setInsertable(insertable); - } - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return null; - } - - // ***** nullable - public Boolean getNullable() { - return null; - } - - public void setNullable(Boolean nullable) { - if (nullable != null) { - this.addAnnotation().setNullable(nullable); - } - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return null; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java deleted file mode 100644 index beb31d43e3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/OrderColumn2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryOrderColumn2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceOrderColumn2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Attribute; - -/** - * javax.persistence.OrderColumn - */ -public final class OrderColumn2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new OrderColumn2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private OrderColumn2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceOrderColumn2_0Annotation((JavaResourcePersistentAttribute) parent, (Attribute) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return new NullOrderColumn2_0Annotation((JavaResourcePersistentAttribute) parent); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryOrderColumn2_0Annotation((JavaResourcePersistentAttribute) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return OrderColumn2_0Annotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SequenceGenerator2_0AnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SequenceGenerator2_0AnnotationDefinition.java deleted file mode 100644 index b93573029c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SequenceGenerator2_0AnnotationDefinition.java +++ /dev/null @@ -1,62 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinarySequenceGenerator2_0Annotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceSequenceGenerator2_0Annotation; -import org.eclipse.jpt.core.resource.java.Annotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.SequenceGenerator - */ -public final class SequenceGenerator2_0AnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final AnnotationDefinition INSTANCE = new SequenceGenerator2_0AnnotationDefinition(); - - /** - * Return the singleton. - */ - public static AnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private SequenceGenerator2_0AnnotationDefinition() { - super(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceSequenceGenerator2_0Annotation((JavaResourcePersistentMember) parent, (Member) annotatedElement); - } - - public Annotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - throw new UnsupportedOperationException(); - } - - public Annotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinarySequenceGenerator2_0Annotation(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return SequenceGeneratorAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumn2_0Annotation.java deleted file mode 100644 index 1dea4addd4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumn2_0Annotation.java +++ /dev/null @@ -1,116 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jpt.core.internal.resource.java.source.SourceBaseJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.NestableMapKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; - -/** - * javax.persistence.MapKeyJoinColumn - */ -public final class SourceMapKeyJoinColumn2_0Annotation - extends SourceBaseJoinColumnAnnotation - implements NestableMapKeyJoinColumnAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - - public SourceMapKeyJoinColumn2_0Annotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, attribute, daa, annotationAdapter); - } - - public SourceMapKeyJoinColumn2_0Annotation(JavaResourceNode parent, Attribute attribute, DeclarationAnnotationAdapter daa) { - this(parent, attribute, daa, new ElementAnnotationAdapter(attribute, daa)); - } - - public SourceMapKeyJoinColumn2_0Annotation(JavaResourceNode parent, Attribute attribute, IndexedDeclarationAnnotationAdapter idaa) { - this(parent, attribute, idaa, new ElementIndexedAnnotationAdapter(attribute, idaa)); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - // ********** SourceNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** SourceBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__UPDATABLE; - } - - - // ********** SourceBaseJoinColumnAnnotation implementation ********** - - @Override - protected String getReferencedColumnNameElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME; - } - - - // ********** static methods ********** - - public static SourceMapKeyJoinColumn2_0Annotation createMapKeyJoinColumn(JavaResourceNode parent, Attribute attribute) { - return new SourceMapKeyJoinColumn2_0Annotation(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - static SourceMapKeyJoinColumn2_0Annotation createNestedMapKeyJoinColumn(JavaResourceNode parent, Attribute attribute, int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, joinColumnsAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(attribute, idaa); - return new SourceMapKeyJoinColumn2_0Annotation(parent, attribute, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter joinColumnsAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(joinColumnsAdapter, index, JPA2_0.MAP_KEY_JOIN_COLUMN); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java deleted file mode 100644 index 8969766c8d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/SourceMapKeyJoinColumns2_0Annotation.java +++ /dev/null @@ -1,114 +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.core.internal.jpa2.resource.java; - -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyJoinColumn2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyJoinColumns2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.NestableMapKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.MapKeyJoinColumns - */ -public final class SourceMapKeyJoinColumns2_0Annotation - extends SourceAnnotation<Attribute> - implements MapKeyJoinColumns2_0Annotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final Vector<NestableMapKeyJoinColumnAnnotation> mapKeyJoinColumns = new Vector<NestableMapKeyJoinColumnAnnotation>(); - - - public SourceMapKeyJoinColumns2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - AnnotationContainerTools.initialize(this, astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - AnnotationContainerTools.synchronize(this, astRoot); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.mapKeyJoinColumns); - } - - - // ********** AnnotationContainer implementation ********** - - public String getElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMNS__VALUE; - } - - public String getNestedAnnotationName() { - return MapKeyJoinColumn2_0Annotation.ANNOTATION_NAME; - } - - public Iterable<NestableMapKeyJoinColumnAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableMapKeyJoinColumnAnnotation>(this.mapKeyJoinColumns); - } - - public int getNestedAnnotationsSize() { - return this.mapKeyJoinColumns.size(); - } - - public NestableMapKeyJoinColumnAnnotation addNestedAnnotation() { - return this.addNestedAnnotation(this.mapKeyJoinColumns.size()); - } - - private NestableMapKeyJoinColumnAnnotation addNestedAnnotation(int index) { - NestableMapKeyJoinColumnAnnotation joinColumn = this.buildMapKeyJoinColumn(index); - this.mapKeyJoinColumns.add(joinColumn); - return joinColumn; - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - int index = this.mapKeyJoinColumns.size(); - NestableMapKeyJoinColumnAnnotation joinColumn = this.addNestedAnnotation(index); - joinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(MAP_KEY_JOIN_COLUMNS_LIST, index, joinColumn); - } - - private NestableMapKeyJoinColumnAnnotation buildMapKeyJoinColumn(int index) { - return SourceMapKeyJoinColumn2_0Annotation.createNestedMapKeyJoinColumn(this, this.annotatedElement, index, this.daa); - } - - public NestableMapKeyJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.mapKeyJoinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public NestableMapKeyJoinColumnAnnotation removeNestedAnnotation(int index) { - return this.mapKeyJoinColumns.remove(index); - } - - public void syncRemoveNestedAnnotations(int index) { - this.removeItemsFromList(index, this.mapKeyJoinColumns, MAP_KEY_JOIN_COLUMNS_LIST); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/StaticMetamodelAnnotationDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/StaticMetamodelAnnotationDefinition.java deleted file mode 100644 index 676036658f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/StaticMetamodelAnnotationDefinition.java +++ /dev/null @@ -1,64 +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.core.internal.jpa2.resource.java; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.binary.BinaryStaticMetamodelAnnotation; -import org.eclipse.jpt.core.internal.jpa2.resource.java.source.SourceStaticMetamodelAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.StaticMetamodelAnnotation; -import org.eclipse.jpt.core.resource.java.AnnotationDefinition; -import org.eclipse.jpt.core.resource.java.JavaResourceAnnotatedElement; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotatedElement; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.metamodel.StaticMetamodel - * <p> - * This annotation definition is not really required; it's just here for a bit - * of consistency.... - */ -public final class StaticMetamodelAnnotationDefinition - implements AnnotationDefinition -{ - // singleton - private static final StaticMetamodelAnnotationDefinition INSTANCE = new StaticMetamodelAnnotationDefinition(); - - /** - * Return the singleton. - */ - public static StaticMetamodelAnnotationDefinition instance() { - return INSTANCE; - } - - /** - * Ensure single instance. - */ - private StaticMetamodelAnnotationDefinition() { - super(); - } - - public StaticMetamodelAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, AnnotatedElement annotatedElement) { - return new SourceStaticMetamodelAnnotation((JavaResourcePersistentType) parent, (Type) annotatedElement); - } - - public StaticMetamodelAnnotation buildNullAnnotation(JavaResourceAnnotatedElement parent) { - return null; - } - - public StaticMetamodelAnnotation buildAnnotation(JavaResourceAnnotatedElement parent, IAnnotation jdtAnnotation) { - return new BinaryStaticMetamodelAnnotation((JavaResourcePersistentType) parent, jdtAnnotation); - } - - public String getAnnotationName() { - return StaticMetamodelAnnotation.ANNOTATION_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAccess2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAccess2_0Annotation.java deleted file mode 100644 index c4fc19b2bd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAccess2_0Annotation.java +++ /dev/null @@ -1,77 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Access - */ -public final class BinaryAccess2_0Annotation - extends BinaryAnnotation - implements Access2_0Annotation -{ - private AccessType value; - - - public BinaryAccess2_0Annotation(JavaResourcePersistentMember parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** AccessAnnotation implementation ********** - - // ***** value - public AccessType getValue() { - return this.value; - } - - public void setValue(AccessType value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(AccessType value) { - AccessType old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private AccessType buildValue() { - return AccessType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA2_0.ACCESS)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAssociationOverride2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAssociationOverride2_0Annotation.java deleted file mode 100644 index 27c9fba3da..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAssociationOverride2_0Annotation.java +++ /dev/null @@ -1,89 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.NullJoinTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAssociationOverrideAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryJoinTableAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; - -/** - * BinarySequenceGenerator2_0Annotation - */ -public final class BinaryAssociationOverride2_0Annotation - extends BinaryAssociationOverrideAnnotation - implements AssociationOverride2_0Annotation -{ - private JoinTableAnnotation joinTable; - - public BinaryAssociationOverride2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinTable = this.buildJoinTable(); - } - - @Override - public void update() { - super.update(); - this.updateJoinTable(); - } - - - // ********** AssociationOverride2_0Annotation implementation ********** - - // ***** joinTable - public JoinTableAnnotation getJoinTable() { - return this.joinTable; - } - - public JoinTableAnnotation getNonNullJoinTable() { - return (this.joinTable != null) ? this.joinTable : new NullJoinTableAnnotation(this); - } - - public JoinTableAnnotation addJoinTable() { - throw new UnsupportedOperationException(); - } - - public void removeJoinTable() { - throw new UnsupportedOperationException(); - } - - private JoinTableAnnotation buildJoinTable() { - IAnnotation jdtJoinTable = this.getJdtJoinTable(); - return (jdtJoinTable == null) ? null : this.buildJoinTable(jdtJoinTable); - } - - private JoinTableAnnotation buildJoinTable(IAnnotation jdtJoinTable) { - return new BinaryJoinTableAnnotation(this, jdtJoinTable); - } - - private IAnnotation getJdtJoinTable() { - return (IAnnotation) this.getJdtMemberValue(JPA2_0.ASSOCIATION_OVERRIDE__JOIN_TABLE); - } - - // TODO - private void updateJoinTable() { - throw new UnsupportedOperationException(); -// IAnnotation jdtJoinTable = this.getJdtJoinTable(); -// if (jdtJoinTable == null) { -// this.setJoinTable(null); -// } else { -// if (this.column == null) { -// this.setJoinTable(this.buildJoinTable(jdtJoinTable)); -// } else { -// this.column.update(jdtJoinTable); -// } -// } - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAssociationOverrides2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAssociationOverrides2_0Annotation.java deleted file mode 100644 index d47f13bc82..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryAssociationOverrides2_0Annotation.java +++ /dev/null @@ -1,33 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; - -/** - * javax.persistence.AssociationOverrides - */ -public class BinaryAssociationOverrides2_0Annotation - extends BinaryAssociationOverridesAnnotation -{ - - public BinaryAssociationOverrides2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - @Override - protected NestableAssociationOverrideAnnotation buildAssociationOverride(Object jdtAssociationOverride) { - return new BinaryAssociationOverride2_0Annotation(this, (IAnnotation) jdtAssociationOverride); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryCacheable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryCacheable2_0Annotation.java deleted file mode 100644 index 1a737311cc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryCacheable2_0Annotation.java +++ /dev/null @@ -1,70 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.Cacheable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.Cacheable - */ -public final class BinaryCacheable2_0Annotation - extends BinaryAnnotation - implements Cacheable2_0Annotation -{ - private Boolean value; - - - public BinaryCacheable2_0Annotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** Cacheable2_0Annotation implementation ********** - - // ***** value - public Boolean getValue() { - return this.value; - } - - public void setValue(Boolean value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(Boolean value) { - Boolean old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - } - - private Boolean buildValue() { - return (Boolean) this.getJdtMemberValue(JPA2_0.CACHEABLE__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryCollectionTable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryCollectionTable2_0Annotation.java deleted file mode 100644 index 1465decdd4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryCollectionTable2_0Annotation.java +++ /dev/null @@ -1,118 +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.core.internal.jpa2.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryBaseTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryJoinColumnAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.CollectionTable - */ -public final class BinaryCollectionTable2_0Annotation - extends BinaryBaseTableAnnotation - implements CollectionTable2_0Annotation -{ - private final Vector<JoinColumnAnnotation> joinColumns; - - - public BinaryCollectionTable2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.joinColumns = this.buildJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateJoinColumns(); - } - - - // ********** BinaryBaseTableAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA2_0.COLLECTION_TABLE__NAME; - } - - @Override - protected String getSchemaElementName() { - return JPA2_0.COLLECTION_TABLE__SCHEMA; - } - - @Override - protected String getCatalogElementName() { - return JPA2_0.COLLECTION_TABLE__CATALOG; - } - - @Override - protected String getUniqueConstraintElementName() { - return JPA2_0.COLLECTION_TABLE__UNIQUE_CONSTRAINTS; - } - - - // ********** CollectionTable2_0Annotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public JoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public JoinColumnAnnotation addJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeJoinColumn(int index) { - throw new UnsupportedOperationException(); - } - - private Vector<JoinColumnAnnotation> buildJoinColumns() { - Object[] jdtJoinColumns = this.getJdtMemberValues(JPA2_0.COLLECTION_TABLE__JOIN_COLUMNS); - Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(jdtJoinColumns.length); - for (Object jdtJoinColumn : jdtJoinColumns) { - result.add(new BinaryJoinColumnAnnotation(this, (IAnnotation) jdtJoinColumn)); - } - return result; - } - - // TODO - private void updateJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryElementCollection2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryElementCollection2_0Annotation.java deleted file mode 100644 index 12d2654def..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryElementCollection2_0Annotation.java +++ /dev/null @@ -1,103 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * org.eclipse.persistence.annotations.Transformation - */ -public class BinaryElementCollection2_0Annotation - extends BinaryAnnotation - implements ElementCollection2_0Annotation -{ - private String targetClass; - private FetchType fetch; - - - public BinaryElementCollection2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.targetClass = this.buildTargetClass(); - this.fetch = this.buildFetch(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setTargetClass_(this.buildTargetClass()); - this.setFetch_(this.buildFetch()); - } - - - // ********** ElementCollection2_0Annotation implementation ********** - - // ***** target entity - public String getTargetClass() { - return this.targetClass; - } - - public void setTargetClass(String targetClass) { - throw new UnsupportedOperationException(); - } - - private void setTargetClass_(String targetClass) { - String old = this.targetClass; - this.targetClass = targetClass; - this.firePropertyChanged(TARGET_CLASS_PROPERTY, old, targetClass); - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_CLASS_NAME_PROPERTY, old, targetClass); - } - - private String buildTargetClass() { - return (String) this.getJdtMemberValue(JPA2_0.ELEMENT_COLLECTION__TARGET_CLASS); - } - - public TextRange getTargetClassTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified target entity class name - public String getFullyQualifiedTargetClassName() { - return this.targetClass; - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - throw new UnsupportedOperationException(); - } - - private void setFetch_(FetchType fetch) { - FetchType old = this.fetch; - this.fetch = fetch; - this.firePropertyChanged(FETCH_PROPERTY, old, fetch); - } - - private FetchType buildFetch() { - return FetchType.fromJavaAnnotationValue(this.getJdtMemberValue(JPA2_0.ELEMENT_COLLECTION__FETCH)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java deleted file mode 100644 index e9f51b48b7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryGeneratedAnnotation.java +++ /dev/null @@ -1,140 +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.core.internal.jpa2.resource.java.binary; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.annotation.Generated - */ -public final class BinaryGeneratedAnnotation - extends BinaryAnnotation - implements GeneratedAnnotation -{ - private final Vector<String> values; - private String date; - private String comments; - - - public BinaryGeneratedAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.values = this.buildValues(); - this.date = this.buildDate(); - this.comments = this.buildComments(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.updateValues(); - this.setDate_(this.buildDate()); - this.setComments_(this.buildComments()); - } - - // TODO - private void updateValues() { - throw new UnsupportedOperationException(); - } - - - // ********** GeneratedAnnotation implementation ********** - - // ***** values - public ListIterator<String> values() { - return new CloneListIterator<String>(this.values); - } - - public int valuesSize() { - return this.values.size(); - } - - public String getValue(int index) { - return this.values.get(index); - } - - private Vector<String> buildValues() { - Object[] jdtValues = this.getJdtMemberValues(VALUE_ELEMENT_NAME); - Vector<String> result = new Vector<String>(jdtValues.length); - for (Object value : jdtValues) { - result.add((String) value); - } - return result; - } - - public void addValue(String value) { - throw new UnsupportedOperationException(); - } - - public void addValue(int index, String value) { - throw new UnsupportedOperationException(); - } - - public void moveValue(int targetIndex, int sourceIndex) { - throw new UnsupportedOperationException(); - } - - public void removeValue(String value) { - throw new UnsupportedOperationException(); - } - - public void removeValue(int index) { - throw new UnsupportedOperationException(); - } - - // ***** date - public String getDate() { - return this.date; - } - - public void setDate(String date) { - throw new UnsupportedOperationException(); - } - - private void setDate_(String date) { - String old = this.date; - this.date = date; - this.firePropertyChanged(DATE_PROPERTY, old, date); - } - - private String buildDate() { - return (String) this.getJdtMemberValue(DATE_ELEMENT_NAME); - } - - // ***** comments - public String getComments() { - return this.comments; - } - - public void setComments(String comments) { - throw new UnsupportedOperationException(); - } - - private void setComments_(String comments) { - String old = this.comments; - this.comments = comments; - this.firePropertyChanged(COMMENTS_PROPERTY, old, comments); - } - - private String buildComments() { - return (String) this.getJdtMemberValue(COMMENTS_ELEMENT_NAME); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyClass2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyClass2_0Annotation.java deleted file mode 100644 index b1072c0d6c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyClass2_0Annotation.java +++ /dev/null @@ -1,80 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapKeyClass - */ -public final class BinaryMapKeyClass2_0Annotation - extends BinaryAnnotation - implements MapKeyClass2_0Annotation -{ - private String value; - - - public BinaryMapKeyClass2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** MapKeyClass2_0Annotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA2_0.MAP_KEY_CLASS__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** fully-qualified class name - /** - * binary is already fully-qualified - */ - public String getFullyQualifiedClassName() { - return this.value; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyColumn2_0Annotation.java deleted file mode 100644 index 37f9db5d65..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyColumn2_0Annotation.java +++ /dev/null @@ -1,93 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryCompleteColumnAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.MapKeyColumn - */ -public final class BinaryMapKeyColumn2_0Annotation - extends BinaryCompleteColumnAnnotation - implements MapKeyColumn2_0Annotation -{ - - public BinaryMapKeyColumn2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - @Override - public String getAnnotationName() { - return MapKeyColumn2_0Annotation.ANNOTATION_NAME; - } - - - // ********** BinaryNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA2_0.MAP_KEY_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA2_0.MAP_KEY_COLUMN__COLUMN_DEFINITION; - } - - - // ********** BinaryBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA2_0.MAP_KEY_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA2_0.MAP_KEY_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA2_0.MAP_KEY_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA2_0.MAP_KEY_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA2_0.MAP_KEY_COLUMN__UPDATABLE; - } - - - // ********** BinaryCompleteColumnAnnotation implementation ********** - - @Override - protected String getLengthElementName() { - return JPA2_0.MAP_KEY_COLUMN__LENGTH; - } - - @Override - protected String getPrecisionElementName() { - return JPA2_0.MAP_KEY_COLUMN__PRECISION; - } - - @Override - protected String getScaleElementName() { - return JPA2_0.MAP_KEY_COLUMN__SCALE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyEnumerated2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyEnumerated2_0Annotation.java deleted file mode 100644 index 34b8d1dfb6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyEnumerated2_0Annotation.java +++ /dev/null @@ -1,38 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryBaseEnumeratedAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyEnumerated2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.MapKeyEnumerated - */ -public final class BinaryMapKeyEnumerated2_0Annotation - extends BinaryBaseEnumeratedAnnotation - implements MapKeyEnumerated2_0Annotation -{ - - public BinaryMapKeyEnumerated2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyEnumerated2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA2_0.MAP_KEY_ENUMERATED__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyJoinColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyJoinColumn2_0Annotation.java deleted file mode 100644 index a08c62aeb3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyJoinColumn2_0Annotation.java +++ /dev/null @@ -1,83 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryBaseJoinColumnAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.NestableMapKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; - -/** - * javax.persistence.MapKeyJoinColumn - */ -public final class BinaryMapKeyJoinColumn2_0Annotation - extends BinaryBaseJoinColumnAnnotation - implements NestableMapKeyJoinColumnAnnotation -{ - - public BinaryMapKeyJoinColumn2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - // ********** BinaryNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__COLUMN_DEFINITION; - } - - - // ********** BinaryBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__UPDATABLE; - } - - - // ********** BinaryBaseJoinColumnAnnotation implementation ********** - - @Override - protected String getReferencedColumnNameElementName() { - return JPA2_0.MAP_KEY_JOIN_COLUMN__REFERENCED_COLUMN_NAME; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyJoinColumns2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyJoinColumns2_0Annotation.java deleted file mode 100644 index 0f9bf96948..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyJoinColumns2_0Annotation.java +++ /dev/null @@ -1,69 +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.core.internal.jpa2.resource.java.binary; - -import java.util.Vector; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryContainerAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyJoinColumns2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.NestableMapKeyJoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; - -/** - * javax.persistence.MapKeyJoinColumns - */ -public final class BinaryMapKeyJoinColumns2_0Annotation - extends BinaryContainerAnnotation<NestableMapKeyJoinColumnAnnotation> - implements MapKeyJoinColumns2_0Annotation -{ - private final Vector<NestableMapKeyJoinColumnAnnotation> mapKeyJoinColumns; - - - public BinaryMapKeyJoinColumns2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.mapKeyJoinColumns = this.buildMapKeyJoinColumns(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public Iterable<NestableMapKeyJoinColumnAnnotation> getNestedAnnotations() { - return new LiveCloneIterable<NestableMapKeyJoinColumnAnnotation>(this.mapKeyJoinColumns); - } - - public int getNestedAnnotationsSize() { - return this.mapKeyJoinColumns.size(); - } - - private Vector<NestableMapKeyJoinColumnAnnotation> buildMapKeyJoinColumns() { - Object[] jdtMapKeyJoinColumns = this.getJdtMemberValues(JPA2_0.MAP_KEY_JOIN_COLUMNS__VALUE); - Vector<NestableMapKeyJoinColumnAnnotation> result = new Vector<NestableMapKeyJoinColumnAnnotation>(jdtMapKeyJoinColumns.length); - for (Object jdtMapKeyJoinColumn : jdtMapKeyJoinColumns) { - result.add(new BinaryMapKeyJoinColumn2_0Annotation(this, (IAnnotation) jdtMapKeyJoinColumn)); - } - return result; - } - - @Override - public void update() { - super.update(); - this.updateMapKeyJoinColumns(); - } - - // TODO - private void updateMapKeyJoinColumns() { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyTemporal2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyTemporal2_0Annotation.java deleted file mode 100644 index 051d689227..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapKeyTemporal2_0Annotation.java +++ /dev/null @@ -1,38 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryBaseTemporalAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyTemporal2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; - -/** - * javax.persistence.MapKeyTemporal - */ -public final class BinaryMapKeyTemporal2_0Annotation - extends BinaryBaseTemporalAnnotation - implements MapKeyTemporal2_0Annotation -{ - - public BinaryMapKeyTemporal2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - public String getAnnotationName() { - return MapKeyTemporal2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA2_0.MAP_KEY_TEMPORAL__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapsId2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapsId2_0Annotation.java deleted file mode 100644 index c6176cbc10..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryMapsId2_0Annotation.java +++ /dev/null @@ -1,80 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapsId2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.MapsId - */ -public class BinaryMapsId2_0Annotation - extends BinaryAnnotation - implements MapsId2_0Annotation -{ - private String value; - - - public BinaryMapsId2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** MapsId2_0Annotation implementation ********** - - public String getValue() { - return this.value; - } - - public void setValue(String newValue) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String newValue) { - String oldValue = this.value; - this.value = newValue; - this.firePropertyChanged(VALUE_PROPERTY, oldValue, newValue); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA2_0.MAPS_ID__VALUE); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean valueTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java deleted file mode 100644 index 23c5499dff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQueries2_0Annotation.java +++ /dev/null @@ -1,32 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NamedQueryAnnotation; - -/** - * javax.persistence.NamedQueries - */ -public final class BinaryNamedQueries2_0Annotation - extends BinaryNamedQueriesAnnotation -{ - public BinaryNamedQueries2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - } - - @Override - protected NamedQueryAnnotation buildNamedQuery(Object jdtQuery) { - return new BinaryNamedQuery2_0Annotation(this, (IAnnotation) jdtQuery); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java deleted file mode 100644 index c42b1289dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryNamedQuery2_0Annotation.java +++ /dev/null @@ -1,69 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedQueryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0; -import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * BinaryNamedQuery2_0Annotation - */ -public final class BinaryNamedQuery2_0Annotation - extends BinaryNamedQueryAnnotation - implements NamedQuery2_0Annotation -{ - private LockModeType_2_0 lockMode; - - public BinaryNamedQuery2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.lockMode = this.buildLockMode(); - } - - @Override - public void update() { - super.update(); - this.setLockMode_(this.buildLockMode()); - } - - // ********** NamedQuery2_0Annotation implementation ********** - - public LockModeType_2_0 getLockMode() { - return this.lockMode; - } - - public void setLockMode(LockModeType_2_0 lockMode) { - throw new UnsupportedOperationException(); - } - - private void setLockMode_(LockModeType_2_0 lockMode) { - LockModeType_2_0 old = this.lockMode; - this.lockMode = lockMode; - this.firePropertyChanged(LOCK_MODE_PROPERTY, old, lockMode); - } - - public TextRange getLockModeTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean lockModeTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - private LockModeType_2_0 buildLockMode() { - return LockModeType_2_0.fromJavaAnnotationValue(this.getJdtMemberValue(JPA2_0.NAMED_QUERY__LOCK_MODE)); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java deleted file mode 100644 index cc581030c2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryOrderColumn2_0Annotation.java +++ /dev/null @@ -1,147 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryNamedColumnAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * javax.persistence.OrderColumn - */ -public class BinaryOrderColumn2_0Annotation - extends BinaryNamedColumnAnnotation - implements OrderColumn2_0Annotation -{ - private Boolean nullable; - private Boolean insertable; - private Boolean updatable; - - - public BinaryOrderColumn2_0Annotation(JavaResourcePersistentAttribute parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.nullable = this.buildNullable(); - this.insertable = this.buildInsertable(); - this.updatable = this.buildUpdatable(); - } - - @Override - public void update() { - super.update(); - this.setNullable_(this.buildNullable()); - this.setInsertable_(this.buildInsertable()); - this.setUpdatable_(this.buildUpdatable()); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - - //************* BinaryNamedColumnAnnotation implementation ************* - - @Override - protected String getColumnDefinitionElementName() { - return JPA.COLUMN__COLUMN_DEFINITION; - } - - @Override - protected String getNameElementName() { - return JPA.COLUMN__NAME; - } - - //************* OrderColumn2_0Annotation implementation ************* - - // ***** nullable - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean nullable) { - throw new UnsupportedOperationException(); - } - - private void setNullable_(Boolean nullable) { - Boolean old = this.nullable; - this.nullable = nullable; - this.firePropertyChanged(NULLABLE_PROPERTY, old, nullable); - } - - private Boolean buildNullable() { - return (Boolean) this.getJdtMemberValue(getNullableElementName()); - } - - String getNullableElementName() { - return JPA.COLUMN__NULLABLE; - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** insertable - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean insertable) { - throw new UnsupportedOperationException(); - } - - private void setInsertable_(Boolean insertable) { - Boolean old = this.insertable; - this.insertable = insertable; - this.firePropertyChanged(INSERTABLE_PROPERTY, old, insertable); - } - - private Boolean buildInsertable() { - return (Boolean) this.getJdtMemberValue(this.getInsertableElementName()); - } - - String getInsertableElementName() { - return JPA.COLUMN__INSERTABLE; - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ***** updatable - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean updatable) { - throw new UnsupportedOperationException(); - } - - private void setUpdatable_(Boolean updatable) { - Boolean old = this.updatable; - this.updatable = updatable; - this.firePropertyChanged(UPDATABLE_PROPERTY, old, updatable); - } - - private Boolean buildUpdatable() { - return (Boolean) this.getJdtMemberValue(this.getUpdatableElementName()); - } - - String getUpdatableElementName() { - return JPA.COLUMN__UPDATABLE; - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinarySequenceGenerator2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinarySequenceGenerator2_0Annotation.java deleted file mode 100644 index 6919129230..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinarySequenceGenerator2_0Annotation.java +++ /dev/null @@ -1,102 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.binary.BinarySequenceGeneratorAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.SequenceGenerator2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; - -/** - * BinarySequenceGenerator2_0Annotation - */ -public final class BinarySequenceGenerator2_0Annotation - extends BinarySequenceGeneratorAnnotation - implements SequenceGenerator2_0Annotation -{ - private String catalog; - private String schema; - - - public BinarySequenceGenerator2_0Annotation(JavaResourceNode parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.catalog = this.buildCatalog(); - this.schema = this.buildSchema(); - } - - @Override - public void update() { - super.update(); - this.setCatalog_(this.buildCatalog()); - this.setSchema_(this.buildSchema()); - } - - // ********** SequenceGenerator2_0Annotation implementation ********** - - // ********** catalog ********** - - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - throw new UnsupportedOperationException(); - } - - private void setCatalog_(String catalog) { - String old = this.catalog; - this.catalog = catalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, catalog); - } - - private String buildCatalog() { - return (String) this.getJdtMemberValue(JPA2_0.SEQUENCE_GENERATOR__CATALOG); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - // ********** schema ********** - - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - throw new UnsupportedOperationException(); - } - - private void setSchema_(String schema) { - String old = this.schema; - this.schema = schema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, schema); - } - - private String buildSchema() { - return (String) this.getJdtMemberValue(JPA2_0.SEQUENCE_GENERATOR__SCHEMA); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - throw new UnsupportedOperationException(); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryStaticMetamodelAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryStaticMetamodelAnnotation.java deleted file mode 100644 index caa427c79b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/binary/BinaryStaticMetamodelAnnotation.java +++ /dev/null @@ -1,74 +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.core.internal.jpa2.resource.java.binary; - -import org.eclipse.jdt.core.IAnnotation; -import org.eclipse.jpt.core.internal.resource.java.binary.BinaryAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.StaticMetamodelAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; - -/** - * javax.persistence.metamodel.StaticMetamodel - */ -public final class BinaryStaticMetamodelAnnotation - extends BinaryAnnotation - implements StaticMetamodelAnnotation -{ - private String value; - - - public BinaryStaticMetamodelAnnotation(JavaResourcePersistentType parent, IAnnotation jdtAnnotation) { - super(parent, jdtAnnotation); - this.value = this.buildValue(); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void update() { - super.update(); - this.setValue_(this.buildValue()); - } - - - // ********** StaticMetamodelAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - throw new UnsupportedOperationException(); - } - - private void setValue_(String value) { - String old = this.value; - this.value = value; - this.firePropertyChanged(VALUE_PROPERTY, old, value); - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, value); - } - - private String buildValue() { - return (String) this.getJdtMemberValue(JPA2_0.STATIC_METAMODEL__VALUE); - } - - // ***** fully-qualified class name - /** - * binary is already fully-qualified - */ - public String getFullyQualifiedClassName() { - return this.value; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java deleted file mode 100644 index 8bcf5f4221..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAccess2_0Annotation.java +++ /dev/null @@ -1,98 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.Access2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.AccessType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.Access - */ -public final class SourceAccess2_0Annotation - extends SourceAnnotation<Member> - implements Access2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private AccessType value; - - - public SourceAccess2_0Annotation(JavaResourcePersistentMember parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(member, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** AccessAnnotation implementation ********** - - // ***** value - public AccessType getValue() { - return this.value; - } - - public void setValue(AccessType value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(AccessType.toJavaAnnotationValue(value)); - } - } - - private void syncValue(AccessType astValue) { - AccessType old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private AccessType buildValue(CompilationUnit astRoot) { - return AccessType.fromJavaAnnotationValue(this.valueAdapter.getValue(astRoot)); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.ACCESS__VALUE); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java deleted file mode 100644 index ac2436b769..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverride2_0Annotation.java +++ /dev/null @@ -1,137 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.jpa2.resource.java.NullAssociationOverrideJoinTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAssociationOverrideAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinTableAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.AssociationOverride2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.JoinTableAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinTableAnnotation; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * SourceSequenceGenerator2_0Annotation - */ -public final class SourceAssociationOverride2_0Annotation - extends SourceAssociationOverrideAnnotation - implements AssociationOverride2_0Annotation -{ - private final ElementAnnotationAdapter joinTableAdapter; - private NestableJoinTableAnnotation joinTable; - - - // ********** constructor ********** - public SourceAssociationOverride2_0Annotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, member, daa, annotationAdapter); - this.joinTableAdapter = new ElementAnnotationAdapter(this.annotatedElement, buildJoinTableAnnotationAdapter(this.daa)); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - if (this.joinTableAdapter.getAnnotation(astRoot) != null) { - this.joinTable = buildJoinTableAnnotation(this, this.annotatedElement, this.daa); - this.joinTable.initialize(astRoot); - } - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncJoinTable(astRoot); - } - - //************ AssociationOverride2_0Annotation implementation **************** - - // ***** joinTable - public JoinTableAnnotation getJoinTable() { - return this.joinTable; - } - - public JoinTableAnnotation getNonNullJoinTable() { - return (this.joinTable != null) ? this.joinTable : new NullAssociationOverrideJoinTableAnnotation(this); - } - - public NestableJoinTableAnnotation addJoinTable() { - if (this.joinTable != null) { - throw new IllegalStateException("'joinTable' element already exists: " + this.joinTable); //$NON-NLS-1$ - } - this.joinTable = buildJoinTableAnnotation(this, this.annotatedElement, this.daa); - this.joinTable.newAnnotation(); - return this.joinTable; - } - - public void removeJoinTable() { - if (this.joinTable == null) { - throw new IllegalStateException("'joinTable' element does not exist"); //$NON-NLS-1$ - } - this.joinTable.removeAnnotation(); - this.joinTable = null; - } - - private void syncJoinTable(CompilationUnit astRoot) { - if (this.joinTableAdapter.getAnnotation(astRoot) == null) { - this.syncJoinTable_(null); - } else { - if (this.joinTable == null) { - NestableJoinTableAnnotation table = buildJoinTableAnnotation(this, this.annotatedElement, this.daa); - table.initialize(astRoot); - this.syncJoinTable_(table); - } else { - this.joinTable.synchronizeWith(astRoot); - } - } - } - - private void syncJoinTable_(NestableJoinTableAnnotation astJoinTable) { - JoinTableAnnotation old = this.joinTable; - this.joinTable = astJoinTable; - this.firePropertyChanged(JOIN_TABLE_PROPERTY, old, astJoinTable); - } - - - // ********** static methods ********** - - public static SourceAssociationOverride2_0Annotation buildAssociationOverride(JavaResourceNode parent, Member member) { - return new SourceAssociationOverride2_0Annotation(parent, member, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(member, DECLARATION_ANNOTATION_ADAPTER)); - } - - static NestableJoinTableAnnotation buildJoinTableAnnotation(JavaResourceNode parent, Member member, DeclarationAnnotationAdapter associationOverrideAnnotationAdapter) { - return new SourceJoinTableAnnotation(parent, member, buildJoinTableAnnotationAdapter(associationOverrideAnnotationAdapter)); - } - - static DeclarationAnnotationAdapter buildJoinTableAnnotationAdapter(DeclarationAnnotationAdapter associationOverrideAnnotationAdapter) { - return new NestedDeclarationAnnotationAdapter(associationOverrideAnnotationAdapter, JPA2_0.ASSOCIATION_OVERRIDE__JOIN_TABLE, org.eclipse.jpt.core.resource.java.JPA.JOIN_TABLE); - } - - - static SourceAssociationOverrideAnnotation buildNestedAssociationOverride(JavaResourceNode parent, Member member, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(member, idaa); - return new SourceAssociationOverride2_0Annotation(parent, member, idaa, annotationAdapter); - } - - protected static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(attributeOverridesAdapter, index, org.eclipse.jpt.core.resource.java.JPA.ASSOCIATION_OVERRIDE); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java deleted file mode 100644 index 65654ebbbb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceAssociationOverrides2_0Annotation.java +++ /dev/null @@ -1,33 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jpt.core.internal.resource.java.source.SourceAssociationOverridesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAssociationOverrideAnnotation; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.AssociationOverrides - */ -public final class SourceAssociationOverrides2_0Annotation - extends SourceAssociationOverridesAnnotation -{ - - public SourceAssociationOverrides2_0Annotation(JavaResourceNode parent, Member member) { - super(parent, member); - } - - @Override - protected NestableAssociationOverrideAnnotation buildAssociationOverride(int index) { - return SourceAssociationOverride2_0Annotation.buildNestedAssociationOverride(this, this.annotatedElement, index, this.daa); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java deleted file mode 100644 index 7879971781..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCacheable2_0Annotation.java +++ /dev/null @@ -1,99 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.Cacheable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.Cacheable - */ -public final class SourceCacheable2_0Annotation - extends SourceAnnotation<Member> - implements Cacheable2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<Boolean> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<Boolean> valueAdapter; - private Boolean value; - - - public SourceCacheable2_0Annotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<Boolean>(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** Cacheable2_0Annotation implementation ********** - - // ***** value - public Boolean getValue() { - return this.value; - } - - public void setValue(Boolean value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(Boolean astValue) { - Boolean old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private Boolean buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<Boolean> buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.CACHEABLE__VALUE, false, BooleanExpressionConverter.instance()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java deleted file mode 100644 index c25acb66ff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceCollectionTable2_0Annotation.java +++ /dev/null @@ -1,235 +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.core.internal.jpa2.resource.java.source; - -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.AnnotationContainerTools; -import org.eclipse.jpt.core.internal.resource.java.source.SourceBaseTableAnnotation; -import org.eclipse.jpt.core.internal.resource.java.source.SourceJoinColumnAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.CollectionTable2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.AnnotationContainer; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation; -import org.eclipse.jpt.core.resource.java.NestableJoinColumnAnnotation; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.persistence.CollectionTable - */ -public final class SourceCollectionTable2_0Annotation - extends SourceBaseTableAnnotation - implements CollectionTable2_0Annotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(CollectionTable2_0Annotation.ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> NAME_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.COLLECTION_TABLE__NAME); - - private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.COLLECTION_TABLE__SCHEMA); - - private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = ConversionDeclarationAnnotationElementAdapter.forStrings(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.COLLECTION_TABLE__CATALOG); - - - private final Vector<NestableJoinColumnAnnotation> joinColumns = new Vector<NestableJoinColumnAnnotation>(); - private final JoinColumnsAnnotationContainer joinColumnsContainer = new JoinColumnsAnnotationContainer(); - - - public SourceCollectionTable2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - AnnotationContainerTools.initialize(this.joinColumnsContainer, astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - AnnotationContainerTools.synchronize(this.joinColumnsContainer, astRoot); - } - - - // ********** SourceBaseTableAnnotation implementation ********** - - @Override - protected DeclarationAnnotationElementAdapter<String> getNameAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @CollectionTable is never nested - return NAME_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getSchemaAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @CollectionTable is never nested - return SCHEMA_ADAPTER; - } - - @Override - protected DeclarationAnnotationElementAdapter<String> getCatalogAdapter(DeclarationAnnotationAdapter declarationAnnotationAdapter) { - // ignore the daa passed in, @CollectionTable is never nested - return CATALOG_ADAPTER; - } - - @Override - protected String getUniqueConstraintsElementName() { - return JPA2_0.COLLECTION_TABLE__UNIQUE_CONSTRAINTS; - } - - // ********** CollectionTable2_0Annotation implementation ********** - - // ***** join columns - public ListIterator<JoinColumnAnnotation> joinColumns() { - return new CloneListIterator<JoinColumnAnnotation>(this.joinColumns); - } - - Iterable<NestableJoinColumnAnnotation> getNestableJoinColumns() { - return new LiveCloneIterable<NestableJoinColumnAnnotation>(this.joinColumns); - } - - public int joinColumnsSize() { - return this.joinColumns.size(); - } - - public NestableJoinColumnAnnotation joinColumnAt(int index) { - return this.joinColumns.get(index); - } - - public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) { - return this.joinColumns.indexOf(joinColumn); - } - - public NestableJoinColumnAnnotation addJoinColumn(int index) { - return (NestableJoinColumnAnnotation) AnnotationContainerTools.addNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation addJoinColumn_() { - return this.addJoinColumn_(this.joinColumns.size()); - } - - private NestableJoinColumnAnnotation addJoinColumn_(int index) { - NestableJoinColumnAnnotation joinColumn = this.buildJoinColumn(index); - this.joinColumns.add(joinColumn); - return joinColumn; - } - - void syncAddJoinColumn(Annotation astAnnotation) { - int index = this.joinColumns.size(); - NestableJoinColumnAnnotation joinColumn = this.addJoinColumn_(index); - joinColumn.initialize((CompilationUnit) astAnnotation.getRoot()); - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - private NestableJoinColumnAnnotation buildJoinColumn(int index) { - return new SourceJoinColumnAnnotation(this, this.annotatedElement, buildJoinColumnAnnotationAdapter(index)); - } - - private IndexedDeclarationAnnotationAdapter buildJoinColumnAnnotationAdapter(int index) { - return new NestedIndexedDeclarationAnnotationAdapter(this.daa, JPA.JOIN_TABLE__JOIN_COLUMNS, index, JPA.JOIN_COLUMN); - } - - void joinColumnAdded(int index, NestableJoinColumnAnnotation joinColumn) { - this.fireItemAdded(JOIN_COLUMNS_LIST, index, joinColumn); - } - - public void moveJoinColumn(int targetIndex, int sourceIndex) { - AnnotationContainerTools.moveNestedAnnotation(targetIndex, sourceIndex, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation moveJoinColumn_(int targetIndex, int sourceIndex) { - return CollectionTools.move(this.joinColumns, targetIndex, sourceIndex).get(targetIndex); - } - - public void removeJoinColumn(int index) { - AnnotationContainerTools.removeNestedAnnotation(index, this.joinColumnsContainer); - } - - NestableJoinColumnAnnotation removeJoinColumn_(int index) { - return this.joinColumns.remove(index); - } - - void syncRemoveJoinColumns(int index) { - this.removeItemsFromList(index, this.joinColumns, JOIN_COLUMNS_LIST); - } - - - // ********** annotation containers ********** - - /** - * adapt the AnnotationContainer interface to the collection table's join columns - */ - class JoinColumnsAnnotationContainer - implements AnnotationContainer<NestableJoinColumnAnnotation> - { - public org.eclipse.jdt.core.dom.Annotation getAstAnnotation(CompilationUnit astRoot) { - return SourceCollectionTable2_0Annotation.this.getAstAnnotation(astRoot); - } - - public String getElementName() { - return JPA2_0.COLLECTION_TABLE__JOIN_COLUMNS; - } - - public String getNestedAnnotationName() { - return JoinColumnAnnotation.ANNOTATION_NAME; - } - - public Iterable<NestableJoinColumnAnnotation> getNestedAnnotations() { - return SourceCollectionTable2_0Annotation.this.getNestableJoinColumns(); - } - - public int getNestedAnnotationsSize() { - return SourceCollectionTable2_0Annotation.this.joinColumnsSize(); - } - - public NestableJoinColumnAnnotation addNestedAnnotation() { - return SourceCollectionTable2_0Annotation.this.addJoinColumn_(); - } - - public void syncAddNestedAnnotation(Annotation astAnnotation) { - SourceCollectionTable2_0Annotation.this.syncAddJoinColumn(astAnnotation); - } - - public NestableJoinColumnAnnotation moveNestedAnnotation(int targetIndex, int sourceIndex) { - return SourceCollectionTable2_0Annotation.this.moveJoinColumn_(targetIndex, sourceIndex); - } - - public NestableJoinColumnAnnotation removeNestedAnnotation(int index) { - return SourceCollectionTable2_0Annotation.this.removeJoinColumn_(index); - } - - public void syncRemoveNestedAnnotations(int index) { - SourceCollectionTable2_0Annotation.this.syncRemoveJoinColumns(index); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java deleted file mode 100644 index 5aadf6afd1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceElementCollection2_0Annotation.java +++ /dev/null @@ -1,168 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.jpa2.resource.java.ElementCollection2_0Annotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.resource.java.FetchType; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; - -/** - * org.eclipse.persistence.annotations.Transformation - */ -public final class SourceElementCollection2_0Annotation - extends SourceAnnotation<Attribute> - implements ElementCollection2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> TARGET_CLASS_ADAPTER = buildTargetClassAdapter(); - private final AnnotationElementAdapter<String> targetClassAdapter; - private String targetClass; - - String fullyQualifiedTargetClassName; - - private static final DeclarationAnnotationElementAdapter<String> FETCH_ADAPTER = buildFetchAdapter(); - private final AnnotationElementAdapter<String> fetchAdapter; - private FetchType fetch; - - - public SourceElementCollection2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.targetClassAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, TARGET_CLASS_ADAPTER); - this.fetchAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, FETCH_ADAPTER); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.targetClass = this.buildTargetClass(astRoot); - this.fullyQualifiedTargetClassName = this.buildFullyQualifiedTargetClassName(astRoot); - this.fetch = this.buildFetch(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncTargetClass(this.buildTargetClass(astRoot)); - this.syncFullyQualifiedTargetClassName(this.buildFullyQualifiedTargetClassName(astRoot)); - this.syncFetch(this.buildFetch(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.targetClass); - } - - - // ********** ElementCollection2_0Annotation implementation ********** - - // ***** target class - public String getTargetClass() { - return this.targetClass; - } - - public void setTargetClass(String targetClass) { - if (this.attributeValueHasChanged(this.targetClass, targetClass)) { - this.targetClass = targetClass; - this.targetClassAdapter.setValue(targetClass); - } - } - - private void syncTargetClass(String astTargetClass) { - String old = this.targetClass; - this.targetClass = astTargetClass; - this.firePropertyChanged(TARGET_CLASS_PROPERTY, old, astTargetClass); - } - - private String buildTargetClass(CompilationUnit astRoot) { - return this.targetClassAdapter.getValue(astRoot); - } - - public TextRange getTargetClassTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(TARGET_CLASS_ADAPTER, astRoot); - } - - // ***** fully-qualified target entity class name - public String getFullyQualifiedTargetClassName() { - return this.fullyQualifiedTargetClassName; - } - - private void syncFullyQualifiedTargetClassName(String name) { - String old = this.fullyQualifiedTargetClassName; - this.fullyQualifiedTargetClassName = name; - this.firePropertyChanged(FULLY_QUALIFIED_TARGET_CLASS_NAME_PROPERTY, old, name); - } - - private String buildFullyQualifiedTargetClassName(CompilationUnit astRoot) { - return (this.targetClass == null) ? null : ASTTools.resolveFullyQualifiedName(this.targetClassAdapter.getExpression(astRoot)); - } - - // ***** fetch - public FetchType getFetch() { - return this.fetch; - } - - public void setFetch(FetchType fetch) { - if (this.attributeValueHasChanged(this.fetch, fetch)) { - this.fetch = fetch; - this.fetchAdapter.setValue(FetchType.toJavaAnnotationValue(fetch)); - } - } - - private void syncFetch(FetchType astFetch) { - FetchType old = this.fetch; - this.fetch = astFetch; - this.firePropertyChanged(FETCH_PROPERTY, old, astFetch); - } - - private FetchType buildFetch(CompilationUnit astRoot) { - return FetchType.fromJavaAnnotationValue(this.fetchAdapter.getValue(astRoot)); - } - - public TextRange getFetchTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(FETCH_ADAPTER, astRoot); - } - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildFetchAdapter() { - return new EnumDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.ELEMENT_COLLECTION__FETCH, false); - } - - private static DeclarationAnnotationElementAdapter<String> buildTargetClassAdapter() { - return buildTargetClassAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.ELEMENT_COLLECTION__TARGET_CLASS); - } - - private static DeclarationAnnotationElementAdapter<String> buildTargetClassAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - // TODO what about QualifiedType? - return buildAnnotationElementAdapter(annotationAdapter, elementName, SimpleTypeStringExpressionConverter.instance()); - } - - private static DeclarationAnnotationElementAdapter<String> buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String> converter) { - return new ConversionDeclarationAnnotationElementAdapter<String>(annotationAdapter, elementName, false, converter); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java deleted file mode 100644 index fe05d57de2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceGeneratedAnnotation.java +++ /dev/null @@ -1,218 +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.core.internal.jpa2.resource.java.source; - -import java.util.Arrays; -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotationStringArrayExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.GeneratedAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.ExpressionConverter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; - -/** - * javax.annotation.Generated - */ -public final class SourceGeneratedAnnotation - extends SourceAnnotation<Type> - implements GeneratedAnnotation -{ - public static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String[]> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String[]> valueAdapter; - private final Vector<String> values = new Vector<String>(); - - private static final DeclarationAnnotationElementAdapter<String> DATE_ADAPTER = buildAdapter(DATE_ELEMENT_NAME); - private final AnnotationElementAdapter<String> dateAdapter; - private String date; - - private static final DeclarationAnnotationElementAdapter<String> COMMENTS_ADAPTER = buildAdapter(COMMENTS_ELEMENT_NAME); - private final AnnotationElementAdapter<String> commentsAdapter; - private String comments; - - - public SourceGeneratedAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = this.buildAnnotationElementAdapter(VALUE_ADAPTER); - this.dateAdapter = this.buildAdapter(DATE_ADAPTER); - this.commentsAdapter = this.buildAdapter(COMMENTS_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - private AnnotationElementAdapter<String[]> buildAnnotationElementAdapter(DeclarationAnnotationElementAdapter<String[]> daea) { - return new AnnotatedElementAnnotationElementAdapter<String[]>(this.annotatedElement, daea); - } - - private AnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationElementAdapter<String> daea) { - return new AnnotatedElementAnnotationElementAdapter<String>(this.annotatedElement, daea); - } - - public void initialize(CompilationUnit astRoot) { - this.initializeValues(astRoot); - this.date = this.buildDate(astRoot); - this.comments = this.buildComments(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValues(astRoot); - this.syncDate(this.buildDate(astRoot)); - this.syncComments(this.buildComments(astRoot)); - } - - public IndexedAnnotationAdapter getIndexedAnnotationAdapter() { - return (IndexedAnnotationAdapter) this.annotationAdapter; - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.values); - } - - - // ********** GeneratedAnnotation implementation ********** - - // ***** values - public ListIterator<String> values() { - return new CloneListIterator<String>(this.values); - } - - public int valuesSize() { - return this.values.size(); - } - - public String getValue(int index) { - return this.values.get(index); - } - - public void addValue(String value) { - this.addValue(this.values.size(), value); - } - - public void addValue(int index, String value) { - this.values.add(index, value); - this.writeValues(); - } - - public void moveValue(int targetIndex, int sourceIndex) { - CollectionTools.move(this.values, targetIndex, sourceIndex); - this.writeValues(); - } - - public void removeValue(String value) { - this.values.remove(value); - this.writeValues(); - } - - public void removeValue(int index) { - this.values.remove(index); - this.writeValues(); - } - - private void writeValues() { - this.valueAdapter.setValue(this.values.toArray(new String[this.values.size()])); - } - - private void initializeValues(CompilationUnit astRoot) { - String[] astValues = this.valueAdapter.getValue(astRoot); - for (int i = 0; i < astValues.length; i++) { - this.values.add(astValues[i]); - } - } - - private void syncValues(CompilationUnit astRoot) { - String[] astValues = this.valueAdapter.getValue(astRoot); - this.synchronizeList(Arrays.asList(astValues), this.values, VALUES_LIST); - } - - // ***** date - public String getDate() { - return this.date; - } - - public void setDate(String date) { - if (this.attributeValueHasChanged(this.date, date)) { - this.date = date; - this.dateAdapter.setValue(date); - } - } - - protected void syncDate(String astDate) { - String old = this.date; - this.date = astDate; - this.firePropertyChanged(DATE_PROPERTY, old, astDate); - } - - private String buildDate(CompilationUnit astRoot) { - return this.dateAdapter.getValue(astRoot); - } - - // ***** comments - public String getComments() { - return this.comments; - } - - public void setComments(String comments) { - if (this.attributeValueHasChanged(this.comments, comments)) { - this.comments = comments; - this.commentsAdapter.setValue(comments); - } - } - - protected void syncComments(String astComments) { - String old = this.comments; - this.comments = astComments; - this.firePropertyChanged(COMMENTS_PROPERTY, old, astComments); - } - - private String buildComments(CompilationUnit astRoot) { - return this.commentsAdapter.getValue(astRoot); - } - - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter<String[]> buildValueAdapter() { - return buildArrayAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, VALUE_ELEMENT_NAME); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings()); - } - - private static DeclarationAnnotationElementAdapter<String[]> buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter<String[]> converter) { - return new ConversionDeclarationAnnotationElementAdapter<String[]>(annotationAdapter, elementName, false, converter); - } - - protected static DeclarationAnnotationElementAdapter<String> buildAdapter(String elementName) { - return buildAdapter(DECLARATION_ANNOTATION_ADAPTER, elementName); - } - - static DeclarationAnnotationElementAdapter<String> buildAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(annotationAdapter, elementName); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java deleted file mode 100644 index 38d0b29b66..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyClass2_0Annotation.java +++ /dev/null @@ -1,119 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.MapKeyClass - */ -public final class SourceMapKeyClass2_0Annotation - extends SourceAnnotation<Attribute> - implements MapKeyClass2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - private String fullyQualifiedClassName; - - - public SourceMapKeyClass2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - this.syncFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** MapKeyClass2_0Annotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - // ***** fully-qualified class name - public String getFullyQualifiedClassName() { - return this.fullyQualifiedClassName; - } - - private void syncFullyQualifiedClassName(String astfullyQualifiedClassName) { - String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = astfullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, astfullyQualifiedClassName); - } - - private String buildFullyQualifiedClassName(CompilationUnit astRoot) { - return (this.value == null) ? null : ASTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot)); - } - - - // ********** static methods ********** - - protected static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<String>(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.MAP_KEY_CLASS__VALUE, SimpleTypeStringExpressionConverter.instance()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyColumn2_0Annotation.java deleted file mode 100644 index 100c78f90f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyColumn2_0Annotation.java +++ /dev/null @@ -1,95 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jpt.core.internal.resource.java.source.SourceCompleteColumnAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * javax.persistence.MapKeyColumn - */ -public final class SourceMapKeyColumn2_0Annotation - extends SourceCompleteColumnAnnotation - implements MapKeyColumn2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(MapKeyColumn2_0Annotation.ANNOTATION_NAME); - - - public SourceMapKeyColumn2_0Annotation(JavaResourcePersistentAttribute parent, Member member) { - super(parent, member, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return MapKeyColumn2_0Annotation.ANNOTATION_NAME; - } - - - // ********** SourceNamedColumnAnnotation implementation ********** - - @Override - protected String getNameElementName() { - return JPA2_0.MAP_KEY_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA2_0.MAP_KEY_COLUMN__COLUMN_DEFINITION; - } - - - // ********** SourceBaseColumnAnnotation implementation ********** - - @Override - protected String getTableElementName() { - return JPA2_0.MAP_KEY_COLUMN__TABLE; - } - - @Override - protected String getUniqueElementName() { - return JPA2_0.MAP_KEY_COLUMN__UNIQUE; - } - - @Override - protected String getNullableElementName() { - return JPA2_0.MAP_KEY_COLUMN__NULLABLE; - } - - @Override - protected String getInsertableElementName() { - return JPA2_0.MAP_KEY_COLUMN__INSERTABLE; - } - - @Override - protected String getUpdatableElementName() { - return JPA2_0.MAP_KEY_COLUMN__UPDATABLE; - } - - // ********** SourceCompleteColumnAnnotation implementation ********** - - @Override - protected String getLengthElementName() { - return JPA2_0.MAP_KEY_COLUMN__LENGTH; - } - - @Override - protected String getPrecisionElementName() { - return JPA2_0.MAP_KEY_COLUMN__PRECISION; - } - - @Override - protected String getScaleElementName() { - return JPA2_0.MAP_KEY_COLUMN__SCALE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyEnumerated2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyEnumerated2_0Annotation.java deleted file mode 100644 index 42bc8e3ce7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyEnumerated2_0Annotation.java +++ /dev/null @@ -1,41 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jpt.core.internal.resource.java.source.SourceBaseEnumeratedAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyEnumerated2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.MapKeyEnumerated - */ -public final class SourceMapKeyEnumerated2_0Annotation - extends SourceBaseEnumeratedAnnotation - implements MapKeyEnumerated2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(MapKeyEnumerated2_0Annotation.ANNOTATION_NAME); - - public SourceMapKeyEnumerated2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return MapKeyEnumerated2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA2_0.MAP_KEY_ENUMERATED__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyTemporal2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyTemporal2_0Annotation.java deleted file mode 100644 index 92e1ce1156..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapKeyTemporal2_0Annotation.java +++ /dev/null @@ -1,42 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jpt.core.internal.resource.java.source.SourceBaseTemporalAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapKeyTemporal2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; - -/** - * javax.persistence.MapKeyTemporal - */ -public final class SourceMapKeyTemporal2_0Annotation - extends SourceBaseTemporalAnnotation - implements MapKeyTemporal2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(MapKeyTemporal2_0Annotation.ANNOTATION_NAME); - - - public SourceMapKeyTemporal2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - } - - public String getAnnotationName() { - return MapKeyTemporal2_0Annotation.ANNOTATION_NAME; - } - - @Override - protected String getValueElementName() { - return JPA2_0.MAP_KEY_TEMPORAL__VALUE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java deleted file mode 100644 index fe3fa6e609..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceMapsId2_0Annotation.java +++ /dev/null @@ -1,105 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.MapsId2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.MapsId - */ -public final class SourceMapsId2_0Annotation - extends SourceAnnotation<Attribute> - implements MapsId2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - - - private final AnnotationElementAdapter<String> valueAdapter; - - private String value; - - - public SourceMapsId2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(attribute, VALUE_ADAPTER); - } - - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** MapsId2_0Annotation implementation ********** - - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - public TextRange getValueTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(VALUE_ADAPTER, astRoot); - } - - public boolean valueTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(VALUE_ADAPTER, pos, astRoot); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return ConversionDeclarationAnnotationElementAdapter.forStrings( - DECLARATION_ANNOTATION_ADAPTER, JPA2_0.MAPS_ID__VALUE, false); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java deleted file mode 100644 index 1e06d80008..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQueries2_0Annotation.java +++ /dev/null @@ -1,31 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueriesAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableNamedQueryAnnotation; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQueries - */ -public final class SourceNamedQueries2_0Annotation - extends SourceNamedQueriesAnnotation -{ - public SourceNamedQueries2_0Annotation(JavaResourceNode parent, Type type) { - super(parent, type); - } - - @Override - protected NestableNamedQueryAnnotation buildNamedQuery(int index) { - return SourceNamedQuery2_0Annotation.createNestedNamedQuery(this, this.annotatedElement, index, this.daa); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java deleted file mode 100644 index 2d9a9e9130..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceNamedQuery2_0Annotation.java +++ /dev/null @@ -1,135 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedQueryAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ElementIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.LockModeType_2_0; -import org.eclipse.jpt.core.jpa2.resource.java.NamedQuery2_0Annotation; -import org.eclipse.jpt.core.resource.java.JPA; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.resource.java.NestableAnnotation; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.NamedQuery - */ -public final class SourceNamedQuery2_0Annotation - extends SourceNamedQueryAnnotation - implements NamedQuery2_0Annotation -{ - private final DeclarationAnnotationElementAdapter<String> lockModeDeclarationAdapter; - private final AnnotationElementAdapter<String> lockModeAdapter; - private LockModeType_2_0 lockMode; - - // ********** constructors ********** - public SourceNamedQuery2_0Annotation(JavaResourceNode parent, Type type, DeclarationAnnotationAdapter daa, AnnotationAdapter annotationAdapter) { - super(parent, type, daa, annotationAdapter); - this.lockModeDeclarationAdapter = this.buildLockModeTypeAdapter(daa); - this.lockModeAdapter = new AnnotatedElementAnnotationElementAdapter<String>(type, this.lockModeDeclarationAdapter); - } - - public SourceNamedQuery2_0Annotation(JavaResourceNode parent, Type type) { - this(parent, type, DECLARATION_ANNOTATION_ADAPTER, new ElementAnnotationAdapter(type, DECLARATION_ANNOTATION_ADAPTER)); - } - - private DeclarationAnnotationElementAdapter<String> buildLockModeTypeAdapter(DeclarationAnnotationAdapter daAdapter) { - return new EnumDeclarationAnnotationElementAdapter(daAdapter, this.getLockModeElementName()); - } - - private String getLockModeElementName() { - return JPA2_0.NAMED_QUERY__LOCK_MODE; - } - - // ********** initialize/update ********** - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.lockMode = this.buildLockMode(astRoot); - } - - @Override - public void initializeFrom(NestableAnnotation oldAnnotation) { - super.initializeFrom(oldAnnotation); - - NamedQuery2_0Annotation old = (NamedQuery2_0Annotation) oldAnnotation; - this.setLockMode(old.getLockMode()); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncLockMode(this.buildLockMode(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.lockMode); - } - - // ********** NamedQuery2_0Annotation implementation ********** - - public LockModeType_2_0 getLockMode() { - return this.lockMode; - } - - public void setLockMode(LockModeType_2_0 lockMode) { - if (this.attributeValueHasChanged(this.lockMode, lockMode)) { - this.lockMode = lockMode; - this.lockModeAdapter.setValue(LockModeType_2_0.toJavaAnnotationValue(lockMode)); - } - } - - private void syncLockMode(LockModeType_2_0 astLockMode) { - LockModeType_2_0 old = this.lockMode; - this.lockMode = astLockMode; - this.firePropertyChanged(LOCK_MODE_PROPERTY, old, astLockMode); - } - - private LockModeType_2_0 buildLockMode(CompilationUnit astRoot) { - return LockModeType_2_0.fromJavaAnnotationValue(this.lockModeAdapter.getValue(astRoot)); - } - - public TextRange getLockModeTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.lockModeDeclarationAdapter, astRoot); - } - - public boolean lockModeTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(this.lockModeDeclarationAdapter, pos, astRoot); - } - - - // ********** static methods ********** - - static SourceNamedQuery2_0Annotation createNestedNamedQuery(JavaResourceNode parent, Type type, int index, DeclarationAnnotationAdapter attributeOverridesAdapter) { - IndexedDeclarationAnnotationAdapter idaa = buildNestedDeclarationAnnotationAdapter(index, attributeOverridesAdapter); - IndexedAnnotationAdapter annotationAdapter = new ElementIndexedAnnotationAdapter(type, idaa); - - return new SourceNamedQuery2_0Annotation(parent, type, idaa, annotationAdapter); - } - - private static IndexedDeclarationAnnotationAdapter buildNestedDeclarationAnnotationAdapter(int index, DeclarationAnnotationAdapter namedQueriesAdapter) { - return new NestedIndexedDeclarationAnnotationAdapter(namedQueriesAdapter, index, JPA.NAMED_QUERY); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java deleted file mode 100644 index 177665cde2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceOrderColumn2_0Annotation.java +++ /dev/null @@ -1,187 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceNamedColumnAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.BooleanExpressionConverter; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.OrderColumn2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Attribute; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; - -/** - * javax.persistence.OrderColumn - */ -public final class SourceOrderColumn2_0Annotation - extends SourceNamedColumnAnnotation - implements OrderColumn2_0Annotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private final DeclarationAnnotationElementAdapter<Boolean> nullableDeclarationAdapter; - private final AnnotationElementAdapter<Boolean> nullableAdapter; - private Boolean nullable; - - private final DeclarationAnnotationElementAdapter<Boolean> insertableDeclarationAdapter; - private final AnnotationElementAdapter<Boolean> insertableAdapter; - private Boolean insertable; - - private final DeclarationAnnotationElementAdapter<Boolean> updatableDeclarationAdapter; - private final AnnotationElementAdapter<Boolean> updatableAdapter; - private Boolean updatable; - - public SourceOrderColumn2_0Annotation(JavaResourcePersistentAttribute parent, Attribute attribute) { - super(parent, attribute, DECLARATION_ANNOTATION_ADAPTER); - this.nullableDeclarationAdapter = this.buildBooleanElementAdapter(this.getNullableElementName()); - this.nullableAdapter = this.buildShortCircuitBooleanElementAdapter(this.nullableDeclarationAdapter); - this.insertableDeclarationAdapter = this.buildBooleanElementAdapter(this.getInsertableElementName()); - this.insertableAdapter = this.buildShortCircuitBooleanElementAdapter(this.insertableDeclarationAdapter); - this.updatableDeclarationAdapter = this.buildBooleanElementAdapter(this.getUpdatableElementName()); - this.updatableAdapter = this.buildShortCircuitBooleanElementAdapter(this.updatableDeclarationAdapter); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.nullable = this.buildNullable(astRoot); - this.insertable = this.buildInsertable(astRoot); - this.updatable = this.buildUpdatable(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncNullable(this.buildNullable(astRoot)); - this.syncInsertable(this.buildInsertable(astRoot)); - this.syncUpdatable(this.buildUpdatable(astRoot)); - } - - @Override - protected DeclarationAnnotationElementAdapter<String> buildStringElementAdapter(String elementName) { - return ConversionDeclarationAnnotationElementAdapter.forStrings(this.daa, elementName, false); - } - - @Override - protected DeclarationAnnotationElementAdapter<Boolean> buildBooleanElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter<Boolean>(this.daa, elementName, false, BooleanExpressionConverter.instance()); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - @Override - protected String getNameElementName() { - return JPA2_0.ORDER_COLUMN__NAME; - } - - @Override - protected String getColumnDefinitionElementName() { - return JPA2_0.ORDER_COLUMN__COLUMN_DEFINITION; - } - //************* OrderColumn2_0Annotation implementation ************* - - // ***** nullable - public Boolean getNullable() { - return this.nullable; - } - - public void setNullable(Boolean nullable) { - if (this.attributeValueHasChanged(this.nullable, nullable)) { - this.nullable = nullable; - this.nullableAdapter.setValue(nullable); - } - } - - private void syncNullable(Boolean astNullable) { - Boolean old = this.nullable; - this.nullable = astNullable; - this.firePropertyChanged(NULLABLE_PROPERTY, old, astNullable); - } - - private Boolean buildNullable(CompilationUnit astRoot) { - return this.nullableAdapter.getValue(astRoot); - } - - public TextRange getNullableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.nullableDeclarationAdapter, astRoot); - } - - String getNullableElementName() { - return JPA2_0.ORDER_COLUMN__NULLABLE; - } - - // ***** insertable - public Boolean getInsertable() { - return this.insertable; - } - - public void setInsertable(Boolean insertable) { - if (this.attributeValueHasChanged(this.insertable, insertable)) { - this.insertable = insertable; - this.insertableAdapter.setValue(insertable); - } - } - - private void syncInsertable(Boolean astInsertable) { - Boolean old = this.insertable; - this.insertable = astInsertable; - this.firePropertyChanged(INSERTABLE_PROPERTY, old, astInsertable); - } - - private Boolean buildInsertable(CompilationUnit astRoot) { - return this.insertableAdapter.getValue(astRoot); - } - - public TextRange getInsertableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.insertableDeclarationAdapter, astRoot); - } - - String getInsertableElementName() { - return JPA2_0.ORDER_COLUMN__INSERTABLE; - } - - // ***** updatable - public Boolean getUpdatable() { - return this.updatable; - } - - public void setUpdatable(Boolean updatable) { - if (this.attributeValueHasChanged(this.updatable, updatable)) { - this.updatable = updatable; - this.updatableAdapter.setValue(updatable); - } - } - - private void syncUpdatable(Boolean astUpdatable) { - Boolean old = this.updatable; - this.updatable = astUpdatable; - this.firePropertyChanged(UPDATABLE_PROPERTY, old, astUpdatable); - } - - private Boolean buildUpdatable(CompilationUnit astRoot) { - return this.updatableAdapter.getValue(astRoot); - } - - public TextRange getUpdatableTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(this.updatableDeclarationAdapter, astRoot); - } - - String getUpdatableElementName() { - return JPA2_0.ORDER_COLUMN__UPDATABLE; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java deleted file mode 100644 index 1fa27a74f9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceSequenceGenerator2_0Annotation.java +++ /dev/null @@ -1,119 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceSequenceGeneratorAnnotation; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.SequenceGenerator2_0Annotation; -import org.eclipse.jpt.core.resource.java.JavaResourceNode; -import org.eclipse.jpt.core.utility.TextRange; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Member; - -/** - * SourceSequenceGenerator2_0Annotation - */ -public final class SourceSequenceGenerator2_0Annotation - extends SourceSequenceGeneratorAnnotation - implements SequenceGenerator2_0Annotation -{ - private static final DeclarationAnnotationElementAdapter<String> CATALOG_ADAPTER = buildAdapter(JPA2_0.SEQUENCE_GENERATOR__CATALOG); - private final AnnotationElementAdapter<String> catalogAdapter; - private String catalog; - - private static final DeclarationAnnotationElementAdapter<String> SCHEMA_ADAPTER = buildAdapter(JPA2_0.SEQUENCE_GENERATOR__SCHEMA); - private final AnnotationElementAdapter<String> schemaAdapter; - private String schema; - - - // ********** constructor ********** - public SourceSequenceGenerator2_0Annotation(JavaResourceNode parent, Member member) { - super(parent, member); - this.catalogAdapter = this.buildAdapter(CATALOG_ADAPTER); - this.schemaAdapter = this.buildAdapter(SCHEMA_ADAPTER); - } - - @Override - public void initialize(CompilationUnit astRoot) { - super.initialize(astRoot); - this.catalog = this.buildCatalog(astRoot); - this.schema = this.buildSchema(astRoot); - } - - @Override - public void synchronizeWith(CompilationUnit astRoot) { - super.synchronizeWith(astRoot); - this.syncCatalog(this.buildCatalog(astRoot)); - this.syncSchema(this.buildSchema(astRoot)); - } - - // ********** catalog ********** - public String getCatalog() { - return this.catalog; - } - - public void setCatalog(String catalog) { - if (this.attributeValueHasChanged(this.catalog, catalog)) { - this.catalog = catalog; - this.catalogAdapter.setValue(catalog); - } - } - - private void syncCatalog(String astCatalog) { - String old = this.catalog; - this.catalog = astCatalog; - this.firePropertyChanged(CATALOG_PROPERTY, old, astCatalog); - } - - private String buildCatalog(CompilationUnit astRoot) { - return this.catalogAdapter.getValue(astRoot); - } - - public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(CATALOG_ADAPTER, astRoot); - } - - public boolean catalogTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(CATALOG_ADAPTER, pos, astRoot); - } - - // ********** schema ********** - public String getSchema() { - return this.schema; - } - - public void setSchema(String schema) { - if (this.attributeValueHasChanged(this.schema, schema)) { - this.schema = schema; - this.schemaAdapter.setValue(schema); - } - } - - private void syncSchema(String astSchema) { - String old = this.schema; - this.schema = astSchema; - this.firePropertyChanged(SCHEMA_PROPERTY, old, astSchema); - } - - private String buildSchema(CompilationUnit astRoot) { - return this.schemaAdapter.getValue(astRoot); - } - - public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return this.getElementTextRange(SCHEMA_ADAPTER, astRoot); - } - - public boolean schemaTouches(int pos, CompilationUnit astRoot) { - return this.elementTouches(SCHEMA_ADAPTER, pos, astRoot); - } - -}
\ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java deleted file mode 100644 index d7c4adb5e7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jpa2/resource/java/source/SourceStaticMetamodelAnnotation.java +++ /dev/null @@ -1,114 +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.core.internal.jpa2.resource.java.source; - -import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jpt.core.internal.resource.java.source.SourceAnnotation; -import org.eclipse.jpt.core.internal.utility.jdt.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.ASTTools; -import org.eclipse.jpt.core.internal.utility.jdt.AnnotatedElementAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.utility.jdt.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0; -import org.eclipse.jpt.core.jpa2.resource.java.StaticMetamodelAnnotation; -import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; -import org.eclipse.jpt.core.utility.jdt.AnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.utility.jdt.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.utility.jdt.Type; - -/** - * javax.persistence.metamodel.StaticMetamodel - */ -public final class SourceStaticMetamodelAnnotation - extends SourceAnnotation<Type> - implements StaticMetamodelAnnotation -{ - private static final DeclarationAnnotationAdapter DECLARATION_ANNOTATION_ADAPTER = new SimpleDeclarationAnnotationAdapter(ANNOTATION_NAME); - - private static final DeclarationAnnotationElementAdapter<String> VALUE_ADAPTER = buildValueAdapter(); - private final AnnotationElementAdapter<String> valueAdapter; - private String value; - - private String fullyQualifiedClassName; - - - public SourceStaticMetamodelAnnotation(JavaResourcePersistentType parent, Type type) { - super(parent, type, DECLARATION_ANNOTATION_ADAPTER); - this.valueAdapter = new AnnotatedElementAnnotationElementAdapter<String>(type, VALUE_ADAPTER); - } - - public String getAnnotationName() { - return ANNOTATION_NAME; - } - - public void initialize(CompilationUnit astRoot) { - this.value = this.buildValue(astRoot); - this.fullyQualifiedClassName = this.buildFullyQualifiedClassName(astRoot); - } - - public void synchronizeWith(CompilationUnit astRoot) { - this.syncValue(this.buildValue(astRoot)); - this.syncFullyQualifiedClassName(this.buildFullyQualifiedClassName(astRoot)); - } - - @Override - public void toString(StringBuilder sb) { - sb.append(this.value); - } - - - // ********** StaticMetamodelAnnotation implementation ********** - - // ***** value - public String getValue() { - return this.value; - } - - public void setValue(String value) { - if (this.attributeValueHasChanged(this.value, value)) { - this.value = value; - this.valueAdapter.setValue(value); - } - } - - private void syncValue(String astValue) { - String old = this.value; - this.value = astValue; - this.firePropertyChanged(VALUE_PROPERTY, old, astValue); - } - - private String buildValue(CompilationUnit astRoot) { - return this.valueAdapter.getValue(astRoot); - } - - // ***** fully-qualified class name - public String getFullyQualifiedClassName() { - return this.fullyQualifiedClassName; - } - - private void syncFullyQualifiedClassName(String astfullyQualifiedClassName) { - String old = this.fullyQualifiedClassName; - this.fullyQualifiedClassName = astfullyQualifiedClassName; - this.firePropertyChanged(FULLY_QUALIFIED_CLASS_NAME_PROPERTY, old, astfullyQualifiedClassName); - } - - private String buildFullyQualifiedClassName(CompilationUnit astRoot) { - return (this.value == null) ? null : ASTTools.resolveFullyQualifiedName(this.valueAdapter.getExpression(astRoot)); - } - - - // ********** static methods ********** - - private static DeclarationAnnotationElementAdapter<String> buildValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter<String>(DECLARATION_ANNOTATION_ADAPTER, JPA2_0.STATIC_METAMODEL__VALUE, SimpleTypeStringExpressionConverter.instance()); - } - -} |