summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaren Butzke2013-02-14 11:59:53 (EST)
committerKaren Butzke2013-02-14 11:59:53 (EST)
commit89acebef4e380766aa8828329822df6c3537fd57 (patch)
tree6be29b652e777091f01ed220e29ca621f552f8b8
parent9af8a34e13cf76a82d3fe8fa516dc8422038ab6c (diff)
downloadwebtools.dali-89acebef4e380766aa8828329822df6c3537fd57.zip
webtools.dali-89acebef4e380766aa8828329822df6c3537fd57.tar.gz
webtools.dali-89acebef4e380766aa8828329822df6c3537fd57.tar.bz2
Bug 392702 - [JPA 2.1] Spec based Converter support
ManagedType/PersistentType refactoring
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlConverter.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlManagedType.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpt_jpa_core_validation.properties10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatform.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatformProvider.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ManagedType.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JarFile.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedType.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedTypeDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentType.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedType.java106
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedTypeDefinition.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmXmlDefinition.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java27
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ManagedTypeContainer.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistentTypeContainer.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaPlatformProvider.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaPlatform.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManagedType.java126
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java91
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentTypeDefinition.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java304
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManagedType.java377
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java101
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java15
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentTypeDefinition.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java275
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java19
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java188
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java106
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java98
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmXml2_1Definition.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformFactory.java7
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformProvider.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaConverterType.java99
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaConverterTypeDefinition.java52
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmConverterType.java124
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java26
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/ConverterType2_1.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/java/JavaConverterType2_1.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/EntityMappings2_1.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmConverterType2_1.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/validation/JptJpaCoreValidationMessages.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverterContainer.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkConverterContainer.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkConverterContainer.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformFactory.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformProvider.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverterContainerImpl.java56
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkStructConverter.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkTypeConverter.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/AbstractOrmEclipseLinkConverterContainerImpl.java582
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5Definition.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverterContainerImpl.java554
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityMappingsConverterContainer.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/EclipseLinkConvertersComposite.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java12
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_5UiDefinition.java11
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF1
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/images/objects/java-class.gif (renamed from jpa/plugins/org.eclipse.jpt.jpa.ui/images/objects/null-type-mapping.gif)bin586 -> 586 bytes
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_persistence.properties6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_preferences_validation.properties10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JavaManagedTypeUiDefinition.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiImages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceResourceUiDefinition.java31
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractPersistenceResourceUiDefinition.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JavaPersistentTypeUiDefinition.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java5
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEmbeddableComposite.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java13
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/RemovePersistentClassHandler.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/JavaConverterTypeUiDefinition.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/persistence/PersistenceXml2_1UiDefinition.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ManagedTypeItemLabelProvider.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemContentProvider.java22
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java3
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/persistence/JptJpaUiPersistenceMessages.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/prefs/validation/JptJpaUiPreferencesValidationMessages.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF3
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java32
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaProjectTests.java106
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableGeneratorTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/EntityMappingsTests.java20
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddableTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java26
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmMappedSuperclassTests.java34
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/ClassRefTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceUnitTests.java49
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0ConnectionTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0OptionsTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceContextModelTests.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/PersistenceUnit2_0TestCase.java (renamed from jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java)6
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java31
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/JpaProject2_1Tests.java210
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/ClassRef2_1Tests.java136
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/JptJpa2_1ContextPersistenceModelTests.java29
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/PersistenceUnit2_1Tests.java1288
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLink2_5ContextModelTestCase.java37
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java32
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java48
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_3JavaMultitenancyTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java23
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_5EntityMappingsTests.java714
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_5OrmEntityTests.java224
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkEntityMappingsTests.java26
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmConverterTests.java16
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEmbeddableTests.java24
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmEntityTests.java24
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmMappedSuperclassTests.java24
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmObjectTypeConverterTests.java28
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmStructConverterTests.java16
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLinkOrmTypeConverterTests.java20
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/JptEclipseLinkCoreOrmContextModelTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLink2_2JpaMetadataConversionTests.java5
-rw-r--r--jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/persistence/EclipseLinkPersistenceUnitTests.java62
162 files changed, 6866 insertions, 1901 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF
index 07df321..da72c36 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF
@@ -65,6 +65,8 @@ Export-Package: org.eclipse.jpt.jpa.core,
org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.binary;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.source;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1;x-internal:=true,
+ org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;x-internal:=true,
+ org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1.resource.java;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1.resource.java.binary;x-internal:=true,
org.eclipse.jpt.jpa.core.internal.jpa2_1.resource.java.source;x-internal:=true,
@@ -88,6 +90,9 @@ Export-Package: org.eclipse.jpt.jpa.core,
org.eclipse.jpt.jpa.core.jpa2.context.persistence.options,
org.eclipse.jpt.jpa.core.jpa2.resource.java,
org.eclipse.jpt.jpa.core.jpa2_1,
+ org.eclipse.jpt.jpa.core.jpa2_1.context,
+ org.eclipse.jpt.jpa.core.jpa2_1.context.java,
+ org.eclipse.jpt.jpa.core.jpa2_1.context.orm,
org.eclipse.jpt.jpa.core.jpa2_1.resource.java,
org.eclipse.jpt.jpa.core.jpql,
org.eclipse.jpt.jpa.core.jpql.spi,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
index 4bbca77..6ebae42 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/AbstractXmlTypeMapping.java
@@ -415,6 +415,10 @@ public abstract class AbstractXmlTypeMapping extends AbstractXmlManagedType impl
}
+ public Class<? extends XmlTypeMapping> getType() {
+ return XmlTypeMapping.class;
+ }
+
public TextRange getAttributesTextRange() {
return getAttributeTextRange(JPA.ATTRIBUTES);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlConverter.java
index 86d33c7..6dd3a11 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlConverter.java
@@ -238,6 +238,10 @@ public class XmlConverter extends AbstractXmlManagedType implements XmlConverter
return result.toString();
}
+
+ public Class<? extends XmlConverter_2_1> getType() {
+ return XmlConverter_2_1.class;
+ }
// ********** translators **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java
index 7ce5ed6..8a12b9b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlEntityMappings.java
@@ -9,10 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.resource.orm;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.content.IContentType;
@@ -33,7 +31,6 @@ import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlEntityMappings_2_1;
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlNamedStoredProcedureQuery_2_1;
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlQueryContainer_2_1;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.resource.orm.v2_0.JPA2_0;
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.JPA2_1;
@@ -1162,20 +1159,6 @@ public class XmlEntityMappings extends ERootObjectImpl implements XmlQueryContai
}
- // ********** type mappings **********
-
- public List<XmlTypeMapping> getTypeMappings() {
- // convert lists to arrays to *reduce* risk of ConcurrentModificationException
- ArrayList<XmlTypeMapping> typeMappings = new ArrayList<XmlTypeMapping>();
- CollectionTools.addAll(typeMappings, this.getMappedSuperclasses().toArray(EMPTY_XML_TYPE_MAPPING_ARRAY));
- CollectionTools.addAll(typeMappings, this.getEntities().toArray(EMPTY_XML_TYPE_MAPPING_ARRAY));
- CollectionTools.addAll(typeMappings, this.getEmbeddables().toArray(EMPTY_XML_TYPE_MAPPING_ARRAY));
- return typeMappings;
- }
-
- private static final XmlTypeMapping[] EMPTY_XML_TYPE_MAPPING_ARRAY = new XmlTypeMapping[0];
-
-
// ********** version -> schema location mapping **********
private static final HashMap<String, String> SCHEMA_LOCATIONS = buildSchemaLocations();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlManagedType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlManagedType.java
index 11858b2..5f866f3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlManagedType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/model/src/org/eclipse/jpt/jpa/core/resource/orm/XmlManagedType.java
@@ -93,6 +93,12 @@ public interface XmlManagedType extends EBaseObject
void setDescription(String value);
+ /**
+ * Return the xml managed type's type.
+ * @see org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition#getResourceType()
+ */
+ Class<? extends XmlManagedType> getType();
+
TextRange getClassTextRange();
// ********** refactoring **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpt_jpa_core_validation.properties b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpt_jpa_core_validation.properties
index d393e7b..642d7a6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpt_jpa_core_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/property_files/jpt_jpa_core_validation.properties
@@ -41,7 +41,7 @@ PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_INTERFACE=Listed class \"{0}\" must not be a
PERSISTENCE_UNIT_LISTED_CLASS_IS_AN_ENUM=Listed class \"{0}\" must not be an enum
PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE=Mapping file \"{0}\" cannot be resolved.
PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE=JAR file \"{0}\" cannot be resolved
-PERSISTENCE_UNIT_INVALID_CLASS=Class \"{0}\" is included in a persistence unit, but is not mapped
+PERSISTENCE_UNIT_INVALID_CLASS=Class \"{0}\" is listed in the persistence.xml file, but is not annotated
PERSISTENCE_UNIT_INVALID_MAPPING_FILE=Mapping file {0} does not have recognized content.
PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING=The path to the JAR file will vary on your runtime environment. Please make sure the specified path fits your particular environment.
PERSISTENCE_UNIT_REDUNDANT_CLASS=Class \"{0}\" is already specified in mapping file \"{1}\"
@@ -56,11 +56,11 @@ ENTITY_NAME_MISSING=The given name of the entity \"{0}\" is empty
ENTITY_NO_PK=The entity has no primary key attribute defined
ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED=A primary key attribute should only be defined on the root entity or a mapped superclass
ENTITY_NON_ROOT_ID_CLASS_SPECIFIED=An ID class should only be defined on the root entity or a mapped superclass
-PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT=Class \"{0}\" is annotated, but is not included in any persistence unit
-PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT=Class \"{0}\" is mapped, but is not included in any persistence unit
+TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML=Class \"{0}\" is annotated, but not listed in the persistence.xml file
+TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML=Class \"{0}\" is managed, but is not listed in the persistence.xml file
PERSISTENT_TYPE_DUPLICATE_CLASS=Duplicate class \"{0}\" found in mapping files. This configuration is not supported by the tooling and may result in invalid error messages.
-PERSISTENT_TYPE_UNRESOLVED_CLASS=Class \"{0}\" cannot be resolved
-PERSISTENT_TYPE_UNSPECIFIED_CLASS=Unspecified class
+MANAGED_TYPE_UNRESOLVED_CLASS=Class \"{0}\" cannot be resolved
+MANAGED_TYPE_UNSPECIFIED_CLASS=Unspecified class
TARGET_NOT_AN_EMBEDDABLE={0} is not mapped as an embeddable
TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR=The Java class for mapped type \"{0}\" must define a non-private zero-argument constructor
TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR=The Java class for mapped type \"{0}\" has a private zero-argument constructor; it must be public or protected
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatform.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatform.java
index d8a7c30..a5c1c7f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatform.java
@@ -18,6 +18,7 @@ import org.eclipse.jpt.common.core.utility.jdt.AnnotationEditFormatter;
import org.eclipse.jpt.common.utility.filter.Filter;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0;
import org.eclipse.jpt.jpa.core.platform.JpaPlatformManager;
@@ -98,6 +99,15 @@ public interface JpaPlatform
IContentType getContentType(IFile file);
+ // ********** Managed Types **********
+
+ /**
+ * Return the Java managed type definitions that will be used to build Java
+ * managed types and their corresponding annotations.
+ */
+ Iterable<JavaManagedTypeDefinition> getJavaManagedTypeDefinitions();
+
+
// ********** Java annotations **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatformProvider.java
index 07d91b1..b5f159a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -12,6 +12,7 @@ package org.eclipse.jpt.jpa.core;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
/**
@@ -54,6 +55,11 @@ public interface JpaPlatformProvider {
Iterable<ResourceDefinition> getResourceDefinitions();
/**
+ * Return the JPA platform's Java managed type definitions.
+ */
+ Iterable<JavaManagedTypeDefinition> getJavaManagedTypeDefinitions();
+
+ /**
* Return the JPA platform's Java type mapping definitions.
*/
Iterable<JavaTypeMappingDefinition> getJavaTypeMappingDefinitions();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
index 2620e57..5eed62a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/JpaProject.java
@@ -27,6 +27,8 @@ import org.eclipse.jpt.common.utility.command.ExtendedCommandExecutor;
import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
import org.eclipse.jpt.jpa.db.Catalog;
@@ -239,15 +241,32 @@ public interface JpaProject
* (ignoring classes in JARs referenced in the <code>persistence.xml</code>).
*/
Iterable<JavaResourceAbstractType> getAnnotatedJavaSourceTypes();
-
+
/**
- * Return only the types of those valid <em>mapped</em> (i.e. annotated with
- * <code>@Entity</code>, <code>@Embeddable</code>, etc.) Java resource
+ * Return only the valid <em>potential</em> types (i.e. those annotated with
+ * <code>@Entity</code>, <code>@Embeddable</code>, <code>@MappedSuperclass</code>,
+ * <code>@Converter</code> in JPA 2.1). Java resource
* types that are directly part of the JPA project, ignoring
* those in JARs referenced in <code>persistence.xml</code>.
+ * @see #getManagedTypeAnnotationNames()
*/
- Iterable<JavaResourceAbstractType> getMappedJavaSourceTypes();
+ Iterable<JavaResourceAbstractType> getPotentialJavaSourceTypes();
+ /**
+ * Return only the valid <em>managed</em> type annotation names
+ * (i.e. <code>@Entity</code>, <code>@Embeddable</code>,
+ * <code>@MappedSuperclass</code>, <code>@Converter</code> in JPA 2.1).
+ * @see JavaManagedTypeDefinition#getAnnotationNames(JpaProject)
+ * @see JpaPlatform#getJavaManagedTypeDefinitions()
+ */
+ Iterable<String> getManagedTypeAnnotationNames();
+
+ /**
+ * Return the valid type mapping annotation names
+ * (i.e. <code>@Entity</code>, <code>@Embeddable</code>, <code>@MappedSuperclass</code>).
+ * @see JavaTypeMappingDefinition#getAnnotationName()
+ * @see JpaPlatform#getJavaTypeMappingDefinitions()
+ */
Iterable<String> getTypeMappingAnnotationNames();
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ManagedType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ManagedType.java
new file mode 100644
index 0000000..12c668d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/ManagedType.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context;
+
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+
+/**
+ * Context managed type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface ManagedType
+ extends JpaContextNode
+{
+
+ /**
+ * Return the managed type's type.
+ * @see org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition#getContextType()
+ * @see org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition#getType()
+ */
+ Class<? extends ManagedType> getType();
+
+
+ // ********** name **********
+
+ /**
+ * Return the managed type's [fully-qualified] name.
+ * The enclosing type separator is <code>'.'</code>,
+ * as opposed to <code>'$'</code>.
+ * @see #getSimpleName()
+ * @see #getTypeQualifiedName()
+ */
+ String getName();
+ String NAME_PROPERTY = "name"; //$NON-NLS-1$
+ Transformer<ManagedType, String> NAME_TRANSFORMER = new NameTransformer();
+ class NameTransformer
+ extends TransformerAdapter<ManagedType, String>
+ {
+ @Override
+ public String transform(ManagedType mt) {
+ return mt.getName();
+ }
+ }
+
+ /**
+ * Return the managed type's simple name.
+ * @see #getName()
+ * @see #getTypeQualifiedName()
+ */
+ String getSimpleName();
+
+ /**
+ * Return the persistent type's type-qualified name; i.e. the type's
+ * name without its package qualification.
+ * @see #getName()
+ * @see #getSimpleName()
+ */
+ String getTypeQualifiedName();
+
+ /**
+ * Return the Java resource type.
+ */
+ JavaResourceType getJavaResourceType();
+
+
+ // ********** misc **********
+
+ /**
+ * Return whether the managed type applies to the
+ * specified type name qualified with <code>'.'</code>.
+ */
+ boolean isFor(String typeName);
+
+ /**
+ * Return whether the managed type resolves to a Java class in the
+ * specified package fragment.
+ */
+ boolean isIn(IPackageFragment packageFragment);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java
index d0fb5e4..212068c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java
@@ -9,7 +9,6 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.context;
-import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jpt.common.core.utility.jdt.TypeBinding;
import org.eclipse.jpt.common.utility.internal.transformer.AbstractTransformer;
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
@@ -30,44 +29,9 @@ import org.eclipse.jpt.jpa.core.JpaStructureNode;
* @since 2.0
*/
public interface PersistentType
- extends JpaStructureNode, AccessHolder
+ extends ManagedType, JpaStructureNode, AccessHolder
{
- // ********** name **********
-
- /**
- * Return the persistent type's [fully-qualified] name.
- * The enclosing type separator is <code>'.'</code>,
- * as opposed to <code>'$'</code>.
- * @see #getSimpleName()
- * @see #getTypeQualifiedName()
- */
- String getName();
- String NAME_PROPERTY = "name"; //$NON-NLS-1$
- Transformer<PersistentType, String> NAME_TRANSFORMER = new NameTransformer();
- class NameTransformer
- extends TransformerAdapter<PersistentType, String>
- {
- @Override
- public String transform(PersistentType pt) {
- return pt.getName();
- }
- }
-
- /**
- * Return the persistent type's simple name.
- * @see #getName()
- * @see #getTypeQualifiedName()
- */
- String getSimpleName();
-
- /**
- * Return the persistent type's type-qualified name; i.e. the type's
- * name without its package qualification.
- * @see #getName()
- * @see #getSimpleName()
- */
- String getTypeQualifiedName();
-
+ Class<? extends PersistentType> getType();
// ********** mapping **********
@@ -206,18 +170,6 @@ public interface PersistentType
// ********** misc **********
/**
- * Return whether the persistent type applies to the
- * specified type name qualified with <code>'.'</code>.
- */
- boolean isFor(String typeName);
-
- /**
- * Return whether the persistent type resolves to a Java class in the
- * specified package fragment.
- */
- boolean isIn(IPackageFragment packageFragment);
-
- /**
* Return the persistent type the persistent type overrides.
* Typically this is the Java persistent type overridden by a
* non-metadata-complete <code>orm.xml</code> persistent type.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JarFile.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JarFile.java
index ae06440..39aa211 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JarFile.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JarFile.java
@@ -34,19 +34,19 @@ public interface JarFile
JavaResourcePackageFragmentRoot getJarResourcePackageFragmentRoot();
- // ********** Java persistent types **********
+ // ********** Java managed types **********
/**
- * Return the JAR file's Java persistent types.
+ * Return the JAR file's Java managed types.
* Return only the types that are annotated with JPA annotations.
*/
- Iterable<JavaPersistentType> getJavaPersistentTypes();
- String JAVA_PERSISTENT_TYPES_COLLECTION = "javaPersistentTypes"; //$NON-NLS-1$
+ Iterable<JavaManagedType> getJavaManagedTypes();
+ String JAVA_MANAGED_TYPES_COLLECTION = "javaManagedTypes"; //$NON-NLS-1$
/**
- * Return the size of the JAR file's Java persistent types.
+ * Return the size of the JAR file's Java managed types.
*/
- int getJavaPersistentTypesSize();
+ int getJavaManagedTypesSize();
// ********** misc **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedType.java
new file mode 100644
index 0000000..79f47c1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedType.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.java;
+
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+
+/**
+ * Context managed type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface JavaManagedType
+ extends ManagedType, JavaElementReference
+{
+ // ********** covariant overrides **********
+
+ /**
+ * Return the managed type's type.
+ */
+ Class<? extends JavaManagedType> getType();
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedTypeDefinition.java
new file mode 100644
index 0000000..d7ce74e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaManagedTypeDefinition.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.java;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
+import org.eclipse.jpt.jpa.core.JpaFactory;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+
+/**
+ * Map a type to a context managed type and its corresponding
+ * Java annotations.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface JavaManagedTypeDefinition
+{
+ /**
+ * Return a class that corresponds to the managed type.
+ * @see ManagedType#getType()
+ */
+ Class<? extends JavaManagedType> getType();
+
+ /**
+ * Return the names of the annotations applicable to this managed type
+ */
+ Iterable<String> getAnnotationNames(JpaProject jpaProject);
+
+ class AnnotationNameTransformer
+ extends TransformerAdapter<JavaManagedTypeDefinition, Iterable<String>>
+ {
+ private JpaProject jpaProject;
+
+ public AnnotationNameTransformer(JpaProject jpaProject) {
+ super();
+ this.jpaProject = jpaProject;
+ }
+ @Override
+ public Iterable<String> transform(JavaManagedTypeDefinition def) {
+ return def.getAnnotationNames(this.jpaProject);
+ }
+ }
+
+ /**
+ * Return a new <code>JavaManagedType</code>
+ */
+ JavaManagedType buildContextManagedType(JpaContextNode parent, JavaResourceType jrt, JpaFactory factory);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentType.java
index 07ab734..80753b8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,7 +10,6 @@
package org.eclipse.jpt.jpa.core.context.java;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.jpa.core.context.PersistentType;
@@ -27,10 +26,12 @@ import org.eclipse.jpt.jpa.core.context.PersistentType;
* @since 2.0
*/
public interface JavaPersistentType
- extends PersistentType, JavaElementReference
+ extends PersistentType, JavaManagedType
{
// ********** covariant overrides **********
+ Class<? extends JavaPersistentType> getType();
+
JavaTypeMapping getMapping();
ListIterable<JavaPersistentAttribute> getAttributes();
@@ -46,10 +47,5 @@ public interface JavaPersistentType
*/
boolean hasAnyAnnotatedAttributes();
- /**
- * Return the Java resource persistent type.
- */
- JavaResourceType getJavaResourceType();
-
JavaPersistentAttribute getAttributeFor(JavaResourceAttribute javaResourceAttribute);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java
index f3b0b45..0f5146c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/EntityMappings.java
@@ -104,15 +104,20 @@ public interface EntityMappings
/**
* Covariant override.
*/
- ListIterable<OrmPersistentType> getPersistentTypes();
+ ListIterable<OrmManagedType> getManagedTypes();
+ int getManagedTypesSize();
+ OrmManagedType getManagedType(String typeName);
+ void removeManagedType(int index);
+ void removeManagedType(OrmManagedType managedType);
+ boolean containsManagedType(String typeName);
+ String MANAGED_TYPES_LIST = "managedTypes"; //$NON-NLS-1$
+
+ /**
+ * Covariant override.
+ */
+ Iterable<OrmPersistentType> getPersistentTypes();
OrmPersistentType getPersistentType(String className);
- int getPersistentTypesSize();
OrmPersistentType addPersistentType(String mappingKey, String className);
- void removePersistentType(int index);
- void removePersistentType(OrmPersistentType persistentType);
- //void movePersistentType(int targetIndex, int sourceIndex);
- boolean containsPersistentType(String className);
- String PERSISTENT_TYPES_LIST = "persistentTypes"; //$NON-NLS-1$
ListIterable<OrmSequenceGenerator> getSequenceGenerators();
int getSequenceGeneratorsSize();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedType.java
new file mode 100644
index 0000000..b517251
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedType.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.DeleteTypeRefactoringParticipant;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
+
+/**
+ * Context managed type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface OrmManagedType
+ extends ManagedType, DeleteTypeRefactoringParticipant, TypeRefactoringParticipant
+{
+ // ********** class **********
+
+ /**
+ * Member class names will be qualified with a <code>'$'</code>
+ * between each declaring class name and member class name.
+ * <strong>NB:</strong> This may be an unqualified name to be prefixed by the
+ * entity mappings's 'package' value.
+ *
+ * @see EntityMappings#getPackage()
+ */
+ String getClass_();
+
+ /**
+ * @see #getClass_()
+ */
+ void setClass(String class_);
+ String CLASS_PROPERTY = "class"; //$NON-NLS-1$
+
+
+ // ********** covariant overrides **********
+
+ EntityMappings getParent();
+
+ XmlManagedType getXmlManagedType();
+
+ /**
+ * Return the managed type's type.
+ */
+ Class<? extends OrmManagedType> getType();
+
+ /**
+ * Managed types are in a sequence in the orm schema. We must keep
+ * the list of managed in the appropriate order so the wtp xml
+ * translators will write them to the xml in that order and they
+ * will adhere to the schema.
+ * <p>
+ * Each concrete implementation must implement this
+ * method and return an int that matches its order in the schema.
+ */
+ int getXmlSequence();
+
+ /**
+ * Add the managed type's XML managed type to the appropriate list
+ * in the specified XML entity mappings.
+ */
+ void addXmlManagedTypeTo(XmlEntityMappings entityMappings);
+
+ /**
+ * Remove the managed type's XML managed type from the appropriate list
+ * in the specified XML entity mappings.
+ */
+ void removeXmlManagedTypeFrom(XmlEntityMappings entityMappings);
+
+
+ // ********** misc **********
+
+ /**
+ * Return the Java managed type that is referred to by the
+ * <code>orm.xml</code> managed type.
+ * Return <code>null</code> if it is missing.
+ */
+ JavaManagedType getJavaManagedType();
+ String JAVA_MANAGED_TYPE_PROPERTY = "javaManagedType"; //$NON-NLS-1$
+
+ /**
+ * Return the managed type's default package, as set in its entity
+ * mappings.
+ */
+ String getDefaultPackage();
+
+ //TODO would like to remove this eventually
+ void dispose();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedTypeDefinition.java
new file mode 100644
index 0000000..035c0b1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmManagedTypeDefinition.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
+
+/**
+ * Map an orm managed type context type and resource type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface OrmManagedTypeDefinition
+{
+ /**
+ * Return a class that corresponds to the context managed type's type.
+ * @see ManagedType#getType()
+ */
+ Class<? extends OrmManagedType> getContextType();
+
+ /**
+ * Return a class that corresponds to the resource managed type's type.
+ * @see XmlManagedType#getType()
+ */
+ Class<? extends XmlManagedType> getResourceType();
+
+ /**
+ * Build a context managed type for the specified parent
+ * and resource managed type, using the specified factory.
+ */
+ OrmManagedType buildContextManagedType(JpaContextNode parent, XmlManagedType resourceManagedType, OrmXmlContextNodeFactory factory);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java
index c4ea189..2e7dc29 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java
@@ -10,11 +10,10 @@
package org.eclipse.jpt.jpa.core.context.orm;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
-import org.eclipse.jpt.jpa.core.context.DeleteTypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
/**
* <code>orm.xml</code> persistent type
@@ -29,11 +28,14 @@ import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
* @since 2.0
*/
public interface OrmPersistentType
- extends PersistentType, PersistentType.Owner, DeleteTypeRefactoringParticipant, TypeRefactoringParticipant
+ extends OrmManagedType, PersistentType, PersistentType.Owner
{
+
// ********** covariant overrides **********
- EntityMappings getParent();
+ Class<? extends OrmPersistentType> getType();
+
+ XmlTypeMapping getXmlManagedType();
OrmTypeMapping getMapping();
@@ -138,16 +140,7 @@ public interface OrmPersistentType
* Return the Java persistent type that is referred to by the
* <code>orm.xml</code> persistent type.
* Return <code>null</code> if it is missing.
+ * @see #getJavaManagedType()
*/
JavaPersistentType getJavaPersistentType();
- String JAVA_PERSISTENT_TYPE_PROPERTY = "javaPersistentType"; //$NON-NLS-1$
-
- /**
- * Return the persistent type's default package, as set in its entity
- * mappings.
- */
- String getDefaultPackage();
-
- //TODO would like to remove this eventually
- void dispose();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java
index 44e6759..efbab98 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmTypeMapping.java
@@ -15,7 +15,6 @@ import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.text.edits.DeleteEdit;
/**
* <code>orm.xml</code> type mapping
@@ -32,24 +31,6 @@ import org.eclipse.text.edits.DeleteEdit;
public interface OrmTypeMapping
extends TypeMapping, TypeRefactoringParticipant
{
- // ********** class **********
-
- /**
- * Member class names will be qualified with a <code>'$'</code>
- * between each declaring class name and member class name.
- * <strong>NB:</strong> This may be an unqualified name to be prefixed by the
- * entity mappings's 'package' value.
- *
- * @see EntityMappings#getPackage()
- */
- String getClass_();
-
- /**
- * @see #getClass_()
- */
- void setClass(String class_);
- String CLASS_PROPERTY = "class"; //$NON-NLS-1$
-
// ********** metadata complete **********
@@ -101,6 +82,7 @@ public interface OrmTypeMapping
* <p>
* Each concrete implementation must implement this
* method and return an int that matches its order in the schema.
+ * @see OrmManagedType#getXmlSequence()
*/
int getXmlSequence();
@@ -120,8 +102,6 @@ public interface OrmTypeMapping
TextRange getSelectionTextRange();
- TextRange getClassTextRange();
-
TextRange getAttributesTextRange();
@@ -147,14 +127,6 @@ public interface OrmTypeMapping
JavaTypeMapping getJavaTypeMappingForDefaults();
- // ********** refactoring **********
-
- /**
- * Create a text DeleteEdit for deleting the type mapping element and any text that precedes it
- */
- DeleteEdit createDeleteEdit();
-
-
// ********** misc **********
OrmPersistentType getPersistentType();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmXmlDefinition.java
index 7ed177a..dbdad15 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmXmlDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmXmlDefinition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,6 +10,7 @@
package org.eclipse.jpt.jpa.core.context.orm;
import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
/**
* <code>orm.xml</code> definition
@@ -37,6 +38,16 @@ public interface OrmXmlDefinition
OrmXmlContextNodeFactory getContextNodeFactory();
+ // ********** managed types **********
+
+ /**
+ * Return the OrmManagedTypeDefinition corresponding to the given resource type
+ * @throws IllegalArgumentException if the resource type is not supported
+ * @see OrmManagedTypeDefinition#getResourceType()
+ */
+ OrmManagedTypeDefinition getManagedTypeDefinition(Class<? extends XmlManagedType> resourceType);
+
+
// ********** type/attribute mappings **********
/**
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
index a46579c..c6b8469 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ClassRef.java
@@ -16,6 +16,7 @@ import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.DeleteTypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
@@ -80,28 +81,36 @@ public interface ClassRef
JavaResourceAbstractType getJavaResourceType();
- // ********** java persistent type **********
+ // ********** java managed type **********
/**
- * String constant associated with changes to the java persistent type
+ * String constant associated with changes to the java managed type
*/
- final static String JAVA_PERSISTENT_TYPE_PROPERTY = "javaPersistentType"; //$NON-NLS-1$
+ final static String JAVA_MANAGED_TYPE_PROPERTY = "javaManagedType"; //$NON-NLS-1$
/**
- * Return the JavaPersistentType that corresponds to this IClassRef.
+ * Return the JavaManagedType that corresponds to this ClassRef.
* This can be null.
* This is not settable by users of this API.
*/
+ JavaManagedType getJavaManagedType();
+
+ /**
+ * Convenience method for returning the JavaManagedType if it is a JavaPersistentType.
+ * It will return null if the JavaManagedType is null or is not a JavaPersistentType.
+ * @see ClassRef#getJavaManagedType()
+ * @see ManagedType#getContextType()
+ */
JavaPersistentType getJavaPersistentType();
- Transformer<ClassRef, JavaPersistentType> JAVA_PERSISTENT_TYPE_TRANSFORMER = new JavaPersistentTypeTransformer();
+ Transformer<ClassRef, JavaManagedType> JAVA_MANAGED_TYPE_TRANSFORMER = new JavaManagedTypeTransformer();
- class JavaPersistentTypeTransformer
- extends AbstractTransformer<ClassRef, JavaPersistentType>
+ class JavaManagedTypeTransformer
+ extends AbstractTransformer<ClassRef, JavaManagedType>
{
@Override
- protected JavaPersistentType transform_(ClassRef ref) {
- return ref.getJavaPersistentType();
+ protected JavaManagedType transform_(ClassRef ref) {
+ return ref.getJavaManagedType();
}
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ManagedTypeContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ManagedTypeContainer.java
new file mode 100644
index 0000000..1349e6f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/ManagedTypeContainer.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.context.persistence;
+
+import org.eclipse.jpt.common.utility.transformer.Transformer;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+
+/**
+ * Interface used by persistence unit to gather up managed types.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface ManagedTypeContainer {
+
+ /**
+ * Return the container's managed types. The returned list may contain
+ * multiple managed types for the same Java class; e.g.<ul>
+ * <li>the same type is specified in both the <code>persistence.xml</code> and
+ * <code>orm.xml</code> files
+ * <Li>the same type is specified multiple times in the same
+ * <code>persistence.xml</code> or <code>orm.xml</code> file
+ * <li>the same type is in a jar file specified in the
+ * <code>persistence.xml</code> file and is specified in the
+ * <code>persistence.xml</code> file and/or an <code>orm.xml</code> file
+ * </ul>
+ */
+ Iterable<? extends ManagedType> getManagedTypes();
+
+ /**
+ * Return the managed type with the specified name.
+ * Return <code>null</code> if the managed type is not found.
+ * If the persistent unit has more than one managed type with the
+ * specified name, return the first one found, using the following
+ * search order:<ul>
+ * <li>mapping files
+ * <li>classes
+ * <li>jar files
+ * </ul>
+ */
+ ManagedType getManagedType(String typeName);
+
+
+ Transformer<ManagedTypeContainer, Iterable<? extends ManagedType>> TRANSFORMER =
+ new Transformer<ManagedTypeContainer, Iterable<? extends ManagedType>>() {
+ public Iterable<? extends ManagedType> transform(ManagedTypeContainer container) {
+ return container.getManagedTypes();
+ }
+ @Override
+ public String toString() {
+ return "ManagedTypeContainer.TRANSFORMER"; //$NON-NLS-1$
+ }
+ };
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
index 670a90a..71bc08c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistenceUnit.java
@@ -753,11 +753,11 @@ public interface PersistenceUnit
XmlPersistenceUnit getXmlPersistenceUnit();
/**
- * Return whether the persistence unit specifies a persistent type with the
+ * Return whether the persistence unit specifies a managed type with the
* specified name (i.e. the type is listed either in the persistence unit's
* list of specified classes or in one of the persistent unit's mapping files).
*/
- boolean specifiesPersistentType(String typeName);
+ boolean specifiesManagedType(String typeName);
/**
* Return the persistence unit's Java persistent types, as specified by
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistentTypeContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistentTypeContainer.java
index 6617b08..547b573 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistentTypeContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/persistence/PersistentTypeContainer.java
@@ -22,10 +22,10 @@ import org.eclipse.jpt.jpa.core.context.PersistentType;
* pioneering adopters on the understanding that any code that uses this API
* will almost certainly be broken (repeatedly) as the API evolves.
*
- * @version 2.3
+ * @version 3.3
* @since 2.3
*/
-public interface PersistentTypeContainer {
+public interface PersistentTypeContainer extends ManagedTypeContainer {
/**
* Return the container's persistent types. The returned list may contain
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java
index 4d1cd05..fb2fab7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java
@@ -39,6 +39,8 @@ import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.jpa2.JpaFactory2_0;
import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0;
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaFactory2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaProject2_1;
import org.eclipse.jpt.jpa.db.Catalog;
import org.eclipse.jpt.jpa.db.Database;
@@ -146,12 +148,22 @@ public abstract class AbstractJpaNode
return this.getJpaPlatformVersion().isCompatibleWithJpaVersion(JpaProject2_0.FACET_VERSION_STRING);
}
+ protected boolean isJpa2_1Compatible() {
+ return this.getJpaPlatformVersion().isCompatibleWithJpaVersion(JpaProject2_1.FACET_VERSION_STRING);
+ }
+
/**
* Call {@link #isJpa2_0Compatible()} before calling this method.
*/
protected JpaFactory2_0 getJpaFactory2_0() {
return (JpaFactory2_0) this.getJpaFactory();
}
+ /**
+ * Call {@link #isJpa2_1Compatible()} before calling this method.
+ */
+ protected JpaFactory2_1 getJpaFactory2_1() {
+ return (JpaFactory2_1) this.getJpaFactory();
+ }
protected JpaFactory getJpaFactory() {
return this.getJpaPlatform().getJpaFactory();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaPlatformProvider.java
index 73df173..c1a670b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -14,13 +14,17 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.jpt.common.core.ContentTypeReference;
import org.eclipse.jpt.common.core.JptResourceType;
+import org.eclipse.jpt.common.core.JptResourceTypeReference;
+import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.transformer.Transformer;
import org.eclipse.jpt.jpa.core.JpaPlatformProvider;
import org.eclipse.jpt.jpa.core.JpaResourceModelProvider;
import org.eclipse.jpt.jpa.core.ResourceDefinition;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaPersistentTypeDefinition;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
/**
@@ -34,6 +38,8 @@ public abstract class AbstractJpaPlatformProvider
protected ArrayList<JpaResourceModelProvider> resourceModelProviders;
+ protected ArrayList<JavaManagedTypeDefinition> javaManagedTypeDefinitions;
+
protected ArrayList<JavaTypeMappingDefinition> javaTypeMappingDefinitions;
protected ArrayList<DefaultJavaAttributeMappingDefinition> defaultJavaAttributeMappingDefinitions;
@@ -99,6 +105,36 @@ public abstract class AbstractJpaPlatformProvider
}
+ // ********** Java managed types **********
+
+ public final synchronized Iterable<JavaManagedTypeDefinition> getJavaManagedTypeDefinitions() {
+ if (this.javaManagedTypeDefinitions == null) {
+ this.javaManagedTypeDefinitions = this.buildJavaManagedTypeDefinitions();
+ }
+ return this.javaManagedTypeDefinitions;
+ }
+
+ protected ArrayList<JavaManagedTypeDefinition> buildJavaManagedTypeDefinitions() {
+ ArrayList<JavaManagedTypeDefinition> definitions = new ArrayList<JavaManagedTypeDefinition>();
+ this.addJavaManagedTypeDefinitionsTo(definitions);
+ return definitions;
+ }
+
+ /**
+ * To the specified list, add Java managed type definitions to use for
+ * analyzing the type given all annotations on it. The order is
+ * important, as once a managed type definition tests positive for a
+ * type, all following managed type definitions are ignored.
+ */
+ protected void addJavaManagedTypeDefinitionsTo(ArrayList<JavaManagedTypeDefinition> definitions) {
+ CollectionTools.addAll(definitions, JAVA_MANAGED_TYPE_DEFINITIONS);
+ }
+
+ protected static final JavaManagedTypeDefinition[] JAVA_MANAGED_TYPE_DEFINITIONS = new JavaManagedTypeDefinition[] {
+ JavaPersistentTypeDefinition.instance()
+ };
+
+
// ********** Java type mappings **********
public final synchronized Iterable<JavaTypeMappingDefinition> getJavaTypeMappingDefinitions() {
@@ -188,7 +224,7 @@ public abstract class AbstractJpaPlatformProvider
protected void validateResourceDefinitions(ArrayList<ResourceDefinition> definitions) {
String message = "Duplicate resource definitions listed for resource type ''{0}'': {1}"; //$NON-NLS-1$
- this.validate(definitions, ResourceDefinition.RESOURCE_TYPE_TRANSFORMER, message);
+ this.validate(definitions, JptResourceTypeReference.RESOURCE_TYPE_TRANSFORMER, message);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
index 0805f61..d056752 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaProject.java
@@ -80,6 +80,7 @@ import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JptJpaCoreMessages;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
@@ -828,26 +829,26 @@ public abstract class AbstractJpaProject
}
/**
- * Return only the types of those valid <em>mapped</em> (i.e. annotated with
- * <code>@Entity</code>, <code>@Embeddable</code>, etc.) Java resource
- * types that are directly part of the JPA project, ignoring
+ * Return only the types of those valid <em>managed</em> (i.e. annotated with
+ * <code>@Entity</code>, <code>@Embeddable</code>, <code>@Converter</code>etc.)
+ * Java resource types that are directly part of the JPA project, ignoring
* those in JARs referenced in <code>persistence.xml</code>.
*/
- public Iterable<JavaResourceAbstractType> getMappedJavaSourceTypes() {
- return getInternalMappedSourceJavaResourceTypes();
+ public Iterable<JavaResourceAbstractType> getPotentialJavaSourceTypes() {
+ return getInternalPotentialSourceJavaResourceTypes();
}
/**
- * Return only those valid <em>mapped</em> (i.e. annotated with
- * <code>@Entity</code>, <code>@Embeddable</code>, etc.) Java resource
- * persistent types that are directly part of the JPA project, ignoring
+ * Return only those valid <em>managed</em> (i.e. annotated with
+ * <code>@Entity</code>, <code>@Embeddable</code>, <code>@Converter</code>etc.) Java resource
+ * types that are directly part of the JPA project, ignoring
* those in JARs referenced in <code>persistence.xml</code>.
*/
- protected Iterable<JavaResourceAbstractType> getInternalMappedSourceJavaResourceTypes() {
- Iterable<String> typeMappingAnnotationNames = this.getTypeMappingAnnotationNames();
+ protected Iterable<JavaResourceAbstractType> getInternalPotentialSourceJavaResourceTypes() {
+ Iterable<String> annotationNames = this.getManagedTypeAnnotationNames();
return IterableTools.filter(
this.getAnnotatedJavaSourceTypes(),
- new JavaResourceAnnotatedElement.IsAnnotatedWithAnyOf(typeMappingAnnotationNames)
+ new JavaResourceAnnotatedElement.IsAnnotatedWithAnyOf(annotationNames)
);
}
@@ -855,6 +856,13 @@ public abstract class AbstractJpaProject
return IterableTools.transform(this.getJpaPlatform().getJavaTypeMappingDefinitions(), JavaTypeMappingDefinition.ANNOTATION_NAME_TRANSFORMER);
}
+ public Iterable<String> getManagedTypeAnnotationNames() {
+ return IterableTools.concatenate(
+ IterableTools.transform(
+ this.getJpaPlatform().getJavaManagedTypeDefinitions(),
+ new JavaManagedTypeDefinition.AnnotationNameTransformer(this.getJpaProject())));
+ }
+
/**
* Return only those Java resource persistent types that are directly
* part of the JPA project, ignoring those in JARs referenced in
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaPlatform.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaPlatform.java
index 21b4a9f..06b12cc 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaPlatform.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/GenericJpaPlatform.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -31,6 +31,7 @@ import org.eclipse.jpt.jpa.core.JpaResourceModelProvider;
import org.eclipse.jpt.jpa.core.ResourceDefinition;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.db.ConnectionProfileFactory;
import org.eclipse.persistence.jpa.jpql.parser.JPQLGrammar;
@@ -169,6 +170,13 @@ public class GenericJpaPlatform
}
+ // ********** Java managed types **********
+
+ public Iterable<JavaManagedTypeDefinition> getJavaManagedTypeDefinitions() {
+ return this.platformProvider.getJavaManagedTypeDefinitions();
+ }
+
+
// ********** Java type mappings **********
public Iterable<JavaTypeMappingDefinition> getJavaTypeMappingDefinitions() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManagedType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManagedType.java
new file mode 100644
index 0000000..081bb13
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManagedType.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.context.java;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.ClassNameTools;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jpa.core.JpaFile;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
+
+public abstract class AbstractJavaManagedType
+ extends AbstractJavaJpaContextNode
+ implements JavaManagedType
+{
+ protected final JavaResourceType resourceType;
+
+ protected String name;
+
+
+ protected AbstractJavaManagedType(JpaContextNode parent, JavaResourceType resourceType) {
+ super(parent);
+ this.resourceType = resourceType;
+ this.name = this.resourceType.getTypeBinding().getQualifiedName();
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setName(this.resourceType.getTypeBinding().getQualifiedName());
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ }
+
+
+ // ********** name **********
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getSimpleName(){
+ return ClassNameTools.simpleName(this.name);
+ }
+
+ public String getTypeQualifiedName() {
+ String packageName = this.getPackageName();
+ return StringTools.isBlank(packageName) ? this.name : this.name.substring(packageName.length() + 1);
+ }
+
+ protected void setName(String name) {
+ String old = this.name;
+ this.name = name;
+ this.firePropertyChanged(NAME_PROPERTY, old, name);
+ }
+
+ public TextRange getValidationTextRange() {
+ return this.getSelectionTextRange();
+ }
+
+ public TextRange getSelectionTextRange() {
+ return this.resourceType.getNameTextRange();
+ }
+
+
+ // ********** misc **********
+
+ @Override
+ public IResource getResource() {
+ return this.resourceType.getFile();
+ }
+
+ public JavaResourceType getJavaResourceType() {
+ return this.resourceType;
+ }
+
+ protected JpaFile getJpaFile() {
+ return this.getJpaFile(this.resourceType.getFile());
+ }
+
+ public boolean isFor(String typeName) {
+ return ObjectTools.equals(typeName, this.name);
+ }
+
+ public boolean isIn(IPackageFragment packageFragment) {
+ return ObjectTools.equals(packageFragment.getElementName(), this.getPackageName());
+ }
+
+ protected String getPackageName() {
+ return this.getJavaResourceType().getTypeBinding().getPackageName();
+ }
+
+ public IJavaElement getJavaElement() {
+ try {
+ return this.getJavaProject().findType(this.name);
+ } catch (JavaModelException ex) {
+ JptJpaCorePlugin.instance().logError(ex);
+ return null;
+ }
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.name);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
index 5ecc3ae..a282aa6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
@@ -15,10 +15,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IJavaElement;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
@@ -30,7 +26,6 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.core.utility.jdt.TypeBinding;
import org.eclipse.jpt.common.utility.filter.Filter;
-import org.eclipse.jpt.common.utility.internal.ClassNameTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
@@ -43,6 +38,7 @@ import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
@@ -63,12 +59,9 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
* </ul>
*/
public abstract class AbstractJavaPersistentType
- extends AbstractJavaJpaContextNode
+ extends AbstractJavaManagedType
implements JavaPersistentType
{
- protected final JavaResourceType resourceType;
-
- protected String name;
protected PersistentType superPersistentType;
@@ -83,9 +76,7 @@ public abstract class AbstractJavaPersistentType
protected AbstractJavaPersistentType(PersistentType.Owner parent, JavaResourceType resourceType) {
- super(parent);
- this.resourceType = resourceType;
- this.name = this.resourceType.getTypeBinding().getQualifiedName();
+ super(parent, resourceType);
this.specifiedAccess = this.buildSpecifiedAccess();
// keep this non-null
@@ -102,7 +93,6 @@ public abstract class AbstractJavaPersistentType
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.setName(this.resourceType.getTypeBinding().getQualifiedName());
this.setSpecifiedAccess_(this.buildSpecifiedAccess());
this.syncMapping();
this.synchronizeNodesWithResourceModel(this.getAttributes());
@@ -119,28 +109,6 @@ public abstract class AbstractJavaPersistentType
}
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public String getSimpleName(){
- return ClassNameTools.simpleName(this.name);
- }
-
- public String getTypeQualifiedName() {
- String packageName = this.getPackageName();
- return StringTools.isBlank(packageName) ? this.name : this.name.substring(packageName.length() + 1);
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
-
// ********** super persistent type **********
public PersistentType getSuperPersistentType() {
@@ -969,18 +937,14 @@ public abstract class AbstractJavaPersistentType
return (fullTextRange == null) ? false : fullTextRange.includes(offset);
}
- public TextRange getSelectionTextRange() {
- return this.resourceType.getNameTextRange();
- }
-
public void gatherRootStructureNodes(JpaFile jpaFile, Collection<JpaStructureNode> rootStructureNodes) {
// the type's resource can be null if the resource type is "external"
if (ObjectTools.equals(this.getResource(), jpaFile.getFile())) {
for (JpaStructureNode root : rootStructureNodes) {
// the JPA file is a java file, so the already-added root nodes must be
- // Java persistent types
- JavaPersistentType jpt = (JavaPersistentType) root;
- if (jpt.getName().equals(this.name)) {
+ // Java managed types
+ JavaManagedType jmt = (JavaManagedType) root;
+ if (jmt.getName().equals(this.name)) {
// no duplicates -
// the first one found is used as a root in the structure view,
// the others are ignored...
@@ -1063,10 +1027,6 @@ public abstract class AbstractJavaPersistentType
}
}
- public TextRange getValidationTextRange() {
- return this.getSelectionTextRange();
- }
-
// ********** misc **********
@@ -1075,15 +1035,6 @@ public abstract class AbstractJavaPersistentType
return (PersistentType.Owner) super.getParent();
}
- @Override
- public IResource getResource() {
- return this.resourceType.getFile();
- }
-
- public JavaResourceType getJavaResourceType() {
- return this.resourceType;
- }
-
public AccessType getOwnerOverrideAccess() {
return this.getParent().getOverridePersistentTypeAccess();
}
@@ -1092,40 +1043,10 @@ public abstract class AbstractJavaPersistentType
return this.getParent().getDefaultPersistentTypeAccess();
}
- protected JpaFile getJpaFile() {
- return this.getJpaFile(this.resourceType.getFile());
- }
-
- public boolean isFor(String typeName) {
- return ObjectTools.equals(typeName, this.name);
- }
-
- public boolean isIn(IPackageFragment packageFragment) {
- return ObjectTools.equals(packageFragment.getElementName(), this.getPackageName());
- }
-
- protected String getPackageName() {
- return this.getJavaResourceType().getTypeBinding().getPackageName();
- }
-
public PersistentType getOverriddenPersistentType() {
return null; // Java persistent types do not override anything
}
- public IJavaElement getJavaElement() {
- try {
- return this.getJavaProject().findType(this.name);
- } catch (JavaModelException ex) {
- JptJpaCorePlugin.instance().logError(ex);
- return null;
- }
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
// ********** Access type **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
index 359aa2d..2e5ee53 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
@@ -13,12 +13,9 @@ import java.util.List;
import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.filter.Filter;
-import org.eclipse.jpt.common.utility.internal.filter.FilterAdapter;
import org.eclipse.jpt.common.utility.internal.iterable.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterable.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.Column;
import org.eclipse.jpt.jpa.core.context.Entity;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentTypeDefinition.java
new file mode 100644
index 0000000..c61c868
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentTypeDefinition.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.context.java;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jpa.core.JpaFactory;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
+
+public class JavaPersistentTypeDefinition implements JavaManagedTypeDefinition
+{
+ // singleton
+ private static final JavaManagedTypeDefinition INSTANCE = new JavaPersistentTypeDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaManagedTypeDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaPersistentTypeDefinition() {
+ super();
+ }
+
+ public Class<? extends JavaPersistentType> getType() {
+ return JavaPersistentType.class;
+ }
+
+ public Iterable<String> getAnnotationNames(JpaProject jpaProject) {
+ return jpaProject.getTypeMappingAnnotationNames();
+ }
+
+ public JavaPersistentType buildContextManagedType(JpaContextNode parent, JavaResourceType jrt, JpaFactory factory) {
+ return factory.buildJavaPersistentType((ClassRef) parent, jrt);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
index cc18aeb..7406045 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
@@ -25,9 +25,12 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.common.core.internal.utility.JDTTools;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement;
+import org.eclipse.jpt.common.core.resource.xml.EmfTools;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.filter.Filter;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.collection.ListTools;
import org.eclipse.jpt.common.utility.internal.iterable.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
@@ -40,12 +43,15 @@ import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.DeleteTypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.Generator;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmIdClassReference;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
@@ -58,14 +64,19 @@ import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddable;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
import org.eclipse.jpt.jpa.core.resource.orm.XmlMappedSuperclass;
import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTableGenerator;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages;
import org.eclipse.jpt.jpa.db.Catalog;
import org.eclipse.jpt.jpa.db.Database;
@@ -84,7 +95,7 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
*/
public abstract class AbstractEntityMappings
extends AbstractOrmXmlContextNode
- implements EntityMappings
+ implements EntityMappings2_1
{
protected final XmlEntityMappings xmlEntityMappings;
@@ -103,8 +114,8 @@ public abstract class AbstractEntityMappings
protected final OrmPersistenceUnitMetadata persistenceUnitMetadata;
- protected final Vector<OrmPersistentType> persistentTypes = new Vector<OrmPersistentType>();
- protected final PersistentTypeContainerAdapter persistentTypeContainerAdapter = new PersistentTypeContainerAdapter();
+ protected final Vector<OrmManagedType> managedTypes = new Vector<OrmManagedType>();
+ protected final ManagedTypeContainerAdapter managedTypeContainerAdapter = new ManagedTypeContainerAdapter();
protected final ContextListContainer<OrmSequenceGenerator, XmlSequenceGenerator> sequenceGeneratorContainer;
@@ -131,7 +142,8 @@ public abstract class AbstractEntityMappings
this.persistenceUnitMetadata = this.buildPersistenceUnitMetadata();
- this.initializePersistentTypes();
+ this.initializeManagedTypes();
+
this.sequenceGeneratorContainer = this.buildSequenceGeneratorContainer();
this.tableGeneratorContainer = this.buildTableGeneratorContainer();
this.queryContainer = this.buildQueryContainer();
@@ -155,7 +167,8 @@ public abstract class AbstractEntityMappings
this.persistenceUnitMetadata.synchronizeWithResourceModel();
- this.syncPersistentTypes();
+ this.syncManagedTypes();
+
this.syncSequenceGenerators();
this.syncTableGenerators();
@@ -172,7 +185,8 @@ public abstract class AbstractEntityMappings
this.persistenceUnitMetadata.update();
- this.updateNodes(this.getPersistentTypes());
+ this.updateNodes(this.getManagedTypes());
+
this.updateNodes(this.getSequenceGenerators());
this.updateNodes(this.getTableGenerators());
@@ -222,14 +236,14 @@ public abstract class AbstractEntityMappings
return this.xmlEntityMappings.getSelectionTextRange();
}
- //TODO I think children needs to include all managed types,
- //thus JPA 2.1 converters are going to appear in the structure and project explorer views??
+ //for now I am making the children only PersistentTypes. If we decide
+ //we want Converters listed in the structure view for an orm.xml, we can change this.
protected void initializeChildren() {
- this.children.addAll(this.persistentTypes);
+ CollectionTools.addAll(this.children, this.getPersistentTypes());
}
protected void updateChildren() {
- this.synchronizeCollection(this.persistentTypes, this.children, CHILDREN_COLLECTION);
+ this.synchronizeCollection(this.getPersistentTypes(), this.children, CHILDREN_COLLECTION);
}
public Iterable<OrmPersistentType> getChildren() {
@@ -306,17 +320,17 @@ public abstract class AbstractEntityMappings
public void changeMapping(OrmPersistentType ormPersistentType, OrmTypeMapping oldMapping, OrmTypeMapping newMapping) {
AccessType savedAccess = ormPersistentType.getSpecifiedAccess();
- int sourceIndex = this.persistentTypes.indexOf(ormPersistentType);
- this.persistentTypes.remove(sourceIndex);
+ int sourceIndex = this.managedTypes.indexOf(ormPersistentType);
+ this.managedTypes.remove(sourceIndex);
oldMapping.removeXmlTypeMappingFrom(this.xmlEntityMappings);
int targetIndex = this.calculateInsertionIndex(ormPersistentType);
- this.persistentTypes.add(targetIndex, ormPersistentType);
+ this.managedTypes.add(targetIndex, ormPersistentType);
newMapping.addXmlTypeMappingTo(this.xmlEntityMappings);
newMapping.initializeFrom(oldMapping);
//not sure where else to put this, need to set the access on the resource model
ormPersistentType.setSpecifiedAccess(savedAccess);
- this.fireItemMoved(PERSISTENT_TYPES_LIST, targetIndex, sourceIndex);
+ this.fireItemMoved(MANAGED_TYPES_LIST, targetIndex, sourceIndex);
}
public TextRange getValidationTextRange() {
@@ -507,21 +521,49 @@ public abstract class AbstractEntityMappings
}
- // ********** persistent types **********
+ // ********** managed types **********
- public ListIterable<OrmPersistentType> getPersistentTypes() {
- return IterableTools.cloneLive(this.persistentTypes);
+ public ListIterable<OrmManagedType> getManagedTypes() {
+ return IterableTools.cloneLive(this.managedTypes);
}
- public int getPersistentTypesSize() {
- return this.persistentTypes.size();
+ public int getManagedTypesSize() {
+ return this.managedTypes.size();
}
- public OrmPersistentType getPersistentType(String className) {
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- if (ormPersistentType.isFor(className)) {
- return ormPersistentType;
+ public OrmManagedType getManagedType(String typeName) {
+ for (OrmManagedType ormManagedType : this.getManagedTypes()) {
+ if (ormManagedType.isFor(typeName)) {
+ return ormManagedType;
+ }
+ }
+ return null;
+ }
+
+ public boolean containsManagedType(String typeName) {
+ return this.getManagedType(typeName) != null;
+ }
+
+
+ // ********** persistent types **********
+
+ public Iterable<OrmPersistentType> getPersistentTypes() {
+ return IterableTools.downCast(IterableTools.filter(
+ this.getManagedTypes(),
+ ORM_PERSISTENT_TYPE_FILTER));
+ }
+
+ protected static final Filter<OrmManagedType> ORM_PERSISTENT_TYPE_FILTER =
+ new Filter<OrmManagedType>() {
+ public boolean accept(OrmManagedType mt) {
+ return mt.getType() == OrmPersistentType.class;
}
+ };
+
+ public OrmPersistentType getPersistentType(String typeName) {
+ ManagedType mt = this.getManagedType(typeName);
+ if (mt != null && (mt.getType() == OrmPersistentType.class)) {
+ return (OrmPersistentType) mt;
}
return null;
}
@@ -656,26 +698,26 @@ public abstract class AbstractEntityMappings
return (className == null) ? null : PRIMITIVE_CLASSES.get(className);
}
+ public OrmPersistentType addPersistentType(String mappingKey, String className) {
+ OrmTypeMappingDefinition md = this.getMappingFileDefinition().getTypeMappingDefinition(mappingKey);
+ XmlTypeMapping xmlManagedType = md.buildResourceMapping(this.getResourceNodeFactory());
+ return (OrmPersistentType) this.addManagedType(xmlManagedType, className);
+ }
+
/**
- * We have to calculate the new persistent type's index.
+ * We have to calculate the new managed type's index.
* We will use the type's short name if the entity mappings's
* package is the same as the type's package.
*/
- public OrmPersistentType addPersistentType(String mappingKey, String className) {
- OrmTypeMappingDefinition md = this.getMappingFileDefinition().getTypeMappingDefinition(mappingKey);
- XmlTypeMapping xmlTypeMapping = md.buildResourceMapping(this.getResourceNodeFactory());
-
+ protected OrmManagedType addManagedType(XmlManagedType xmlManagedType, String className) {
// adds short name if package name is relevant
- className = this.normalizeClassName(className);
- xmlTypeMapping.setClassName(className);
-
- OrmPersistentType persistentType = this.buildPersistentType(xmlTypeMapping);
- int index = this.calculateInsertionIndex(persistentType);
- this.addItemToList(index, persistentType, this.persistentTypes, PERSISTENT_TYPES_LIST);
-
- persistentType.getMapping().addXmlTypeMappingTo(this.xmlEntityMappings);
+ xmlManagedType.setClassName(this.normalizeClassName(className));
- return persistentType;
+ OrmManagedType managedType = this.buildManagedType(xmlManagedType);
+ int index = this.calculateInsertionIndex(managedType);
+ this.addItemToList(index, managedType, this.managedTypes, MANAGED_TYPES_LIST);
+ managedType.addXmlManagedTypeTo(this.xmlEntityMappings);
+ return managedType;
}
//TODO add API - added this post-M6
@@ -704,7 +746,7 @@ public abstract class AbstractEntityMappings
}
List<XmlMappedSuperclass> mappedSuperclasses = new ArrayList<XmlMappedSuperclass>(addedItems.size());
for (OrmPersistentType persistentType : addedItems) {
- mappedSuperclasses.add((XmlMappedSuperclass) persistentType.getMapping().getXmlTypeMapping());
+ mappedSuperclasses.add((XmlMappedSuperclass) persistentType.getXmlManagedType());
}
sm.subTask(JptJpaCoreMessages.MAKE_PERSISTENT_ADD_TO_XML_RESOURCE_MODEL);
//use addAll to minimize change notifications to our model
@@ -721,7 +763,7 @@ public abstract class AbstractEntityMappings
}
List<XmlEntity> entities = new ArrayList<XmlEntity>(addedItems.size());
for (OrmPersistentType persistentType : addedItems) {
- entities.add((XmlEntity) persistentType.getMapping().getXmlTypeMapping());
+ entities.add((XmlEntity) persistentType.getXmlManagedType());
}
sm.subTask(JptJpaCoreMessages.MAKE_PERSISTENT_ADD_TO_XML_RESOURCE_MODEL);
//use addAll to minimize change notifications to our model
@@ -738,7 +780,7 @@ public abstract class AbstractEntityMappings
}
List<XmlEmbeddable> embeddables = new ArrayList<XmlEmbeddable>(addedItems.size());
for (OrmPersistentType persistentType : addedItems) {
- embeddables.add((XmlEmbeddable) persistentType.getMapping().getXmlTypeMapping());
+ embeddables.add((XmlEmbeddable) persistentType.getXmlManagedType());
}
sm.subTask(JptJpaCoreMessages.MAKE_PERSISTENT_ADD_TO_XML_RESOURCE_MODEL);
//use addAll to minimize change notifications to our model
@@ -760,7 +802,7 @@ public abstract class AbstractEntityMappings
className = this.normalizeClassName(className);
xmlTypeMapping.setClassName(className);
- addedItems.add(this.buildPersistentType(xmlTypeMapping));
+ addedItems.add((OrmPersistentType) this.buildManagedType(xmlTypeMapping));
}
}
if (addedItems.size() == 0 || sm.isCanceled()) {
@@ -770,7 +812,7 @@ public abstract class AbstractEntityMappings
int index = this.calculateInsertionIndex(addedItems.get(0));
sm.subTask(JptJpaCoreMessages.MAKE_PERSISTENT_UPDATING_JPA_MODEL);
- this.addItemsToList(index, addedItems, this.persistentTypes, PERSISTENT_TYPES_LIST);
+ this.addItemsToList(index, addedItems, this.managedTypes, MANAGED_TYPES_LIST);
sm.worked(9);
return addedItems;
}
@@ -787,19 +829,20 @@ public abstract class AbstractEntityMappings
className;
}
- protected OrmPersistentType buildPersistentType(XmlTypeMapping xmlTypeMapping) {
- return this.getContextNodeFactory().buildOrmPersistentType(this, xmlTypeMapping);
+ protected OrmManagedType buildManagedType(XmlManagedType xmlManagedType) {
+ OrmManagedTypeDefinition md = this.getMappingFileDefinition().getManagedTypeDefinition(xmlManagedType.getType());
+ return md.buildContextManagedType(this, xmlManagedType, this.getContextNodeFactory());
}
- protected int calculateInsertionIndex(OrmPersistentType ormPersistentType) {
- return ListTools.insertionIndexOf(this.persistentTypes, ormPersistentType, MAPPING_COMPARATOR);
+ protected int calculateInsertionIndex(OrmManagedType ormManagedType) {
+ return ListTools.insertionIndexOf(this.managedTypes, ormManagedType, MAPPING_COMPARATOR);
}
- protected static final Comparator<OrmPersistentType> MAPPING_COMPARATOR =
- new Comparator<OrmPersistentType>() {
- public int compare(OrmPersistentType o1, OrmPersistentType o2) {
- int o1Sequence = o1.getMapping().getXmlSequence();
- int o2Sequence = o2.getMapping().getXmlSequence();
+ protected static final Comparator<OrmManagedType> MAPPING_COMPARATOR =
+ new Comparator<OrmManagedType>() {
+ public int compare(OrmManagedType o1, OrmManagedType o2) {
+ int o1Sequence = o1.getXmlSequence();
+ int o2Sequence = o2.getXmlSequence();
if (o1Sequence < o2Sequence) {
return -1;
}
@@ -810,74 +853,94 @@ public abstract class AbstractEntityMappings
}
};
- public void removePersistentType(int index) {
- OrmPersistentType persistentType = this.removePersistentType_(index);
- persistentType.getMapping().removeXmlTypeMappingFrom(this.xmlEntityMappings);
+ public void removeManagedType(int index) {
+ OrmManagedType managedType = this.removeManagedType_(index);
+ managedType.removeXmlManagedTypeFrom(this.xmlEntityMappings);
}
/**
- * dispose and return the persistent type
+ * dispose and return the managed type
*/
- protected OrmPersistentType removePersistentType_(int index) {
- OrmPersistentType persistentType = this.removeItemFromList(index, this.persistentTypes, PERSISTENT_TYPES_LIST);
- persistentType.dispose();
- return persistentType;
+ protected OrmManagedType removeManagedType_(int index) {
+ OrmManagedType managedType = this.removeItemFromList(index, this.managedTypes, MANAGED_TYPES_LIST);
+ managedType.dispose();
+ return managedType;
}
- public void removePersistentType(OrmPersistentType persistentType) {
- this.removePersistentType(this.persistentTypes.indexOf(persistentType));
+ public void removeManagedType(OrmManagedType managedType) {
+ this.removeManagedType(this.managedTypes.indexOf(managedType));
}
- protected void initializePersistentTypes() {
- for (XmlTypeMapping xmlTypeMapping : this.getXmlTypeMappings()) {
- this.persistentTypes.add(this.buildPersistentType(xmlTypeMapping));
+ protected void initializeManagedTypes() {
+ for (XmlManagedType xmlManagedType : this.getXmlManagedTypes()) {
+ this.managedTypes.add(this.buildManagedType(xmlManagedType));
}
}
- protected void syncPersistentTypes() {
- ContextContainerTools.synchronizeWithResourceModel(this.persistentTypeContainerAdapter);
+ protected void syncManagedTypes() {
+ ContextContainerTools.synchronizeWithResourceModel(this.managedTypeContainerAdapter);
}
- protected Iterable<XmlTypeMapping> getXmlTypeMappings() {
+ protected Iterable<XmlManagedType> getXmlManagedTypes() {
// clone to reduce chance of concurrency problems
- return IterableTools.cloneLive(this.xmlEntityMappings.getTypeMappings());
+ return IterableTools.cloneLive(this.getXmlManagedTypes_());
}
- protected void movePersistentType_(int index, OrmPersistentType persistentType) {
- this.moveItemInList(index, persistentType, this.persistentTypes, PERSISTENT_TYPES_LIST);
+ // ********** managed types **********
+
+ protected List<XmlManagedType> getXmlManagedTypes_() {
+ // convert lists to arrays to *reduce* risk of ConcurrentModificationException
+ ArrayList<XmlManagedType> managedTypes = new ArrayList<XmlManagedType>();
+ CollectionTools.addAll(managedTypes, this.xmlEntityMappings.getMappedSuperclasses().toArray(EMPTY_XML_MANAGED_TYPE_ARRAY));
+ CollectionTools.addAll(managedTypes, this.xmlEntityMappings.getEntities().toArray(EMPTY_XML_MANAGED_TYPE_ARRAY));
+ CollectionTools.addAll(managedTypes, this.xmlEntityMappings.getEmbeddables().toArray(EMPTY_XML_MANAGED_TYPE_ARRAY));
+ if (this.isJpa2_1Compatible()) {
+ CollectionTools.addAll(managedTypes, this.getXml2_1Converters().toArray(EMPTY_XML_MANAGED_TYPE_ARRAY));
+ }
+ return managedTypes;
+ }
+
+ protected List<XmlConverter_2_1> getXml2_1Converters() {
+ return this.xmlEntityMappings.getConverters();
+ }
+
+ protected static final XmlManagedType[] EMPTY_XML_MANAGED_TYPE_ARRAY = new XmlManagedType[0];
+
+ protected void moveManagedType_(int index, OrmManagedType managedType) {
+ this.moveItemInList(index, managedType, this.managedTypes, MANAGED_TYPES_LIST);
}
- protected void addPersistentType_(int index, XmlTypeMapping xmlTypeMapping) {
- this.addItemToList(index, this.buildPersistentType(xmlTypeMapping), this.persistentTypes, PERSISTENT_TYPES_LIST);
+ protected void addManagedType_(int index, XmlManagedType xmlManagedType) {
+ this.addItemToList(index, this.buildManagedType(xmlManagedType), this.managedTypes, MANAGED_TYPES_LIST);
}
- protected void removePersistentType_(OrmPersistentType persistentType) {
- this.removePersistentType_(this.persistentTypes.indexOf(persistentType));
+ protected void removeManagedType_(OrmManagedType managedType) {
+ this.removeManagedType_(this.managedTypes.indexOf(managedType));
}
/**
- * persistent type container adapter
+ * managed type container adapter
*/
- protected class PersistentTypeContainerAdapter
- implements ContextContainerTools.Adapter<OrmPersistentType, XmlTypeMapping>
+ protected class ManagedTypeContainerAdapter
+ implements ContextContainerTools.Adapter<OrmManagedType, XmlManagedType>
{
- public Iterable<OrmPersistentType> getContextElements() {
- return AbstractEntityMappings.this.getPersistentTypes();
+ public Iterable<OrmManagedType> getContextElements() {
+ return AbstractEntityMappings.this.getManagedTypes();
}
- public Iterable<XmlTypeMapping> getResourceElements() {
- return AbstractEntityMappings.this.getXmlTypeMappings();
+ public Iterable<XmlManagedType> getResourceElements() {
+ return AbstractEntityMappings.this.getXmlManagedTypes();
}
- public XmlTypeMapping getResourceElement(OrmPersistentType contextElement) {
- return contextElement.getMapping().getXmlTypeMapping();
+ public XmlManagedType getResourceElement(OrmManagedType contextElement) {
+ return contextElement.getXmlManagedType();
}
- public void moveContextElement(int index, OrmPersistentType element) {
- AbstractEntityMappings.this.movePersistentType_(index, element);
+ public void moveContextElement(int index, OrmManagedType element) {
+ AbstractEntityMappings.this.moveManagedType_(index, element);
}
- public void addContextElement(int index, XmlTypeMapping resourceElement) {
- AbstractEntityMappings.this.addPersistentType_(index, resourceElement);
+ public void addContextElement(int index, XmlManagedType resourceElement) {
+ AbstractEntityMappings.this.addManagedType_(index, resourceElement);
}
- public void removeContextElement(OrmPersistentType element) {
- AbstractEntityMappings.this.removePersistentType_(element);
+ public void removeContextElement(OrmManagedType element) {
+ AbstractEntityMappings.this.removeManagedType_(element);
}
}
@@ -1048,6 +1111,45 @@ public abstract class AbstractEntityMappings
}
+ // ********** converter types **********
+
+ public Iterable<OrmConverterType2_1> getConverterTypes() {
+ return IterableTools.downCast(IterableTools.filter(
+ this.getManagedTypes(),
+ ORM_CONVERTER_TYPE_FILTER));
+ }
+
+ protected static final Filter<OrmManagedType> ORM_CONVERTER_TYPE_FILTER =
+ new Filter<OrmManagedType>() {
+ public boolean accept(OrmManagedType mt) {
+ return mt.getType() == OrmConverterType2_1.class;
+ }
+ };
+
+ public OrmConverterType2_1 getConverterType(String typeName) {
+ ManagedType mt = this.getManagedType(typeName);
+ if (mt != null && (mt.getType() == OrmPersistentType.class)) {
+ return (OrmConverterType2_1) mt;
+ }
+ return null;
+ }
+
+ public boolean containsConverterType(String typeName) {
+ return this.getConverterType(typeName) != null;
+ }
+
+ public OrmConverterType2_1 addConverterType(String className) {
+ return (OrmConverterType2_1) this.addManagedType(this.buildXmlConverter(), className);
+ }
+
+ protected XmlConverter_2_1 buildXmlConverter() {
+ return EmfTools.create(
+ this.getResourceNodeFactory(),
+ OrmPackage.eINSTANCE.getXmlConverter(),
+ XmlConverter_2_1.class);
+ }
+
+
// ********** query container **********
public OrmQueryContainer getQueryContainer() {
@@ -1103,8 +1205,8 @@ public abstract class AbstractEntityMappings
this.validateVersion(messages);
// generators are validated in the persistence unit
this.queryContainer.validate(messages, reporter);
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- this.validatePersistentType(ormPersistentType, messages, reporter);
+ for (OrmManagedType managedType : this.getManagedTypes()) {
+ this.validateManagedType(managedType, messages, reporter);
}
}
@@ -1132,9 +1234,9 @@ public abstract class AbstractEntityMappings
return XmlEntityMappings.CONTENT_TYPE;
}
- protected void validatePersistentType(OrmPersistentType persistentType, List<IMessage> messages, IReporter reporter) {
+ protected void validateManagedType(OrmManagedType managedType, List<IMessage> messages, IReporter reporter) {
try {
- persistentType.validate(messages, reporter);
+ managedType.validate(messages, reporter);
} catch (Throwable exception) {
JptJpaCorePlugin.instance().logError(exception);
}
@@ -1144,26 +1246,26 @@ public abstract class AbstractEntityMappings
// ********** refactoring **********
public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) {
- return IterableTools.children(this.getPersistentTypes(), new DeleteTypeRefactoringParticipant.DeleteTypeEditsTransformer(type));
+ return IterableTools.children(this.getManagedTypes(), new DeleteTypeRefactoringParticipant.DeleteTypeEditsTransformer(type));
}
public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return IterableTools.children(this.getPersistentTypes(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
+ return IterableTools.children(this.getManagedTypes(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
}
public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return IterableTools.children(this.getPersistentTypes(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
+ return IterableTools.children(this.getManagedTypes(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
}
@SuppressWarnings("unchecked")
public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
return IterableTools.concatenate(
- this.createPersistentTypeRenamePackageEdits(originalPackage, newName),
+ this.createManagedTypeRenamePackageEdits(originalPackage, newName),
this.createRenamePackageEdit(originalPackage, newName));
}
- protected Iterable<ReplaceEdit> createPersistentTypeRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return IterableTools.children(this.getPersistentTypes(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
+ protected Iterable<ReplaceEdit> createManagedTypeRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return IterableTools.children(this.getManagedTypes(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
}
protected Iterable<ReplaceEdit> createRenamePackageEdit(IPackageFragment originalPackage, String newName) {
@@ -1203,8 +1305,8 @@ public abstract class AbstractEntityMappings
if (this.packageTouches(pos)) {
return this.getCandidatePackages();
}
- for (OrmPersistentType persistentType : this.getPersistentTypes()) {
- result = persistentType.getCompletionProposals(pos);
+ for (OrmManagedType managedType : this.getManagedTypes()) {
+ result = managedType.getCompletionProposals(pos);
if (result != null) {
return result;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
index becb45d..de6f09b 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
@@ -300,7 +300,7 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
if (javaEntity != null) {
return javaEntity.getName();
}
- String className = this.getClass_();
+ String className = this.getPersistentType().getClass_();
return StringTools.isBlank(className) ? null : ClassNameTools.simpleName(className);
}
@@ -1744,7 +1744,7 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
JptJpaCoreValidationMessages.ENTITY_NAME_MISSING,
- new String[] {this.getClass_()},
+ new String[] {this.getPersistentType().getClass_()},
this,
this.getNameTextRange()
)
@@ -1756,7 +1756,6 @@ public abstract class AbstractOrmEntity<X extends XmlEntity>
return true;
}
- @Override
public TextRange getNameTextRange() {
return this.getXmlTypeMapping().getNameTextRange();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManagedType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManagedType.java
new file mode 100644
index 0000000..02528f1
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManagedType.java
@@ -0,0 +1,377 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.context.orm;
+
+import java.util.List;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.AstNodeType;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.ClassNameTools;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
+import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
+import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
+import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages;
+import org.eclipse.text.edits.DeleteEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.wst.validation.internal.provisional.core.IMessage;
+import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+
+/**
+ * specified <code>orm.xml</code> managed type:<ul>
+
+ * <li>Java managed type
+ * </ul>
+ */
+public abstract class AbstractOrmManagedType
+ extends AbstractOrmXmlContextNode
+ implements OrmManagedType {
+
+ protected XmlManagedType xmlManagedType;
+
+ protected String class_;
+
+ protected String name;
+
+ protected JavaManagedType javaManagedType;
+
+
+ protected AbstractOrmManagedType(EntityMappings parent, XmlManagedType xmlManagedType) {
+ super(parent);
+ this.xmlManagedType = xmlManagedType;
+ this.class_ = this.xmlManagedType.getClassName();
+ this.name = this.buildName();
+ // 'javaManagedType' is resolved in the update
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setClass_(this.xmlManagedType.getClassName());
+ this.setName(this.buildName());
+ this.syncJavaManagedType();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateJavaManagedType();
+ }
+
+ public XmlManagedType getXmlManagedType() {
+ return this.xmlManagedType;
+ }
+
+
+ // ********** class **********
+
+ public String getClass_() {
+ return this.class_;
+ }
+
+ public void setClass(String class_) {
+ this.setClass_(class_);
+ this.xmlManagedType.setClassName(class_);
+ }
+
+ protected void setClass_(String class_) {
+ String old = this.class_;
+ this.class_ = class_;
+ this.firePropertyChanged(CLASS_PROPERTY, old, class_);
+ }
+
+
+ // ********** name **********
+
+ public String getName() {
+ return this.name;
+ }
+
+ protected void setName(String name) {
+ String old = this.name;
+ this.name = name;
+ if (this.firePropertyChanged(NAME_PROPERTY, old, name)) {
+ // clear out the Java managed type here, it will be rebuilt during "update"
+ if (this.javaManagedType != null) {
+ this.setJavaManagedType(null);
+ }
+ }
+ }
+
+ protected String buildName() {
+ return this.getEntityMappings().qualify(this.class_);
+ }
+
+ public String getSimpleName(){
+ String className = this.getName();
+ return StringTools.isBlank(className) ? null : ClassNameTools.simpleName(className);
+ }
+
+ public String getTypeQualifiedName() {
+ String className = this.class_;
+ if (className == null) {
+ return null;
+ }
+ int lastPeriod = className.lastIndexOf('.');
+ className = (lastPeriod == -1) ? className : className.substring(lastPeriod + 1);
+ className = className.replace('$', '.');
+ return className;
+ }
+
+ protected TextRange getClassTextRange() {
+ return this.getValidationTextRange(this.getXmlManagedType().getClassTextRange());
+ }
+
+
+ // ********** Java managed type **********
+
+ public JavaManagedType getJavaManagedType() {
+ return this.javaManagedType;
+ }
+
+ protected void setJavaManagedType(JavaManagedType javaManagedType) {
+ ManagedType old = this.javaManagedType;
+ this.javaManagedType = javaManagedType;
+ this.firePropertyChanged(JAVA_MANAGED_TYPE_PROPERTY, old, javaManagedType);
+ }
+
+ /**
+ * If the managed type's name changes during <em>update</em>,
+ * the Java managed type will be cleared out in
+ * {@link #setName(String)}. If we get here and
+ * the Java managed type is present, we can
+ * <em>sync</em> it. In some circumstances it will be obsolete
+ * since the name is changed during update (the class name or
+ * the entity mapping's package affect the name)
+ *
+ * @see #updateJavaManagedType()
+ */
+ protected void syncJavaManagedType() {
+ if (this.javaManagedType != null) {
+ this.javaManagedType.synchronizeWithResourceModel();
+ }
+ }
+
+ /**
+ * @see #syncJavaManagedType()
+ */
+ protected void updateJavaManagedType() {
+ if (this.getName() == null) {
+ if (this.javaManagedType != null) {
+ this.setJavaManagedType(null);
+ }
+ }
+ else {
+ JavaResourceType resourceType = this.resolveJavaResourceType();
+ if (this.javaManagedType == null) {
+ this.setJavaManagedType(this.buildJavaManagedType(resourceType));
+ }
+ else {
+ // bug 379051 using == here because it is possible that the names are the same,
+ // but the location has changed: the java resource type has moved from "external"
+ // to part of the jpa project's jpa files.
+ if (this.javaManagedType.getJavaResourceType() == resourceType) {
+ this.javaManagedType.update();
+ } else {
+ this.setJavaManagedType(this.buildJavaManagedType(resourceType));
+ }
+ }
+ }
+ }
+
+ /**
+ * Return null it's an enum; don't build a JavaManagedType
+ * @see #updateJavaManagedType()
+ */
+ protected JavaResourceType resolveJavaResourceType() {
+ if (this.name == null) {
+ return null;
+ }
+ return (JavaResourceType) this.getJpaProject().getJavaResourceType(this.name, AstNodeType.TYPE);
+ }
+
+ protected abstract JavaManagedType buildJavaManagedType(JavaResourceType jrt);
+
+
+ public JavaResourceType getJavaResourceType() {
+ return (this.javaManagedType == null) ? null : this.javaManagedType.getJavaResourceType();
+ }
+
+ public TextRange getValidationTextRange() {
+ // this should never be null;
+ TextRange textRange = this.getXmlManagedType().getValidationTextRange();
+ //*return an Empty text range because validation sometimes run concurrently
+ //with the code adding the type mapping to xml; the IDOMNode might not
+ //be set when this is called. Brian's batch update changes in 3.2 should
+ //fix this problem. bug 358745
+ return (textRange != null) ? textRange : TextRange.Empty.instance();
+ }
+
+ public TextRange getFullTextRange() {
+ return this.getXmlManagedType().getFullTextRange();
+ }
+
+ public boolean containsOffset(int textOffset) {
+ return this.getXmlManagedType().containsOffset(textOffset);
+ }
+
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getCompletionProposals(int pos) {
+ Iterable<String> result = super.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ if (this.classNameTouches(pos)) {
+ return this.getCandidateClassNames();
+ }
+ return null;
+ }
+
+ protected Iterable<String> getCandidateClassNames() {
+ return MappingTools.getSortedJavaClassNames(this.getJavaProject());
+ }
+
+ protected boolean classNameTouches(int pos) {
+ return this.getXmlManagedType().classNameTouches(pos);
+ }
+
+
+ //*********** refactoring ***********
+
+ public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) {
+ return this.isFor(type.getFullyQualifiedName('.')) ?
+ IterableTools.singletonIterable(this.createDeleteTypeEdit()) :
+ IterableTools.<DeleteEdit>emptyIterable();
+ }
+
+ protected DeleteEdit createDeleteTypeEdit() {
+ return this.getXmlManagedType().createDeleteEdit();
+ }
+
+ public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
+ return this.isFor(originalType.getFullyQualifiedName('.')) ?
+ IterableTools.singletonIterable(this.createRenameTypeEdit(originalType, newName)) :
+ IterableTools.<ReplaceEdit>emptyIterable();
+ }
+
+ protected ReplaceEdit createRenameTypeEdit(IType originalType, String newName) {
+ return this.getXmlManagedType().createRenameTypeEdit(originalType, newName);
+ }
+
+ public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
+ return this.isFor(originalType.getFullyQualifiedName('.')) ?
+ IterableTools.singletonIterable(this.createRenamePackageEdit(newPackage.getElementName())) :
+ IterableTools.<ReplaceEdit>emptyIterable();
+ }
+
+ public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return this.isIn(originalPackage) ?
+ IterableTools.singletonIterable(this.createRenamePackageEdit(newName)) :
+ IterableTools.<ReplaceEdit>emptyIterable();
+ }
+
+ protected ReplaceEdit createRenamePackageEdit(String newName) {
+ return this.getXmlManagedType().createRenamePackageEdit(newName);
+ }
+
+
+ // ********** validation **********
+
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+ this.validateClass(messages);
+ }
+
+ protected void validateClass(List<IMessage> messages) {
+ if (StringTools.isBlank(this.class_)) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JptJpaCoreValidationMessages.MANAGED_TYPE_UNSPECIFIED_CLASS,
+ this,
+ this.getClassTextRange()
+ )
+ );
+ return;
+ }
+ this.validateClassResolves(messages);
+ }
+
+ protected void validateClassResolves(List<IMessage> messages) {
+ if (this.javaManagedType == null) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.HIGH_SEVERITY,
+ JptJpaCoreValidationMessages.MANAGED_TYPE_UNRESOLVED_CLASS,
+ new String[] {this.getName()},
+ this,
+ this.getClassTextRange()
+ )
+ );
+ }
+ }
+
+
+ // ********** misc **********
+
+ @Override
+ public EntityMappings getParent() {
+ return (EntityMappings) super.getParent();
+ }
+
+ protected EntityMappings getEntityMappings() {
+ return this.getParent();
+ }
+
+ public String getDefaultPackage() {
+ return this.getEntityMappings().getDefaultPersistentTypePackage();
+ }
+
+ public boolean isFor(String typeName) {
+ return ObjectTools.equals(typeName, this.getName());
+ }
+
+ public boolean isIn(IPackageFragment packageFragment) {
+ String packageName = this.getPackageName();
+ if (ObjectTools.equals(packageName, packageFragment.getElementName())) {
+ return true;
+ }
+ return false;
+ }
+
+ protected String getPackageName() {
+ String className = this.class_;
+ if (className == null) {
+ return null;
+ }
+ int lastPeriod = className.lastIndexOf('.');
+ return (lastPeriod == -1) ? this.getDefaultPackage() : className.substring(0, lastPeriod);
+ }
+
+ @Override
+ public void toString(StringBuilder sb) {
+ sb.append(this.getName());
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
index a3b1b77..34bc00a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
@@ -14,10 +14,8 @@ import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.iterable.FilteringIterable;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.Column;
import org.eclipse.jpt.jpa.core.context.Entity;
@@ -37,12 +35,9 @@ import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericTypeMappingValidator;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages;
import org.eclipse.jpt.jpa.db.Schema;
import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -57,8 +52,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
// never null
protected final X xmlTypeMapping;
- protected String class_;
-
protected Boolean specifiedMetadataComplete;
protected boolean overrideMetadataComplete;
@@ -69,7 +62,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
protected AbstractOrmTypeMapping(OrmPersistentType parent, X xmlTypeMapping) {
super(parent);
this.xmlTypeMapping = xmlTypeMapping;
- this.class_ = xmlTypeMapping.getClassName();
this.specifiedMetadataComplete = xmlTypeMapping.getMetadataComplete();
this.specifiedParentClass = this.buildSpecifiedParentClass();
}
@@ -80,7 +72,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.setClass_(this.xmlTypeMapping.getClassName());
this.setSpecifiedMetadataComplete_(this.xmlTypeMapping.getMetadataComplete());
this.setSpecifiedParentClass_(this.buildSpecifiedParentClass());
}
@@ -94,24 +85,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
}
- // ********** class **********
-
- public String getClass_() {
- return this.class_;
- }
-
- public void setClass(String class_) {
- this.setClass_(class_);
- this.xmlTypeMapping.setClassName(class_);
- }
-
- protected void setClass_(String class_) {
- String old = this.class_;
- this.class_ = class_;
- this.firePropertyChanged(CLASS_PROPERTY, old, class_);
- }
-
-
// ********** metadata complete **********
/**
@@ -283,7 +256,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
* mapping to the new (this).
*/
public void initializeFrom(OrmTypeMapping oldMapping) {
- this.setClass(oldMapping.getClass_());
this.setSpecifiedMetadataComplete(oldMapping.getSpecifiedMetadataComplete());
this.setOverrideMetadataComplete(oldMapping.isOverrideMetadataComplete());
}
@@ -435,57 +407,27 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
// ********** text ranges **********
- public JpaStructureNode getStructureNode(int offset) {
- return this.xmlTypeMapping.containsOffset(offset) ? this.getPersistentType() : null;
- }
-
public TextRange getSelectionTextRange() {
return this.xmlTypeMapping.getSelectionTextRange();
}
- public TextRange getClassTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getClassTextRange());
- }
-
public TextRange getAttributesTextRange() {
return this.getValidationTextRange(this.xmlTypeMapping.getAttributesTextRange());
}
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getNameTextRange());
- }
-
// ********** refactoring **********
- public DeleteEdit createDeleteEdit() {
- return this.xmlTypeMapping.createDeleteEdit();
- }
-
public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return this.getPersistentType().isFor(originalType.getFullyQualifiedName('.')) ?
- IterableTools.singletonIterable(this.createRenameTypeEdit(originalType, newName)) :
- IterableTools.<ReplaceEdit>emptyIterable();
- }
-
- protected ReplaceEdit createRenameTypeEdit(IType originalType, String newName) {
- return this.xmlTypeMapping.createRenameTypeEdit(originalType, newName);
+ return IterableTools.<ReplaceEdit>emptyIterable();
}
public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.getPersistentType().isFor(originalType.getFullyQualifiedName('.')) ?
- IterableTools.singletonIterable(this.createRenamePackageEdit(newPackage.getElementName())) :
- IterableTools.<ReplaceEdit>emptyIterable();
+ return IterableTools.<ReplaceEdit>emptyIterable();
}
public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.getPersistentType().isIn(originalPackage) ?
- IterableTools.singletonIterable(this.createRenamePackageEdit(newName)) :
- IterableTools.<ReplaceEdit>emptyIterable();
- }
-
- protected ReplaceEdit createRenamePackageEdit(String newName) {
- return this.xmlTypeMapping.createRenamePackageEdit(newName);
+ return IterableTools.<ReplaceEdit>emptyIterable();
}
@@ -505,17 +447,6 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
}
protected void validateClass(List<IMessage> messages, IReporter reporter) {
- if (StringTools.isBlank(this.class_)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JptJpaCoreValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS,
- this,
- this.getClassTextRange()
- )
- );
- return;
- }
if (this.getJavaResourceType() != null) {
this.buildTypeMappingValidator().validate(messages, reporter);
}
@@ -534,35 +465,11 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
}
public TextRange getValidationTextRange() {
- // this should never be null; also, the persistent type delegates
- // to here, so don't delegate back to it (or we will get a stack overflow) bug 355415
- TextRange textRange = this.xmlTypeMapping.getValidationTextRange();
- //*return an Empty text range because validation sometimes run concurrently
- //with the code adding the type mapping to xml; the IDOMNode might not
- //be set when this is called. Brian's batch update changes in 3.2 should
- //fix this problem. bug 358745
- return (textRange != null) ? textRange : TextRange.Empty.instance();
- }
-
- // ********** completion proposals **********
-
- @Override
- public Iterable<String> getCompletionProposals(int pos) {
- Iterable<String> result = super.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- if (this.classNameTouches(pos)) {
- return this.getCandidateClassNames();
- }
- return null;
+ return this.getPersistentType().getValidationTextRange();
}
protected Iterable<String> getCandidateClassNames() {
return MappingTools.getSortedJavaClassNames(this.getJavaProject());
}
- protected boolean classNameTouches(int pos) {
- return this.getXmlTypeMapping().classNameTouches(pos);
- }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java
index 9e513dd..7096ae8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,7 +17,9 @@ import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
import org.eclipse.jpt.jpa.core.internal.context.AbstractJpaContextNode;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_0Definition;
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_1Definition;
import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmXml2_1ContextNodeFactory;
/**
* Use this abstract class for context nodes that are part of an
@@ -56,6 +58,10 @@ public abstract class AbstractOrmXmlContextNode
return this.getResourceType().isKindOf(GenericOrmXml2_0Definition.instance().getResourceType());
}
+ protected boolean isOrmXml2_1Compatible() {
+ return this.getResourceType().isKindOf(GenericOrmXml2_1Definition.instance().getResourceType());
+ }
+
/**
* Call {@link #isOrmXml2_0Compatible()} before calling this method.
*/
@@ -63,6 +69,13 @@ public abstract class AbstractOrmXmlContextNode
return (OrmXml2_0ContextNodeFactory) this.getContextNodeFactory();
}
+ /**
+ * Call {@link #isOrmXml2_1Compatible()} before calling this method.
+ */
+ protected OrmXml2_1ContextNodeFactory getContextNodeFactory2_1() {
+ return (OrmXml2_1ContextNodeFactory) this.getContextNodeFactory();
+ }
+
protected OrmXmlContextNodeFactory getContextNodeFactory() {
return this.getMappingFileDefinition().getContextNodeFactory();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java
index 3b492ec..ccf3ad4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -16,10 +16,12 @@ import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
import org.eclipse.jpt.jpa.core.context.orm.UnsupportedOrmAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
/**
* All the state in the definition should be "static"
@@ -30,6 +32,8 @@ public abstract class AbstractOrmXmlDefinition
{
protected final OrmXmlContextNodeFactory factory;
+ protected ArrayList<OrmManagedTypeDefinition> managedTypeDefinitions;
+
protected ArrayList<OrmTypeMappingDefinition> typeMappingDefinitions;
protected ArrayList<OrmAttributeMappingDefinition> attributeMappingDefinitions;
@@ -52,6 +56,47 @@ public abstract class AbstractOrmXmlDefinition
return this.factory;
}
+ // ********** managed type definitions **********
+
+ public OrmManagedTypeDefinition getManagedTypeDefinition(Class<? extends XmlManagedType> resourceType) {
+ for (OrmManagedTypeDefinition definition : this.getManagedTypeDefinitions()) {
+ if (definition.getResourceType() == resourceType) {
+ return definition;
+ }
+ }
+ throw new IllegalArgumentException("Illegal managed type resource type: " + resourceType); //$NON-NLS-1$
+ }
+
+ /**
+ * Return a list of mapping definitions to use for types in
+ * <code>orm.xml</code> mapping files.
+ * The order is unimportant.
+ */
+ protected synchronized ArrayList<OrmManagedTypeDefinition> getManagedTypeDefinitions() {
+ if (this.managedTypeDefinitions == null) {
+ this.managedTypeDefinitions = this.buildManagedTypeDefinitions();
+ }
+ return this.managedTypeDefinitions;
+ }
+
+ protected ArrayList<OrmManagedTypeDefinition> buildManagedTypeDefinitions() {
+ ArrayList<OrmManagedTypeDefinition> definitions = new ArrayList<OrmManagedTypeDefinition>();
+ this.addManagedTypeDefinitionsTo(definitions);
+ return definitions;
+ }
+
+ protected void addManagedTypeDefinitionsTo(ArrayList<OrmManagedTypeDefinition> definitions) {
+ CollectionTools.addAll(definitions, MANAGED_TYPE_DEFINITIONS);
+ }
+
+ /**
+ * Order should not matter here; but we'll use the same order as for Java.
+ * @see org.eclipse.jpt.jpa.core.internal.GenericJpaPlatformProvider
+ */
+ protected static final OrmManagedTypeDefinition[] MANAGED_TYPE_DEFINITIONS = new OrmManagedTypeDefinition[] {
+ OrmPersistentTypeDefinition.instance(),
+ };
+
// ********** type mapping definitions **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentTypeDefinition.java
new file mode 100644
index 0000000..c3de65c
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentTypeDefinition.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
+
+public class OrmPersistentTypeDefinition
+ implements OrmManagedTypeDefinition
+{
+ // singleton
+ private static final OrmManagedTypeDefinition INSTANCE = new OrmPersistentTypeDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static OrmManagedTypeDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Enforce singleton usage
+ */
+ private OrmPersistentTypeDefinition() {
+ super();
+ }
+
+ public Class<? extends OrmPersistentType> getContextType() {
+ return OrmPersistentType.class;
+ }
+
+ public Class<? extends XmlManagedType> getResourceType() {
+ return XmlTypeMapping.class;
+ }
+
+ public OrmManagedType buildContextManagedType(JpaContextNode parent, XmlManagedType resourceManagedType, OrmXmlContextNodeFactory factory) {
+ return factory.buildOrmPersistentType((EntityMappings) parent, (XmlTypeMapping) resourceManagedType);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
index eac7b8d..1aeb24c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentType.java
@@ -28,9 +28,7 @@ import org.eclipse.jpt.common.core.utility.BodySourceWriter;
import org.eclipse.jpt.common.core.utility.TextRange;
import org.eclipse.jpt.common.core.utility.jdt.TypeBinding;
import org.eclipse.jpt.common.utility.filter.Filter;
-import org.eclipse.jpt.common.utility.internal.ClassNameTools;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.common.utility.internal.collection.ListTools;
import org.eclipse.jpt.common.utility.internal.filter.FilterAdapter;
@@ -45,6 +43,7 @@ import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
@@ -58,15 +57,13 @@ import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentType;
import org.eclipse.jpt.jpa.core.internal.context.java.PropertyAccessor;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelSourceType;
import org.eclipse.jpt.jpa.core.jpa2.context.PersistentType2_0;
import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages;
-import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -81,15 +78,11 @@ import org.eclipse.wst.validation.internal.provisional.core.IReporter;
* </ul>
*/
public abstract class SpecifiedOrmPersistentType
- extends AbstractOrmXmlContextNode
+ extends AbstractOrmManagedType
implements OrmPersistentType, PersistentType2_0 {
protected OrmTypeMapping mapping; // never null
- protected String name;
-
- protected JavaPersistentType javaPersistentType;
-
protected AccessType specifiedAccess;
protected AccessType defaultAccess; // never null
@@ -108,10 +101,8 @@ public abstract class SpecifiedOrmPersistentType
protected SpecifiedOrmPersistentType(EntityMappings parent, XmlTypeMapping xmlTypeMapping) {
- super(parent);
+ super(parent, xmlTypeMapping);
this.mapping = this.buildMapping(xmlTypeMapping);
- this.name = this.buildName();
- // 'javaPersistentType' is resolved in the update
this.specifiedAccess = this.buildSpecifiedAccess();
this.defaultAccess = AccessType.FIELD; // keep this non-null
this.initializeSpecifiedAttributes();
@@ -126,8 +117,6 @@ public abstract class SpecifiedOrmPersistentType
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
this.mapping.synchronizeWithResourceModel();
- this.setName(this.buildName());
- this.syncJavaPersistentType();
this.setSpecifiedAccess_(this.buildSpecifiedAccess());
this.syncSpecifiedAttributes();
this.synchronizeNodesWithResourceModel(this.getDefaultAttributes());
@@ -137,7 +126,6 @@ public abstract class SpecifiedOrmPersistentType
public void update() {
super.update();
this.mapping.update();
- this.updateJavaPersistentType();
this.setDefaultAccess(this.buildDefaultAccess());
this.updateNodes(this.getSpecifiedAttributes());
this.updateDefaultAttributes();
@@ -146,10 +134,9 @@ public abstract class SpecifiedOrmPersistentType
this.updateChildren();
}
- public void gatherRootStructureNodes(JpaFile jpaFile, Collection<JpaStructureNode> rootStructureNodes) {
- if (this.javaPersistentType != null) {
- this.javaPersistentType.gatherRootStructureNodes(jpaFile, rootStructureNodes);
- }
+ @Override
+ public XmlTypeMapping getXmlManagedType() {
+ return (XmlTypeMapping) super.getXmlManagedType();
}
@@ -172,8 +159,10 @@ public abstract class SpecifiedOrmPersistentType
protected void setMappingKey_(String mappingKey) {
OrmTypeMapping old = this.mapping;
OrmTypeMappingDefinition mappingDefinition = this.getMappingFileDefinition().getTypeMappingDefinition(mappingKey);
- XmlTypeMapping xmlTypeMapping = mappingDefinition.buildResourceMapping(this.getResourceNodeFactory());
- this.mapping = this.buildMapping(xmlTypeMapping);
+ String className = this.getClass_();
+ this.xmlManagedType = mappingDefinition.buildResourceMapping(this.getResourceNodeFactory());
+ this.xmlManagedType.setClassName(className);
+ this.mapping = this.buildMapping(this.getXmlTypeMapping());
this.getEntityMappings().changeMapping(this, old, this.mapping);
this.firePropertyChanged(MAPPING_PROPERTY, old, this.mapping);
}
@@ -184,7 +173,7 @@ public abstract class SpecifiedOrmPersistentType
}
protected XmlTypeMapping getXmlTypeMapping() {
- return this.mapping.getXmlTypeMapping();
+ return this.getXmlManagedType();
}
public boolean isMapped() {
@@ -192,115 +181,14 @@ public abstract class SpecifiedOrmPersistentType
}
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- if (this.firePropertyChanged(NAME_PROPERTY, old, name)) {
- // clear out the Java persistent type here, it will be rebuilt during "update"
- if (this.javaPersistentType != null) {
- this.setJavaPersistentType(null);
- }
- }
- }
-
- protected String buildName() {
- return this.getEntityMappings().qualify(this.getMappingClassName());
- }
-
- public String getSimpleName(){
- String className = this.getName();
- return StringTools.isBlank(className) ? null : ClassNameTools.simpleName(className);
- }
-
- public String getTypeQualifiedName() {
- String className = this.getMappingClassName();
- if (className == null) {
- return null;
- }
- int lastPeriod = className.lastIndexOf('.');
- className = (lastPeriod == -1) ? className : className.substring(lastPeriod + 1);
- className = className.replace('$', '.');
- return className;
- }
-
- protected String getMappingClassName() {
- return this.mapping.getClass_();
- }
-
// ********** Java persistent type **********
public JavaPersistentType getJavaPersistentType() {
- return this.javaPersistentType;
- }
-
- protected void setJavaPersistentType(JavaPersistentType javaPersistentType) {
- JavaPersistentType old = this.javaPersistentType;
- this.javaPersistentType = javaPersistentType;
- this.firePropertyChanged(JAVA_PERSISTENT_TYPE_PROPERTY, old, javaPersistentType);
+ return (JavaPersistentType) super.getJavaManagedType();
}
- /**
- * If the persistent type's name changes during <em>update</em>,
- * the Java persistent type will be cleared out in
- * {@link #setName(String)}. If we get here and
- * the Java persistent type is present, we can
- * <em>sync</em> it. In some circumstances it will be obsolete
- * since the name is changed during update (the mapping class name or
- * the entity mapping's package affect the name)
- *
- * @see #updateJavaPersistentType()
- */
- protected void syncJavaPersistentType() {
- if (this.javaPersistentType != null) {
- this.javaPersistentType.synchronizeWithResourceModel();
- }
- }
-
- /**
- * @see #syncJavaPersistentType()
- */
- protected void updateJavaPersistentType() {
- if (this.getName() == null) {
- if (this.javaPersistentType != null) {
- this.setJavaPersistentType(null);
- }
- }
- else {
- JavaResourceType resourceType = this.resolveJavaResourceType();
- if (this.javaPersistentType == null) {
- this.setJavaPersistentType(this.buildJavaPersistentType(resourceType));
- }
- else {
- // bug 379051 using == here because it is possible that the names are the same,
- // but the location has changed: the java resource type has moved from "external"
- // to part of the jpa project's jpa files.
- if (this.javaPersistentType.getJavaResourceType() == resourceType) {
- this.javaPersistentType.update();
- } else {
- this.setJavaPersistentType(this.buildJavaPersistentType(resourceType));
- }
- }
- }
- }
-
- /**
- * Return null it's an enum; don't build a JavaPersistentType
- * @see #updateJavaPersistentType()
- */
- protected JavaResourceType resolveJavaResourceType() {
- if (this.name == null) {
- return null;
- }
- return (JavaResourceType) this.getJpaProject().getJavaResourceType(this.name, AstNodeType.TYPE);
- }
-
- protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrt) {
+ @Override
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) {
return jrt != null ? this.getJpaFactory().buildJavaPersistentType(this, jrt) : null;
}
@@ -342,9 +230,9 @@ public abstract class SpecifiedOrmPersistentType
protected AccessType buildDefaultAccess() {
if ( ! this.mapping.isMetadataComplete()) {
- if (this.javaPersistentType != null) {
+ if (this.getJavaPersistentType() != null) {
if (this.javaPersistentTypeHasSpecifiedAccess()) {
- return this.javaPersistentType.getAccess();
+ return this.getJavaPersistentType().getAccess();
}
}
if (this.superPersistentType != null) {
@@ -359,8 +247,8 @@ public abstract class SpecifiedOrmPersistentType
* pre-condition: {@link #javaPersistentType} is not <code>null</code>
*/
protected boolean javaPersistentTypeHasSpecifiedAccess() {
- return (this.javaPersistentType.getSpecifiedAccess() != null) ||
- this.javaPersistentType.hasAnyAnnotatedAttributes();
+ return (this.getJavaPersistentType().getSpecifiedAccess() != null) ||
+ this.getJavaPersistentType().hasAnyAnnotatedAttributes();
}
public AccessType getOwnerOverrideAccess() {
@@ -419,7 +307,7 @@ public abstract class SpecifiedOrmPersistentType
}
public TypeBinding getAttributeTypeBinding(ReadOnlyPersistentAttribute attribute) {
- return (this.javaPersistentType == null) ? null : this.javaPersistentType.getAttributeTypeBinding(attribute);
+ return (this.getJavaPersistentType() == null) ? null : this.getJavaPersistentType().getAttributeTypeBinding(attribute);
}
@@ -908,10 +796,6 @@ public abstract class SpecifiedOrmPersistentType
};
}
- protected JavaResourceType getJavaResourceType() {
- return (this.javaPersistentType == null) ? null : this.javaPersistentType.getJavaResourceType();
- }
-
/**
* Return the access type that determines which Java attributes are to be
* used for the <code>orm.xml</code> type's <em>default</em> attributes.
@@ -923,7 +807,7 @@ public abstract class SpecifiedOrmPersistentType
if (this.mapping.isMetadataComplete()) {
return this.defaultAccess;
}
- AccessType javaAccess = this.javaPersistentType == null ? null : this.javaPersistentType.getSpecifiedAccess();
+ AccessType javaAccess = this.getJavaPersistentType() == null ? null : this.getJavaPersistentType().getSpecifiedAccess();
return (javaAccess != null) ? javaAccess : this.defaultAccess;
}
@@ -1023,7 +907,7 @@ public abstract class SpecifiedOrmPersistentType
}
protected PersistentType buildSuperPersistentType_() {
- return (this.javaPersistentType == null) ? null : this.javaPersistentType.getSuperPersistentType();
+ return (this.getJavaPersistentType() == null) ? null : this.getJavaPersistentType().getSuperPersistentType();
}
@@ -1060,8 +944,8 @@ public abstract class SpecifiedOrmPersistentType
}
protected String buildDeclaringTypeName_() {
- return (this.javaPersistentType == null) ?
- null : ((PersistentType2_0) this.javaPersistentType).getDeclaringTypeName();
+ return (this.getJavaPersistentType() == null) ?
+ null : ((PersistentType2_0) this.getJavaPersistentType()).getDeclaringTypeName();
}
@@ -1074,7 +958,7 @@ public abstract class SpecifiedOrmPersistentType
}
public IFile getMetamodelFile() {
- return (this.javaPersistentType == null) ? null : this.metamodelSynchronizer.getFile();
+ return (this.getJavaPersistentType() == null) ? null : this.metamodelSynchronizer.getFile();
}
public void initializeMetamodel() {
@@ -1090,13 +974,13 @@ public abstract class SpecifiedOrmPersistentType
* because 1.0 <code>orm.xml</code> files can be referenced from 2.0 persistence.xml files.
*/
public void synchronizeMetamodel(Map<String, Collection<MetamodelSourceType>> memberTypeTree) {
- if (this.javaPersistentType != null) {
+ if (this.getJavaPersistentType() != null) {
this.metamodelSynchronizer.synchronize(memberTypeTree);
}
}
public void printBodySourceOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType>> memberTypeTree) {
- if (this.javaPersistentType != null) {
+ if (this.getJavaPersistentType() != null) {
this.metamodelSynchronizer.printBodySourceOn(pw, memberTypeTree);
}
}
@@ -1110,6 +994,21 @@ public abstract class SpecifiedOrmPersistentType
}
+ // ********** OrmManagedType implementation **********
+
+ public int getXmlSequence() {
+ return this.getMapping().getXmlSequence();
+ }
+
+ public void addXmlManagedTypeTo(XmlEntityMappings entityMappings) {
+ this.getMapping().addXmlTypeMappingTo(entityMappings);
+ }
+
+ public void removeXmlManagedTypeFrom(XmlEntityMappings entityMappings) {
+ this.getMapping().removeXmlTypeMappingFrom(entityMappings);
+ }
+
+
// ********** JpaStructureNode implementation **********
public ContextType getContextType() {
@@ -1120,6 +1019,12 @@ public abstract class SpecifiedOrmPersistentType
return OrmPersistentType.class;
}
+ public void gatherRootStructureNodes(JpaFile jpaFile, Collection<JpaStructureNode> rootStructureNodes) {
+ if (this.getJavaPersistentType() != null) {
+ this.getJavaPersistentType().gatherRootStructureNodes(jpaFile, rootStructureNodes);
+ }
+ }
+
protected void initializeChildren() {
this.children.addAll(this.specifiedAttributes); //defaultAttributes haven't been built yet
}
@@ -1139,12 +1044,9 @@ public abstract class SpecifiedOrmPersistentType
return this.children.size();
}
- public TextRange getFullTextRange() {
- return this.getXmlTypeMapping().getFullTextRange();
- }
- public boolean containsOffset(int textOffset) {
- return this.getXmlTypeMapping().containsOffset(textOffset);
+ public TextRange getSelectionTextRange() {
+ return this.mapping.getSelectionTextRange();
}
public JpaStructureNode getStructureNode(int textOffset) {
@@ -1156,10 +1058,6 @@ public abstract class SpecifiedOrmPersistentType
return this;
}
- public TextRange getSelectionTextRange() {
- return this.mapping.getSelectionTextRange();
- }
-
public void dispose() {
for (OrmReadOnlyPersistentAttribute defaultAttribute : this.getDefaultAttributes()) {
defaultAttribute.dispose();
@@ -1206,15 +1104,11 @@ public abstract class SpecifiedOrmPersistentType
//*********** refactoring ***********
- public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) {
- return this.isFor(type.getFullyQualifiedName('.')) ?
- IterableTools.singletonIterable(this.mapping.createDeleteEdit()) :
- IterableTools.<DeleteEdit>emptyIterable();
- }
-
+ @Override
@SuppressWarnings("unchecked")
public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
return IterableTools.concatenate(
+ super.createRenameTypeEdits(originalType, newName),
this.mapping.createRenameTypeEdits(originalType, newName),
this.createSpecifiedAttributesRenameTypeEdits(originalType, newName)
);
@@ -1224,9 +1118,11 @@ public abstract class SpecifiedOrmPersistentType
return IterableTools.children(this.getSpecifiedAttributes(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
}
+ @Override
@SuppressWarnings("unchecked")
public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
return IterableTools.concatenate(
+ super.createMoveTypeEdits(originalType, newPackage),
this.mapping.createMoveTypeEdits(originalType, newPackage),
this.createSpecifiedAttributesMoveTypeEdits(originalType, newPackage)
);
@@ -1236,9 +1132,11 @@ public abstract class SpecifiedOrmPersistentType
return IterableTools.children(this.getSpecifiedAttributes(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
}
+ @Override
@SuppressWarnings("unchecked")
public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
return IterableTools.concatenate(
+ super.createRenamePackageEdits(originalPackage, newName),
this.mapping.createRenamePackageEdits(originalPackage, newName),
this.createSpecifiedAttributesRenamePackageEdits(originalPackage, newName)
);
@@ -1254,25 +1152,10 @@ public abstract class SpecifiedOrmPersistentType
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
- this.validateClass(messages);
this.validateMapping(messages, reporter);
this.validateAttributes(messages, reporter);
}
- protected void validateClass(List<IMessage> messages) {
- if (this.javaPersistentType == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JptJpaCoreValidationMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS,
- new String[] {this.getName()},
- this,
- this.mapping.getClassTextRange()
- )
- );
- }
- }
-
protected void validateMapping(List<IMessage> messages, IReporter reporter) {
try {
this.mapping.validate(messages, reporter);
@@ -1295,10 +1178,6 @@ public abstract class SpecifiedOrmPersistentType
}
}
- public TextRange getValidationTextRange() {
- return this.mapping.getValidationTextRange();
- }
-
// ********** completion proposals **********
@Override
@@ -1320,48 +1199,10 @@ public abstract class SpecifiedOrmPersistentType
return null;
}
- // ********** misc **********
-
- @Override
- public EntityMappings getParent() {
- return (EntityMappings) super.getParent();
- }
-
- protected EntityMappings getEntityMappings() {
- return this.getParent();
- }
-
- public String getDefaultPackage() {
- return this.getEntityMappings().getDefaultPersistentTypePackage();
- }
-
- public boolean isFor(String typeName) {
- return ObjectTools.equals(typeName, this.getName());
- }
-
- public boolean isIn(IPackageFragment packageFragment) {
- String packageName = this.getPackageName();
- if (ObjectTools.equals(packageName, packageFragment.getElementName())) {
- return true;
- }
- return false;
- }
- protected String getPackageName() {
- String className = this.getMappingClassName();
- if (className == null) {
- return null;
- }
- int lastPeriod = className.lastIndexOf('.');
- return (lastPeriod == -1) ? this.getDefaultPackage() : className.substring(0, lastPeriod);
- }
+ // ********** misc **********
public PersistentType getOverriddenPersistentType() {
- return this.mapping.isMetadataComplete() ? null : this.javaPersistentType;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
+ return this.mapping.isMetadataComplete() ? null : this.getJavaPersistentType();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
index 6625e55..256144f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
@@ -24,9 +24,9 @@ import org.eclipse.jpt.common.utility.internal.iterable.EmptyIterable;
import org.eclipse.jpt.common.utility.internal.iterable.SingleElementIterable;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JarFile;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
@@ -299,15 +299,26 @@ public abstract class AbstractJarFileRef
return this.xmlJarFileRef;
}
+
+ // ********** PersistentTypeContainer implementation **********
+
+ public Iterable<? extends PersistentType> getPersistentTypes() {
+ return (this.jarFile != null) ? this.jarFile.getPersistentTypes() : EmptyIterable.<PersistentType>instance();
+ }
+
public PersistentType getPersistentType(String typeName) {
return (this.jarFile == null) ? null : this.jarFile.getPersistentType(typeName);
}
- // ********** PersistentTypeContainer implementation **********
+ // ********** ManagedTypeContainer implementation **********
- public Iterable<? extends PersistentType> getPersistentTypes() {
- return (this.jarFile != null) ? this.jarFile.getPersistentTypes() : EmptyIterable.<JavaPersistentType>instance();
+ public Iterable<? extends ManagedType> getManagedTypes() {
+ return (this.jarFile != null) ? this.jarFile.getManagedTypes() : EmptyIterable.<ManagedType>instance();
+ }
+
+ public ManagedType getManagedType(String typeName) {
+ return (this.jarFile == null) ? null : this.jarFile.getManagedType(typeName);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java
index 7fca53e..1b774ee 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java
@@ -23,6 +23,7 @@ import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.Generator;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.MappingFile;
import org.eclipse.jpt.jpa.core.context.MappingFilePersistenceUnitMetadata;
import org.eclipse.jpt.jpa.core.context.PersistentType;
@@ -247,16 +248,24 @@ public abstract class AbstractMappingFileRef<MF extends MappingFile>
return (PersistenceUnit) super.getParent();
}
+ public Iterable<? extends PersistentType> getPersistentTypes() {
+ return (this.mappingFile != null) ? this.mappingFile.getPersistentTypes() : EmptyIterable.<PersistentType>instance();
+ }
+
+ public Iterable<? extends ManagedType> getManagedTypes() {
+ return (this.mappingFile != null) ? this.mappingFile.getManagedTypes() : EmptyIterable.<ManagedType>instance();
+ }
+
+ public ManagedType getManagedType(String typeName) {
+ return (this.mappingFile == null) ? null : this.mappingFile.getManagedType(typeName);
+ }
+
@Override
public void toString(StringBuilder sb) {
super.toString(sb);
sb.append(this.fileName);
}
- public Iterable<? extends PersistentType> getPersistentTypes() {
- return (this.mappingFile != null) ? this.mappingFile.getPersistentTypes() : EmptyIterable.<PersistentType>instance();
- }
-
// ********** validation **********
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
index cf1ffae..18db7b4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
@@ -37,6 +37,7 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceNode;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.BodySourceWriter;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.filter.Filter;
import org.eclipse.jpt.common.utility.internal.ObjectTools;
import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
@@ -61,6 +62,7 @@ import org.eclipse.jpt.jpa.core.context.Embeddable;
import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.Generator;
import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.MappingFile;
import org.eclipse.jpt.jpa.core.context.MappingFilePersistenceUnitDefaults;
import org.eclipse.jpt.jpa.core.context.MappingFilePersistenceUnitMetadata;
@@ -70,13 +72,16 @@ import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.java.JavaGenerator;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.ManagedTypeContainer;
import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRefactoringParticipant;
import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
@@ -140,9 +145,9 @@ public abstract class AbstractPersistenceUnit
* Use with caution since this contains no duplicates (e.g. class is listed in 2 different mappings files)
* Rebuilt at the *beginning* of {@link #update()}
*
- * @see #rebuildPersistentTypeMap()
+ * @see #rebuildManagedTypeMap()
*/
- protected final Hashtable<String, PersistentType> persistentTypeMap = new Hashtable<String, PersistentType>();
+ protected final Hashtable<String, ManagedType> managedTypeMap = new Hashtable<String, ManagedType>();
protected final ContextListContainer<MappingFileRef, XmlMappingFileRef> specifiedMappingFileRefContainer;
@@ -267,9 +272,9 @@ public abstract class AbstractPersistenceUnit
public void update() {
super.update();
- //Rebuild the persistent type map first. I *think* if anything changes to cause
+ //Rebuild the managed type map first. I *think* if anything changes to cause
//this to be out of sync another update would be triggered by that change.
- this.rebuildPersistentTypeMap();
+ this.rebuildManagedTypeMap();
this.setDefaultTransactionType(this.buildDefaultTransactionType());
@@ -562,7 +567,7 @@ public abstract class AbstractPersistenceUnit
}
@Override
public boolean accept(MappingFileRef mappingFileRef) {
- return mappingFileRef.getPersistentType(this.typeName) != null;
+ return mappingFileRef.getManagedType(this.typeName) != null;
}
}
@@ -951,19 +956,19 @@ public abstract class AbstractPersistenceUnit
/**
* Return the names of all the Java classes in the JPA project that are
- * mapped (i.e. have the appropriate annotation etc.) but not specified
+ * managed (i.e. have the appropriate annotation etc.) but not specified
* in the persistence unit or any of its mapping files.
*/
protected Iterable<JavaResourceAbstractType> getImpliedClassResourceTypes_() {
- return IterableTools.filter(this.getJpaProject().getMappedJavaSourceTypes(), new SpecifiesPersistentType());
+ return IterableTools.filter(this.getJpaProject().getPotentialJavaSourceTypes(), new SpecifiesManagedType());
}
- public class SpecifiesPersistentType
+ public class SpecifiesManagedType
extends FilterAdapter<JavaResourceAbstractType>
{
@Override
public boolean accept(JavaResourceAbstractType jrat) {
- return ! AbstractPersistenceUnit.this.specifiesPersistentType(jrat.getTypeBinding().getQualifiedName());
+ return ! AbstractPersistenceUnit.this.specifiesManagedType(jrat.getTypeBinding().getQualifiedName());
}
}
@@ -1680,83 +1685,83 @@ public abstract class AbstractPersistenceUnit
}
- // ********** persistent types **********
+ // ********** managed types **********
@SuppressWarnings("unchecked")
- public Iterable<PersistentType> getPersistentTypes() {
+ public Iterable<ManagedType> getManagedTypes() {
return IterableTools.concatenate(
- this.getMappingFilePersistentTypes(),
- this.getClassRefPersistentTypes(),
- this.getJarFilePersistentTypes()
+ this.getMappingFileManagedTypes(),
+ this.getClassRefManagedTypes(),
+ this.getJarFileManagedTypes()
);
}
- protected Iterable<PersistentType> getMappingFilePersistentTypes() {
- return IterableTools.children(this.getMappingFileRefs(), PersistentTypeContainer.TRANSFORMER);
+ protected Iterable<ManagedType> getMappingFileManagedTypes() {
+ return IterableTools.children(this.getMappingFileRefs(), ManagedTypeContainer.TRANSFORMER);
}
@SuppressWarnings("unchecked")
- public Iterable<PersistentType> getJavaPersistentTypes() {
+ public Iterable<ManagedType> getJavaManagedTypes() {
return IterableTools.concatenate(
- this.getClassRefPersistentTypes(),
- this.getJarFilePersistentTypes()
+ this.getClassRefManagedTypes(),
+ this.getJarFileManagedTypes()
);
}
/**
- * Return the non-<code>null</code> class ref persistent types,
+ * Return the non-<code>null</code> class ref managed types,
* both specified and implied.
*/
- protected Iterable<PersistentType> getClassRefPersistentTypes() {
- return IterableTools.removeNulls(this.getClassRefPersistentTypes_());
+ protected Iterable<ManagedType> getClassRefManagedTypes() {
+ return IterableTools.removeNulls(this.getClassRefManagedTypes_());
}
/**
* Both specified and implied. May contain <code>null</code>s.
- * @see #getClassRefPersistentTypes()
+ * @see #getClassRefManagedTypes()
*/
- protected Iterable<PersistentType> getClassRefPersistentTypes_() {
- return IterableTools.transform(this.getClassRefs(), CLASS_REF_PERSISTENT_TYPE_TRANSFORMER);
+ protected Iterable<ManagedType> getClassRefManagedTypes_() {
+ return IterableTools.transform(this.getClassRefs(), CLASS_REF_MANAGED_TYPE_TRANSFORMER);
}
- protected static final Transformer<ClassRef, PersistentType> CLASS_REF_PERSISTENT_TYPE_TRANSFORMER = TransformerTools.superTransformer(ClassRef.JAVA_PERSISTENT_TYPE_TRANSFORMER);
+ protected static final Transformer<ClassRef, ManagedType> CLASS_REF_MANAGED_TYPE_TRANSFORMER = TransformerTools.superTransformer(ClassRef.JAVA_MANAGED_TYPE_TRANSFORMER);
/**
* We only get <em>annotated</em> types from jar files.
*/
- protected Iterable<PersistentType> getJarFilePersistentTypes() {
- return IterableTools.children(this.getJarFileRefs(), PersistentTypeContainer.TRANSFORMER);
+ protected Iterable<ManagedType> getJarFileManagedTypes() {
+ return IterableTools.children(this.getJarFileRefs(), ManagedTypeContainer.TRANSFORMER);
}
- public PersistentType getPersistentType(String typeName) {
- return typeName == null ? null : this.persistentTypeMap.get(typeName);
+ public ManagedType getManagedType(String typeName) {
+ return typeName == null ? null : this.managedTypeMap.get(typeName);
}
- protected void rebuildPersistentTypeMap() {
- synchronized (this.persistentTypeMap) {
- this.persistentTypeMap.clear();
+ protected void rebuildManagedTypeMap() {
+ synchronized (this.managedTypeMap) {
+ this.managedTypeMap.clear();
for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- for (PersistentType persistentType : mappingFileRef.getPersistentTypes()) {
- if (persistentType.getName() != null) {
- if (! this.persistentTypeMap.containsKey(persistentType.getName())) {
- this.persistentTypeMap.put(persistentType.getName(), persistentType);
+ for (ManagedType mt : mappingFileRef.getManagedTypes()) {
+ if (mt.getName() != null) {
+ if (! this.managedTypeMap.containsKey(mt.getName())) {
+ this.managedTypeMap.put(mt.getName(), mt);
}
}
}
}
for (ClassRef classRef : this.getClassRefs()) {
- PersistentType persistentType = classRef.getJavaPersistentType();
- if (persistentType != null && persistentType.getName() != null) {
- if (! this.persistentTypeMap.containsKey(persistentType.getName())) {
- this.persistentTypeMap.put(persistentType.getName(), persistentType);
+ ManagedType mt = classRef.getJavaManagedType();
+ if (mt != null && mt.getName() != null) {
+ if (! this.managedTypeMap.containsKey(mt.getName())) {
+ this.managedTypeMap.put(mt.getName(), mt);
}
}
}
for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- for (PersistentType persistentType : jarFileRef.getPersistentTypes()) {
- if (persistentType.getName() != null) {
- if (! this.persistentTypeMap.containsKey(persistentType.getName())) {
- this.persistentTypeMap.put(persistentType.getName(), persistentType);
+ for (ManagedType mt : jarFileRef.getManagedTypes()) {
+ if (mt.getName() != null) {
+ if (! this.managedTypeMap.containsKey(mt.getName())) {
+ this.managedTypeMap.put(mt.getName(), mt);
}
}
}
@@ -1767,14 +1772,14 @@ public abstract class AbstractPersistenceUnit
/**
* Ignore implied class refs and jar files.
*/
- public boolean specifiesPersistentType(String typeName) {
+ public boolean specifiesManagedType(String typeName) {
for (ClassRef classRef : this.getSpecifiedClassRefs()) {
if (classRef.isFor(typeName)) {
return true;
}
}
for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.getPersistentType(typeName) != null) {
+ if (mappingFileRef.getManagedType(typeName) != null) {
return true;
}
}
@@ -1843,6 +1848,49 @@ public abstract class AbstractPersistenceUnit
return IterableTools.transform(this.getMappingFilePersistentTypes(), PersistentType.OVERRIDDEN_PERSISTENT_TYPE_TRANSFORMER);
}
+ public Iterable<PersistentType> getPersistentTypes() {
+ return IterableTools.downCast(IterableTools.filter(
+ this.getManagedTypes(),
+ PERSISTENT_TYPE_FILTER));
+ }
+
+ protected static final Filter<ManagedType> PERSISTENT_TYPE_FILTER =
+ new Filter<ManagedType>() {
+ public boolean accept(ManagedType mt) {
+ return mt.getType() == JavaPersistentType.class || mt.getType() == OrmPersistentType.class; //is this right? what about just getType() == PersistentType.class??
+ }
+ };
+
+ public PersistentType getPersistentType(String typeName) {
+ ManagedType mt = this.getManagedType(typeName);
+ if (mt != null && (mt.getType() == JavaPersistentType.class || mt.getType() == OrmPersistentType.class)) {
+ return (PersistentType) mt;
+ }
+ return null;
+ }
+
+ protected Iterable<PersistentType> getMappingFilePersistentTypes() {
+ return IterableTools.children(this.getMappingFileRefs(), PersistentTypeContainer.TRANSFORMER);
+ }
+
+ protected Iterable<PersistentType> getClassRefPersistentTypes() {
+ return IterableTools.downCast(IterableTools.filter(
+ this.getClassRefManagedTypes(),
+ PERSISTENT_TYPE_FILTER));
+ }
+
+ protected Iterable<PersistentType> getJarFilePersistentTypes() {
+ return IterableTools.downCast(IterableTools.filter(
+ this.getJarFileManagedTypes(),
+ PERSISTENT_TYPE_FILTER));
+ }
+
+ public Iterable<PersistentType> getJavaPersistentTypes() {
+ return IterableTools.downCast(IterableTools.filter(
+ this.getJavaManagedTypes(),
+ PERSISTENT_TYPE_FILTER));
+ }
+
// ********** type mappings **********
@@ -1956,17 +2004,17 @@ public abstract class AbstractPersistenceUnit
SubMonitor sm = SubMonitor.convert(monitor, 3);
// calculate the refs to remove and add
- HashSet<JavaResourceAbstractType> newTypes = CollectionTools.set(this.getJpaProject().getMappedJavaSourceTypes());
+ HashSet<JavaResourceAbstractType> newTypes = CollectionTools.set(this.getJpaProject().getPotentialJavaSourceTypes());
ArrayList<ClassRef> deadClassRefs = new ArrayList<ClassRef>();
HashSet<String> mappingFileTypeNames = this.getMappingFileTypeNames();
for (ClassRef classRef : this.getSpecifiedClassRefs()) {
- JavaPersistentType specifiedJPT = classRef.getJavaPersistentType();
- if (specifiedJPT == null) {
+ JavaManagedType specifiedJMT = classRef.getJavaManagedType();
+ if (specifiedJMT == null) {
// Java type cannot be resolved
deadClassRefs.add(classRef);
} else {
- JavaResourceType specifiedType = specifiedJPT.getJavaResourceType();
+ JavaResourceType specifiedType = specifiedJMT.getJavaResourceType();
if ( ! newTypes.remove(specifiedType)) {
// Java type is not annotated
deadClassRefs.add(classRef);
@@ -1998,8 +2046,8 @@ public abstract class AbstractPersistenceUnit
protected HashSet<String> getMappingFileTypeNames() {
HashSet<String> result = new HashSet<String>();
for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- for (PersistentType persistentType : mappingFileRef.getPersistentTypes()) {
- result.add(persistentType.getName());
+ for (ManagedType managedType : mappingFileRef.getManagedTypes()) {
+ result.add(managedType.getName());
}
}
return result;
@@ -2136,8 +2184,8 @@ public abstract class AbstractPersistenceUnit
public Iterable<String> getPackageNames() {
Set<String> packageNames = new HashSet<String>();
- for (PersistentType pType : this.getJavaPersistentTypes()) {
- JavaResourceType jrt = ((JavaPersistentType)pType).getJavaResourceType();
+ for (ManagedType mType : this.getJavaManagedTypes()) {
+ JavaResourceType jrt = mType.getJavaResourceType();
packageNames.add(jrt.getTypeBinding().getPackageName());
}
return packageNames;
@@ -2229,13 +2277,13 @@ public abstract class AbstractPersistenceUnit
}
protected void checkForDuplicateMappingFileClasses(List<IMessage> messages) {
- for (Map.Entry<String, ArrayList<PersistentType>> entry : this.mapMappingFilePersistentTypesByName().entrySet()) {
- String ptName = entry.getKey();
- if (StringTools.isNotBlank(ptName)) {
- ArrayList<PersistentType> dups = entry.getValue();
+ for (Map.Entry<String, ArrayList<ManagedType>> entry : this.mapMappingFileManagedTypesByName().entrySet()) {
+ String mtName = entry.getKey();
+ if (StringTools.isNotBlank(mtName)) {
+ ArrayList<ManagedType> dups = entry.getValue();
if (dups.size() > 1) {
- String[] parms = new String[] {ptName};
- for (PersistentType dup : dups) {
+ String[] parms = new String[] {mtName};
+ for (ManagedType dup : dups) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.NORMAL_SEVERITY,
@@ -2252,19 +2300,19 @@ public abstract class AbstractPersistenceUnit
}
/**
- * Return the persistence unit's mapping file persistent types
+ * Return the persistence unit's mapping file managed types
* keyed by their class names.
*/
- protected HashMap<String, ArrayList<PersistentType>> mapMappingFilePersistentTypesByName() {
- HashMap<String, ArrayList<PersistentType>> map = new HashMap<String, ArrayList<PersistentType>>();
- for (PersistentType persistentType : this.getMappingFilePersistentTypes()) {
- String ptName = persistentType.getName();
- ArrayList<PersistentType> list = map.get(ptName);
+ protected HashMap<String, ArrayList<ManagedType>> mapMappingFileManagedTypesByName() {
+ HashMap<String, ArrayList<ManagedType>> map = new HashMap<String, ArrayList<ManagedType>>();
+ for (ManagedType managedType : this.getMappingFileManagedTypes()) {
+ String mtName = managedType.getName();
+ ArrayList<ManagedType> list = map.get(mtName);
if (list == null) {
- list = new ArrayList<PersistentType>();
- map.put(ptName, list);
+ list = new ArrayList<ManagedType>();
+ map.put(mtName, list);
}
- list.add(persistentType);
+ list.add(managedType);
}
return map;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java
index 1b8e107..b1755bf 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTypeMappingValidator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2010, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,6 +17,7 @@ import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
+//AbstractTypeMappingTypeValidator might be a better name
public abstract class AbstractTypeMappingValidator<M extends TypeMapping>
implements JptValidator
{
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java
index 5e71574..59030ec 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericRootContextNode.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -286,7 +286,7 @@ public class GenericRootContextNode
HashBag<JavaResourceAbstractType> annotatedTypes = CollectionTools.bag(this.jpaProject.getAnnotatedJavaSourceTypes());
HashBag<JavaResourceAbstractType> orphans = annotatedTypes.clone();
for (JavaResourceAbstractType jrat : annotatedTypes) {
- if (persistenceUnit.specifiesPersistentType(jrat.getTypeBinding().getQualifiedName())) {
+ if (persistenceUnit.specifiesManagedType(jrat.getTypeBinding().getQualifiedName())) {
orphans.remove(jrat);
}
else if (MetamodelSynchronizer.MetamodelTools.isMetamodel(jrat)) {
@@ -294,13 +294,13 @@ public class GenericRootContextNode
}
}
- Iterable<String> typeMappingAnnotationNames = this.jpaProject.getTypeMappingAnnotationNames();
+ Iterable<String> managedTypeAnnotationNames = this.jpaProject.getManagedTypeAnnotationNames();
for (JavaResourceAbstractType jrat : orphans) {
- if (jrat.isAnnotatedWithAnyOf(typeMappingAnnotationNames)) {
+ if (jrat.isAnnotatedWithAnyOf(managedTypeAnnotationNames)) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.HIGH_SEVERITY,
- JptJpaCoreValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT,
+ JptJpaCoreValidationMessages.TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML,
new String[] {jrat.getTypeBinding().getQualifiedName()},
jrat.getFile(),
jrat.getNameTextRange()
@@ -311,8 +311,8 @@ public class GenericRootContextNode
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.NORMAL_SEVERITY,
- JptJpaCoreValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT,
- new String[] {jrat.getName()},
+ JptJpaCoreValidationMessages.TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML,
+ new String[] {jrat.getTypeBinding().getQualifiedName()},
jrat.getFile(),
jrat.getNameTextRange()
)
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java
index 7110f4f..5fbcd2a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJarFile.java
@@ -20,12 +20,16 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceAnnotatedElement.As
import org.eclipse.jpt.common.core.resource.java.JavaResourcePackageFragmentRoot;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.filter.Filter;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JarFile;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaPersistentTypeDefinition;
import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode;
import org.eclipse.wst.validation.internal.provisional.core.IMessage;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
@@ -39,7 +43,7 @@ public class GenericJarFile
{
protected final JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot;
- protected final ContextCollectionContainer<JavaPersistentType, JavaResourceType> javaPersistentTypeContainer;
+ protected final ContextCollectionContainer<JavaManagedType, JavaResourceType> javaManagedTypeContainer;
// ********** constructor/initialization **********
@@ -47,7 +51,7 @@ public class GenericJarFile
public GenericJarFile(JarFileRef parent, JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot) {
super(parent);
this.jarResourcePackageFragmentRoot = jarResourcePackageFragmentRoot;
- this.javaPersistentTypeContainer = this.buildJavaPersistentTypeContainer();
+ this.javaManagedTypeContainer = this.buildJavaManagedTypeContainer();
}
@@ -56,13 +60,13 @@ public class GenericJarFile
@Override
public void synchronizeWithResourceModel() {
super.synchronizeWithResourceModel();
- this.syncJavaPersistentTypes();
+ this.syncJavaManagedTypes();
}
@Override
public void update() {
super.update();
- this.updateNodes(this.getJavaPersistentTypes());
+ this.updateNodes(this.getJavaManagedTypes());
}
public JavaResourcePackageFragmentRoot getJarResourcePackageFragmentRoot() {
@@ -78,35 +82,35 @@ public class GenericJarFile
}
- // ********** Java persistent types **********
+ // ********** Java managed types **********
- public JavaPersistentType getPersistentType(String typeName) {
- for (JavaPersistentType pt : this.getJavaPersistentTypes()) {
- if (pt.getName().equals(typeName)) {
- return pt;
+ public JavaManagedType getManagedType(String typeName) {
+ for (JavaManagedType mt : this.getJavaManagedTypes()) {
+ if (mt.getName().equals(typeName)) {
+ return mt;
}
}
return null;
}
- public Iterable<JavaPersistentType> getJavaPersistentTypes() {
- return this.javaPersistentTypeContainer.getContextElements();
+ public Iterable<JavaManagedType> getJavaManagedTypes() {
+ return this.javaManagedTypeContainer.getContextElements();
}
- public int getJavaPersistentTypesSize() {
- return this.javaPersistentTypeContainer.getContextElementsSize();
+ public int getJavaManagedTypesSize() {
+ return this.javaManagedTypeContainer.getContextElementsSize();
}
- protected void syncJavaPersistentTypes() {
- this.javaPersistentTypeContainer.synchronizeWithResourceModel();
+ protected void syncJavaManagedTypes() {
+ this.javaManagedTypeContainer.synchronizeWithResourceModel();
}
- protected void addJavaPersistentType(JavaResourceType jrt) {
- this.javaPersistentTypeContainer.addContextElement(getJavaPersistentTypesSize(), jrt);
+ protected void addJavaManagedType(JavaResourceType jrt) {
+ this.javaManagedTypeContainer.addContextElement(getJavaManagedTypesSize(), jrt);
}
- protected void removeJavaPersistentType(JavaPersistentType javaPersistentType ) {
- this.javaPersistentTypeContainer.removeContextElement(javaPersistentType);
+ protected void removeJavaManagedType(JavaManagedType javaManagedType) {
+ this.javaManagedTypeContainer.removeContextElement(javaManagedType);
}
//only accept types, enums aren't valid for JPA
@@ -127,47 +131,85 @@ public class GenericJarFile
return this.jarResourcePackageFragmentRoot.getTypes();
}
- protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrt) {
- return this.getJpaFactory().buildJavaPersistentType(this, jrt);
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt, JavaManagedTypeDefinition managedTypeDefinition) {
+ return managedTypeDefinition.buildContextManagedType(this, jrt, this.getJpaFactory());
+ }
+
+ protected Iterable<JavaManagedTypeDefinition> getJavaManagedTypeDefinitions() {
+ return this.getJpaPlatform().getJavaManagedTypeDefinitions();
+ }
+
+ protected JavaManagedTypeDefinition getJavaManagedTypeDefinition(JavaResourceType jrt) {
+ for (JavaManagedTypeDefinition managedTypeDefinition : this.getJavaManagedTypeDefinitions()) {
+ if (jrt.isAnnotatedWithAnyOf(managedTypeDefinition.getAnnotationNames(this.getJpaProject()))) {
+ return managedTypeDefinition;
+ }
+ }
+ return JavaPersistentTypeDefinition.instance();
+ }
+
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) {
+ return getJavaManagedTypeDefinition(jrt).buildContextManagedType(this, jrt, getJpaFactory());
}
- protected ContextCollectionContainer<JavaPersistentType, JavaResourceType> buildJavaPersistentTypeContainer() {
- JavaPersistentTypeContainer container = new JavaPersistentTypeContainer();
+ protected ContextCollectionContainer<JavaManagedType, JavaResourceType> buildJavaManagedTypeContainer() {
+ JavaManagedTypeContainer container = new JavaManagedTypeContainer();
container.initialize();
return container;
}
/**
- * Java persistent type container
+ * Java managed type container
*/
- protected class JavaPersistentTypeContainer
- extends ContextCollectionContainer<JavaPersistentType, JavaResourceType>
+ protected class JavaManagedTypeContainer
+ extends ContextCollectionContainer<JavaManagedType, JavaResourceType>
{
@Override
protected String getContextElementsPropertyName() {
- return JAVA_PERSISTENT_TYPES_COLLECTION;
+ return JAVA_MANAGED_TYPES_COLLECTION;
}
@Override
- protected JavaPersistentType buildContextElement(JavaResourceType resourceElement) {
- return GenericJarFile.this.buildJavaPersistentType(resourceElement);
+ protected JavaManagedType buildContextElement(JavaResourceType resourceElement) {
+ return GenericJarFile.this.buildJavaManagedType(resourceElement);
}
@Override
protected Iterable<JavaResourceType> getResourceElements() {
return GenericJarFile.this.getJavaResourceTypes();
}
@Override
- protected JavaResourceType getResourceElement(JavaPersistentType contextElement) {
+ protected JavaResourceType getResourceElement(JavaManagedType contextElement) {
return contextElement.getJavaResourceType();
}
}
+ // ********** ManagedTypeContainer implementation **********
+
+ public Iterable<JavaManagedType> getManagedTypes() {
+ return this.getJavaManagedTypes();
+ }
+
+
// ********** PersistentTypeContainer implementation **********
+ public JavaPersistentType getPersistentType(String typeName) {
+ JavaManagedType managedType = this.getManagedType(typeName);
+ return managedType.getType() == JavaPersistentType.class ? (JavaPersistentType) managedType : null;
+ }
+
public Iterable<JavaPersistentType> getPersistentTypes() {
- return this.getJavaPersistentTypes();
+ return IterableTools.downCast(IterableTools.filter(
+ this.getManagedTypes(),
+ JAVA_PERSISTENT_TYPE_FILTER));
}
+ protected static final Filter<JavaManagedType> JAVA_PERSISTENT_TYPE_FILTER =
+ new Filter<JavaManagedType>() {
+ public boolean accept(JavaManagedType mt) {
+ return mt.getType() == JavaPersistentType.class;
+ }
+ };
+
// ********** PersistentType.Owner implementation **********
@@ -203,7 +245,7 @@ public class GenericJarFile
@Override
public void validate(List<IMessage> messages, IReporter reporter) {
super.validate(messages, reporter);
- // TODO validate 'javaPersistentTypes'
+ // TODO validate 'javaManagedTypes'
}
public boolean isIn(org.eclipse.core.resources.IFolder folder) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java
index 98e66e6..2713e45 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentAttribute.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -45,7 +45,7 @@ public class GenericOrmPersistentAttribute
JptJpaCoreValidationMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED,
new String[] {
this.getName(),
- this.getOwningPersistentType().getMapping().getClass_()
+ this.getOwningPersistentType().getClass_()
},
this.mapping,
this.mapping.getNameTextRange()
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java
index e3b3f17..5f30c13 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java
@@ -25,10 +25,12 @@ import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.Generator;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.MappingFile;
import org.eclipse.jpt.jpa.core.context.Query;
import org.eclipse.jpt.jpa.core.context.XmlFile;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
@@ -298,6 +300,17 @@ public class GenericOrmXml
}
+ // ********** ManagedTypeContainer implementation **********
+
+ public Iterable<OrmManagedType> getManagedTypes() {
+ return (this.root != null) ? this.root.getManagedTypes() : EmptyIterable.<OrmManagedType>instance();
+ }
+
+ public ManagedType getManagedType(String typeName) {
+ return (this.root == null) ? null : this.root.getManagedType(typeName);
+ }
+
+
// ********** refactoring **********
public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
index 14ef346..fd1913f 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java
@@ -24,10 +24,14 @@ import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.AccessType;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaPersistentTypeDefinition;
import org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceXmlContextNode;
import org.eclipse.jpt.jpa.core.internal.plugin.JptJpaCorePlugin;
import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
@@ -55,11 +59,11 @@ public class GenericClassRef
protected String className;
/**
- * The Java persistent type corresponding to the ref's class name;
+ * The Java managed type corresponding to the ref's class name;
* this can be <code>null</code> if the className is invalid or
* refers to an enum instead of a class or interface.
*/
- protected JavaPersistentType javaPersistentType;
+ protected JavaManagedType javaManagedType;
/**
* Hold on to this for validation if the resourceType is not of type {@link AstNodeType#TYPE}
@@ -76,7 +80,7 @@ public class GenericClassRef
super(parent);
this.xmlJavaClassRef = xmlJavaClassRef;
this.className = xmlJavaClassRef.getJavaClass();
- this.initializeJavaPersistentType(this.resolveJavaResourceType());
+ this.initializeJavaManagedType(this.resolveJavaResourceType());
}
/**
@@ -87,13 +91,13 @@ public class GenericClassRef
super(parent);
this.xmlJavaClassRef = null;
this.className = resourceType.getTypeBinding().getQualifiedName();
- this.initializeJavaPersistentType(resourceType);
+ this.initializeJavaManagedType(resourceType);
}
- protected void initializeJavaPersistentType(JavaResourceAbstractType jrat) {
+ protected void initializeJavaManagedType(JavaResourceAbstractType jrat) {
this.resourceType = jrat;
if (this.resourceType != null && this.resourceType.getAstNodeType() == AstNodeType.TYPE) {
- this.javaPersistentType = this.buildJavaPersistentType((JavaResourceType) this.resourceType);
+ this.javaManagedType = this.buildJavaManagedType((JavaResourceType) this.resourceType);
}
}
@@ -109,20 +113,21 @@ public class GenericClassRef
// the name probably never changes...
this.setClassName_(this.xmlJavaClassRef.getJavaClass());
}
- if (this.javaPersistentType != null) {
- this.javaPersistentType.synchronizeWithResourceModel();
+ if (this.javaManagedType != null) {
+ this.javaManagedType.synchronizeWithResourceModel();
}
}
@Override
public void update() {
super.update();
- this.updateJavaPersistentType();
+ this.updateJavaManagedType();
}
public void gatherRootStructureNodes(JpaFile jpaFile, Collection<JpaStructureNode> rootStructureNodes) {
- if (this.javaPersistentType != null) {
- this.javaPersistentType.gatherRootStructureNodes(jpaFile, rootStructureNodes);
+ JavaPersistentType javaPersistentType = this.getJavaPersistentType();
+ if (javaPersistentType != null) {
+ javaPersistentType.gatherRootStructureNodes(jpaFile, rootStructureNodes);
}
}
@@ -160,45 +165,68 @@ public class GenericClassRef
}
- // ********** java persistent type **********
+ // ********** Java managed type **********
- public JavaPersistentType getJavaPersistentType() {
- return this.javaPersistentType;
+ public JavaManagedType getJavaManagedType() {
+ return this.javaManagedType;
}
- protected void setJavaPersistentType(JavaPersistentType javaPersistentType) {
- JavaPersistentType old = this.javaPersistentType;
- this.javaPersistentType = javaPersistentType;
- this.firePropertyChanged(JAVA_PERSISTENT_TYPE_PROPERTY, old, javaPersistentType);
+ protected void setJavaManagedType(JavaManagedType managedType) {
+ ManagedType old = this.javaManagedType;
+ this.javaManagedType = managedType;
+ this.firePropertyChanged(JAVA_MANAGED_TYPE_PROPERTY, old, managedType);
}
- protected void updateJavaPersistentType() {
+ protected void updateJavaManagedType() {
this.resourceType = this.resolveJavaResourceType();
if (this.resourceType == null || this.resourceType.getAstNodeType() != AstNodeType.TYPE) {
- if (this.javaPersistentType != null) {
- this.setJavaPersistentType(null);
+ if (this.javaManagedType != null) {
+ this.setJavaManagedType(null);
}
} else {
JavaResourceType jrt = (JavaResourceType) this.resourceType;
- if (this.javaPersistentType == null) {
- this.setJavaPersistentType(this.buildJavaPersistentType(jrt));
+ JavaManagedTypeDefinition managedTypeDefinition = this.getJavaManagedTypeDefinition(jrt);
+ if (this.javaManagedType == null) {
+ this.setJavaManagedType(this.buildJavaManagedType(jrt, managedTypeDefinition));
} else {
- if (this.javaPersistentType.getJavaResourceType() == jrt) {
- this.javaPersistentType.update();
+ if (this.javaManagedType.getType() == managedTypeDefinition.getType()) {
+ this.javaManagedType.update();
} else {
- this.setJavaPersistentType(this.buildJavaPersistentType(jrt));
+ this.setJavaManagedType(this.buildJavaManagedType(jrt, managedTypeDefinition));
}
}
}
}
+ public JavaPersistentType getJavaPersistentType() {
+ return this.javaManagedType == null ? null :
+ this.javaManagedType.getType() == JavaPersistentType.class ? (JavaPersistentType) this.javaManagedType : null;
+ }
+
protected JavaResourceAbstractType resolveJavaResourceType() {
String javaClassName = this.getJavaClassName();
return (javaClassName == null) ? null : this.getJpaProject().getJavaResourceType(javaClassName);
}
- protected JavaPersistentType buildJavaPersistentType(JavaResourceType jrt) {
- return this.getJpaFactory().buildJavaPersistentType(this, jrt);
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) {
+ return this.buildJavaManagedType(jrt, this.getJavaManagedTypeDefinition(jrt));
+ }
+
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt, JavaManagedTypeDefinition managedTypeDefinition) {
+ return managedTypeDefinition.buildContextManagedType(this, jrt, this.getJpaFactory());
+ }
+
+ protected Iterable<JavaManagedTypeDefinition> getJavaManagedTypeDefinitions() {
+ return this.getJpaPlatform().getJavaManagedTypeDefinitions();
+ }
+
+ protected JavaManagedTypeDefinition getJavaManagedTypeDefinition(JavaResourceType jrt) {
+ for (JavaManagedTypeDefinition managedTypeDefinition : this.getJavaManagedTypeDefinitions()) {
+ if (jrt.isAnnotatedWithAnyOf(managedTypeDefinition.getAnnotationNames(this.getJpaProject()))) {
+ return managedTypeDefinition;
+ }
+ }
+ return JavaPersistentTypeDefinition.instance();
}
@@ -401,15 +429,15 @@ public class GenericClassRef
}
}
- if (this.javaPersistentType == null) {
+ if (this.javaManagedType == null) {
return;
}
// 190062 validate Java class only if this is the only reference to it
// i.e. the persistence.xml ref is the only ref - none of the mapping
// files reference the same class
- boolean validateJavaPersistentType = true;
+ boolean validateJavaManagedType = true;
for (MappingFileRef mappingFileRef : this.getPersistenceUnit().getMappingFileRefsContaining(this.getJavaClassName())) {
- validateJavaPersistentType = false;
+ validateJavaManagedType = false;
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.LOW_SEVERITY,
@@ -421,14 +449,14 @@ public class GenericClassRef
);
}
- if (validateJavaPersistentType) {
- this.validateJavaPersistentType(messages, reporter);
+ if (validateJavaManagedType) {
+ this.validateJavaManagedType(messages, reporter);
}
}
- protected void validateJavaPersistentType(List<IMessage> messages, IReporter reporter) {
+ protected void validateJavaManagedType(List<IMessage> messages, IReporter reporter) {
try {
- this.javaPersistentType.validate(messages, reporter);
+ this.javaManagedType.validate(messages, reporter);
} catch (Throwable t) {
JptJpaCorePlugin.instance().logError(t);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmXml2_1Definition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmXml2_1Definition.java
index 7778995..80d29ac 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmXml2_1Definition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmXml2_1Definition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,12 +10,12 @@
package org.eclipse.jpt.jpa.core.internal.jpa2.context.orm;
import java.util.ArrayList;
-
import org.eclipse.emf.ecore.EFactory;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.jpa.core.context.orm.NullOrmAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlDefinition;
@@ -27,8 +27,12 @@ import org.eclipse.jpt.jpa.core.internal.context.orm.OrmManyToManyMappingDefinit
import org.eclipse.jpt.jpa.core.internal.context.orm.OrmManyToOneMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOneToManyMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.orm.OrmOneToOneMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.orm.OrmPersistentTypeDefinition;
import org.eclipse.jpt.jpa.core.internal.context.orm.OrmTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.context.orm.OrmVersionMappingDefinition;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.Generic2_1JpaPlatformProvider;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.GenericOrmXml2_1ContextNodeFactory;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmConverterTypeDefinition;
import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.orm.v2_1.JPA2_1;
@@ -64,9 +68,21 @@ public class GenericOrmXml2_1Definition
@Override
protected OrmXmlContextNodeFactory buildContextNodeFactory() {
- return new GenericOrmXml2_0ContextNodeFactory();
+ return new GenericOrmXml2_1ContextNodeFactory();
}
+ // ********* Managed Types *********
+
+ @Override
+ protected void addManagedTypeDefinitionsTo(ArrayList<OrmManagedTypeDefinition> definitions) {
+ CollectionTools.addAll(definitions, MANAGED_TYPE_DEFINITIONS_2_1);
+ }
+
+ protected static final OrmManagedTypeDefinition[] MANAGED_TYPE_DEFINITIONS_2_1 = new OrmManagedTypeDefinition[] {
+ OrmPersistentTypeDefinition.instance(),
+ OrmConverterTypeDefinition.instance(),
+ };
+
@Override
protected void addAttributeMappingDefinitionsTo(ArrayList<OrmAttributeMappingDefinition> definitions) {
CollectionTools.addAll(definitions, ATTRIBUTE_MAPPING_DEFINITIONS);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformFactory.java
index 8b698f1..14e247a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,7 +17,6 @@ import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.internal.GenericJpaPlatform;
import org.eclipse.jpt.jpa.core.internal.GenericJpaPlatformFactory.GenericJpaPlatformVersion;
import org.eclipse.jpt.jpa.core.internal.JpaAnnotationProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa2.GenericJpaFactory2_0;
import org.eclipse.jpt.jpa.core.jpa2_1.JpaProject2_1;
import org.eclipse.persistence.jpa.jpql.parser.JPQLGrammar2_1;
@@ -41,7 +40,7 @@ public class Generic2_1JpaPlatformFactory
return new GenericJpaPlatform(
config,
this.buildJpaVersion(),
- new GenericJpaFactory2_0(),
+ new GenericJpaFactory2_1(),
new JpaAnnotationProvider(Generic2_1JpaAnnotationDefinitionProvider.instance()),
Generic2_1JpaPlatformProvider.instance(),
this.buildJpaPlatformVariation(),
@@ -66,4 +65,4 @@ public class Generic2_1JpaPlatformFactory
}
};
}
-} \ No newline at end of file
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformProvider.java
index a722338..ba9654a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/Generic2_1JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,6 +17,7 @@ import org.eclipse.jpt.jpa.core.JpaResourceModelProvider;
import org.eclipse.jpt.jpa.core.ResourceDefinition;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaPlatformProvider;
import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
@@ -24,6 +25,7 @@ import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.context.java.JarDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaPersistentTypeDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaSourceFileDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
@@ -45,6 +47,7 @@ import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_0Defini
import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_1Definition;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_1Definition;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaConverterTypeDefinition;
/**
* All the state in the JPA platform should be "static" (i.e. unchanging once
@@ -100,6 +103,25 @@ public class Generic2_1JpaPlatformProvider
};
+ // ********* Java managed types *********
+
+ /**
+ * To the specified list, add java managed type definitions to use for
+ * analyzing the type given all annotations on it. The order is
+ * important, as once a managed type definition tests positive for a
+ * type, all following managed type definitions are ignored.
+ */
+ @Override
+ protected void addJavaManagedTypeDefinitionsTo(ArrayList<JavaManagedTypeDefinition> definitions) {
+ CollectionTools.addAll(definitions, JAVA_MANAGED_TYPE_DEFINITIONS_2_1);
+ }
+
+ protected static final JavaManagedTypeDefinition[] JAVA_MANAGED_TYPE_DEFINITIONS_2_1 = new JavaManagedTypeDefinition[] {
+ JavaPersistentTypeDefinition.instance(),
+ JavaConverterTypeDefinition.instance()
+ };
+
+
// ********** Java type mappings **********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java
new file mode 100644
index 0000000..7662d29
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/GenericJpaFactory2_1.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2.GenericJpaFactory2_0;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaConverterType;
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaFactory2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+
+
+/**
+ * Central class that allows extenders to easily replace implementations of
+ * various Dali interfaces.
+ */
+public class GenericJpaFactory2_1
+ extends GenericJpaFactory2_0
+ implements JpaFactory2_1
+{
+
+ public GenericJpaFactory2_1() {
+ super();
+ }
+
+ public JavaConverterType2_1 buildJavaConverterType(JpaContextNode parent, JavaResourceType jrt) {
+ return new GenericJavaConverterType(parent, jrt);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaConverterType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaConverterType.java
new file mode 100644
index 0000000..3b4ffd8
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/GenericJavaConverterType.java
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaManagedType;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.Converter2_1Annotation;
+
+public class GenericJavaConverterType extends AbstractJavaManagedType
+ implements JavaConverterType2_1
+{
+
+ protected boolean autoApply;
+
+ protected Boolean specifiedAutoApply;
+
+ public GenericJavaConverterType(JpaContextNode parent, JavaResourceType resourceType) {
+ super(parent, resourceType);
+ this.specifiedAutoApply = this.buildSpecifiedAutoApply();
+ this.autoApply = this.buildAutoApply();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setSpecifiedAutoApply_(this.buildSpecifiedAutoApply());
+ this.setAutoApply(this.buildAutoApply());
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ }
+
+
+ // ********** auto apply **********
+
+ public boolean isAutoApply() {
+ return this.autoApply;
+ }
+
+ protected void setAutoApply(boolean autoApply) {
+ boolean old = this.autoApply;
+ this.autoApply = autoApply;
+ firePropertyChanged(AUTO_APPLY_PROPERTY, old, autoApply);
+ }
+
+ protected boolean buildAutoApply() {
+ return this.specifiedAutoApply == null ? this.isDefaultAutoApply() : this.specifiedAutoApply.booleanValue();
+ }
+
+ public boolean isDefaultAutoApply() {
+ return DEFAULT_AUTO_APPLY;
+ }
+
+ public Boolean getSpecifiedAutoApply() {
+ return this.specifiedAutoApply;
+ }
+
+ public void setSpecifiedAutoApply(Boolean autoApply) {
+ this.getConverterAnnotation().setAutoApply(autoApply);
+ this.setSpecifiedAutoApply_(autoApply);
+ }
+
+ protected void setSpecifiedAutoApply_(Boolean autoApply) {
+ Boolean old = this.specifiedAutoApply;
+ this.specifiedAutoApply = autoApply;
+ this.firePropertyChanged(SPECIFIED_AUTO_APPLY_PROPERTY, old, autoApply);
+ }
+
+ protected Boolean buildSpecifiedAutoApply() {
+ Converter2_1Annotation converterAnnotation = this.getConverterAnnotation();
+ return converterAnnotation != null ? converterAnnotation.getAutoApply() : null;
+ }
+
+
+ // ********** converter annotation **********
+
+ protected Converter2_1Annotation getConverterAnnotation() {
+ return (Converter2_1Annotation) this.resourceType.getAnnotation(Converter2_1Annotation.ANNOTATION_NAME);
+ }
+
+
+ // ********** ManagedType implementation **********
+
+ public Class<JavaConverterType2_1> getType() {
+ return JavaConverterType2_1.class;
+ }
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaConverterTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaConverterTypeDefinition.java
new file mode 100644
index 0000000..e9c94e3
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/java/JavaConverterTypeDefinition.java
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.jpa.core.JpaFactory;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaFactory2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.Converter2_1Annotation;
+
+public class JavaConverterTypeDefinition implements JavaManagedTypeDefinition
+{
+ // singleton
+ private static final JavaManagedTypeDefinition INSTANCE = new JavaConverterTypeDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaManagedTypeDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Enforce singleton usage
+ */
+ private JavaConverterTypeDefinition() {
+ super();
+ }
+
+ public Class<? extends JavaConverterType2_1> getType() {
+ return JavaConverterType2_1.class;
+ }
+
+ public Iterable<String> getAnnotationNames(JpaProject jpaProject) {
+ return IterableTools.singletonIterable(Converter2_1Annotation.ANNOTATION_NAME);
+ }
+
+ public JavaConverterType2_1 buildContextManagedType(JpaContextNode parent, JavaResourceType jrt, JpaFactory factory) {
+ return ((JpaFactory2_1) factory).buildJavaConverterType(parent, jrt);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmConverterType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmConverterType.java
new file mode 100644
index 0000000..1afbfd2
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmConverterType.java
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmManagedType;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+
+public class GenericOrmConverterType extends AbstractOrmManagedType
+ implements OrmConverterType2_1
+{
+ protected boolean autoApply;
+
+ protected Boolean specifiedAutoApply;
+
+ public GenericOrmConverterType(EntityMappings2_1 parent, XmlConverter_2_1 xmlConverter) {
+ super(parent, xmlConverter);
+ this.specifiedAutoApply = this.buildSpecifiedAutoApply();
+ this.autoApply = this.buildAutoApply();
+ }
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.setSpecifiedAutoApply_(this.buildSpecifiedAutoApply());
+ this.setAutoApply(this.buildAutoApply());
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ }
+
+ @Override
+ public XmlConverter_2_1 getXmlManagedType() {
+ return (XmlConverter_2_1) super.getXmlManagedType();
+ }
+
+ public XmlConverter_2_1 getXmlConverter() {
+ return this.getXmlManagedType();
+ }
+
+
+ // ********** auto apply **********
+
+ public boolean isAutoApply() {
+ return this.autoApply;
+ }
+
+ protected void setAutoApply(boolean autoApply) {
+ boolean old = this.autoApply;
+ this.autoApply = autoApply;
+ firePropertyChanged(AUTO_APPLY_PROPERTY, old, autoApply);
+ }
+
+ protected boolean buildAutoApply() {
+ return this.specifiedAutoApply == null ? this.isDefaultAutoApply() : this.specifiedAutoApply.booleanValue();
+ }
+
+ public boolean isDefaultAutoApply() {
+ return DEFAULT_AUTO_APPLY;
+ }
+
+ public Boolean getSpecifiedAutoApply() {
+ return this.specifiedAutoApply;
+ }
+
+ public void setSpecifiedAutoApply(Boolean autoApply) {
+ this.setSpecifiedAutoApply_(autoApply);
+ this.getXmlConverter().setAutoApply(autoApply);
+ }
+
+ protected void setSpecifiedAutoApply_(Boolean autoApply) {
+ Boolean old = this.specifiedAutoApply;
+ this.specifiedAutoApply = autoApply;
+ this.firePropertyChanged(SPECIFIED_AUTO_APPLY_PROPERTY, old, autoApply);
+ }
+
+ protected Boolean buildSpecifiedAutoApply() {
+ return this.getXmlConverter().getAutoApply();
+ }
+
+
+ // ********** JpaStructureNode implementation **********
+
+ public Class<OrmConverterType2_1> getType() {
+ return OrmConverterType2_1.class;
+ }
+
+ public void dispose() {
+ //do nothing
+ }
+
+
+ // ********** OrmManagedType implementation **********
+
+ public int getXmlSequence() {
+ return 4;
+ }
+
+ public void addXmlManagedTypeTo(XmlEntityMappings entityMappings) {
+ entityMappings.getConverters().add(this.getXmlConverter());
+ }
+
+ public void removeXmlManagedTypeFrom(XmlEntityMappings entityMappings) {
+ entityMappings.getConverters().remove(this.getXmlConverter());
+ }
+
+ @Override
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) {
+ return jrt != null ? this.getJpaFactory2_1().buildJavaConverterType(this, jrt) : null;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java
new file mode 100644
index 0000000..57b966f
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/GenericOrmXml2_1ContextNodeFactory.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_0ContextNodeFactory;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmXml2_1ContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+
+public class GenericOrmXml2_1ContextNodeFactory
+ extends GenericOrmXml2_0ContextNodeFactory
+ implements OrmXml2_1ContextNodeFactory
+{
+
+ public OrmConverterType2_1 buildOrmConverter(EntityMappings2_1 parent, XmlConverter_2_1 xmlConverter) {
+ return new GenericOrmConverterType(parent, xmlConverter);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java
new file mode 100644
index 0000000..bb22d0a
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2_1/context/orm/OrmConverterTypeDefinition.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmXml2_1ContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlManagedType;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+
+public class OrmConverterTypeDefinition
+ implements OrmManagedTypeDefinition
+{
+ // singleton
+ private static final OrmManagedTypeDefinition INSTANCE = new OrmConverterTypeDefinition();
+
+ /**
+ * Return the singleton.
+ */
+ public static OrmManagedTypeDefinition instance() {
+ return INSTANCE;
+ }
+
+ /**
+ * Enforce singleton usage
+ */
+ private OrmConverterTypeDefinition() {
+ super();
+ }
+
+ public Class<? extends OrmConverterType2_1> getContextType() {
+ return OrmConverterType2_1.class;
+ }
+
+ public Class<? extends XmlManagedType> getResourceType() {
+ return XmlConverter_2_1.class;
+ }
+
+ public OrmManagedType buildContextManagedType(JpaContextNode parent, XmlManagedType resourceManagedType, OrmXmlContextNodeFactory factory) {
+ return ((OrmXml2_1ContextNodeFactory) factory).buildOrmConverter((EntityMappings2_1) parent, (XmlConverter_2_1) resourceManagedType);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java
new file mode 100644
index 0000000..71001de
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/JpaFactory2_1.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.jpa2_1;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.jpa2.JpaFactory2_0;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+
+/**
+ * JPA 2.1 factory
+ *<p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface JpaFactory2_1
+ extends JpaFactory2_0
+{
+
+ JavaConverterType2_1 buildJavaConverterType(JpaContextNode parent, JavaResourceType jrt);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/ConverterType2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/ConverterType2_1.java
new file mode 100644
index 0000000..ba2bd5d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/ConverterType2_1.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.jpa2_1.context;
+
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+
+/**
+ * Context converter type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface ConverterType2_1
+ extends ManagedType
+{
+
+ boolean isAutoApply();
+ String AUTO_APPLY_PROPERTY = "autoApply"; //$NON-NLS-1$
+
+ boolean isDefaultAutoApply();
+ boolean DEFAULT_AUTO_APPLY = false;
+
+ Boolean getSpecifiedAutoApply();
+ void setSpecifiedAutoApply(Boolean autoApply);
+ String SPECIFIED_AUTO_APPLY_PROPERTY = "specifiedAutoApply"; //$NON-NLS-1$
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/java/JavaConverterType2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/java/JavaConverterType2_1.java
new file mode 100644
index 0000000..7d45367
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/java/JavaConverterType2_1.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.jpa2_1.context.java;
+
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.ConverterType2_1;
+
+/**
+ * Context converter type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface JavaConverterType2_1
+ extends ConverterType2_1, JavaManagedType
+{
+ Class<? extends JavaConverterType2_1> getType();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/EntityMappings2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/EntityMappings2_1.java
new file mode 100644
index 0000000..50293f9
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/EntityMappings2_1.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+
+/**
+ * Context model corresponding to the
+ * XML resource model {@link XmlEntityMappings},
+ * which corresponds to the <code>entity-mappings</code> element
+ * in the 2.1 <code>orm.xml</code> file.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+*/
+public interface EntityMappings2_1
+ extends EntityMappings
+{
+
+ Iterable<OrmConverterType2_1> getConverterTypes();
+ OrmConverterType2_1 getConverterType(String className);
+ OrmConverterType2_1 addConverterType(String className);
+ boolean containsConverterType(String className);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmConverterType2_1.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmConverterType2_1.java
new file mode 100644
index 0000000..118d228
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmConverterType2_1.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.ConverterType2_1;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+
+/**
+ * Context converter type.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface OrmConverterType2_1
+ extends ConverterType2_1, OrmManagedType
+{
+
+ Class<? extends OrmConverterType2_1> getType();
+
+ XmlConverter_2_1 getXmlConverter();
+
+ XmlConverter_2_1 getXmlManagedType();
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java
new file mode 100644
index 0000000..db67db8
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2_1/context/orm/OrmXml2_1ContextNodeFactory.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.jpa2_1.context.orm;
+
+import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+
+/**
+ * JPA 2.1 <code>orm.xml</code> context node factory
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface OrmXml2_1ContextNodeFactory
+ extends OrmXmlContextNodeFactory
+{
+ OrmConverterType2_1 buildOrmConverter(EntityMappings2_1 parent, XmlConverter_2_1 xmlConverter);
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/validation/JptJpaCoreValidationMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/validation/JptJpaCoreValidationMessages.java
index db6edd6..66d27b0 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/validation/JptJpaCoreValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/validation/JptJpaCoreValidationMessages.java
@@ -58,10 +58,10 @@ public interface JptJpaCoreValidationMessages {
public static final String ENTITY_NO_PK = "ENTITY_NO_PK";
public static final String ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED = "ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED";
public static final String ENTITY_NON_ROOT_ID_CLASS_SPECIFIED = "ENTITY_NON_ROOT_ID_CLASS_SPECIFIED";
- public static final String PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT = "PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT";
- public static final String PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT = "PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT";
- public static final String PERSISTENT_TYPE_UNRESOLVED_CLASS = "PERSISTENT_TYPE_UNRESOLVED_CLASS";
- public static final String PERSISTENT_TYPE_UNSPECIFIED_CLASS = "PERSISTENT_TYPE_UNSPECIFIED_CLASS";
+ public static final String TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML = "TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML";
+ public static final String TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML = "TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML";
+ public static final String MANAGED_TYPE_UNRESOLVED_CLASS = "MANAGED_TYPE_UNRESOLVED_CLASS";
+ public static final String MANAGED_TYPE_UNSPECIFIED_CLASS = "MANAGED_TYPE_UNSPECIFIED_CLASS";
public static final String TARGET_NOT_AN_EMBEDDABLE = "TARGET_NOT_AN_EMBEDDABLE";
public static final String TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR = "TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR";
public static final String TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR = "TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR";
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverterContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverterContainer.java
index 0e8dde0..eb16849 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverterContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/EclipseLinkConverterContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
+ * Copyright (c) 2011, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -50,7 +50,7 @@ public interface EclipseLinkConverterContainer
/**
* Add a custom converter to the converter holder, return the object representing it.
*/
- EclipseLinkCustomConverter addCustomConverter(int index);
+ EclipseLinkCustomConverter addCustomConverter(String name, int index);
/**
* Remove the custom converter at the index from the converter holder.
@@ -86,7 +86,7 @@ public interface EclipseLinkConverterContainer
/**
* Add a object type converter to the converter holder, return the object representing it.
*/
- EclipseLinkObjectTypeConverter addObjectTypeConverter(int index);
+ EclipseLinkObjectTypeConverter addObjectTypeConverter(String name, int index);
/**
* Remove the object type converter at the index from the converter holder.
@@ -122,7 +122,7 @@ public interface EclipseLinkConverterContainer
/**
* Add a struct converter to the converter holder, return the object representing it.
*/
- EclipseLinkStructConverter addStructConverter(int index);
+ EclipseLinkStructConverter addStructConverter(String name, int index);
/**
* Remove the struct converter at the index from the converter holder.
@@ -158,7 +158,7 @@ public interface EclipseLinkConverterContainer
/**
* Add a type converter to the converter holder, return the object representing it.
*/
- EclipseLinkTypeConverter addTypeConverter(int index);
+ EclipseLinkTypeConverter addTypeConverter(String name, int index);
/**
* Remove the type converter at the index from the converter holder.
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkConverterContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkConverterContainer.java
index a95fb8e..c795af8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkConverterContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/java/JavaEclipseLinkConverterContainer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -34,16 +34,16 @@ public interface JavaEclipseLinkConverterContainer
extends EclipseLinkConverterContainer
{
ListIterable<JavaEclipseLinkCustomConverter> getCustomConverters();
- JavaEclipseLinkCustomConverter addCustomConverter(int index);
+ JavaEclipseLinkCustomConverter addCustomConverter(String name, int index);
ListIterable<JavaEclipseLinkObjectTypeConverter> getObjectTypeConverters();
- JavaEclipseLinkObjectTypeConverter addObjectTypeConverter(int index);
+ JavaEclipseLinkObjectTypeConverter addObjectTypeConverter(String name, int index);
ListIterable<JavaEclipseLinkStructConverter> getStructConverters();
- JavaEclipseLinkStructConverter addStructConverter(int index);
+ JavaEclipseLinkStructConverter addStructConverter(String name, int index);
ListIterable<JavaEclipseLinkTypeConverter> getTypeConverters();
- JavaEclipseLinkTypeConverter addTypeConverter(int index);
+ JavaEclipseLinkTypeConverter addTypeConverter(String name, int index);
/**
* Parent adapter
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkConverterContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkConverterContainer.java
index 7db14a8..899a53c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkConverterContainer.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/context/orm/OrmEclipseLinkConverterContainer.java
@@ -34,20 +34,20 @@ public interface OrmEclipseLinkConverterContainer
{
ListIterable<OrmEclipseLinkCustomConverter> getCustomConverters();
- OrmEclipseLinkCustomConverter addCustomConverter(int index);
- OrmEclipseLinkCustomConverter addCustomConverter();
+ OrmEclipseLinkCustomConverter addCustomConverter(String name, int index);
+ OrmEclipseLinkCustomConverter addCustomConverter(String name);
ListIterable<OrmEclipseLinkObjectTypeConverter> getObjectTypeConverters();
- OrmEclipseLinkObjectTypeConverter addObjectTypeConverter(int index);
- OrmEclipseLinkObjectTypeConverter addObjectTypeConverter();
+ OrmEclipseLinkObjectTypeConverter addObjectTypeConverter(String name, int index);
+ OrmEclipseLinkObjectTypeConverter addObjectTypeConverter(String name);
ListIterable<OrmEclipseLinkStructConverter> getStructConverters();
- OrmEclipseLinkStructConverter addStructConverter(int index);
- OrmEclipseLinkStructConverter addStructConverter();
+ OrmEclipseLinkStructConverter addStructConverter(String name, int index);
+ OrmEclipseLinkStructConverter addStructConverter(String name);
ListIterable<OrmEclipseLinkTypeConverter> getTypeConverters();
- OrmEclipseLinkTypeConverter addTypeConverter(int index);
- OrmEclipseLinkTypeConverter addTypeConverter();
+ OrmEclipseLinkTypeConverter addTypeConverter(String name, int index);
+ OrmEclipseLinkTypeConverter addTypeConverter(String name);
interface Owner {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java
new file mode 100644
index 0000000..42fe680
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaFactory.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal;
+
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.GenericJavaConverterType;
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaFactory2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+
+/**
+ * EclipseLink 2.5 factory
+ */
+public class EclipseLink2_5JpaFactory
+ extends EclipseLink2_4JpaFactory
+ implements JpaFactory2_1
+{
+ public EclipseLink2_5JpaFactory() {
+ super();
+ }
+
+ public JavaConverterType2_1 buildJavaConverterType(JpaContextNode parent, JavaResourceType jrt) {
+ return new GenericJavaConverterType(parent, jrt);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformFactory.java
index f79c738..1bbf2a2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformFactory.java
@@ -47,7 +47,7 @@ public class EclipseLink2_5JpaPlatformFactory
return new GenericJpaPlatform(
config,
buildJpaVersion(),
- new EclipseLink2_4JpaFactory(),
+ new EclipseLink2_5JpaFactory(),
buildAnnotationProvider(),
EclipseLink2_5JpaPlatformProvider.instance(),
buildJpaVariation(),
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformProvider.java
index 803fae3..780b15e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/EclipseLink2_5JpaPlatformProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,6 +17,7 @@ import org.eclipse.jpt.jpa.core.JpaResourceModelProvider;
import org.eclipse.jpt.jpa.core.ResourceDefinition;
import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.AbstractJpaPlatformProvider;
import org.eclipse.jpt.jpa.core.internal.JarResourceModelProvider;
@@ -24,12 +25,14 @@ import org.eclipse.jpt.jpa.core.internal.JavaResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.OrmResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.PersistenceResourceModelProvider;
import org.eclipse.jpt.jpa.core.internal.context.java.JarDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.java.JavaPersistentTypeDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaSourceFileDefinition;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaTransientMappingDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXmlDefinition;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_0Definition;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.GenericOrmXml2_1Definition;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_1Definition;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.java.JavaConverterTypeDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaArrayMappingDefinition2_3;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicCollectionMappingDefinition2_0;
import org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.EclipseLinkJavaBasicMapMappingDefinition2_0;
@@ -145,6 +148,25 @@ public class EclipseLink2_5JpaPlatformProvider
};
+ // ********* Java managed types *********
+
+ /**
+ * To the specified list, add java managed type definitions to use for
+ * analyzing the type given all annotations on it. The order is
+ * important, as once a managed type definition tests positive for a
+ * type, all following managed type definitions are ignored.
+ */
+ @Override
+ protected void addJavaManagedTypeDefinitionsTo(ArrayList<JavaManagedTypeDefinition> definitions) {
+ CollectionTools.addAll(definitions, JAVA_MANAGED_TYPE_DEFINITIONS_2_5);
+ }
+
+ protected static final JavaManagedTypeDefinition[] JAVA_MANAGED_TYPE_DEFINITIONS_2_5 = new JavaManagedTypeDefinition[] {
+ JavaPersistentTypeDefinition.instance(),
+ JavaConverterTypeDefinition.instance()
+ };
+
+
// ********* Java type mappings *********
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverterContainerImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverterContainerImpl.java
index 9ab235a..8f9c63a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverterContainerImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkConverterContainerImpl.java
@@ -84,17 +84,19 @@ public class JavaEclipseLinkConverterContainerImpl
return this.customConverterContainer.getContextElementsSize();
}
- public JavaEclipseLinkCustomConverter addCustomConverter() {
- return this.addCustomConverter(this.getCustomConvertersSize());
+ public JavaEclipseLinkCustomConverter addCustomConverter(String name) {
+ return this.addCustomConverter(name, this.getCustomConvertersSize());
}
- public JavaEclipseLinkCustomConverter addCustomConverter(int index) {
- EclipseLinkConverterAnnotation annotation = this.addCustomConverterAnnotation(index);
+ public JavaEclipseLinkCustomConverter addCustomConverter(String name, int index) {
+ EclipseLinkConverterAnnotation annotation = this.addCustomConverterAnnotation(name, index);
return this.customConverterContainer.addContextElement(index, annotation);
}
- protected EclipseLinkConverterAnnotation addCustomConverterAnnotation(int index) {
- return (EclipseLinkConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkConverterAnnotation.ANNOTATION_NAME);
+ protected EclipseLinkConverterAnnotation addCustomConverterAnnotation(String name, int index) {
+ EclipseLinkConverterAnnotation annotation = (EclipseLinkConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkConverterAnnotation.ANNOTATION_NAME);
+ annotation.setName(name);
+ return annotation;
}
public void removeCustomConverter(EclipseLinkCustomConverter customConverter) {
@@ -169,17 +171,19 @@ public class JavaEclipseLinkConverterContainerImpl
return this.objectTypeConverterContainer.getContextElementsSize();
}
- public JavaEclipseLinkObjectTypeConverter addObjectTypeConverter() {
- return this.addObjectTypeConverter(this.getObjectTypeConvertersSize());
+ public JavaEclipseLinkObjectTypeConverter addObjectTypeConverter(String name) {
+ return this.addObjectTypeConverter(name, this.getObjectTypeConvertersSize());
}
- public JavaEclipseLinkObjectTypeConverter addObjectTypeConverter(int index) {
- EclipseLinkObjectTypeConverterAnnotation annotation = this.addObjectTypeConverterAnnotation(index);
+ public JavaEclipseLinkObjectTypeConverter addObjectTypeConverter(String name, int index) {
+ EclipseLinkObjectTypeConverterAnnotation annotation = this.addObjectTypeConverterAnnotation(name, index);
return this.objectTypeConverterContainer.addContextElement(index, annotation);
}
- protected EclipseLinkObjectTypeConverterAnnotation addObjectTypeConverterAnnotation(int index) {
- return (EclipseLinkObjectTypeConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
+ protected EclipseLinkObjectTypeConverterAnnotation addObjectTypeConverterAnnotation(String name, int index) {
+ EclipseLinkObjectTypeConverterAnnotation annotation = (EclipseLinkObjectTypeConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkObjectTypeConverterAnnotation.ANNOTATION_NAME);
+ annotation.setName(name);
+ return annotation;
}
public void removeObjectTypeConverter(EclipseLinkObjectTypeConverter objectTypeConverter) {
@@ -254,17 +258,19 @@ public class JavaEclipseLinkConverterContainerImpl
return this.structConverterContainer.getContextElementsSize();
}
- public JavaEclipseLinkStructConverter addStructConverter() {
- return this.addStructConverter(this.getStructConvertersSize());
+ public JavaEclipseLinkStructConverter addStructConverter(String name) {
+ return this.addStructConverter(name, this.getStructConvertersSize());
}
- public JavaEclipseLinkStructConverter addStructConverter(int index) {
- EclipseLinkStructConverterAnnotation annotation = this.addStructConverterAnnotation(index);
+ public JavaEclipseLinkStructConverter addStructConverter(String name, int index) {
+ EclipseLinkStructConverterAnnotation annotation = this.addStructConverterAnnotation(name, index);
return this.structConverterContainer.addContextElement(index, annotation);
}
- protected EclipseLinkStructConverterAnnotation addStructConverterAnnotation(int index) {
- return (EclipseLinkStructConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
+ protected EclipseLinkStructConverterAnnotation addStructConverterAnnotation(String name, int index) {
+ EclipseLinkStructConverterAnnotation annotation = (EclipseLinkStructConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkStructConverterAnnotation.ANNOTATION_NAME);
+ annotation.setName(name);
+ return annotation;
}
public void removeStructConverter(EclipseLinkStructConverter structConverter) {
@@ -340,17 +346,19 @@ public class JavaEclipseLinkConverterContainerImpl
return this.typeConverterContainer.getContextElementsSize();
}
- public JavaEclipseLinkTypeConverter addTypeConverter() {
- return this.addTypeConverter(this.getTypeConvertersSize());
+ public JavaEclipseLinkTypeConverter addTypeConverter(String name) {
+ return this.addTypeConverter(name, this.getTypeConvertersSize());
}
- public JavaEclipseLinkTypeConverter addTypeConverter(int index) {
- EclipseLinkTypeConverterAnnotation annotation = this.addTypeConverterAnnotation(index);
+ public JavaEclipseLinkTypeConverter addTypeConverter(String name, int index) {
+ EclipseLinkTypeConverterAnnotation annotation = this.addTypeConverterAnnotation(name, index);
return this.typeConverterContainer.addContextElement(index, annotation);
}
- protected EclipseLinkTypeConverterAnnotation addTypeConverterAnnotation(int index) {
- return (EclipseLinkTypeConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
+ protected EclipseLinkTypeConverterAnnotation addTypeConverterAnnotation(String name, int index) {
+ EclipseLinkTypeConverterAnnotation annotation = (EclipseLinkTypeConverterAnnotation) this.getJavaResourceAnnotatedElement().addAnnotation(index, EclipseLinkTypeConverterAnnotation.ANNOTATION_NAME);
+ annotation.setName(name);
+ return annotation;
}
public void removeTypeConverter(EclipseLinkTypeConverter typeConverter) {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java
index a5b82f3..1bf1013 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkCustomConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -101,7 +101,7 @@ public class JavaEclipseLinkCustomConverter
@Override
public void convertTo(OrmEclipseLinkConverterContainer ormConverterContainer) {
- ormConverterContainer.addCustomConverter().convertFrom(this);
+ ormConverterContainer.addCustomConverter(this.getName()).convertFrom(this);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java
index 14c9bf3..46708d5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkObjectTypeConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -332,7 +332,7 @@ public class JavaEclipseLinkObjectTypeConverter
@Override
public void convertTo(OrmEclipseLinkConverterContainer ormConverterContainer) {
- ormConverterContainer.addObjectTypeConverter().convertFrom(this);
+ ormConverterContainer.addObjectTypeConverter(this.getName()).convertFrom(this);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkStructConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkStructConverter.java
index 81fd37e..2145a5c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkStructConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkStructConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -76,7 +76,7 @@ public class JavaEclipseLinkStructConverter
@Override
public void convertTo(OrmEclipseLinkConverterContainer ormConverterContainer) {
- ormConverterContainer.addStructConverter().convertFrom(this);
+ ormConverterContainer.addStructConverter(this.getName()).convertFrom(this);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkTypeConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkTypeConverter.java
index 11b822d..53cd36d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkTypeConverter.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkTypeConverter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -141,7 +141,7 @@ public class JavaEclipseLinkTypeConverter
@Override
public void convertTo(OrmEclipseLinkConverterContainer ormConverterContainer) {
- ormConverterContainer.addTypeConverter().convertFrom(this);
+ ormConverterContainer.addTypeConverter(this.getName()).convertFrom(this);
}
@Override
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/AbstractOrmEclipseLinkConverterContainerImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/AbstractOrmEclipseLinkConverterContainerImpl.java
new file mode 100644
index 0000000..6c02fa5
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/AbstractOrmEclipseLinkConverterContainerImpl.java
@@ -0,0 +1,582 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
+
+import java.util.List;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jpt.common.core.utility.TextRange;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.iterable.ListIterable;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
+import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverterContainer;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
+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 AbstractOrmEclipseLinkConverterContainerImpl
+ extends AbstractOrmXmlContextNode
+ implements OrmEclipseLinkConverterContainer
+{
+
+ private final Owner owner;
+ protected final XmlConverterContainer xmlConverterContainer;
+
+ protected final ContextListContainer<OrmEclipseLinkCustomConverter, XmlConverter_2_1> customConverterContainer;
+ protected final ContextListContainer<OrmEclipseLinkObjectTypeConverter, XmlObjectTypeConverter> objectTypeConverterContainer;
+ protected final ContextListContainer<OrmEclipseLinkStructConverter, XmlStructConverter> structConverterContainer;
+ protected final ContextListContainer<OrmEclipseLinkTypeConverter, XmlTypeConverter> typeConverterContainer;
+
+
+ protected AbstractOrmEclipseLinkConverterContainerImpl(JpaContextNode parent, Owner owner, XmlConverterContainer xmlConverterContainer) {
+ super(parent);
+ this.owner = owner;
+ this.xmlConverterContainer = xmlConverterContainer;
+
+ this.customConverterContainer = this.buildCustomConverterContainer();
+ this.objectTypeConverterContainer = this.buildObjectTypeConverterContainer();
+ this.structConverterContainer = this.buildStructConverterContainer();
+ this.typeConverterContainer = this.buildTypeConverterContainer();
+ }
+
+
+ // ********** synchronize/update **********
+
+ @Override
+ public void synchronizeWithResourceModel() {
+ super.synchronizeWithResourceModel();
+ this.syncCustomConverters();
+ this.syncObjectTypeConverters();
+ this.syncStructConverters();
+ this.syncTypeConverters();
+ }
+
+ @Override
+ public void update() {
+ super.update();
+ this.updateNodes(this.getCustomConverters());
+ this.updateNodes(this.getObjectTypeConverters());
+ this.updateNodes(this.getStructConverters());
+ this.updateNodes(this.getTypeConverters());
+ }
+
+
+ // ********** custom converters **********
+
+ public ListIterable<OrmEclipseLinkCustomConverter> getCustomConverters() {
+ return this.customConverterContainer.getContextElements();
+ }
+
+ public int getCustomConvertersSize() {
+ return this.customConverterContainer.getContextElementsSize();
+ }
+
+ public OrmEclipseLinkCustomConverter addCustomConverter(String name) {
+ return this.addCustomConverter(name, this.getCustomConvertersSize());
+ }
+
+ public OrmEclipseLinkCustomConverter addCustomConverter(String name, int index) {
+ XmlConverter xmlConverter = this.buildXmlCustomConverter(name);
+ OrmEclipseLinkCustomConverter converter = this.customConverterContainer.addContextElement(index, xmlConverter);
+ this.xmlConverterContainer.getConverters().add(index, xmlConverter);
+ return converter;
+ }
+
+ protected XmlConverter buildXmlCustomConverter(String name) {
+ XmlConverter converter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
+ converter.setName(name);
+ return converter;
+ }
+
+ public void removeCustomConverter(EclipseLinkCustomConverter converter) {
+ this.removeCustomConverter(this.customConverterContainer.indexOfContextElement((OrmEclipseLinkCustomConverter) converter));
+ }
+
+ public void removeCustomConverter(int index) {
+ this.customConverterContainer.removeContextElement(index);
+ this.xmlConverterContainer.getConverters().remove(index);
+ }
+
+ public void moveCustomConverter(int targetIndex, int sourceIndex) {
+ this.customConverterContainer.moveContextElement(targetIndex, sourceIndex);
+ this.xmlConverterContainer.getConverters().move(targetIndex, sourceIndex);
+ }
+
+ protected OrmEclipseLinkCustomConverter buildCustomConverter(XmlConverter xmlConverter) {
+ return new OrmEclipseLinkCustomConverter(this, xmlConverter);
+ }
+
+ protected void syncCustomConverters() {
+ this.customConverterContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<XmlConverter_2_1> getXmlCustomConverters() {
+ // clone to reduce chance of concurrency problems
+ return IterableTools.cloneLive(this.getNamedXmlConverters());
+ }
+
+ protected List<XmlConverter_2_1> getNamedXmlConverters() {
+ return this.xmlConverterContainer.getConverters();
+ }
+
+ protected ContextListContainer<OrmEclipseLinkCustomConverter, XmlConverter_2_1> buildCustomConverterContainer() {
+ CustomConverterContainer container = new CustomConverterContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * custom converter container
+ */
+ protected class CustomConverterContainer
+ extends ContextListContainer<OrmEclipseLinkCustomConverter, XmlConverter_2_1>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return CUSTOM_CONVERTERS_LIST;
+ }
+ @Override
+ protected OrmEclipseLinkCustomConverter buildContextElement(XmlConverter_2_1 resourceElement) {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.buildCustomConverter((XmlConverter) resourceElement);
+ }
+ @Override
+ protected ListIterable<XmlConverter_2_1> getResourceElements() {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.getXmlCustomConverters();
+ }
+ @Override
+ protected XmlConverter_2_1 getResourceElement(OrmEclipseLinkCustomConverter contextElement) {
+ return contextElement.getXmlConverter();
+ }
+ }
+
+
+ // ********** object type converters **********
+
+ public ListIterable<OrmEclipseLinkObjectTypeConverter> getObjectTypeConverters() {
+ return this.objectTypeConverterContainer.getContextElements();
+ }
+
+ public int getObjectTypeConvertersSize() {
+ return this.objectTypeConverterContainer.getContextElementsSize();
+ }
+
+ public OrmEclipseLinkObjectTypeConverter addObjectTypeConverter(String name) {
+ return this.addObjectTypeConverter(name, this.getObjectTypeConvertersSize());
+ }
+
+ public OrmEclipseLinkObjectTypeConverter addObjectTypeConverter(String name, int index) {
+ XmlObjectTypeConverter xmlConverter = this.buildXmlObjectTypeConverter(name);
+ OrmEclipseLinkObjectTypeConverter converter = this.objectTypeConverterContainer.addContextElement(index, xmlConverter);
+ this.xmlConverterContainer.getObjectTypeConverters().add(index, xmlConverter);
+ return converter;
+ }
+
+ protected XmlObjectTypeConverter buildXmlObjectTypeConverter(String name) {
+ XmlObjectTypeConverter converter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
+ converter.setName(name);
+ return converter;
+ }
+
+ public void removeObjectTypeConverter(EclipseLinkObjectTypeConverter converter) {
+ this.removeObjectTypeConverter(this.objectTypeConverterContainer.indexOfContextElement((OrmEclipseLinkObjectTypeConverter) converter));
+ }
+
+ public void removeObjectTypeConverter(int index) {
+ this.objectTypeConverterContainer.removeContextElement(index);
+ this.xmlConverterContainer.getObjectTypeConverters().remove(index);
+ }
+
+ public void moveObjectTypeConverter(int targetIndex, int sourceIndex) {
+ this.objectTypeConverterContainer.moveContextElement(targetIndex, sourceIndex);
+ this.xmlConverterContainer.getObjectTypeConverters().move(targetIndex, sourceIndex);
+ }
+
+ protected OrmEclipseLinkObjectTypeConverter buildObjectTypeConverter(XmlObjectTypeConverter xmlConverter) {
+ return new OrmEclipseLinkObjectTypeConverter(this, xmlConverter);
+ }
+
+ protected void syncObjectTypeConverters() {
+ this.objectTypeConverterContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<XmlObjectTypeConverter> getXmlObjectTypeConverters() {
+ // clone to reduce chance of concurrency problems
+ return IterableTools.cloneLive(this.xmlConverterContainer.getObjectTypeConverters());
+ }
+
+ protected ContextListContainer<OrmEclipseLinkObjectTypeConverter, XmlObjectTypeConverter> buildObjectTypeConverterContainer() {
+ ObjectTypeConverterContainer container = new ObjectTypeConverterContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * object type converter container
+ */
+ protected class ObjectTypeConverterContainer
+ extends ContextListContainer<OrmEclipseLinkObjectTypeConverter, XmlObjectTypeConverter>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return OBJECT_TYPE_CONVERTERS_LIST;
+ }
+ @Override
+ protected OrmEclipseLinkObjectTypeConverter buildContextElement(XmlObjectTypeConverter resourceElement) {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.buildObjectTypeConverter(resourceElement);
+ }
+ @Override
+ protected ListIterable<XmlObjectTypeConverter> getResourceElements() {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.getXmlObjectTypeConverters();
+ }
+ @Override
+ protected XmlObjectTypeConverter getResourceElement(OrmEclipseLinkObjectTypeConverter contextElement) {
+ return contextElement.getXmlConverter();
+ }
+ }
+
+ // ********** struct converters **********
+
+ public ListIterable<OrmEclipseLinkStructConverter> getStructConverters() {
+ return this.structConverterContainer.getContextElements();
+ }
+
+ public int getStructConvertersSize() {
+ return this.structConverterContainer.getContextElementsSize();
+ }
+
+ public OrmEclipseLinkStructConverter addStructConverter(String name) {
+ return this.addStructConverter(name, this.getStructConvertersSize());
+ }
+
+ public OrmEclipseLinkStructConverter addStructConverter(String name, int index) {
+ XmlStructConverter xmlConverter = this.buildXmlStructConverter(name);
+ OrmEclipseLinkStructConverter converter = this.structConverterContainer.addContextElement(index, xmlConverter);
+ this.xmlConverterContainer.getStructConverters().add(index, xmlConverter);
+ return converter;
+ }
+
+ protected XmlStructConverter buildXmlStructConverter(String name) {
+ XmlStructConverter converter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
+ converter.setName(name);
+ return converter;
+ }
+
+ public void removeStructConverter(EclipseLinkStructConverter converter) {
+ this.removeStructConverter(this.structConverterContainer.indexOfContextElement((OrmEclipseLinkStructConverter) converter));
+ }
+
+ public void removeStructConverter(int index) {
+ this.structConverterContainer.removeContextElement(index);
+ this.xmlConverterContainer.getStructConverters().remove(index);
+ }
+
+ public void moveStructConverter(int targetIndex, int sourceIndex) {
+ this.structConverterContainer.moveContextElement(targetIndex, sourceIndex);
+ this.xmlConverterContainer.getStructConverters().move(targetIndex, sourceIndex);
+ }
+
+ protected OrmEclipseLinkStructConverter buildStructConverter(XmlStructConverter xmlConverter) {
+ return new OrmEclipseLinkStructConverter(this, xmlConverter);
+ }
+
+ protected void syncStructConverters() {
+ this.structConverterContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<XmlStructConverter> getXmlStructConverters() {
+ // clone to reduce chance of concurrency problems
+ return IterableTools.cloneLive(this.xmlConverterContainer.getStructConverters());
+ }
+
+ protected ContextListContainer<OrmEclipseLinkStructConverter, XmlStructConverter> buildStructConverterContainer() {
+ StructConverterContainer container = new StructConverterContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * struct converter container
+ */
+ protected class StructConverterContainer
+ extends ContextListContainer<OrmEclipseLinkStructConverter, XmlStructConverter>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return STRUCT_CONVERTERS_LIST;
+ }
+ @Override
+ protected OrmEclipseLinkStructConverter buildContextElement(XmlStructConverter resourceElement) {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.buildStructConverter(resourceElement);
+ }
+ @Override
+ protected ListIterable<XmlStructConverter> getResourceElements() {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.getXmlStructConverters();
+ }
+ @Override
+ protected XmlStructConverter getResourceElement(OrmEclipseLinkStructConverter contextElement) {
+ return contextElement.getXmlConverter();
+ }
+ }
+
+
+ // ********** type converters **********
+
+ public ListIterable<OrmEclipseLinkTypeConverter> getTypeConverters() {
+ return this.typeConverterContainer.getContextElements();
+ }
+
+ public int getTypeConvertersSize() {
+ return this.typeConverterContainer.getContextElementsSize();
+ }
+
+ public OrmEclipseLinkTypeConverter addTypeConverter(String name) {
+ return this.addTypeConverter(name, this.getTypeConvertersSize());
+ }
+
+ public OrmEclipseLinkTypeConverter addTypeConverter(String name, int index) {
+ XmlTypeConverter xmlConverter = this.buildXmlTypeConverter(name);
+ OrmEclipseLinkTypeConverter converter = this.typeConverterContainer.addContextElement(index, xmlConverter);
+ this.xmlConverterContainer.getTypeConverters().add(index, xmlConverter);
+ return converter;
+ }
+
+ protected XmlTypeConverter buildXmlTypeConverter(String name) {
+ XmlTypeConverter converter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
+ converter.setName(name);
+ return converter;
+ }
+
+ public void removeTypeConverter(EclipseLinkTypeConverter converter) {
+ this.removeTypeConverter(this.typeConverterContainer.indexOfContextElement((OrmEclipseLinkTypeConverter) converter));
+ }
+
+ public void removeTypeConverter(int index) {
+ this.typeConverterContainer.removeContextElement(index);
+ this.xmlConverterContainer.getTypeConverters().remove(index);
+ }
+
+ public void moveTypeConverter(int targetIndex, int sourceIndex) {
+ this.typeConverterContainer.moveContextElement(targetIndex, sourceIndex);
+ this.xmlConverterContainer.getTypeConverters().move(targetIndex, sourceIndex);
+ }
+
+ protected OrmEclipseLinkTypeConverter buildTypeConverter(XmlTypeConverter xmlConverter) {
+ return new OrmEclipseLinkTypeConverter(this, xmlConverter);
+ }
+
+ protected void syncTypeConverters() {
+ this.typeConverterContainer.synchronizeWithResourceModel();
+ }
+
+ protected ListIterable<XmlTypeConverter> getXmlTypeConverters() {
+ // clone to reduce chance of concurrency problems
+ return IterableTools.cloneLive(this.xmlConverterContainer.getTypeConverters());
+ }
+
+ protected ContextListContainer<OrmEclipseLinkTypeConverter, XmlTypeConverter> buildTypeConverterContainer() {
+ TypeConverterContainer container = new TypeConverterContainer();
+ container.initialize();
+ return container;
+ }
+
+ /**
+ * type converter container
+ */
+ protected class TypeConverterContainer
+ extends ContextListContainer<OrmEclipseLinkTypeConverter, XmlTypeConverter>
+ {
+ @Override
+ protected String getContextElementsPropertyName() {
+ return TYPE_CONVERTERS_LIST;
+ }
+ @Override
+ protected OrmEclipseLinkTypeConverter buildContextElement(XmlTypeConverter resourceElement) {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.buildTypeConverter(resourceElement);
+ }
+ @Override
+ protected ListIterable<XmlTypeConverter> getResourceElements() {
+ return AbstractOrmEclipseLinkConverterContainerImpl.this.getXmlTypeConverters();
+ }
+ @Override
+ protected XmlTypeConverter getResourceElement(OrmEclipseLinkTypeConverter contextElement) {
+ return contextElement.getXmlConverter();
+ }
+ }
+
+
+ // ********** refactoring **********
+
+ @SuppressWarnings("unchecked")
+ public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
+ return IterableTools.concatenate(
+ this.createRenameObjectTypeConverterEdits(originalType, newName),
+ this.createRenameTypeConverterEdits(originalType, newName),
+ this.createRenameStructConverterEdits(originalType, newName),
+ this.createRenameCustomConverterEdits(originalType, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createRenameObjectTypeConverterEdits(IType originalType, String newName) {
+ return IterableTools.children(getObjectTypeConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createRenameTypeConverterEdits(IType originalType, String newName) {
+ return IterableTools.children(getTypeConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createRenameStructConverterEdits(IType originalType, String newName) {
+ return IterableTools.children(getStructConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createRenameCustomConverterEdits(IType originalType, String newName) {
+ return IterableTools.children(getCustomConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
+ }
+
+ @SuppressWarnings("unchecked")
+ public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
+ return IterableTools.concatenate(
+ this.createMoveObjectTypeConverterEdits(originalType, newPackage),
+ this.createMoveTypeConverterEdits(originalType, newPackage),
+ this.createMoveStructConverterEdits(originalType, newPackage),
+ this.createMoveCustomConverterEdits(originalType, newPackage));
+ }
+
+ protected Iterable<ReplaceEdit> createMoveObjectTypeConverterEdits(IType originalType, IPackageFragment newPackage) {
+ return IterableTools.children(getObjectTypeConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
+ }
+
+ protected Iterable<ReplaceEdit> createMoveTypeConverterEdits(IType originalType, IPackageFragment newPackage) {
+ return IterableTools.children(getTypeConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
+ }
+
+ protected Iterable<ReplaceEdit> createMoveStructConverterEdits(IType originalType, IPackageFragment newPackage) {
+ return IterableTools.children(getStructConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
+ }
+
+ protected Iterable<ReplaceEdit> createMoveCustomConverterEdits(IType originalType, IPackageFragment newPackage) {
+ return IterableTools.children(getCustomConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return IterableTools.concatenate(
+ this.createObjectTypeConverterRenamePackageEdits(originalPackage, newName),
+ this.createTypeConverterRenamePackageEdits(originalPackage, newName),
+ this.createStructConverterRenamePackageEdits(originalPackage, newName),
+ this.createCustomConverterRenamePackageEdits(originalPackage, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createObjectTypeConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return IterableTools.children(getObjectTypeConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createTypeConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return IterableTools.children(getTypeConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createStructConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return IterableTools.children(getStructConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
+ }
+
+ protected Iterable<ReplaceEdit> createCustomConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
+ return IterableTools.children(getCustomConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
+ }
+
+
+ // ********** validation **********
+
+ /**
+ * The converters are validated in the persistence unit.
+ * @see org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit#validateConverters(List, IReporter)
+ */
+ @Override
+ public void validate(List<IMessage> messages, IReporter reporter) {
+ super.validate(messages, reporter);
+ // converters are validated in the persistence unit
+ }
+
+ public TextRange getValidationTextRange() {
+ TextRange textRange = this.xmlConverterContainer.getValidationTextRange();
+ return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
+ }
+
+
+ // ********** misc **********
+
+ @SuppressWarnings("unchecked")
+ public Iterable<EclipseLinkConverter> getConverters() {
+ return IterableTools.<EclipseLinkConverter>concatenate(
+ this.getCustomConverters(),
+ this.getObjectTypeConverters(),
+ this.getStructConverters(),
+ this.getTypeConverters()
+ );
+ }
+
+ public int getConvertersSize() {
+ return this.getCustomConvertersSize()
+ + this.getObjectTypeConvertersSize()
+ + this.getStructConvertersSize()
+ + this.getTypeConvertersSize();
+ }
+
+ public int getNumberSupportedConverters() {
+ return this.owner.getNumberSupportedConverters();
+ }
+
+ // ********** completion proposals **********
+
+ @Override
+ public Iterable<String> getCompletionProposals(int pos) {
+ Iterable<String> result = super.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ for (OrmEclipseLinkCustomConverter converter : this.customConverterContainer.getContextElements()) {
+ result = converter.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ for (OrmEclipseLinkStructConverter converter : this.structConverterContainer.getContextElements()) {
+ result = converter.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ for (OrmEclipseLinkObjectTypeConverter converter : this.objectTypeConverterContainer.getContextElements()) {
+ result = converter.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ for (OrmEclipseLinkTypeConverter converter : this.typeConverterContainer.getContextElements()) {
+ result = converter.getCompletionProposals(pos);
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java
index b924cb8..be8c0c6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkEntityMappingsImpl.java
@@ -9,6 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jdt.core.IPackageFragment;
@@ -26,6 +27,7 @@ import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedDiscriminatorColumn;
import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
import org.eclipse.jpt.jpa.db.Table;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConverter;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeMapping;
@@ -40,6 +42,7 @@ import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersi
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlAccessMethods;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlNamedConverter;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTenantDiscriminatorColumn;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlUuidGenerator;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_3.XmlTenantDiscriminatorColumn_2_3;
@@ -129,6 +132,21 @@ public class EclipseLinkEntityMappingsImpl
}
+ // ********** managed types **********
+
+ @Override
+ protected List<XmlConverter_2_1> getXml2_1Converters() {
+ ArrayList<XmlConverter_2_1> xmlConverters = new ArrayList<XmlConverter_2_1>();
+ for (XmlConverter_2_1 xmlConverter : this.xmlEntityMappings.getConverters()) {
+ if (((XmlNamedConverter) xmlConverter).getName() == null){
+ xmlConverters.add(xmlConverter);
+ }
+ }
+
+ return xmlConverters;
+ }
+
+
// ********** converter container **********
public OrmEclipseLinkConverterContainer getConverterContainer() {
@@ -136,7 +154,7 @@ public class EclipseLinkEntityMappingsImpl
}
protected OrmEclipseLinkConverterContainer buildConverterContainer() {
- return new OrmEclipseLinkConverterContainerImpl(this, this, (XmlEntityMappings) this.xmlEntityMappings);
+ return new OrmEclipseLinkEntityMappingsConverterContainer(this, this, (XmlEntityMappings) this.xmlEntityMappings);
}
public int getNumberSupportedConverters() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java
index c08656d..b65a7c2 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmPersistentTypeImpl.java
@@ -14,15 +14,14 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.utility.jdt.TypeBinding;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
import org.eclipse.jpt.jpa.core.internal.context.orm.SpecifiedOrmPersistentType;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
import org.eclipse.jpt.jpa.core.jpa2.context.PersistentType2_0;
import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.validation.JptJpaCoreValidationMessages;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkAccessType;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkOrmPersistentType;
@@ -102,9 +101,9 @@ public class EclipseLinkOrmPersistentTypeImpl
boolean old = this.dynamic;
this.dynamic = dynamic;
if (this.firePropertyChanged(DYNAMIC_PROPERTY, old, this.dynamic)) {
- // clear out the Java persistent type here, it will be rebuilt during "update"
- if (this.javaPersistentType != null) {
- this.setJavaPersistentType(null);
+ // clear out the Java managed type here, it will be rebuilt during "update"
+ if (this.javaManagedType != null) {
+ this.setJavaManagedType(null);
}
}
}
@@ -128,10 +127,10 @@ public class EclipseLinkOrmPersistentTypeImpl
}
@Override
- protected JavaPersistentType buildJavaPersistentType(JavaResourceType javaResourceType) {
+ protected JavaManagedType buildJavaManagedType(JavaResourceType jrt) {
return this.isDynamic() ?
this.buildVirtualJavaPersistentType() :
- super.buildJavaPersistentType(javaResourceType);
+ super.buildJavaManagedType(jrt);
}
protected JavaPersistentType buildVirtualJavaPersistentType() {
@@ -324,17 +323,9 @@ public class EclipseLinkOrmPersistentTypeImpl
}
@Override
- protected void validateClass(List<IMessage> messages) {
+ protected void validateClassResolves(List<IMessage> messages) {
if (this.isDynamic() && !this.isVirtualAccess()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JptJpaCoreValidationMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS,
- new String[] {this.getName()},
- this,
- this.mapping.getClassTextRange()
- )
- );
+ super.validateClassResolves(messages);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java
new file mode 100644
index 0000000..df7cf82
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5ContextNodeFactory.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
+
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.GenericOrmConverterType;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmXml2_1ContextNodeFactory;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+
+public class EclipseLinkOrmXml2_5ContextNodeFactory
+ extends EclipseLinkOrmXml2_4ContextNodeFactory
+ implements OrmXml2_1ContextNodeFactory
+{
+ public OrmConverterType2_1 buildOrmConverter(EntityMappings2_1 parent, XmlConverter_2_1 xmlConverter) {
+ return new GenericOrmConverterType(parent, xmlConverter);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5Definition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5Definition.java
index 91d4741..799e2f6 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5Definition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/EclipseLinkOrmXml2_5Definition.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 Oracle. All rights reserved.
+ * Copyright (c) 2012, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -10,12 +10,14 @@
package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
import java.util.ArrayList;
-
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.common.utility.internal.collection.CollectionTools;
import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedTypeDefinition;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
+import org.eclipse.jpt.jpa.core.internal.context.orm.OrmPersistentTypeDefinition;
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.context.orm.OrmConverterTypeDefinition;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_5.EclipseLink2_5;
@@ -49,9 +51,23 @@ public class EclipseLinkOrmXml2_5Definition
@Override
protected OrmXmlContextNodeFactory buildContextNodeFactory() {
- return new EclipseLinkOrmXml2_4ContextNodeFactory();
+ return new EclipseLinkOrmXml2_5ContextNodeFactory();
+ }
+
+
+ // ********* Managed Types *********
+
+ @Override
+ protected void addManagedTypeDefinitionsTo(ArrayList<OrmManagedTypeDefinition> definitions) {
+ CollectionTools.addAll(definitions, MANAGED_TYPE_DEFINITIONS_2_5);
}
+ protected static final OrmManagedTypeDefinition[] MANAGED_TYPE_DEFINITIONS_2_5 = new OrmManagedTypeDefinition[] {
+ OrmPersistentTypeDefinition.instance(),
+ OrmConverterTypeDefinition.instance(),
+ };
+
+
@Override
protected void addAttributeMappingDefinitionsTo(ArrayList<OrmAttributeMappingDefinition> definitions) {
CollectionTools.addAll(definitions, EclipseLinkOrmXml2_3Definition.ECLIPSELINK_2_3_ATTRIBUTE_MAPPING_DEFINITIONS);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverterContainerImpl.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverterContainerImpl.java
index b32882a..ad08400 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverterContainerImpl.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkConverterContainerImpl.java
@@ -9,562 +9,14 @@
******************************************************************************/
package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
-import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-import org.eclipse.jpt.jpa.core.context.TypeRefactoringParticipant;
-import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode;
-import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverterContainer;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
-import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
-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 class OrmEclipseLinkConverterContainerImpl
- extends AbstractOrmXmlContextNode
- implements OrmEclipseLinkConverterContainer
+public final class OrmEclipseLinkConverterContainerImpl
+ extends AbstractOrmEclipseLinkConverterContainerImpl
{
- private final Owner owner;
- private final XmlConverterContainer xmlConverterContainer;
-
- protected final ContextListContainer<OrmEclipseLinkCustomConverter, XmlConverter_2_1> customConverterContainer;
- protected final ContextListContainer<OrmEclipseLinkObjectTypeConverter, XmlObjectTypeConverter> objectTypeConverterContainer;
- protected final ContextListContainer<OrmEclipseLinkStructConverter, XmlStructConverter> structConverterContainer;
- protected final ContextListContainer<OrmEclipseLinkTypeConverter, XmlTypeConverter> typeConverterContainer;
-
-
public OrmEclipseLinkConverterContainerImpl(JpaContextNode parent, Owner owner, XmlConverterContainer xmlConverterContainer) {
- super(parent);
- this.owner = owner;
- this.xmlConverterContainer = xmlConverterContainer;
-
- this.customConverterContainer = this.buildCustomConverterContainer();
- this.objectTypeConverterContainer = this.buildObjectTypeConverterContainer();
- this.structConverterContainer = this.buildStructConverterContainer();
- this.typeConverterContainer = this.buildTypeConverterContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncCustomConverters();
- this.syncObjectTypeConverters();
- this.syncStructConverters();
- this.syncTypeConverters();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getCustomConverters());
- this.updateNodes(this.getObjectTypeConverters());
- this.updateNodes(this.getStructConverters());
- this.updateNodes(this.getTypeConverters());
- }
-
-
- // ********** custom converters **********
-
- public ListIterable<OrmEclipseLinkCustomConverter> getCustomConverters() {
- return this.customConverterContainer.getContextElements();
- }
-
- public int getCustomConvertersSize() {
- return this.customConverterContainer.getContextElementsSize();
- }
-
- public OrmEclipseLinkCustomConverter addCustomConverter() {
- return this.addCustomConverter(this.getCustomConvertersSize());
- }
-
- public OrmEclipseLinkCustomConverter addCustomConverter(int index) {
- XmlConverter xmlConverter = this.buildXmlCustomConverter();
- OrmEclipseLinkCustomConverter converter = this.customConverterContainer.addContextElement(index, xmlConverter);
- this.xmlConverterContainer.getConverters().add(index, xmlConverter);
- return converter;
- }
-
- protected XmlConverter buildXmlCustomConverter() {
- return EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
- }
-
- public void removeCustomConverter(EclipseLinkCustomConverter converter) {
- this.removeCustomConverter(this.customConverterContainer.indexOfContextElement((OrmEclipseLinkCustomConverter) converter));
- }
-
- public void removeCustomConverter(int index) {
- this.customConverterContainer.removeContextElement(index);
- this.xmlConverterContainer.getConverters().remove(index);
- }
-
- public void moveCustomConverter(int targetIndex, int sourceIndex) {
- this.customConverterContainer.moveContextElement(targetIndex, sourceIndex);
- this.xmlConverterContainer.getConverters().move(targetIndex, sourceIndex);
- }
-
- protected OrmEclipseLinkCustomConverter buildCustomConverter(XmlConverter xmlConverter) {
- return new OrmEclipseLinkCustomConverter(this, xmlConverter);
- }
-
- protected void syncCustomConverters() {
- this.customConverterContainer.synchronizeWithResourceModel();
- }
-
- protected ListIterable<XmlConverter_2_1> getXmlCustomConverters() {
- // clone to reduce chance of concurrency problems
- return IterableTools.cloneLive(this.xmlConverterContainer.getConverters());
- }
-
- protected ContextListContainer<OrmEclipseLinkCustomConverter, XmlConverter_2_1> buildCustomConverterContainer() {
- CustomConverterContainer container = new CustomConverterContainer();
- container.initialize();
- return container;
- }
-
- /**
- * custom converter container
- */
- protected class CustomConverterContainer
- extends ContextListContainer<OrmEclipseLinkCustomConverter, XmlConverter_2_1>
- {
- @Override
- protected String getContextElementsPropertyName() {
- return CUSTOM_CONVERTERS_LIST;
- }
- @Override
- protected OrmEclipseLinkCustomConverter buildContextElement(XmlConverter_2_1 resourceElement) {
- return OrmEclipseLinkConverterContainerImpl.this.buildCustomConverter((XmlConverter) resourceElement);
- }
- @Override
- protected ListIterable<XmlConverter_2_1> getResourceElements() {
- return OrmEclipseLinkConverterContainerImpl.this.getXmlCustomConverters();
- }
- @Override
- protected XmlConverter_2_1 getResourceElement(OrmEclipseLinkCustomConverter contextElement) {
- return contextElement.getXmlConverter();
- }
- }
-
-
- // ********** object type converters **********
-
- public ListIterable<OrmEclipseLinkObjectTypeConverter> getObjectTypeConverters() {
- return this.objectTypeConverterContainer.getContextElements();
- }
-
- public int getObjectTypeConvertersSize() {
- return this.objectTypeConverterContainer.getContextElementsSize();
- }
-
- public OrmEclipseLinkObjectTypeConverter addObjectTypeConverter() {
- return this.addObjectTypeConverter(this.getObjectTypeConvertersSize());
- }
-
- public OrmEclipseLinkObjectTypeConverter addObjectTypeConverter(int index) {
- XmlObjectTypeConverter xmlConverter = this.buildXmlObjectTypeConverter();
- OrmEclipseLinkObjectTypeConverter converter = this.objectTypeConverterContainer.addContextElement(index, xmlConverter);
- this.xmlConverterContainer.getObjectTypeConverters().add(index, xmlConverter);
- return converter;
- }
-
- protected XmlObjectTypeConverter buildXmlObjectTypeConverter() {
- return EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
- }
-
- public void removeObjectTypeConverter(EclipseLinkObjectTypeConverter converter) {
- this.removeObjectTypeConverter(this.objectTypeConverterContainer.indexOfContextElement((OrmEclipseLinkObjectTypeConverter) converter));
- }
-
- public void removeObjectTypeConverter(int index) {
- this.objectTypeConverterContainer.removeContextElement(index);
- this.xmlConverterContainer.getObjectTypeConverters().remove(index);
- }
-
- public void moveObjectTypeConverter(int targetIndex, int sourceIndex) {
- this.objectTypeConverterContainer.moveContextElement(targetIndex, sourceIndex);
- this.xmlConverterContainer.getObjectTypeConverters().move(targetIndex, sourceIndex);
- }
-
- protected OrmEclipseLinkObjectTypeConverter buildObjectTypeConverter(XmlObjectTypeConverter xmlConverter) {
- return new OrmEclipseLinkObjectTypeConverter(this, xmlConverter);
- }
-
- protected void syncObjectTypeConverters() {
- this.objectTypeConverterContainer.synchronizeWithResourceModel();
- }
-
- protected ListIterable<XmlObjectTypeConverter> getXmlObjectTypeConverters() {
- // clone to reduce chance of concurrency problems
- return IterableTools.cloneLive(this.xmlConverterContainer.getObjectTypeConverters());
- }
-
- protected ContextListContainer<OrmEclipseLinkObjectTypeConverter, XmlObjectTypeConverter> buildObjectTypeConverterContainer() {
- ObjectTypeConverterContainer container = new ObjectTypeConverterContainer();
- container.initialize();
- return container;
- }
-
- /**
- * object type converter container
- */
- protected class ObjectTypeConverterContainer
- extends ContextListContainer<OrmEclipseLinkObjectTypeConverter, XmlObjectTypeConverter>
- {
- @Override
- protected String getContextElementsPropertyName() {
- return OBJECT_TYPE_CONVERTERS_LIST;
- }
- @Override
- protected OrmEclipseLinkObjectTypeConverter buildContextElement(XmlObjectTypeConverter resourceElement) {
- return OrmEclipseLinkConverterContainerImpl.this.buildObjectTypeConverter(resourceElement);
- }
- @Override
- protected ListIterable<XmlObjectTypeConverter> getResourceElements() {
- return OrmEclipseLinkConverterContainerImpl.this.getXmlObjectTypeConverters();
- }
- @Override
- protected XmlObjectTypeConverter getResourceElement(OrmEclipseLinkObjectTypeConverter contextElement) {
- return contextElement.getXmlConverter();
- }
- }
-
- // ********** struct converters **********
-
- public ListIterable<OrmEclipseLinkStructConverter> getStructConverters() {
- return this.structConverterContainer.getContextElements();
- }
-
- public int getStructConvertersSize() {
- return this.structConverterContainer.getContextElementsSize();
- }
-
- public OrmEclipseLinkStructConverter addStructConverter() {
- return this.addStructConverter(this.getStructConvertersSize());
- }
-
- public OrmEclipseLinkStructConverter addStructConverter(int index) {
- XmlStructConverter xmlConverter = this.buildXmlStructConverter();
- OrmEclipseLinkStructConverter converter = this.structConverterContainer.addContextElement(index, xmlConverter);
- this.xmlConverterContainer.getStructConverters().add(index, xmlConverter);
- return converter;
- }
-
- protected XmlStructConverter buildXmlStructConverter() {
- return EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
- }
-
- public void removeStructConverter(EclipseLinkStructConverter converter) {
- this.removeStructConverter(this.structConverterContainer.indexOfContextElement((OrmEclipseLinkStructConverter) converter));
- }
-
- public void removeStructConverter(int index) {
- this.structConverterContainer.removeContextElement(index);
- this.xmlConverterContainer.getStructConverters().remove(index);
- }
-
- public void moveStructConverter(int targetIndex, int sourceIndex) {
- this.structConverterContainer.moveContextElement(targetIndex, sourceIndex);
- this.xmlConverterContainer.getStructConverters().move(targetIndex, sourceIndex);
- }
-
- protected OrmEclipseLinkStructConverter buildStructConverter(XmlStructConverter xmlConverter) {
- return new OrmEclipseLinkStructConverter(this, xmlConverter);
- }
-
- protected void syncStructConverters() {
- this.structConverterContainer.synchronizeWithResourceModel();
- }
-
- protected ListIterable<XmlStructConverter> getXmlStructConverters() {
- // clone to reduce chance of concurrency problems
- return IterableTools.cloneLive(this.xmlConverterContainer.getStructConverters());
- }
-
- protected ContextListContainer<OrmEclipseLinkStructConverter, XmlStructConverter> buildStructConverterContainer() {
- StructConverterContainer container = new StructConverterContainer();
- container.initialize();
- return container;
- }
-
- /**
- * struct converter container
- */
- protected class StructConverterContainer
- extends ContextListContainer<OrmEclipseLinkStructConverter, XmlStructConverter>
- {
- @Override
- protected String getContextElementsPropertyName() {
- return STRUCT_CONVERTERS_LIST;
- }
- @Override
- protected OrmEclipseLinkStructConverter buildContextElement(XmlStructConverter resourceElement) {
- return OrmEclipseLinkConverterContainerImpl.this.buildStructConverter(resourceElement);
- }
- @Override
- protected ListIterable<XmlStructConverter> getResourceElements() {
- return OrmEclipseLinkConverterContainerImpl.this.getXmlStructConverters();
- }
- @Override
- protected XmlStructConverter getResourceElement(OrmEclipseLinkStructConverter contextElement) {
- return contextElement.getXmlConverter();
- }
- }
-
-
- // ********** type converters **********
-
- public ListIterable<OrmEclipseLinkTypeConverter> getTypeConverters() {
- return this.typeConverterContainer.getContextElements();
- }
-
- public int getTypeConvertersSize() {
- return this.typeConverterContainer.getContextElementsSize();
- }
-
- public OrmEclipseLinkTypeConverter addTypeConverter() {
- return this.addTypeConverter(this.getTypeConvertersSize());
- }
-
- public OrmEclipseLinkTypeConverter addTypeConverter(int index) {
- XmlTypeConverter xmlConverter = this.buildXmlTypeConverter();
- OrmEclipseLinkTypeConverter converter = this.typeConverterContainer.addContextElement(index, xmlConverter);
- this.xmlConverterContainer.getTypeConverters().add(index, xmlConverter);
- return converter;
- }
-
- protected XmlTypeConverter buildXmlTypeConverter() {
- return EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
- }
-
- public void removeTypeConverter(EclipseLinkTypeConverter converter) {
- this.removeTypeConverter(this.typeConverterContainer.indexOfContextElement((OrmEclipseLinkTypeConverter) converter));
- }
-
- public void removeTypeConverter(int index) {
- this.typeConverterContainer.removeContextElement(index);
- this.xmlConverterContainer.getTypeConverters().remove(index);
- }
-
- public void moveTypeConverter(int targetIndex, int sourceIndex) {
- this.typeConverterContainer.moveContextElement(targetIndex, sourceIndex);
- this.xmlConverterContainer.getTypeConverters().move(targetIndex, sourceIndex);
- }
-
- protected OrmEclipseLinkTypeConverter buildTypeConverter(XmlTypeConverter xmlConverter) {
- return new OrmEclipseLinkTypeConverter(this, xmlConverter);
- }
-
- protected void syncTypeConverters() {
- this.typeConverterContainer.synchronizeWithResourceModel();
- }
-
- protected ListIterable<XmlTypeConverter> getXmlTypeConverters() {
- // clone to reduce chance of concurrency problems
- return IterableTools.cloneLive(this.xmlConverterContainer.getTypeConverters());
- }
-
- protected ContextListContainer<OrmEclipseLinkTypeConverter, XmlTypeConverter> buildTypeConverterContainer() {
- TypeConverterContainer container = new TypeConverterContainer();
- container.initialize();
- return container;
- }
-
- /**
- * type converter container
- */
- protected class TypeConverterContainer
- extends ContextListContainer<OrmEclipseLinkTypeConverter, XmlTypeConverter>
- {
- @Override
- protected String getContextElementsPropertyName() {
- return TYPE_CONVERTERS_LIST;
- }
- @Override
- protected OrmEclipseLinkTypeConverter buildContextElement(XmlTypeConverter resourceElement) {
- return OrmEclipseLinkConverterContainerImpl.this.buildTypeConverter(resourceElement);
- }
- @Override
- protected ListIterable<XmlTypeConverter> getResourceElements() {
- return OrmEclipseLinkConverterContainerImpl.this.getXmlTypeConverters();
- }
- @Override
- protected XmlTypeConverter getResourceElement(OrmEclipseLinkTypeConverter contextElement) {
- return contextElement.getXmlConverter();
- }
- }
-
-
- // ********** refactoring **********
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return IterableTools.concatenate(
- this.createRenameObjectTypeConverterEdits(originalType, newName),
- this.createRenameTypeConverterEdits(originalType, newName),
- this.createRenameStructConverterEdits(originalType, newName),
- this.createRenameCustomConverterEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createRenameObjectTypeConverterEdits(IType originalType, String newName) {
- return IterableTools.children(getObjectTypeConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createRenameTypeConverterEdits(IType originalType, String newName) {
- return IterableTools.children(getTypeConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createRenameStructConverterEdits(IType originalType, String newName) {
- return IterableTools.children(getStructConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createRenameCustomConverterEdits(IType originalType, String newName) {
- return IterableTools.children(getCustomConverters(), new TypeRefactoringParticipant.RenameTypeEditsTransformer(originalType, newName));
- }
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return IterableTools.concatenate(
- this.createMoveObjectTypeConverterEdits(originalType, newPackage),
- this.createMoveTypeConverterEdits(originalType, newPackage),
- this.createMoveStructConverterEdits(originalType, newPackage),
- this.createMoveCustomConverterEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createMoveObjectTypeConverterEdits(IType originalType, IPackageFragment newPackage) {
- return IterableTools.children(getObjectTypeConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createMoveTypeConverterEdits(IType originalType, IPackageFragment newPackage) {
- return IterableTools.children(getTypeConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createMoveStructConverterEdits(IType originalType, IPackageFragment newPackage) {
- return IterableTools.children(getStructConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createMoveCustomConverterEdits(IType originalType, IPackageFragment newPackage) {
- return IterableTools.children(getCustomConverters(), new TypeRefactoringParticipant.MoveTypeEditsTransformer(originalType, newPackage));
- }
-
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return IterableTools.concatenate(
- this.createObjectTypeConverterRenamePackageEdits(originalPackage, newName),
- this.createTypeConverterRenamePackageEdits(originalPackage, newName),
- this.createStructConverterRenamePackageEdits(originalPackage, newName),
- this.createCustomConverterRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createObjectTypeConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return IterableTools.children(getObjectTypeConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createTypeConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return IterableTools.children(getTypeConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createStructConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return IterableTools.children(getStructConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createCustomConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return IterableTools.children(getCustomConverters(), new TypeRefactoringParticipant.RenamePackageEditsTransformer(originalPackage, newName));
- }
-
-
- // ********** validation **********
-
- /**
- * The converters are validated in the persistence unit.
- * @see org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit#validateConverters(List, IReporter)
- */
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- // converters are validated in the persistence unit
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.xmlConverterContainer.getValidationTextRange();
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
- }
-
-
- // ********** misc **********
-
- @SuppressWarnings("unchecked")
- public Iterable<EclipseLinkConverter> getConverters() {
- return IterableTools.<EclipseLinkConverter>concatenate(
- this.getCustomConverters(),
- this.getObjectTypeConverters(),
- this.getStructConverters(),
- this.getTypeConverters()
- );
- }
-
- public int getConvertersSize() {
- return this.getCustomConvertersSize()
- + this.getObjectTypeConvertersSize()
- + this.getStructConvertersSize()
- + this.getTypeConvertersSize();
- }
-
- public int getNumberSupportedConverters() {
- return this.owner.getNumberSupportedConverters();
- }
-
- // ********** completion proposals **********
-
- @Override
- public Iterable<String> getCompletionProposals(int pos) {
- Iterable<String> result = super.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- for (OrmEclipseLinkCustomConverter converter : this.customConverterContainer.getContextElements()) {
- result = converter.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- }
- for (OrmEclipseLinkStructConverter converter : this.structConverterContainer.getContextElements()) {
- result = converter.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- }
- for (OrmEclipseLinkObjectTypeConverter converter : this.objectTypeConverterContainer.getContextElements()) {
- result = converter.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- }
- for (OrmEclipseLinkTypeConverter converter : this.typeConverterContainer.getContextElements()) {
- result = converter.getCompletionProposals(pos);
- if (result != null) {
- return result;
- }
- }
- return null;
+ super(parent, owner, xmlConverterContainer);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityMappingsConverterContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityMappingsConverterContainer.java
new file mode 100644
index 0000000..521009e
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityMappingsConverterContainer.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.jpt.jpa.core.context.JpaContextNode;
+import org.eclipse.jpt.jpa.core.resource.orm.v2_1.XmlConverter_2_1;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverterContainer;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlNamedConverter;
+
+public final class OrmEclipseLinkEntityMappingsConverterContainer
+ extends AbstractOrmEclipseLinkConverterContainerImpl
+{
+
+ public OrmEclipseLinkEntityMappingsConverterContainer(JpaContextNode parent, Owner owner, XmlConverterContainer xmlConverterContainer) {
+ super(parent, owner, xmlConverterContainer);
+ }
+
+ /**
+ * Return those XmlConverters that have a name, otherwise the converters are
+ * JPA 2.1 converters
+ */
+ @Override
+ protected List<XmlConverter_2_1> getNamedXmlConverters() {
+ if (this.isJpa2_1Compatible()) {
+ ArrayList<XmlConverter_2_1> xmlConverters = new ArrayList<XmlConverter_2_1>();
+ for (XmlConverter_2_1 xmlConverter : this.xmlConverterContainer.getConverters()) {
+ if (((XmlNamedConverter) xmlConverter).getName() != null){
+ xmlConverters.add(xmlConverter);
+ }
+ }
+
+ return xmlConverters;
+ }
+ return super.getNamedXmlConverters();
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java
index 3c5dafa..6a78999 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/VirtualJavaPersistentType.java
@@ -31,6 +31,7 @@ import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.AccessType;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
@@ -270,7 +271,7 @@ public class VirtualJavaPersistentType
throw new UnsupportedOperationException();
}
- public Class<? extends JpaStructureNode> getType() {
+ public Class<? extends JavaPersistentType> getType() {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/EclipseLinkConvertersComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/EclipseLinkConvertersComposite.java
index ed34d3e..52d45e8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/EclipseLinkConvertersComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/EclipseLinkConvertersComposite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -213,23 +213,23 @@ public class EclipseLinkConvertersComposite extends Pane<EclipseLinkConverterCon
return null;
}
Class<? extends EclipseLinkConverter> converterType = dialog.getConverterType();
+ String converterName = dialog.getName();
EclipseLinkConverter converter;
if (converterType == EclipseLinkCustomConverter.class) {
- converter = this.getSubject().addCustomConverter(getSubject().getCustomConvertersSize());
+ converter = this.getSubject().addCustomConverter(converterName, getSubject().getCustomConvertersSize());
}
else if (converterType == EclipseLinkObjectTypeConverter.class) {
- converter = this.getSubject().addObjectTypeConverter(getSubject().getObjectTypeConvertersSize());
+ converter = this.getSubject().addObjectTypeConverter(converterName, getSubject().getObjectTypeConvertersSize());
}
else if (converterType == EclipseLinkStructConverter.class) {
- converter = this.getSubject().addStructConverter(getSubject().getStructConvertersSize());
+ converter = this.getSubject().addStructConverter(converterName, getSubject().getStructConvertersSize());
}
else if (converterType == EclipseLinkTypeConverter.class) {
- converter = this.getSubject().addTypeConverter(getSubject().getTypeConvertersSize());
+ converter = this.getSubject().addTypeConverter(converterName, getSubject().getTypeConvertersSize());
}
else {
throw new IllegalArgumentException();
}
- converter.setName(dialog.getName());
return converter;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java
index 4639ea4..42d2743 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/details/orm/AbstractOrmEclipseLinkMappedSuperclassComposite.java
@@ -14,6 +14,7 @@ import org.eclipse.jpt.common.ui.WidgetFactory;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCaching;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkMappedSuperclass;
@@ -63,7 +64,7 @@ public abstract class AbstractOrmEclipseLinkMappedSuperclassComposite<T extends
// Java class widgets
Hyperlink javaClassHyperlink = addHyperlink(container, JptJpaUiDetailsOrmMessages.ORM_JAVA_CLASS_CHOOSER_JAVA_CLASS);
- new OrmJavaClassChooser(this, getSubjectHolder(), container, javaClassHyperlink);
+ new OrmJavaClassChooser(this, this.buildPersistentTypeReferenceModel(), container, javaClassHyperlink);
// Access type widgets
this.addLabel(container, JptJpaUiMessages.AccessTypeComposite_access);
@@ -82,6 +83,15 @@ public abstract class AbstractOrmEclipseLinkMappedSuperclassComposite<T extends
return container;
}
+ protected PropertyValueModel<OrmPersistentType> buildPersistentTypeReferenceModel() {
+ return new PropertyAspectAdapter<T, OrmPersistentType>(getSubjectHolder()) {
+ @Override
+ protected OrmPersistentType buildValue_() {
+ return this.subject.getPersistentType();
+ }
+ };
+ }
+
protected void initializeCachingCollapsibleSection(Composite container) {
final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java
index 36e9e8c..942c201 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/persistence/EclipseLinkPersistenceXmlUiDefinition.java
@@ -17,7 +17,7 @@ import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.Eclips
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.customization.EclipseLinkPersistenceUnitCustomizationEditorPageDefinition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.options.EclipseLinkPersistenceUnitOptionsEditorPageDefinition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
@@ -26,13 +26,13 @@ public class EclipseLinkPersistenceXmlUiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXmlUiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXmlUiDefinition();
/**
* Return the singleton
*/
- public static ResourceUiDefinition instance() {
+ public static PersistenceResourceUiDefinition instance() {
return INSTANCE;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java
index 2eb30e8..c1bba40 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_0UiDefinition.java
@@ -14,7 +14,7 @@ import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.EclipseLinkPersistenceUnitConnectionEditorPageDefinition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
@@ -23,12 +23,12 @@ public class EclipseLinkPersistenceXml2_0UiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_0UiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_0UiDefinition();
/**
* Return the singleton
*/
- public static ResourceUiDefinition instance() {
+ public static PersistenceResourceUiDefinition instance() {
return INSTANCE;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java
index 8b39d68..346644e 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_4UiDefinition.java
@@ -14,7 +14,7 @@ import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.EclipseLinkPersistenceUnitConnectionEditorPageDefinition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
@@ -23,12 +23,12 @@ public class EclipseLinkPersistenceXml2_4UiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_4UiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_4UiDefinition();
/**
* Return the singleton
*/
- public static ResourceUiDefinition instance() {
+ public static PersistenceResourceUiDefinition instance() {
return INSTANCE;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_5UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_5UiDefinition.java
index adae75d..3bbe0e4 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_5UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.ui/src/org/eclipse/jpt/jpa/eclipselink/ui/internal/v2_0/persistence/EclipseLinkPersistenceXml2_5UiDefinition.java
@@ -14,16 +14,19 @@ import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_1Definition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.connection.EclipseLinkPersistenceUnitConnectionEditorPageDefinition;
import org.eclipse.jpt.jpa.eclipselink.ui.internal.persistence.general.EclipseLinkPersistenceUnitGeneralEditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.JavaManagedTypeUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2_1.JavaConverterTypeUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
public class EclipseLinkPersistenceXml2_5UiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_5UiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new EclipseLinkPersistenceXml2_5UiDefinition();
/**
* Return the singleton
@@ -53,4 +56,10 @@ public class EclipseLinkPersistenceXml2_5UiDefinition
public boolean providesUi(JptResourceType resourceType) {
return resourceType.equals(GenericPersistenceXml2_1Definition.instance().getResourceType());
}
+
+ @Override
+ protected void addJavaManagedTypeUiDefinitionsTo(List<JavaManagedTypeUiDefinition> definitions) {
+ super.addJavaManagedTypeUiDefinitionsTo(definitions);
+ definitions.add(JavaConverterTypeUiDefinition.instance());
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java
index acfcc7c..5f26bda 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.gen/src/org/eclipse/jpt/jpa/gen/internal/PackageGenerator.java
@@ -165,7 +165,7 @@ public class PackageGenerator {
persistenceUnit = persistence.getPersistenceUnit(0);
}
for (String className : genClasses) {
- if (IterableTools.isEmpty(persistenceUnit.getMappingFileRefsContaining(className)) && !persistenceUnit.specifiesPersistentType(className)) {
+ if (IterableTools.isEmpty(persistenceUnit.getMappingFileRefsContaining(className)) && !persistenceUnit.specifiesManagedType(className)) {
persistenceUnit.addSpecifiedClassRef(className);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF
index 7ad3800..1ccc968 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF
@@ -68,6 +68,7 @@ Export-Package: org.eclipse.jpt.jpa.ui,
org.eclipse.jpt.jpa.ui.internal.jpa2.details.orm;x-internal:=true,
org.eclipse.jpt.jpa.ui.internal.jpa2.persistence;x-internal:=true,
org.eclipse.jpt.jpa.ui.internal.jpa2.platform.generic;x-internal:=true,
+ org.eclipse.jpt.jpa.ui.internal.jpa2_1;x-internal:=true,
org.eclipse.jpt.jpa.ui.internal.jpa2_1.persistence;x-internal:=true,
org.eclipse.jpt.jpa.ui.internal.jpql;x-internal:=true,
org.eclipse.jpt.jpa.ui.internal.listeners;x-internal:=true,
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/images/objects/null-type-mapping.gif b/jpa/plugins/org.eclipse.jpt.jpa.ui/images/objects/java-class.gif
index 6279478..6279478 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/images/objects/null-type-mapping.gif
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/images/objects/java-class.gif
Binary files differ
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_persistence.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_persistence.properties
index a24cb1f..b032a18 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_persistence.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_persistence.properties
@@ -14,9 +14,9 @@ ARCHIVE_FILE_SELECTION_DIALOG_JAR_PATH_HELP_LABEL=The correct path to the JAR fi
ARCHIVE_FILE_SELECTION_DIALOG_JAR_PATH_LABEL=JAR file path:
PERSISTENCE_UNIT_CLASSES_COMPOSITE_DESCRIPTION=Specify the list of classes to be managed in this persistence unit.
-PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES=Exclude unlisted classes
-PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES_WITH_DEFAULT=Exclude unlisted classes ({0})
-PERSISTENCE_UNIT_CLASSES_COMPOSITE_MAPPED_CLASSES_NO_NAME=<name not set>
+PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES=Exclude unlisted classes
+PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES_WITH_DEFAULT=Exclude unlisted classes ({0})
+PERSISTENCE_UNIT_CLASSES_COMPOSITE_CLASS_REF_NO_NAME=<name not set>
PERSISTENCE_UNIT_CLASSES_COMPOSITE_OPEN=Open
PERSISTENCE_UNIT_CONNECTION_GENERAL_COMPOSITE_DEFAULT=Default(JTA)
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_preferences_validation.properties b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_preferences_validation.properties
index fdd1078..5150c3d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_preferences_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/property_files/jpt_jpa_ui_preferences_validation.properties
@@ -32,7 +32,7 @@ PERSISTENT_TYPE_DUPLICATE_CLASS=Duplicate ORM class:
PERSISTENCE_UNIT_DUPLICATE_CLASS=Duplicate Java class:
PERSISTENCE_UNIT_DUPLICATE_JAR_FILE=Duplicate JAR file:
PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE=Duplicate mapping file:
-PERSISTENCE_UNIT_INVALID_CLASS=Class is included in a persistence unit but is not mapped:
+PERSISTENCE_UNIT_INVALID_CLASS=Class is listed in the persistence.xml file, but is not annotated:
PERSISTENCE_UNIT_INVALID_MAPPING_FILE=Mapping file does not have ORM content:
PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING=The path to the JAR file will vary:
PERSISTENCE_UNIT_NONEXISTENT_CLASS=Class cannot be resolved:
@@ -52,10 +52,10 @@ ENTITY_NAME_MISSING=Entity name is empty:
ENTITY_NO_PK=Entity has no primary key:
ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED=Primary key attribute should only be defined on the root entity or a mapped superclass:
ENTITY_NON_ROOT_ID_CLASS_SPECIFIED=ID class should only be defined on the root entity or a mapped superclass:
-PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT=Class is annotated, but is not in a persistence unit:
-PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT=Class is mapped, but is not in a persistence unit:
-PERSISTENT_TYPE_UNRESOLVED_CLASS=Class in orm.xml cannot be resolved to a java class:
-PERSISTENT_TYPE_UNSPECIFIED_CLASS=Class is unspecified in orm.xml:
+TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML=Class is annotated, but is not listed in the persistence.xml file:
+TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML=Class is managed, but is not listed in the persistence.xml file:
+MANAGED_TYPE_UNRESOLVED_CLASS=Class in orm.xml cannot be resolved to a java class:
+MANAGED_TYPE_UNSPECIFIED_CLASS=Class is unspecified in orm.xml:
TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR=Mapped Java class has no no-arg constructor:
TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR=Mapped Java class has a private no-arg constructor:
TYPE_MAPPING_FINAL_CLASS=Mapped Java class is final:
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JavaManagedTypeUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JavaManagedTypeUiDefinition.java
new file mode 100644
index 0000000..97ee3fc
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JavaManagedTypeUiDefinition.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+
+/**
+ * A managed type UI definition provides the labels and images for the
+ * managed type indicated by {@link #getType()}.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ *
+ * @version 3.3
+ * @since 3.3
+ */
+public interface JavaManagedTypeUiDefinition {
+
+ /**
+ * Return a class that corresponds to the managed type.
+ *
+ * @see org.eclipse.jpt.jpa.core.context.java.JavaManagedTypeDefinition#getType()
+ */
+ Class<? extends JavaManagedType> getType();
+
+ /**
+ * Return an image descriptor corresponding to the managed type.
+ */
+ ImageDescriptor getImageDescriptor(JavaManagedType managedType);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiImages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiImages.java
index b8bbd4c..fca124a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiImages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/JptJpaUiImages.java
@@ -68,7 +68,7 @@ public final class JptJpaUiImages {
public static final ImageDescriptor PERSISTENCE = buildImageDescriptor(OBJECTS_ + "persistence.gif");
public static final ImageDescriptor PERSISTENCE_UNIT = buildImageDescriptor(OBJECTS_ + "persistence-unit.gif");
public static final ImageDescriptor MAPPING_FILE_REF = buildImageDescriptor(OBJECTS_ + "jpa-file.gif");
- public static final ImageDescriptor CLASS_REF = buildImageDescriptor(OBJECTS_ + "null-type-mapping.gif");
+ public static final ImageDescriptor CLASS_REF = buildImageDescriptor(OBJECTS_ + "java-class.gif");
public static final ImageDescriptor JAR_FILE_REF = buildImageDescriptor(OBJECTS_ + "jpa-jar-file.gif");
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceResourceUiDefinition.java
new file mode 100644
index 0000000..89f8837
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/PersistenceResourceUiDefinition.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui;
+
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+
+/**
+ * Persistence resource UI definition.
+ * <p>
+ * Provisional API: This interface is part of an interim API that is still
+ * under development and expected to change significantly before reaching
+ * stability. It is available at this early stage to solicit feedback from
+ * pioneering adopters on the understanding that any code that uses this API
+ * will almost certainly be broken (repeatedly) as the API evolves.
+ */
+public interface PersistenceResourceUiDefinition
+ extends ResourceUiDefinition
+{
+
+ // ********** managed types **********
+
+ JavaManagedTypeUiDefinition getJavaManagedTypeUiDefinition(Class<? extends JavaManagedType> type);
+
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractPersistenceResourceUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractPersistenceResourceUiDefinition.java
index abbb0da..45c7e02 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractPersistenceResourceUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/AbstractPersistenceResourceUiDefinition.java
@@ -9,8 +9,14 @@
******************************************************************************/
package org.eclipse.jpt.jpa.ui.internal;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jpt.common.ui.internal.jface.SimpleItemTreeStateProviderFactoryProvider;
import org.eclipse.jpt.common.ui.jface.ItemTreeStateProviderFactoryProvider;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.ui.JavaManagedTypeUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.structure.JpaFileStructureItemContentProviderFactory;
import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceStructureItemLabelProviderFactory;
@@ -19,7 +25,9 @@ import org.eclipse.jpt.jpa.ui.internal.structure.PersistenceStructureItemLabelPr
*/
public abstract class AbstractPersistenceResourceUiDefinition
extends AbstractResourceUiDefinition
+ implements PersistenceResourceUiDefinition
{
+ private ArrayList<JavaManagedTypeUiDefinition> javaManagedTypeUiDefinitions;
/**
@@ -29,6 +37,34 @@ public abstract class AbstractPersistenceResourceUiDefinition
super();
}
+
+ // ********** java managed types ui definitions **********
+
+ public JavaManagedTypeUiDefinition getJavaManagedTypeUiDefinition(Class<? extends JavaManagedType> type) {
+ for (JavaManagedTypeUiDefinition definition : this.getJavaManagedTypeUiDefinitions()) {
+ if (ObjectTools.equals(definition.getType(), type)) {
+ return definition;
+ }
+ }
+ throw new IllegalArgumentException("Illegal type : " + type); //$NON-NLS-1$
+ }
+
+ protected synchronized Iterable<JavaManagedTypeUiDefinition> getJavaManagedTypeUiDefinitions() {
+ if (this.javaManagedTypeUiDefinitions == null) {
+ this.javaManagedTypeUiDefinitions = this.buildJavaManagedTypeUiDefinitions();
+ }
+ return this.javaManagedTypeUiDefinitions;
+ }
+
+ protected ArrayList<JavaManagedTypeUiDefinition> buildJavaManagedTypeUiDefinitions() {
+ ArrayList<JavaManagedTypeUiDefinition> definitions = new ArrayList<JavaManagedTypeUiDefinition>();
+ this.addJavaManagedTypeUiDefinitionsTo(definitions);
+ return definitions;
+ }
+
+ protected void addJavaManagedTypeUiDefinitionsTo(List<JavaManagedTypeUiDefinition> definitions) {
+ definitions.add(JavaPersistentTypeUiDefinition.instance());
+ }
public ItemTreeStateProviderFactoryProvider getStructureViewFactoryProvider() {
return STRUCTURE_VIEW_FACTORY_PROVIDER;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JavaPersistentTypeUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JavaPersistentTypeUiDefinition.java
new file mode 100644
index 0000000..d7c3d6d
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/JavaPersistentTypeUiDefinition.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
+import org.eclipse.jpt.jpa.ui.JavaManagedTypeUiDefinition;
+import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition;
+
+//TODO NullManagedTypeUiDefinition or should it be a JavaPersistentType implementation if it doesn't match any of the ManagedType types
+public class JavaPersistentTypeUiDefinition
+ implements JavaManagedTypeUiDefinition
+{
+ // singleton
+ private static final JavaPersistentTypeUiDefinition INSTANCE =
+ new JavaPersistentTypeUiDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaManagedTypeUiDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ protected JavaPersistentTypeUiDefinition() {
+ super();
+ }
+
+ public Class<JavaPersistentType> getType() {
+ return JavaPersistentType.class;
+ }
+
+ public ImageDescriptor getImageDescriptor(JavaManagedType managedType) {
+ return this.getTypeMappingUiDefinition((JavaPersistentType) managedType).getImageDescriptor();
+ }
+
+ private MappingUiDefinition getTypeMappingUiDefinition(JavaPersistentType persistentType) {
+ return this.getJpaPlatformUi(persistentType).getTypeMappingUiDefinition(persistentType.getResourceType(), persistentType.getMappingKey());
+ }
+
+ private JpaPlatformUi getJpaPlatformUi(JavaPersistentType persistentType) {
+ return (JpaPlatformUi) persistentType.getJpaPlatform().getAdapter(JpaPlatformUi.class);
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java
index a8205e9..a410c66 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/PersistentTypeMapAsComposite.java
@@ -12,6 +12,7 @@ package org.eclipse.jpt.jpa.ui.internal.details;
import java.util.Collection;
import org.eclipse.jpt.common.ui.internal.widgets.Pane;
import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
import org.eclipse.jpt.jpa.ui.details.DefaultMappingUiDefinition;
@@ -100,7 +101,7 @@ public class PersistentTypeMapAsComposite
protected void addPropertyNames(Collection<String> propertyNames) {
super.addPropertyNames(propertyNames);
propertyNames.add(PersistentType.MAPPING_PROPERTY);
- propertyNames.add(PersistentType.NAME_PROPERTY);
+ propertyNames.add(ManagedType.NAME_PROPERTY);
}
@Override
@@ -108,7 +109,7 @@ public class PersistentTypeMapAsComposite
super.propertyChanged(propertyName);
if (propertyName == PersistentType.MAPPING_PROPERTY ||
- propertyName == PersistentType.NAME_PROPERTY) {
+ propertyName == ManagedType.NAME_PROPERTY) {
updateDescription();
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEmbeddableComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEmbeddableComposite.java
index b689128..5e918e3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEmbeddableComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEmbeddableComposite.java
@@ -11,8 +11,10 @@ package org.eclipse.jpt.jpa.ui.internal.details.orm;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.ui.JptJpaUiMessages;
import org.eclipse.jpt.jpa.ui.details.orm.JptJpaUiDetailsOrmMessages;
import org.eclipse.jpt.jpa.ui.internal.details.AbstractEmbeddableComposite;
@@ -40,7 +42,7 @@ public abstract class AbstractOrmEmbeddableComposite<T extends OrmEmbeddable>
// Java class widgets
Hyperlink javaClassHyperlink = this.addHyperlink(container, JptJpaUiDetailsOrmMessages.ORM_JAVA_CLASS_CHOOSER_JAVA_CLASS);
- new OrmJavaClassChooser(this, getSubjectHolder(), container, javaClassHyperlink);
+ new OrmJavaClassChooser(this, this.buildPersistentTypeReferenceModel(), container, javaClassHyperlink);
// Access type widgets
this.addLabel(container, JptJpaUiMessages.AccessTypeComposite_access);
@@ -54,4 +56,13 @@ public abstract class AbstractOrmEmbeddableComposite<T extends OrmEmbeddable>
return container;
}
+
+ protected PropertyValueModel<OrmPersistentType> buildPersistentTypeReferenceModel() {
+ return new PropertyAspectAdapter<T, OrmPersistentType>(getSubjectHolder()) {
+ @Override
+ protected OrmPersistentType buildValue_() {
+ return this.subject.getPersistentType();
+ }
+ };
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java
index b5a7d12..36f8f20 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/AbstractOrmEntityComposite.java
@@ -11,8 +11,10 @@ package org.eclipse.jpt.jpa.ui.internal.details.orm;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.ui.JptJpaUiMessages;
import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
import org.eclipse.jpt.jpa.ui.details.orm.JptJpaUiDetailsOrmMessages;
@@ -54,7 +56,7 @@ public abstract class AbstractOrmEntityComposite<T extends OrmEntity>
// Java class widgets
Hyperlink javaClassHyperlink = this.addHyperlink(container, JptJpaUiDetailsOrmMessages.ORM_JAVA_CLASS_CHOOSER_JAVA_CLASS);
- new OrmJavaClassChooser(this, getSubjectHolder(), container, javaClassHyperlink);
+ new OrmJavaClassChooser(this, this.buildPersistentTypeReferenceModel(), container, javaClassHyperlink);
// Table widgets
TableComposite tableComposite = new TableComposite(this, container);
@@ -83,6 +85,15 @@ public abstract class AbstractOrmEntityComposite<T extends OrmEntity>
return container;
}
+ protected PropertyValueModel<OrmPersistentType> buildPersistentTypeReferenceModel() {
+ return new PropertyAspectAdapter<T, OrmPersistentType>(getSubjectHolder()) {
+ @Override
+ protected OrmPersistentType buildValue_() {
+ return this.subject.getPersistentType();
+ }
+ };
+ }
+
@Override
protected Control initializeSecondaryTablesSection(Composite container) {
return new OrmSecondaryTablesComposite(this, container).getControl();
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java
index 4a44f3c..c8166a7 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmJavaClassChooser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2006, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -15,7 +15,7 @@ import org.eclipse.jpt.common.ui.internal.widgets.Pane;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.Hyperlink;
@@ -33,14 +33,14 @@ import org.eclipse.ui.forms.widgets.Hyperlink;
* choose a class from the package.
* Not sure if this should be driven by the UI or by ui api in the model
*
- * @see OrmTypeMapping
+ * @see OrmManagedType
* @see OrmPersistentTypeDetailsPage - The parent container
* @see ClassChooserPane
*
* @version 2.0
* @since 1.0
*/
-public class OrmJavaClassChooser extends ClassChooserPane<OrmTypeMapping> {
+public class OrmJavaClassChooser extends ClassChooserPane<OrmManagedType> {
/**
* Creates a new <code>XmlJavaClassChooser</code>.
@@ -50,7 +50,7 @@ public class OrmJavaClassChooser extends ClassChooserPane<OrmTypeMapping> {
* @param parent The parent container
*/
public OrmJavaClassChooser(Pane<?> parentPane,
- PropertyValueModel<? extends OrmTypeMapping> subjectHolder,
+ PropertyValueModel<? extends OrmManagedType> subjectHolder,
Composite parent,
Hyperlink hyperlink) {
@@ -59,7 +59,7 @@ public class OrmJavaClassChooser extends ClassChooserPane<OrmTypeMapping> {
@Override
protected ModifiablePropertyValueModel<String> buildTextHolder() {
- return new PropertyAspectAdapter<OrmTypeMapping, String>(getSubjectHolder(), OrmTypeMapping.CLASS_PROPERTY) {
+ return new PropertyAspectAdapter<OrmManagedType, String>(getSubjectHolder(), OrmManagedType.CLASS_PROPERTY) {
@Override
protected String buildValue_() {
return this.subject.getClass_();
@@ -89,6 +89,6 @@ public class OrmJavaClassChooser extends ClassChooserPane<OrmTypeMapping> {
@Override
protected String getFullyQualifiedClassName() {
- return getSubject().getPersistentType().getName();
+ return getSubject().getName();
}
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java
index 91fa95e..78d5d93 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/details/orm/OrmMappedSuperclassComposite.java
@@ -11,8 +11,10 @@ package org.eclipse.jpt.jpa.ui.internal.details.orm;
import org.eclipse.jface.resource.ResourceManager;
import org.eclipse.jpt.common.ui.WidgetFactory;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
import org.eclipse.jpt.jpa.ui.JptJpaUiMessages;
import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
import org.eclipse.jpt.jpa.ui.details.orm.JptJpaUiDetailsOrmMessages;
@@ -41,7 +43,7 @@ public class OrmMappedSuperclassComposite
// Java class widgets
Hyperlink javaClassHyperlink = this.addHyperlink(container, JptJpaUiDetailsOrmMessages.ORM_JAVA_CLASS_CHOOSER_JAVA_CLASS);
- new OrmJavaClassChooser(this, getSubjectHolder(), container, javaClassHyperlink);
+ new OrmJavaClassChooser(this, this.buildPersistentTypeReferenceModel(), container, javaClassHyperlink);
// Access type widgets
this.addLabel(container, JptJpaUiMessages.AccessTypeComposite_access);
@@ -59,4 +61,14 @@ public class OrmMappedSuperclassComposite
return container;
}
+
+ protected PropertyValueModel<OrmPersistentType> buildPersistentTypeReferenceModel() {
+ return new PropertyAspectAdapter<OrmMappedSuperclass, OrmPersistentType>(getSubjectHolder()) {
+ @Override
+ protected OrmPersistentType buildValue_() {
+ return this.subject.getPersistentType();
+ }
+ };
+ }
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java
index b6a08e8..54b9c86 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/dialogs/AddPersistentClassDialog.java
@@ -284,7 +284,7 @@ public class AddPersistentClassDialog extends StatusDialog
return;
}
- if (this.entityMappings.containsPersistentType(className)) {
+ if (this.entityMappings.containsManagedType(className)) {
updateStatus(JptJpaUiPlugin.instance().buildWarningStatus(JptJpaUiMessages.AddPersistentClassDialog_duplicateClassWarning));
return;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/RemovePersistentClassHandler.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/RemovePersistentClassHandler.java
index 463591e..9541616 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/RemovePersistentClassHandler.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/handlers/RemovePersistentClassHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle.
+ * Copyright (c) 2007, 2013 Oracle.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,7 @@ public class RemovePersistentClassHandler extends AbstractHandler
// only applies for multiply selected OrmPersistentType objects in a tree
for (Iterator<OrmPersistentType> stream = selection.iterator(); stream.hasNext(); ) {
OrmPersistentType persistentType = stream.next();
- ((EntityMappings) persistentType.getMappingFileRoot()).removePersistentType(persistentType);
+ ((EntityMappings) persistentType.getMappingFileRoot()).removeManagedType(persistentType);
}
return null;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java
index b831cc7..91c6aab 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/details/orm/OrmEntity2_0Composite.java
@@ -51,7 +51,7 @@ public class OrmEntity2_0Composite
// Java class widgets
Hyperlink javaClassHyperlink = this.addHyperlink(container, JptJpaUiDetailsOrmMessages.ORM_JAVA_CLASS_CHOOSER_JAVA_CLASS);
- new OrmJavaClassChooser(this, getSubjectHolder(), container, javaClassHyperlink);
+ new OrmJavaClassChooser(this, this.buildPersistentTypeReferenceModel(), container, javaClassHyperlink);
// Table widgets
TableComposite tableComposite = new TableComposite(this, container);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java
index 9adc2e6..94f34b3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2/persistence/PersistenceXml2_0UiDefinition.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jpa.ui.internal.jpa2.persistence;
import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_0Definition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralEditorPageDefinition;
@@ -22,12 +22,12 @@ public class PersistenceXml2_0UiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new PersistenceXml2_0UiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new PersistenceXml2_0UiDefinition();
/**
* Return the singleton
*/
- public static ResourceUiDefinition instance() {
+ public static PersistenceResourceUiDefinition instance() {
return INSTANCE;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/JavaConverterTypeUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/JavaConverterTypeUiDefinition.java
new file mode 100644
index 0000000..af99cad
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/JavaConverterTypeUiDefinition.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.jpa2_1;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.ui.JptJpaUiImages;
+import org.eclipse.jpt.jpa.ui.JavaManagedTypeUiDefinition;
+
+public class JavaConverterTypeUiDefinition
+ implements JavaManagedTypeUiDefinition
+{
+ // singleton
+ private static final JavaConverterTypeUiDefinition INSTANCE =
+ new JavaConverterTypeUiDefinition();
+
+
+ /**
+ * Return the singleton.
+ */
+ public static JavaManagedTypeUiDefinition instance() {
+ return INSTANCE;
+ }
+
+
+ /**
+ * Ensure single instance.
+ */
+ protected JavaConverterTypeUiDefinition() {
+ super();
+ }
+
+ public Class<JavaConverterType2_1> getType() {
+ return JavaConverterType2_1.class;
+ }
+
+ public ImageDescriptor getImageDescriptor(JavaManagedType managedType) {
+ return JptJpaUiImages.CLASS_REF;
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/persistence/PersistenceXml2_1UiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/persistence/PersistenceXml2_1UiDefinition.java
index d1536b6..f5faf7d 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/persistence/PersistenceXml2_1UiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/jpa2_1/persistence/PersistenceXml2_1UiDefinition.java
@@ -12,11 +12,13 @@ package org.eclipse.jpt.jpa.ui.internal.jpa2_1.persistence;
import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.GenericPersistenceXml2_1Definition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.JavaManagedTypeUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitConnection2_0EditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.PersistenceUnitOptions2_0EditorPageDefinition;
+import org.eclipse.jpt.jpa.ui.internal.jpa2_1.JavaConverterTypeUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitGeneralEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.persistence.PersistenceUnitPropertiesEditorPageDefinition;
@@ -24,12 +26,12 @@ public class PersistenceXml2_1UiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new PersistenceXml2_1UiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new PersistenceXml2_1UiDefinition();
/**
* Return the singleton
*/
- public static ResourceUiDefinition instance() {
+ public static PersistenceResourceUiDefinition instance() {
return INSTANCE;
}
@@ -52,4 +54,10 @@ public class PersistenceXml2_1UiDefinition
public boolean providesUi(JptResourceType resourceType) {
return resourceType.equals(GenericPersistenceXml2_1Definition.instance().getResourceType());
}
+
+ @Override
+ protected void addJavaManagedTypeUiDefinitionsTo(List<JavaManagedTypeUiDefinition> definitions) {
+ super.addJavaManagedTypeUiDefinitionsTo(definitions);
+ definitions.add(JavaConverterTypeUiDefinition.instance());
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
index c562d98..e9fde84 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceUnitClassesComposite.java
@@ -40,11 +40,11 @@ import org.eclipse.jpt.common.utility.model.value.ModifiableCollectionValueModel
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.transformer.Transformer;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
-import org.eclipse.jpt.jpa.ui.details.MappingUiDefinition;
+import org.eclipse.jpt.jpa.ui.JavaManagedTypeUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.internal.JpaHelpContextIds;
import org.eclipse.jpt.jpa.ui.internal.plugin.JptJpaUiPlugin;
import org.eclipse.jpt.jpa.ui.persistence.JptJpaUiPersistenceMessages;
@@ -72,7 +72,7 @@ public class PersistenceUnitClassesComposite
this,
container,
this.buildAddRemovePaneAdapter(),
- this.buildItemListHolder(),
+ this.buildItemListModel(),
this.buildSelectedItemsModel(),
this.buildClassRefLabelProvider(),
JpaHelpContextIds.PERSISTENCE_XML_GENERAL
@@ -80,15 +80,15 @@ public class PersistenceUnitClassesComposite
this.addTriStateCheckBoxWithDefault(
container,
- JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES,
- buildExcludeUnlistedMappedClassesHolder(),
- buildExcludeUnlistedMappedClassesStringHolder(),
+ JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES,
+ buildExcludeUnlistedClassesModel(),
+ buildExcludeUnlistedClassesStringModel(),
JpaHelpContextIds.PERSISTENCE_XML_GENERAL
);
}
- protected ClassRef addMappedClass() {
+ protected ClassRef addClassRef() {
IType type = chooseType();
@@ -114,7 +114,7 @@ public class PersistenceUnitClassesComposite
private AddRemovePane.Adapter<ClassRef> buildAddRemovePaneAdapter() {
return new AddRemovePane.AbstractAdapter<ClassRef>() {
public ClassRef addNewItem() {
- return addMappedClass();
+ return addClassRef();
}
@Override
@@ -152,7 +152,7 @@ public class PersistenceUnitClassesComposite
};
}
- private ModifiablePropertyValueModel<Boolean> buildExcludeUnlistedMappedClassesHolder() {
+ private ModifiablePropertyValueModel<Boolean> buildExcludeUnlistedClassesModel() {
return new PropertyAspectAdapter<PersistenceUnit, Boolean>(
getSubjectHolder(),
PersistenceUnit.SPECIFIED_EXCLUDE_UNLISTED_CLASSES_PROPERTY)
@@ -169,20 +169,20 @@ public class PersistenceUnitClassesComposite
};
}
- private PropertyValueModel<String> buildExcludeUnlistedMappedClassesStringHolder() {
- return new TransformationPropertyValueModel<Boolean, String>(buildDefaultExcludeUnlistedMappedClassesHolder()) {
+ private PropertyValueModel<String> buildExcludeUnlistedClassesStringModel() {
+ return new TransformationPropertyValueModel<Boolean, String>(buildDefaultExcludeUnlistedClassesModel()) {
@Override
protected String transform(Boolean v) {
if (v != null) {
String defaultStringValue = v.booleanValue() ? JptCommonUiMessages.BOOLEAN_TRUE : JptCommonUiMessages.BOOLEAN_FALSE;
- return NLS.bind(JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES_WITH_DEFAULT, defaultStringValue);
+ return NLS.bind(JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES_WITH_DEFAULT, defaultStringValue);
}
- return JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES;
+ return JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES;
}
};
}
- private PropertyValueModel<Boolean> buildDefaultExcludeUnlistedMappedClassesHolder() {
+ private PropertyValueModel<Boolean> buildDefaultExcludeUnlistedClassesModel() {
return new PropertyAspectAdapter<PersistenceUnit, Boolean>(
getSubjectHolder(),
PersistenceUnit.SPECIFIED_EXCLUDE_UNLISTED_CLASSES_PROPERTY,
@@ -206,32 +206,39 @@ public class PersistenceUnitClassesComposite
);
}
+ //TODO this image does not update if the java persistent type mapping is changed.
+ //also need to make the image and label the same in the structure view
private static final Transformer<ClassRef, ImageDescriptor> CLASS_REF_LABEL_IMAGE_DESCRIPTOR_TRANSFORMER = new ClassRefLabelImageDescriptorTransformer();
/* CU private */ static class ClassRefLabelImageDescriptorTransformer
extends AbstractTransformer<ClassRef, ImageDescriptor>
{
@Override
protected ImageDescriptor transform_(ClassRef classRef) {
- return this.getImageDescriptor(classRef.getJavaPersistentType());
+ return this.getImageDescriptor(classRef);
}
- private ImageDescriptor getImageDescriptor(JavaPersistentType persistentType) {
- if (persistentType == null) {
+ private ImageDescriptor getImageDescriptor(ClassRef classRef) {
+ if (classRef.getJavaManagedType() == null) {
return JptCommonUiImages.WARNING;
}
- MappingUiDefinition def = this.getTypeMappingUiDefinition(persistentType);
+ JavaManagedTypeUiDefinition def = this.getManagedTypeUiDefinition(classRef);
return (def != null) ?
- def.getImageDescriptor() :
- JptCommonUiImages.WARNING;
+ def.getImageDescriptor(classRef.getJavaManagedType()) :
+ JptCommonUiImages.WARNING;
}
- private MappingUiDefinition getTypeMappingUiDefinition(JavaPersistentType persistentType) {
- JpaPlatformUi ui = this.getJpaPlatformUi(persistentType);
- return (ui == null) ? null : ui.getTypeMappingUiDefinition(persistentType.getResourceType(), persistentType.getMappingKey());
+ private JavaManagedTypeUiDefinition getManagedTypeUiDefinition(ClassRef classRef) {
+ PersistenceResourceUiDefinition def = this.getPersistenceResourceUiDefinition(classRef);
+ return def == null ? null : def.getJavaManagedTypeUiDefinition(classRef.getJavaManagedType().getType());
}
- private JpaPlatformUi getJpaPlatformUi(JavaPersistentType persistentType) {
- return (JpaPlatformUi) persistentType.getJpaPlatform().getAdapter(JpaPlatformUi.class);
+ private PersistenceResourceUiDefinition getPersistenceResourceUiDefinition(ClassRef classRef) {
+ JpaPlatformUi ui = this.getJpaPlatformUi(classRef);
+ return ui == null ? null : (PersistenceResourceUiDefinition) this.getJpaPlatformUi(classRef).getResourceUiDefinition(classRef.getResourceType());
+ }
+
+ private JpaPlatformUi getJpaPlatformUi(ClassRef classRef) {
+ return (JpaPlatformUi) classRef.getJpaPlatform().getAdapter(JpaPlatformUi.class);
}
}
@@ -242,19 +249,19 @@ public class PersistenceUnitClassesComposite
@Override
protected String transform_(ClassRef classRef) {
String name = classRef.getClassName();
- return (name != null) ? name : JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_MAPPED_CLASSES_NO_NAME;
+ return (name != null) ? name : JptJpaUiPersistenceMessages.PERSISTENCE_UNIT_CLASSES_COMPOSITE_CLASS_REF_NO_NAME;
}
}
- private ListValueModel<ClassRef> buildItemListHolder() {
+ private ListValueModel<ClassRef> buildItemListModel() {
return new ItemPropertyListValueModelAdapter<ClassRef>(
- buildListHolder(),
- ClassRef.JAVA_PERSISTENT_TYPE_PROPERTY,
+ buildListModel(),
+ ClassRef.JAVA_MANAGED_TYPE_PROPERTY,
ClassRef.CLASS_NAME_PROPERTY
);
}
- private ListValueModel<ClassRef> buildListHolder() {
+ private ListValueModel<ClassRef> buildListModel() {
return new ListAspectAdapter<PersistenceUnit, ClassRef>(getSubjectHolder(), PersistenceUnit.SPECIFIED_CLASS_REFS_LIST) {
@Override
protected ListIterable<ClassRef> getListIterable() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java
index d68eadd..0d84a6a 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/persistence/PersistenceXmlUiDefinition.java
@@ -12,7 +12,7 @@ package org.eclipse.jpt.jpa.ui.internal.persistence;
import java.util.List;
import org.eclipse.jpt.common.core.JptResourceType;
import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXmlDefinition;
-import org.eclipse.jpt.jpa.ui.ResourceUiDefinition;
+import org.eclipse.jpt.jpa.ui.PersistenceResourceUiDefinition;
import org.eclipse.jpt.jpa.ui.editors.JpaEditorPageDefinition;
import org.eclipse.jpt.jpa.ui.internal.AbstractPersistenceResourceUiDefinition;
@@ -20,13 +20,13 @@ public class PersistenceXmlUiDefinition
extends AbstractPersistenceResourceUiDefinition
{
// singleton
- private static final ResourceUiDefinition INSTANCE = new PersistenceXmlUiDefinition();
+ private static final PersistenceResourceUiDefinition INSTANCE = new PersistenceXmlUiDefinition();
/**
* Return the singleton
*/
- public static ResourceUiDefinition instance() {
+ public static PersistenceResourceUiDefinition instance() {
return INSTANCE;
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java
index f4f452a..3357222 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/GenericNavigatorItemLabelProviderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -15,6 +15,7 @@ import org.eclipse.jpt.common.ui.internal.jface.StaticItemExtendedLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProviderFactory;
import org.eclipse.jpt.jpa.core.JpaNode;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
import org.eclipse.jpt.jpa.core.context.java.JarFile;
@@ -58,6 +59,9 @@ public class GenericNavigatorItemLabelProviderFactory
if (item instanceof PersistentType) {
return this.buildPersistentTypeProvider((PersistentType) item, manager);
}
+ if (item instanceof ManagedType) { //check instanceof PersistentType first, then ManagedType
+ return this.buildManagedTypeProvider((ManagedType) item, manager);
+ }
if (item instanceof ReadOnlyPersistentAttribute) {
return this.buildPersistentAttributeProvider((ReadOnlyPersistentAttribute) item, manager);
}
@@ -83,6 +87,10 @@ public class GenericNavigatorItemLabelProviderFactory
return new PersistentTypeItemLabelProvider(item, manager);
}
+ protected ItemExtendedLabelProvider buildManagedTypeProvider(ManagedType item, ItemExtendedLabelProvider.Manager manager) {
+ return new ManagedTypeItemLabelProvider(item, manager);
+ }
+
protected ItemExtendedLabelProvider buildPersistentAttributeProvider(ReadOnlyPersistentAttribute item, ItemExtendedLabelProvider.Manager manager) {
return new PersistentAttributeItemLabelProvider(item, manager);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ManagedTypeItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ManagedTypeItemLabelProvider.java
new file mode 100644
index 0000000..8fe6820
--- /dev/null
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/ManagedTypeItemLabelProvider.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.ui.internal.platform.generic;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jpt.common.ui.internal.jface.AbstractItemExtendedLabelProvider;
+import org.eclipse.jpt.common.ui.jface.ItemExtendedLabelProvider;
+import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
+import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
+import org.eclipse.jpt.jpa.ui.JptJpaUiImages;
+
+public class ManagedTypeItemLabelProvider
+ extends AbstractItemExtendedLabelProvider<ManagedType>
+{
+ public ManagedTypeItemLabelProvider(ManagedType managedType, ItemExtendedLabelProvider.Manager manager) {
+ super(managedType, manager);
+ }
+
+
+ // ********** image **********
+
+ @Override
+ protected ImageDescriptor getImageDescriptor() {
+ return JptJpaUiImages.CLASS_REF;
+ }
+
+
+ // ********** text **********
+
+ @Override
+ protected PropertyValueModel<String> buildTextModel() {
+ return new TextModel(this.item);
+ }
+
+ protected static class TextModel
+ extends PropertyAspectAdapter<ManagedType, String>
+ {
+ public TextModel(ManagedType subject) {
+ super(ManagedType.NAME_PROPERTY, subject);
+ }
+ @Override
+ protected String buildValue_() {
+ return this.subject.getSimpleName();
+ }
+ }
+
+
+ // ********** description **********
+
+ @Override
+ @SuppressWarnings("unchecked")
+ protected PropertyValueModel<String> buildDescriptionModel() {
+ return PersistenceUnitItemLabelProvider.buildNonQuotedComponentDescriptionModel(
+ this.item,
+ this.textModel
+ );
+ }
+}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java
index 0e9e8bf..293bbc8 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/OrmXmlItemContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2008, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,12 +17,12 @@ import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.jpa.core.context.XmlFile;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
public class OrmXmlItemContentProvider
- extends AbstractItemTreeContentProvider<OrmXml, OrmPersistentType>
+ extends AbstractItemTreeContentProvider<OrmXml, OrmManagedType>
{
public OrmXmlItemContentProvider(OrmXml ormXml, Manager manager) {
super(ormXml, manager);
@@ -33,25 +33,25 @@ public class OrmXmlItemContentProvider
}
@Override
- protected CollectionValueModel<OrmPersistentType> buildChildrenModel() {
- return new ListCollectionValueModelAdapter<OrmPersistentType>(new ChildrenModel(this.item));
+ protected CollectionValueModel<OrmManagedType> buildChildrenModel() {
+ return new ListCollectionValueModelAdapter<OrmManagedType>(new ChildrenModel(this.item));
}
protected static class ChildrenModel
- extends ListAspectAdapter<EntityMappings, OrmPersistentType>
+ extends ListAspectAdapter<EntityMappings, OrmManagedType>
{
ChildrenModel(OrmXml ormXml) {
- super(new EntityMappingsModel(ormXml), EntityMappings.PERSISTENT_TYPES_LIST);
+ super(new EntityMappingsModel(ormXml), EntityMappings.MANAGED_TYPES_LIST);
}
@Override
- protected ListIterable<OrmPersistentType> getListIterable() {
- return subject.getPersistentTypes();
+ protected ListIterable<OrmManagedType> getListIterable() {
+ return this.subject.getManagedTypes();
}
@Override
protected int size_() {
- return subject.getPersistentTypesSize();
+ return this.subject.getManagedTypesSize();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemContentProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemContentProvider.java
index d8ce9fe..6eb7d81 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemContentProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistenceUnitItemContentProvider.java
@@ -28,7 +28,7 @@ import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.jpa.core.context.JpaContextNode;
import org.eclipse.jpt.jpa.core.context.MappingFile;
import org.eclipse.jpt.jpa.core.context.java.JarFile;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.java.JavaManagedType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
@@ -60,7 +60,7 @@ public class PersistenceUnitItemContentProvider
protected void addChildrenModelsTo(ArrayList<CollectionValueModel<? extends JpaContextNode>> list) {
list.add(this.buildNotNullSpecifiedMappingFilesModel());
list.add(this.buildImpliedMappingFilesModel());
- list.add(this.buildNotNullPersistentTypesModel());
+ list.add(this.buildNotNullJavaManagedTypesModel());
list.add(this.buildNotNullJarFilesModel());
}
@@ -112,26 +112,26 @@ public class PersistenceUnitItemContentProvider
}
- // ********** persistent types **********
+ // ********** managed types **********
- protected CollectionValueModel<JavaPersistentType> buildNotNullPersistentTypesModel() {
- return new FilteringCollectionValueModel<JavaPersistentType>(
- this.buildPersistentTypesModel(),
- NotNullFilter.<JavaPersistentType>instance()
+ protected CollectionValueModel<JavaManagedType> buildNotNullJavaManagedTypesModel() {
+ return new FilteringCollectionValueModel<JavaManagedType>(
+ this.buildJavaManagedTypesModel(),
+ NotNullFilter.<JavaManagedType>instance()
);
}
- protected ListValueModel<JavaPersistentType> buildPersistentTypesModel() {
- return new TransformationListValueModel<ClassRef, JavaPersistentType>(
+ protected ListValueModel<JavaManagedType> buildJavaManagedTypesModel() {
+ return new TransformationListValueModel<ClassRef, JavaManagedType>(
this.buildClassRefsModel(),
- ClassRef.JAVA_PERSISTENT_TYPE_TRANSFORMER
+ ClassRef.JAVA_MANAGED_TYPE_TRANSFORMER
);
}
protected ListValueModel<ClassRef> buildClassRefsModel() {
return new ItemPropertyListValueModelAdapter<ClassRef>(
this.buildClassRefsModel_(),
- ClassRef.JAVA_PERSISTENT_TYPE_PROPERTY
+ ClassRef.JAVA_MANAGED_TYPE_PROPERTY
);
}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java
index 8595fa2..fc4a3d3 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/platform/generic/PersistentTypeItemLabelProvider.java
@@ -17,6 +17,7 @@ import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropert
import org.eclipse.jpt.common.utility.internal.transformer.TransformerAdapter;
import org.eclipse.jpt.common.utility.model.value.PropertyValueModel;
import org.eclipse.jpt.common.utility.transformer.Transformer;
+import org.eclipse.jpt.jpa.core.context.ManagedType;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.TypeMapping;
import org.eclipse.jpt.jpa.ui.JpaPlatformUi;
@@ -89,7 +90,7 @@ public class PersistentTypeItemLabelProvider
extends PropertyAspectAdapter<PersistentType, String>
{
public TextModel(PersistentType subject) {
- super(PersistentType.NAME_PROPERTY, subject);
+ super(ManagedType.NAME_PROPERTY, subject);
}
@Override
protected String buildValue_() {
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
index a2acf8e..3cd63e5 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/internal/prefs/JpaProblemSeveritiesPage.java
@@ -185,7 +185,7 @@ public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
result.put(JptJpaCoreValidationMessages.PERSISTENT_TYPE_DUPLICATE_CLASS, JpaPreferences.PROBLEM_WARNING); //3.0 M7
result.put(JptJpaCoreValidationMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING, JpaPreferences.PROBLEM_WARNING);
result.put(JptJpaCoreValidationMessages.PERSISTENT_ATTRIBUTE_INHERITED_ATTRIBUTES_NOT_SUPPORTED, JpaPreferences.PROBLEM_WARNING);
- result.put(JptJpaCoreValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, JpaPreferences.PROBLEM_WARNING);
+ result.put(JptJpaCoreValidationMessages.TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML, JpaPreferences.PROBLEM_WARNING);
result.put(JptJpaCoreValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED, JpaPreferences.PROBLEM_WARNING);
result.put(JptJpaCoreValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE, JpaPreferences.PROBLEM_WARNING); //3.0 M7
result.put(JptJpaCoreValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED, JpaPreferences.PROBLEM_WARNING);
@@ -315,10 +315,10 @@ public class JpaProblemSeveritiesPage extends PropertyAndPreferencePage {
addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.ENTITY_NO_PK, JptJpaCoreValidationMessages.ENTITY_NO_PK);
addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED, JptJpaCoreValidationMessages.ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED); //3.0 M7
addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.ENTITY_NON_ROOT_ID_CLASS_SPECIFIED, JptJpaCoreValidationMessages.ENTITY_NON_ROOT_ID_CLASS_SPECIFIED); //3.0 M7
- addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, JptJpaCoreValidationMessages.PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT);
- addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT, JptJpaCoreValidationMessages.PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT);
- addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS, JptJpaCoreValidationMessages.PERSISTENT_TYPE_UNRESOLVED_CLASS);
- addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS, JptJpaCoreValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS);
+ addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML, JptJpaCoreValidationMessages.TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML);
+ addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML, JptJpaCoreValidationMessages.TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML);
+ addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.MANAGED_TYPE_UNRESOLVED_CLASS, JptJpaCoreValidationMessages.MANAGED_TYPE_UNRESOLVED_CLASS);
+ addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.MANAGED_TYPE_UNSPECIFIED_CLASS, JptJpaCoreValidationMessages.MANAGED_TYPE_UNSPECIFIED_CLASS);
addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR, JptJpaCoreValidationMessages.TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR);
addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR, JptJpaCoreValidationMessages.TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR);
addLabeledCombo(parent, JptJpaUiPreferencesValidationMessages.TYPE_MAPPING_FINAL_CLASS, JptJpaCoreValidationMessages.TYPE_MAPPING_FINAL_CLASS);
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/persistence/JptJpaUiPersistenceMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/persistence/JptJpaUiPersistenceMessages.java
index 4db1040..b24293c 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/persistence/JptJpaUiPersistenceMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/persistence/JptJpaUiPersistenceMessages.java
@@ -26,9 +26,9 @@ public class JptJpaUiPersistenceMessages {
public static String ARCHIVE_FILE_SELECTION_DIALOG_JAR_PATH_LABEL;
public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_DESCRIPTION;
- public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES;
- public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_MAPPED_CLASSES_WITH_DEFAULT;
- public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_MAPPED_CLASSES_NO_NAME;
+ public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES;
+ public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_EXCLUDE_UNLISTED_CLASSES_WITH_DEFAULT;
+ public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_CLASS_REF_NO_NAME;
public static String PERSISTENCE_UNIT_CLASSES_COMPOSITE_OPEN;
public static String PERSISTENCE_UNIT_CONNECTION_COMPOSITE_CONNECTION;
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/prefs/validation/JptJpaUiPreferencesValidationMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/prefs/validation/JptJpaUiPreferencesValidationMessages.java
index dbef3f0..51051ab 100644
--- a/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/prefs/validation/JptJpaUiPreferencesValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.jpa.ui/src/org/eclipse/jpt/jpa/ui/prefs/validation/JptJpaUiPreferencesValidationMessages.java
@@ -68,10 +68,10 @@ public class JptJpaUiPreferencesValidationMessages {
public static String ENTITY_NO_PK;
public static String ENTITY_NON_ROOT_ID_ATTRIBUTE_SPECIFIED; //3.0 M7
public static String ENTITY_NON_ROOT_ID_CLASS_SPECIFIED; //3.0 M7
- public static String PERSISTENT_TYPE_ANNOTATED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT;
- public static String PERSISTENT_TYPE_MAPPED_BUT_NOT_INCLUDED_IN_PERSISTENCE_UNIT;
- public static String PERSISTENT_TYPE_UNRESOLVED_CLASS;
- public static String PERSISTENT_TYPE_UNSPECIFIED_CLASS;
+ public static String TYPE_ANNOTATED_BUT_NOT_LISTED_IN_PERSISTENCE_XML;
+ public static String TYPE_MANAGED_BUT_NOT_LISTED_IN_PERSISTENCE_XML;
+ public static String MANAGED_TYPE_UNRESOLVED_CLASS;
+ public static String MANAGED_TYPE_UNSPECIFIED_CLASS;
public static String TYPE_MAPPING_CLASS_MISSING_NO_ARG_CONSTRUCTOR;
public static String TYPE_MAPPING_CLASS_PRIVATE_NO_ARG_CONSTRUCTOR;
public static String TYPE_MAPPING_FINAL_CLASS;
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF
index 94f4b2d..da067da 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/META-INF/MANIFEST.MF
@@ -39,6 +39,9 @@ Export-Package: org.eclipse.jpt.jpa.core.tests.internal;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.orm;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.persistence;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.jpa2.resource.java;x-internal:=true,
+ org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context;x-internal:=true,
+ org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence;x-internal:=true,
+ org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.resource.java;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.model;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.platform;x-internal:=true,
org.eclipse.jpt.jpa.core.tests.internal.projects;x-internal:=true,
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java
index 03f024e..b5806c2 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaFileTests.java
@@ -99,7 +99,7 @@ public class JpaFileTests
//persistence.xml <class> tag and mapping file <entity> tag exist for a particulary java class
assertEquals(ormPersistentType.getJavaPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
- getEntityMappings().removePersistentType(ormPersistentType);
+ getEntityMappings().removeManagedType(ormPersistentType);
assertEquals(getJavaEntity().getPersistentType(), javaJpaFile.getRootStructureNodes().iterator().next());
@@ -229,14 +229,14 @@ public class JpaFileTests
JpaFile javaJpaFile = this.getJpaFile(cu);
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertTrue(node.getParent() instanceof OrmPersistentType);
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ node = javaJpaFile.getRootStructureNodes().iterator().next();
assertTrue(node.getParent() instanceof ClassRef);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
}
@@ -249,13 +249,13 @@ public class JpaFileTests
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertTrue(node.getParent() instanceof OrmPersistentType);
getXmlEntityMappings().getEntities().remove(0);
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ node = javaJpaFile.getRootStructureNodes().iterator().next();
assertTrue(node.getParent() instanceof ClassRef);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
}
@@ -267,12 +267,12 @@ public class JpaFileTests
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
JavaPersistentType javaPersistentType = getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getEntityMappings().getPersistenceUnit().getSpecifiedClassRefs().iterator().next(), node.getParent());
getEntityMappings().getPersistenceUnit().removeSpecifiedClassRef(0);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
@@ -290,7 +290,7 @@ public class JpaFileTests
removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
@@ -319,7 +319,7 @@ public class JpaFileTests
getOrmXmlResource().getContents().remove(getXmlEntityMappings());
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
@@ -362,10 +362,10 @@ public class JpaFileTests
JavaPersistentType javaPersistentType = ormPersistentType.getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
@@ -383,10 +383,10 @@ public class JpaFileTests
javaPersistentType = getEntityMappings().getPersistentTypes().iterator().next().getJavaPersistentType();
assertEquals(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getEntityMappings().getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
@@ -438,8 +438,8 @@ public class JpaFileTests
assertNotSame(javaPersistentType, javaJpaFile.getRootStructureNodes().iterator().next());
assertEquals(1, javaJpaFile.getRootStructureNodesSize());
- JpaNode node = (JpaNode) javaJpaFile.getRootStructureNodes().iterator().next();
+ JpaNode node = javaJpaFile.getRootStructureNodes().iterator().next();
assertEquals(getPersistenceUnit().getImpliedClassRefs().iterator().next(), node.getParent());
}
//TODO test rootStructureNodes with a static inner class
-} \ No newline at end of file
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaProjectTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaProjectTests.java
index b84bf8f..367a632 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaProjectTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JpaProjectTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,76 +9,69 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.tests.internal.context;
-import junit.framework.TestCase;
-import org.eclipse.core.resources.ResourcesPlugin;
+import java.util.Iterator;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
-import org.eclipse.jpt.jpa.core.JpaPlatform;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JpaWorkspace;
-import org.eclipse.jpt.jpa.core.internal.GenericJpaPlatformFactory;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
-import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProvider;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
import org.eclipse.jpt.jpa.core.internal.operations.PersistenceFileCreationDataModelProvider;
-import org.eclipse.jpt.jpa.core.platform.JpaPlatformManager;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
-import org.eclipse.jpt.jpa.core.tests.internal.projects.TestJpaProject;
-import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
@SuppressWarnings("nls")
public class JpaProjectTests
- extends TestCase
+ extends ContextModelTestCase
{
- static final String BASE_PROJECT_NAME = JpaProjectTests.class.getSimpleName();
-
- TestJpaProject jpaProject;
-
public JpaProjectTests(String name) {
super(name);
}
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.jpaProject = TestJpaProject.buildJpaProject(BASE_PROJECT_NAME, false, buildJpaConfigDataModel()); // false = no auto-build
- }
- protected IDataModel buildJpaConfigDataModel() {
- IDataModel dataModel = DataModelFactory.createDataModel(new JpaFacetInstallDataModelProvider());
- dataModel.setProperty(IFacetDataModelProperties.FACET_VERSION_STR, JpaProject.FACET_VERSION_STRING);
- dataModel.setProperty(JpaFacetDataModelProperties.PLATFORM, this.getJpaPlatformConfig());
- dataModel.setProperty(JpaFacetInstallDataModelProperties.CREATE_ORM_XML, Boolean.TRUE);
- return dataModel;
- }
-
- protected JpaPlatform.Config getJpaPlatformConfig() {
- return this.getJpaPlatformManager().getJpaPlatformConfig(GenericJpaPlatformFactory.ID);
- }
-
- protected JpaPlatformManager getJpaPlatformManager() {
- return this.getJpaWorkspace().getJpaPlatformManager();
+ private ICompilationUnit createTestEntity() throws Exception {
+ return this.createTestType("MyEntity", new DefaultAnnotationWriter() {
+
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity");
+ }
+ });
}
-
- protected JpaWorkspace getJpaWorkspace() {
- return (JpaWorkspace) ResourcesPlugin.getWorkspace().getAdapter(JpaWorkspace.class);
- }
-
- @Override
- protected void tearDown() throws Exception {
- this.jpaProject.getProject().delete(true, true, null);
- this.jpaProject = null;
- super.tearDown();
+
+ private ICompilationUnit createTestMappedSuperclass() throws Exception {
+ return this.createTestType("MyMappedSuperclass", new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.MAPPED_SUPERCLASS);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@MappedSuperclass");
+ }
+ });
}
- protected JpaProject getJpaProject() {
- return this.jpaProject.getJpaProject();
+ private ICompilationUnit createTestEmbeddable() throws Exception {
+ return this.createTestType("MyEmbeddable", new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.EMBEDDABLE);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Embeddable");
+ }
+ });
}
public void testGetPersistenceXmlResource() throws Exception {
@@ -186,4 +179,17 @@ public class JpaProjectTests
assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
}
+
+ public void testGetPotentialJavaSourceTypes() throws Exception {
+ createTestEntity();
+ createTestEmbeddable();
+ createTestMappedSuperclass();
+ createTestType();
+
+ Iterable<JavaResourceAbstractType> potentialJavaSourceTypes = this.getJpaProject().getPotentialJavaSourceTypes();
+ assertEquals(3, IterableTools.size(potentialJavaSourceTypes));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyEntity")));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyEmbeddable")));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyMappedSuperclass")));
+ }
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java
index 52c3042..8a22329 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/JptJpaCoreContextModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -19,6 +19,8 @@ import org.eclipse.jpt.jpa.core.tests.internal.context.persistence.JptCorePersis
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.java.Generic2_0JavaContextModelTests;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.orm.Generic2_0OrmContextModelTests;
import org.eclipse.jpt.jpa.core.tests.internal.jpa2.context.persistence.Generic2_0PersistenceContextModelTests;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.JpaProject2_1Tests;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence.JptJpa2_1ContextPersistenceModelTests;
/**
* Required Java system property:
@@ -33,12 +35,14 @@ public class JptJpaCoreContextModelTests
if (JptJpaCoreTests.requiredJarsExists()) {
suite.addTestSuite(JpaProjectTests.class);
suite.addTestSuite(JpaFileTests.class);
+ suite.addTestSuite(JpaProject2_1Tests.class);
suite.addTest(JptCorePersistenceContextModelTests.suite());
suite.addTest(JptCoreOrmContextModelTests.suite());
suite.addTest(JptCoreContextJavaModelTests.suite());
suite.addTest(Generic2_0JavaContextModelTests.suite());
suite.addTest(Generic2_0OrmContextModelTests.suite());
suite.addTest(Generic2_0PersistenceContextModelTests.suite());
+ suite.addTest(JptJpa2_1ContextPersistenceModelTests.suite());
} else {
suite.addTest(TestSuite.warning(JptJpaCoreTests.buildMissingJarErrorMessage()));
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableGeneratorTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableGeneratorTests.java
index f14efce..fa01203 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableGeneratorTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableGeneratorTests.java
@@ -197,7 +197,7 @@ public class JavaTableGeneratorTests extends ContextModelTestCase
ormEntity.getTable().setSpecifiedSchema("XML_SCHEMA");
assertEquals("BAR", idMapping.getGeneratorContainer().getTableGenerator().getDefaultSchema());
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
//default schema taken from persistence-unit-defaults not entity-mappings since the entity is not in an orm.xml file
assertEquals("FOO", ((IdMapping) getJavaPersistentType().getAttributeNamed("id").getMapping()).getGeneratorContainer().getTableGenerator().getDefaultSchema());
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableTests.java
index 2c768ff..d4c2262 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/java/JavaTableTests.java
@@ -178,7 +178,7 @@ public class JavaTableTests extends ContextModelTestCase
ormEntity.getTable().setSpecifiedSchema("XML_SCHEMA");
assertEquals("BAR", javaEntity.getTable().getDefaultSchema());
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
//default schema taken from persistence-unit-defaults not entity-mappings since the entity is not in an orm.xml file
assertEquals("FOO", getJavaEntity().getTable().getDefaultSchema());
@@ -298,7 +298,7 @@ public class JavaTableTests extends ContextModelTestCase
ormEntity.getTable().setSpecifiedCatalog("XML_CATALOG");
assertEquals("BAR", javaEntity.getTable().getDefaultCatalog());
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
//default catalog taken from persistence-unite-defaults not entity-mappings since the entity is not in an orm.xml file
assertEquals("FOO", getJavaEntity().getTable().getDefaultCatalog());
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/EntityMappingsTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/EntityMappingsTests.java
index 950518d..1125289 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/EntityMappingsTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/EntityMappingsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -370,7 +370,7 @@ public class EntityMappingsTests extends ContextModelTestCase
getXmlEntityMappings().getEmbeddables().add(embeddable);
embeddable.setClassName("model.Foo");
assertTrue(getEntityMappings().getPersistentTypes().iterator().hasNext());
- assertEquals("model.Foo", getEntityMappings().getPersistentTypes().iterator().next().getMapping().getClass_());
+ assertEquals("model.Foo", getEntityMappings().getPersistentTypes().iterator().next().getClass_());
assertTrue(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertTrue(getXmlEntityMappings().getEntities().isEmpty());
assertFalse(getXmlEntityMappings().getEmbeddables().isEmpty());
@@ -381,7 +381,7 @@ public class EntityMappingsTests extends ContextModelTestCase
getXmlEntityMappings().getEntities().add(entity);
entity.setClassName("model.Foo2");
assertTrue(getEntityMappings().getPersistentTypes().iterator().hasNext());
- assertEquals("model.Foo2", getEntityMappings().getPersistentTypes().iterator().next().getMapping().getClass_());
+ assertEquals("model.Foo2", getEntityMappings().getPersistentTypes().iterator().next().getClass_());
assertTrue(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertFalse(getXmlEntityMappings().getEntities().isEmpty());
assertFalse(getXmlEntityMappings().getEmbeddables().isEmpty());
@@ -392,7 +392,7 @@ public class EntityMappingsTests extends ContextModelTestCase
getXmlEntityMappings().getMappedSuperclasses().add(mappedSuperclass);
mappedSuperclass.setClassName("model.Foo3");
assertTrue(getEntityMappings().getPersistentTypes().iterator().hasNext());
- assertEquals("model.Foo3", getEntityMappings().getPersistentTypes().iterator().next().getMapping().getClass_());
+ assertEquals("model.Foo3", getEntityMappings().getPersistentTypes().iterator().next().getClass_());
assertFalse(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertFalse(getXmlEntityMappings().getEntities().isEmpty());
assertFalse(getXmlEntityMappings().getEmbeddables().isEmpty());
@@ -409,7 +409,7 @@ public class EntityMappingsTests extends ContextModelTestCase
//add embeddable in the context model, verify resource model modified
getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
assertTrue(getEntityMappings().getPersistentTypes().iterator().hasNext());
- assertEquals("model.Foo", getEntityMappings().getPersistentTypes().iterator().next().getMapping().getClass_());
+ assertEquals("model.Foo", getEntityMappings().getPersistentTypes().iterator().next().getClass_());
assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, getEntityMappings().getPersistentTypes().iterator().next().getMapping().getKey());
assertTrue(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertTrue(getXmlEntityMappings().getEntities().isEmpty());
@@ -419,7 +419,7 @@ public class EntityMappingsTests extends ContextModelTestCase
//add entity in the context model, verify resource model modified
getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo2");
assertTrue(getEntityMappings().getPersistentTypes().iterator().hasNext());
- assertEquals("model.Foo2", getEntityMappings().getPersistentTypes().iterator().next().getMapping().getClass_());
+ assertEquals("model.Foo2", getEntityMappings().getPersistentTypes().iterator().next().getClass_());
assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, getEntityMappings().getPersistentTypes().iterator().next().getMapping().getKey());
assertTrue(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertFalse(getXmlEntityMappings().getEntities().isEmpty());
@@ -429,7 +429,7 @@ public class EntityMappingsTests extends ContextModelTestCase
//add mapped-superclass in the context model, verify resource model modified
getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo3");
assertTrue(getEntityMappings().getPersistentTypes().iterator().hasNext());
- assertEquals("model.Foo3", getEntityMappings().getPersistentTypes().iterator().next().getMapping().getClass_());
+ assertEquals("model.Foo3", getEntityMappings().getPersistentTypes().iterator().next().getClass_());
assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, getEntityMappings().getPersistentTypes().iterator().next().getMapping().getKey());
assertFalse(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertFalse(getXmlEntityMappings().getEntities().isEmpty());
@@ -448,17 +448,17 @@ public class EntityMappingsTests extends ContextModelTestCase
getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo3");
//remove ormPersistentType from the context model, verify resource model modified
- getEntityMappings().removePersistentType(1);
+ getEntityMappings().removeManagedType(1);
assertFalse(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertTrue(getXmlEntityMappings().getEntities().isEmpty());
assertFalse(getXmlEntityMappings().getEmbeddables().isEmpty());
- getEntityMappings().removePersistentType(1);
+ getEntityMappings().removeManagedType(1);
assertFalse(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertTrue(getXmlEntityMappings().getEntities().isEmpty());
assertTrue(getXmlEntityMappings().getEmbeddables().isEmpty());
- getEntityMappings().removePersistentType(0);
+ getEntityMappings().removeManagedType(0);
assertTrue(getXmlEntityMappings().getMappedSuperclasses().isEmpty());
assertTrue(getXmlEntityMappings().getEntities().isEmpty());
assertTrue(getXmlEntityMappings().getEmbeddables().isEmpty());
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddableTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddableTests.java
index 0e554c8..cc4a97a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddableTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEmbeddableTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.tests.internal.context.orm;
-import java.util.ListIterator;
+import java.util.Iterator;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable;
@@ -44,37 +44,35 @@ public class OrmEmbeddableTests extends ContextModelTestCase
public void testUpdateClass() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
XmlEmbeddable embeddableResource = getXmlEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", ormEmbeddable.getClass_());
+ assertEquals("model.Foo", ormPersistentType.getClass_());
assertEquals("model.Foo", embeddableResource.getClassName());
//set class in the resource model, verify context model updated
embeddableResource.setClassName("com.Bar");
- assertEquals("com.Bar", ormEmbeddable.getClass_());
+ assertEquals("com.Bar", ormPersistentType.getClass_());
assertEquals("com.Bar", embeddableResource.getClassName());
//set class to null in the resource model
embeddableResource.setClassName(null);
- assertNull(ormEmbeddable.getClass_());
+ assertNull(ormPersistentType.getClass_());
assertNull(embeddableResource.getClassName());
}
public void testModifyClass() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, "model.Foo");
- OrmEmbeddable ormEmbeddable = (OrmEmbeddable) ormPersistentType.getMapping();
XmlEmbeddable embeddableResource = getXmlEntityMappings().getEmbeddables().get(0);
- assertEquals("model.Foo", ormEmbeddable.getClass_());
+ assertEquals("model.Foo", ormPersistentType.getClass_());
assertEquals("model.Foo", embeddableResource.getClassName());
//set class in the context model, verify resource model modified
- ormEmbeddable.setClass("com.Bar");
- assertEquals("com.Bar", ormEmbeddable.getClass_());
+ ormPersistentType.setClass("com.Bar");
+ assertEquals("com.Bar", ormPersistentType.getClass_());
assertEquals("com.Bar", embeddableResource.getClassName());
//set class to null in the context model
- ormEmbeddable.setClass(null);
- assertNull(ormEmbeddable.getClass_());
+ ormPersistentType.setClass(null);
+ assertNull(ormPersistentType.getClass_());
assertNull(embeddableResource.getClassName());
}
//TODO add tests for setting the className when the package is set on entity-mappings
@@ -216,7 +214,7 @@ public class OrmEmbeddableTests extends ContextModelTestCase
assertNull(entity.getName());
OrmEntity ormEntity = (OrmEntity) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
+ assertEquals("model.Foo", embeddablePersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, embeddablePersistentType.getSpecifiedAccess());
}
@@ -239,11 +237,11 @@ public class OrmEmbeddableTests extends ContextModelTestCase
assertNull(entity.getName());
OrmEntity ormEntity = (OrmEntity) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
+ assertEquals("model.Foo", embeddablePersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, embeddablePersistentType.getSpecifiedAccess());
- ListIterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
+ Iterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
}
@@ -262,7 +260,7 @@ public class OrmEmbeddableTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
+ assertEquals("model.Foo", embeddablePersistentType.getClass_());
assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, embeddablePersistentType.getSpecifiedAccess());
}
@@ -283,11 +281,11 @@ public class OrmEmbeddableTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) embeddablePersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
+ assertEquals("model.Foo", embeddablePersistentType.getClass_());
assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, embeddablePersistentType.getSpecifiedAccess());
- ListIterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
+ Iterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java
index a87fad0..6984757 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmEntityTests.java
@@ -388,37 +388,35 @@ public class OrmEntityTests extends ContextModelTestCase
public void testUpdateClass() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", ormEntity.getClass_());
+ assertEquals("model.Foo", ormPersistentType.getClass_());
assertEquals("model.Foo", entityResource.getClassName());
//set class in the resource model, verify context model updated
entityResource.setClassName("com.Bar");
- assertEquals("com.Bar", ormEntity.getClass_());
+ assertEquals("com.Bar", ormPersistentType.getClass_());
assertEquals("com.Bar", entityResource.getClassName());
//set class to null in the resource model
entityResource.setClassName(null);
- assertNull(ormEntity.getClass_());
+ assertNull(ormPersistentType.getClass_());
assertNull(entityResource.getClassName());
}
public void testModifyClass() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
- OrmEntity ormEntity = (OrmEntity) ormPersistentType.getMapping();
XmlEntity entityResource = getXmlEntityMappings().getEntities().get(0);
- assertEquals("model.Foo", ormEntity.getClass_());
+ assertEquals("model.Foo", ormPersistentType.getClass_());
assertEquals("model.Foo", entityResource.getClassName());
//set class in the context model, verify resource model modified
- ormEntity.setClass("com.Bar");
- assertEquals("com.Bar", ormEntity.getClass_());
+ ormPersistentType.setClass("com.Bar");
+ assertEquals("com.Bar", ormPersistentType.getClass_());
assertEquals("com.Bar", entityResource.getClassName());
//set class to null in the context model
- ormEntity.setClass(null);
- assertNull(ormEntity.getClass_());
+ ormPersistentType.setClass(null);
+ assertNull(ormPersistentType.getClass_());
assertNull(entityResource.getClassName());
}
//TODO add tests for setting the className when the package is set on entity-mappings
@@ -1029,7 +1027,7 @@ public class OrmEntityTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
OrmEmbeddable ormEmbeddable = (OrmEmbeddable) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
+ assertEquals("model.Foo", entityPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, entityPersistentType.getSpecifiedAccess());
}
@@ -1055,7 +1053,7 @@ public class OrmEntityTests extends ContextModelTestCase
// assertEquals("basicMapping", embeddable.getAttributes().getBasics().get(0).getName());
OrmEmbeddable ormEmbeddable = (OrmEmbeddable) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
+ assertEquals("model.Foo", entityPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, entityPersistentType.getSpecifiedAccess());
// assertEquals("basicMapping", ormEmbeddable.persistentType().attributes().next().getName());
@@ -1078,7 +1076,7 @@ public class OrmEntityTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
+ assertEquals("model.Foo", entityPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, entityPersistentType.getSpecifiedAccess());
}
@@ -1101,7 +1099,7 @@ public class OrmEntityTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, mappedSuperclass.getAccess());
OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) entityPersistentType.getMapping();
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
+ assertEquals("model.Foo", entityPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormMappedSuperclass.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, entityPersistentType.getSpecifiedAccess());
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmMappedSuperclassTests.java
index 048045c..7a2f4ad 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmMappedSuperclassTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/orm/OrmMappedSuperclassTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2007, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -9,7 +9,7 @@
******************************************************************************/
package org.eclipse.jpt.jpa.core.tests.internal.context.orm;
-import java.util.ListIterator;
+import java.util.Iterator;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject.SourceWriter;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AccessType;
@@ -57,37 +57,35 @@ public class OrmMappedSuperclassTests extends ContextModelTestCase
public void testUpdateClass() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
XmlMappedSuperclass mappedSuperclassResource = getXmlEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
+ assertEquals("model.Foo", ormPersistentType.getClass_());
assertEquals("model.Foo", mappedSuperclassResource.getClassName());
//set class in the resource model, verify context model updated
mappedSuperclassResource.setClassName("com.Bar");
- assertEquals("com.Bar", ormMappedSuperclass.getClass_());
+ assertEquals("com.Bar", ormPersistentType.getClass_());
assertEquals("com.Bar", mappedSuperclassResource.getClassName());
//set class to null in the resource model
mappedSuperclassResource.setClassName(null);
- assertNull(ormMappedSuperclass.getClass_());
+ assertNull(ormPersistentType.getClass_());
assertNull(mappedSuperclassResource.getClassName());
}
public void testModifyClass() throws Exception {
OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, "model.Foo");
- OrmMappedSuperclass ormMappedSuperclass = (OrmMappedSuperclass) ormPersistentType.getMapping();
XmlMappedSuperclass mappedSuperclassResource = getXmlEntityMappings().getMappedSuperclasses().get(0);
- assertEquals("model.Foo", ormMappedSuperclass.getClass_());
+ assertEquals("model.Foo", ormPersistentType.getClass_());
assertEquals("model.Foo", mappedSuperclassResource.getClassName());
//set class in the context model, verify resource model modified
- ormMappedSuperclass.setClass("com.Bar");
- assertEquals("com.Bar", ormMappedSuperclass.getClass_());
+ ormPersistentType.setClass("com.Bar");
+ assertEquals("com.Bar", ormPersistentType.getClass_());
assertEquals("com.Bar", mappedSuperclassResource.getClassName());
//set class to null in the context model
- ormMappedSuperclass.setClass(null);
- assertNull(ormMappedSuperclass.getClass_());
+ ormPersistentType.setClass(null);
+ assertNull(ormPersistentType.getClass_());
assertNull(mappedSuperclassResource.getClassName());
}
//TODO add tests for setting the className when the package is set on entity-mappings
@@ -233,7 +231,7 @@ public class OrmMappedSuperclassTests extends ContextModelTestCase
assertNull(entity.getName());
OrmEntity ormEntity = (OrmEntity) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
+ assertEquals("model.Foo", mappedSuperclassPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, mappedSuperclassPersistentType.getSpecifiedAccess());
}
@@ -256,11 +254,11 @@ public class OrmMappedSuperclassTests extends ContextModelTestCase
assertNull(entity.getName());
OrmEntity ormEntity = (OrmEntity) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEntity.getClass_());
+ assertEquals("model.Foo", mappedSuperclassPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEntity.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, mappedSuperclassPersistentType.getSpecifiedAccess());
- ListIterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
+ Iterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
assertEquals(MappingKeys.ENTITY_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
}
@@ -279,7 +277,7 @@ public class OrmMappedSuperclassTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
OrmEmbeddable ormEmbeddable = (OrmEmbeddable) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
+ assertEquals("model.Foo", mappedSuperclassPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, mappedSuperclassPersistentType.getSpecifiedAccess());
}
@@ -299,11 +297,11 @@ public class OrmMappedSuperclassTests extends ContextModelTestCase
assertEquals(org.eclipse.jpt.jpa.core.resource.orm.AccessType.PROPERTY, embeddable.getAccess());
OrmEmbeddable ormEmbeddable = (OrmEmbeddable) mappedSuperclassPersistentType.getMapping();
- assertEquals("model.Foo", ormEmbeddable.getClass_());
+ assertEquals("model.Foo", mappedSuperclassPersistentType.getClass_());
assertEquals(Boolean.TRUE, ormEmbeddable.getSpecifiedMetadataComplete());
assertEquals(AccessType.PROPERTY, mappedSuperclassPersistentType.getSpecifiedAccess());
- ListIterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
+ Iterator<OrmPersistentType> persistentTypes = getEntityMappings().getPersistentTypes().iterator();
assertEquals(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
assertEquals(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, persistentTypes.next().getMappingKey());
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/ClassRefTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/ClassRefTests.java
index a74b189..b1aeb65 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/ClassRefTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/ClassRefTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle.
+ * Copyright (c) 2007, 2013 Oracle.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -91,7 +91,7 @@ public class ClassRefTests extends ContextModelTestCase
}
- public void testGetPersistentType() throws Exception {
+ public void testGetJavaManagedType() throws Exception {
createTestType();
XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
@@ -102,12 +102,12 @@ public class ClassRefTests extends ContextModelTestCase
ClassRef classRef = getSpecifiedClassRef();
- assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaPersistentType().getName());
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaManagedType().getName());
//test setting to a class that does not exist in the project
xmlClassRef.setJavaClass("com.foo.Bar");
classRef = getSpecifiedClassRef();
- assertNull(classRef.getJavaPersistentType());
+ assertNull(classRef.getJavaManagedType());
}
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceUnitTests.java
index f49b285..67d0289 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceUnitTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/context/persistence/PersistenceUnitTests.java
@@ -51,6 +51,8 @@ public class PersistenceUnitTests extends ContextModelTestCase
public static final String OTHER_TYPE_NAME = "OtherTestType";
public static final String FULLY_QUALIFIED_OTHER_TYPE_NAME = PACKAGE_NAME + "." + OTHER_TYPE_NAME;
+ public static final String ORM2_XML_FILE_NAME = "orm2.xml";
+ public static final String ORM3_XML_FILE_NAME = "orm3.xml";
public PersistenceUnitTests(String name) {
super(name);
@@ -1081,7 +1083,7 @@ public class PersistenceUnitTests extends ContextModelTestCase
public void testGetDefaultAccess() throws Exception {
addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
- createOrm2XmlFile();
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
PersistenceUnit persistenceUnit = getPersistenceUnit();
ListIterator<MappingFileRef> mappingFileRefs = getPersistenceUnit().getMappingFileRefs().iterator();
OrmXml ormMappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
@@ -1105,7 +1107,7 @@ public class PersistenceUnitTests extends ContextModelTestCase
public void testGetDefaultSchema() throws Exception {
addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
- createOrm2XmlFile();
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
PersistenceUnit persistenceUnit = getPersistenceUnit();
ListIterator<MappingFileRef> mappingFileRefs = getPersistenceUnit().getMappingFileRefs().iterator();
OrmXml ormMappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
@@ -1126,7 +1128,7 @@ public class PersistenceUnitTests extends ContextModelTestCase
public void testGetDefaultCatalog() throws Exception {
addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
- createOrm2XmlFile();
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
PersistenceUnit persistenceUnit = getPersistenceUnit();
ListIterator<MappingFileRef> mappingFileRefs = getPersistenceUnit().getMappingFileRefs().iterator();
OrmXml ormMappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
@@ -1145,15 +1147,15 @@ public class PersistenceUnitTests extends ContextModelTestCase
assertEquals("BAR", persistenceUnit.getDefaultCatalog());
}
- protected void createOrm2XmlFile() throws Exception {
+ protected void createOrmXmlFile(String fileName) throws Exception {
IDataModel config =
DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
- config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, "orm2.xml");
+ config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, fileName);
config.getDefaultOperation().execute(null, null);
- addXmlMappingFileRef("META-INF/orm2.xml");
+ addXmlMappingFileRef("META-INF/" + fileName);
getPersistenceXmlResource().save(null);
}
@@ -1235,6 +1237,41 @@ public class PersistenceUnitTests extends ContextModelTestCase
getXmlPersistenceUnit().getMappingFiles().remove(0);
assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
}
+
+ public void testGetMappingFileRefsContaining() throws Exception {
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
+ createOrmXmlFile(ORM3_XML_FILE_NAME);
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ Iterable<MappingFileRef> mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(true, IterableTools.isEmpty(mappingFileRefs));
+
+ OrmXml ormXml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 0).getMappingFile();
+ OrmXml orm2Xml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 1).getMappingFile();
+ OrmXml orm3Xml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 2).getMappingFile();
+
+ ormXml.getRoot().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(1, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+
+ orm2Xml.getRoot().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(2, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+ assertEquals(orm2Xml, IterableTools.get(mappingFileRefs, 1).getMappingFile());
+
+ orm3Xml.getRoot().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(3, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+ assertEquals(orm2Xml, IterableTools.get(mappingFileRefs, 1).getMappingFile());
+ assertEquals(orm3Xml, IterableTools.get(mappingFileRefs, 2).getMappingFile());
+
+ }
//TODO
// String getDefaultSchema();
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java
index 37260bc..3873b37 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/java/GenericJavaSequenceGenerator2_0Tests.java
@@ -149,7 +149,7 @@ public class GenericJavaSequenceGenerator2_0Tests extends Generic2_0ContextModel
ormEntity.getTable().setSpecifiedSchema("XML_SCHEMA");
assertEquals("BAR", sequenceGenerator.getDefaultSchema());
- this.getEntityMappings().removePersistentType(0);
+ this.getEntityMappings().removeManagedType(0);
this.addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
//default schema taken from persistence-unit-defaults not entity-mappings since the entity is not in an orm.xml file
idMapping = (IdMapping) getJavaPersistentType().getAttributeNamed("id").getMapping();
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0ConnectionTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0ConnectionTests.java
index a913b9e..9773cd4 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0ConnectionTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0ConnectionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009 Oracle. All rights reserved.
+* Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -17,7 +17,7 @@ import org.eclipse.jpt.jpa.core.jpa2.context.persistence.connection.JpaConnectio
* GenericConnection2_0Tests
*/
@SuppressWarnings("nls")
-public class Generic2_0ConnectionTests extends Generic2_0PersistenceUnitTests
+public class Generic2_0ConnectionTests extends PersistenceUnit2_0TestCase
{
private JpaConnection2_0 connection;
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0OptionsTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0OptionsTests.java
index 10ea07e..9a537fb 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0OptionsTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0OptionsTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
-* Copyright (c) 2009, 2011 Oracle. All rights reserved.
+* Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -26,7 +26,7 @@ import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.JpaOptions2_0;
* GenericOptions2_0Tests
*/
@SuppressWarnings("nls")
-public class Generic2_0OptionsTests extends Generic2_0PersistenceUnitTests
+public class Generic2_0OptionsTests extends PersistenceUnit2_0TestCase
{
private JpaOptions2_0 options;
private ListChangeEvent prePersistEvent;
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceContextModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceContextModelTests.java
index d2fd0dd..8ecbb5c 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceContextModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceContextModelTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -18,7 +18,8 @@ public class Generic2_0PersistenceContextModelTests
{
public static Test suite() {
- TestSuite suite = new TestSuite(Generic2_0ConnectionTests.class.getPackage().getName());
+ TestSuite suite = new TestSuite(Generic2_0PersistenceContextModelTests.class.getPackage().getName());
+ suite.addTestSuite(Generic2_0ConnectionTests.class);
suite.addTestSuite(Generic2_0OptionsTests.class);
suite.addTestSuite(Generic2_0JpaMetadataConversionTests.class);
return suite;
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/PersistenceUnit2_0TestCase.java
index 7bf7888..b9576cc 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/Generic2_0PersistenceUnitTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2/context/persistence/PersistenceUnit2_0TestCase.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2012 Oracle. All rights reserved.
+ * Copyright (c) 2009, 2013 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html.
@@ -16,7 +16,7 @@ import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0;
import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
import org.eclipse.jpt.jpa.core.tests.internal.context.persistence.PersistenceUnitTestCase;
-public abstract class Generic2_0PersistenceUnitTests
+public abstract class PersistenceUnit2_0TestCase
extends PersistenceUnitTestCase
{
protected PersistenceUnit2_0 subject;
@@ -24,7 +24,7 @@ public abstract class Generic2_0PersistenceUnitTests
protected PropertyValueModel<PersistenceUnit2_0> subjectHolder;
// ********** constructors **********
- protected Generic2_0PersistenceUnitTests(String name) {
+ protected PersistenceUnit2_0TestCase(String name) {
super(name);
}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java
new file mode 100644
index 0000000..cdf2c1d
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/Generic2_1ContextModelTestCase.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context;
+
+import org.eclipse.jpt.jpa.core.internal.jpa2_1.Generic2_1JpaPlatformFactory;
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaProject2_1;
+import org.eclipse.jpt.jpa.core.tests.internal.context.ContextModelTestCase;
+
+public abstract class Generic2_1ContextModelTestCase extends ContextModelTestCase
+{
+ protected Generic2_1ContextModelTestCase(String name) {
+ super(name);
+ }
+
+ @Override
+ protected String getJpaPlatformID() {
+ return Generic2_1JpaPlatformFactory.ID;
+ }
+
+ @Override
+ protected String getJpaFacetVersionString() {
+ return JpaProject2_1.FACET_VERSION_STRING;
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/JpaProject2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/JpaProject2_1Tests.java
new file mode 100644
index 0000000..354da56
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/JpaProject2_1Tests.java
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context;
+
+import java.util.Iterator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
+import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
+import org.eclipse.jpt.jpa.core.internal.operations.PersistenceFileCreationDataModelProvider;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.JPA2_1;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+@SuppressWarnings("nls")
+public class JpaProject2_1Tests
+ extends Generic2_1ContextModelTestCase
+{
+
+ public JpaProject2_1Tests(String name) {
+ super(name);
+ }
+
+ private ICompilationUnit createTestEntity() throws Exception {
+ return this.createTestType("MyEntity", new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestMappedSuperclass() throws Exception {
+ return this.createTestType("MyMappedSuperclass", new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.MAPPED_SUPERCLASS);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@MappedSuperclass");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestEmbeddable() throws Exception {
+ return this.createTestType("MyEmbeddable", new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.EMBEDDABLE);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Embeddable");
+ }
+ });
+ }
+
+ private ICompilationUnit createTestConverter() throws Exception {
+ return this.createTestType("MyConverter", new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA2_1.CONVERTER);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Converter");
+ }
+ });
+ }
+
+ public void testGetPersistenceXmlResource() throws Exception {
+ JptXmlResource resource = this.getJpaProject().getPersistenceXmlResource();
+ assertNotNull(resource);
+ assertEquals(XmlPersistence.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/persistence.xml", resource.getFile().getProjectRelativePath().toString());
+
+ //delete the persistence.xml file and verify it is not returned from getPersistenceXmlResource()
+ resource.delete(null);
+ resource = this.getJpaProject().getPersistenceXmlResource();
+ assertNull(resource);
+
+ //add the persistence.xml file back
+ createPersistenceXmlFile();
+ resource = this.getJpaProject().getPersistenceXmlResource();
+ assertNotNull(resource);
+ assertEquals(XmlPersistence.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/persistence.xml", resource.getFile().getProjectRelativePath().toString());
+ }
+
+ private void createPersistenceXmlFile() throws Exception {
+ IDataModel config =
+ DataModelFactory.createDataModel(new PersistenceFileCreationDataModelProvider());
+ config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
+ getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
+ config.getDefaultOperation().execute(null, null);
+ }
+
+ public void testGetDefaultOrmXmlResource() throws Exception {
+ JptXmlResource resource = this.getJpaProject().getDefaultOrmXmlResource();
+ assertNotNull(resource);
+ assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
+
+ //delete the orm.xml file and verify it is not returned from getDefaultOrmXmlResource()
+ resource.delete(null);
+ resource = this.getJpaProject().getDefaultOrmXmlResource();
+ assertNull(resource);
+
+ //add the default orm.xml file back
+ createDefaultOrmXmlFile();
+ resource = this.getJpaProject().getDefaultOrmXmlResource();
+ assertNotNull(resource);
+ assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
+ }
+
+ private void createDefaultOrmXmlFile() throws Exception {
+ IDataModel config =
+ DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
+ config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
+ getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
+ config.getDefaultOperation().execute(null, null);
+ }
+
+ private void createOrmXmlFile(String fileName) throws Exception {
+ IDataModel config =
+ DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
+ config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
+ getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
+ config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, fileName);
+ config.getDefaultOperation().execute(null, null);
+ }
+
+ public void testGetMappingFileResource() throws Exception {
+ JptXmlResource resource = this.getJpaProject().getMappingFileXmlResource(XmlEntityMappings.DEFAULT_RUNTIME_PATH);
+ assertNotNull(resource);
+ assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
+
+ //delete the orm.xml file and verify it is not returned from getMappingFileResource()
+ resource.delete(null);
+ resource = this.getJpaProject().getMappingFileXmlResource(XmlEntityMappings.DEFAULT_RUNTIME_PATH);
+ assertNull(resource);
+
+ //add the orm.xml file back
+ createDefaultOrmXmlFile();
+ resource = this.getJpaProject().getMappingFileXmlResource(XmlEntityMappings.DEFAULT_RUNTIME_PATH);
+ assertNotNull(resource);
+ assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/orm.xml", resource.getFile().getProjectRelativePath().toString());
+ }
+
+ public void testGetMappingFileResourceDifferentlyName() throws Exception {
+ JptXmlResource resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
+ assertNull(resource);
+
+ //create the orm2.xml file
+ createOrmXmlFile("orm2.xml");
+ resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
+ assertNotNull(resource);
+ assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
+
+ //delete the orm2.xml file and verify it is not returned from getMappingFileResource()
+ resource.delete(null);
+ resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
+ assertNull(resource);
+
+ //add the orm2.xml file back
+ createOrmXmlFile("orm2.xml");
+ resource = this.getJpaProject().getMappingFileXmlResource(new Path("META-INF/orm2.xml"));
+ assertNotNull(resource);
+ assertEquals(XmlEntityMappings.CONTENT_TYPE, resource.getContentType());
+ assertEquals("src/META-INF/orm2.xml", resource.getFile().getProjectRelativePath().toString());
+ }
+
+ public void testGetPotentialJavaSourceTypes() throws Exception {
+ createTestEntity();
+ createTestEmbeddable();
+ createTestMappedSuperclass();
+ createTestConverter();
+ createTestType();
+
+ Iterable<JavaResourceAbstractType> potentialJavaSourceTypes = this.getJpaProject().getPotentialJavaSourceTypes();
+ assertEquals(4, IterableTools.size(potentialJavaSourceTypes));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyEntity")));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyEmbeddable")));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyMappedSuperclass")));
+ assertTrue(IterableTools.contains(potentialJavaSourceTypes, getJpaProject().getJavaResourceType("test.MyConverter")));
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/ClassRef2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/ClassRef2_1Tests.java
new file mode 100644
index 0000000..303d3c3
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/ClassRef2_1Tests.java
@@ -0,0 +1,136 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence;
+
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.java.JavaConverterType2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.resource.java.Converter2_1Annotation;
+import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation;
+import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class ClassRef2_1Tests extends Generic2_1ContextModelTestCase
+{
+ public ClassRef2_1Tests(String name) {
+ super(name);
+ }
+
+ public void testUpdateClassName() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add class ref
+ XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Bar");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+ ClassRef classRef = persistenceUnit.getSpecifiedClassRefs().iterator().next();
+
+ // test that class names are initially equal
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set xml class name to different name, test equality
+ xmlClassRef.setJavaClass("com.bar.Foo");
+
+ classRef = persistenceUnit.getSpecifiedClassRefs().iterator().next();
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set class name to empty string, test equality
+ xmlClassRef.setJavaClass("");
+
+ classRef = persistenceUnit.getSpecifiedClassRefs().iterator().next();
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set name back to non empty string, test equality
+ xmlClassRef.setJavaClass("com.foo.Bar");
+
+ classRef = persistenceUnit.getSpecifiedClassRefs().iterator().next();
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+ }
+
+ public void testModifyClassName() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add class ref
+ XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Bar");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+ ClassRef classRef = persistenceUnit.getSpecifiedClassRefs().iterator().next();
+
+ // test that class names are initially equal
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set context class name to different name, test equality
+ classRef.setClassName("com.bar.Foo");
+
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set class name to empty string, test equality
+ classRef.setClassName("");
+
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set class name to null, test equality
+ classRef.setClassName(null);
+
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+
+ // set name back to non-null, test equality
+ classRef.setClassName("com.foo.Bar");
+
+ assertEquals(classRef.getClassName(), xmlClassRef.getJavaClass());
+ }
+
+ public void testGetJavaManagedType() throws Exception {
+ createTestType();
+
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+
+ XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass(FULLY_QUALIFIED_TYPE_NAME);
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+
+ ClassRef classRef = getSpecifiedClassRef();
+
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaManagedType().getName());
+
+ //test setting to a class that does not exist in the project
+ xmlClassRef.setJavaClass("com.foo.Bar");
+
+ classRef = getSpecifiedClassRef();
+ assertNull(classRef.getJavaManagedType());
+
+ xmlClassRef.setJavaClass(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaManagedType().getName());
+ assertEquals(JavaPersistentType.class, classRef.getJavaManagedType().getType());
+
+ classRef.getJavaResourceType().addAnnotation(Converter2_1Annotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaManagedType().getName());
+ assertEquals(JavaConverterType2_1.class, classRef.getJavaManagedType().getType());
+
+ //verify both @Converter and @Entity annotation, Entity wins
+ classRef.getJavaResourceType().addAnnotation(EntityAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaManagedType().getName());
+ assertEquals(JavaPersistentType.class, classRef.getJavaManagedType().getType());
+
+ classRef.getJavaResourceType().removeAnnotation(EntityAnnotation.ANNOTATION_NAME);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(FULLY_QUALIFIED_TYPE_NAME, classRef.getJavaManagedType().getName());
+ assertEquals(JavaConverterType2_1.class, classRef.getJavaManagedType().getType());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/JptJpa2_1ContextPersistenceModelTests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/JptJpa2_1ContextPersistenceModelTests.java
new file mode 100644
index 0000000..669e346
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/JptJpa2_1ContextPersistenceModelTests.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class JptJpa2_1ContextPersistenceModelTests
+ extends TestCase
+{
+ public static Test suite() {
+ TestSuite suite = new TestSuite(JptJpa2_1ContextPersistenceModelTests.class.getPackage().getName());
+ suite.addTestSuite(ClassRef2_1Tests.class);
+ suite.addTestSuite(PersistenceUnit2_1Tests.class);
+ return suite;
+ }
+
+ private JptJpa2_1ContextPersistenceModelTests() {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/PersistenceUnit2_1Tests.java b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/PersistenceUnit2_1Tests.java
new file mode 100644
index 0000000..aa91d9a
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.core.tests/src/org/eclipse/jpt/jpa/core/tests/internal/jpa2_1/context/persistence/PersistenceUnit2_1Tests.java
@@ -0,0 +1,1288 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.persistence;
+
+import java.util.Iterator;
+import java.util.ListIterator;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jpt.common.core.internal.operations.JptFileCreationDataModelProperties;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.common.utility.internal.ObjectTools;
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.common.utility.internal.iterator.IteratorTools;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.AccessType;
+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
+import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
+import org.eclipse.jpt.jpa.core.internal.operations.OrmFileCreationDataModelProvider;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.resource.java.JPA;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnitTransactionType;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperties;
+import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperty;
+import org.eclipse.jpt.jpa.core.tests.internal.jpa2_1.context.Generic2_1ContextModelTestCase;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+
+@SuppressWarnings("nls")
+public class PersistenceUnit2_1Tests extends Generic2_1ContextModelTestCase
+{
+
+ protected static final String INNER_CLASS_NAME = "InnerAnnotationTestType";
+ protected static final String FULLY_QUALIFIED_INNER_CLASS_NAME = PACKAGE_NAME + "." + TYPE_NAME + "." + INNER_CLASS_NAME;
+
+ public static final String OTHER_TYPE_NAME = "OtherTestType";
+ public static final String FULLY_QUALIFIED_OTHER_TYPE_NAME = PACKAGE_NAME + "." + OTHER_TYPE_NAME;
+
+ public static final String ORM2_XML_FILE_NAME = "orm2.xml";
+ public static final String ORM3_XML_FILE_NAME = "orm3.xml";
+ public static final String ORM4_XML_FILE_NAME = "orm4.xml";
+
+ public PersistenceUnit2_1Tests(String name) {
+ super(name);
+ }
+
+ public void testUpdateName() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that names are initially equal
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name to different name, test equality
+ xmlPersistenceUnit.setName("newName");
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name to empty string, test equality
+ xmlPersistenceUnit.setName("");
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name to null, test equality
+ xmlPersistenceUnit.setName(null);
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name back to non-null, test equality
+ xmlPersistenceUnit.setName("newName");
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+ }
+
+ public void testModifyName() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that names are initially equal
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name to different name, test equality
+ persistenceUnit.setName("newName");
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name to empty string, test equality
+ persistenceUnit.setName("");
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name to null, test equality
+ persistenceUnit.setName(null);
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+
+ // set name back to non-null, test equality
+ persistenceUnit.setName("newName");
+
+ assertEquals(xmlPersistenceUnit.getName(), persistenceUnit.getName());
+ }
+
+ public void testUpdateTransactionType() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // 1 - initial value is default
+ assertNull(xmlPersistenceUnit.getTransactionType());
+ assertNull(persistenceUnit.getSpecifiedTransactionType());
+
+ // 2 - set value, context changed
+ xmlPersistenceUnit.setTransactionType(XmlPersistenceUnitTransactionType.JTA);
+
+ assertEquals(PersistenceUnitTransactionType.JTA, persistenceUnit.getSpecifiedTransactionType());
+
+ xmlPersistenceUnit.setTransactionType(XmlPersistenceUnitTransactionType.RESOURCE_LOCAL);
+
+ assertEquals(PersistenceUnitTransactionType.RESOURCE_LOCAL, persistenceUnit.getSpecifiedTransactionType());
+
+ // 3 - unset value, context changed
+ xmlPersistenceUnit.setTransactionType(null);
+
+ assertNull(persistenceUnit.getSpecifiedTransactionType());
+ }
+
+ public void testModifyTransactionType() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // 1 - initial value is default
+ assertNull(xmlPersistenceUnit.getTransactionType());
+ assertNull(persistenceUnit.getSpecifiedTransactionType());
+
+ // 2 - set context value, resource changed
+ persistenceUnit.setSpecifiedTransactionType(PersistenceUnitTransactionType.JTA);
+
+ assertEquals(XmlPersistenceUnitTransactionType.JTA, xmlPersistenceUnit.getTransactionType());
+
+ persistenceUnit.setSpecifiedTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL);
+
+ assertEquals(XmlPersistenceUnitTransactionType.RESOURCE_LOCAL, xmlPersistenceUnit.getTransactionType());
+
+ // 3 - set context value to default, resource unset
+ persistenceUnit.setSpecifiedTransactionType(null);
+
+ assertNull(persistenceUnit.getSpecifiedTransactionType());
+ assertNull(xmlPersistenceUnit.getTransactionType());
+ }
+
+ public void testUpdateDescription() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that descriptions are initially equal
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description to different description, test equality
+ xmlPersistenceUnit.setDescription("newDescription");
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description to empty string, test equality
+ xmlPersistenceUnit.setDescription("");
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description to null, test equality
+ xmlPersistenceUnit.setDescription(null);
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description back to non-null, test equality
+ xmlPersistenceUnit.setDescription("newDescription");
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+ }
+
+ public void testModifyDescription() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that descriptions are initially equal
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description to different description, test equality
+ persistenceUnit.setDescription("newDescription");
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description to empty string, test equality
+ persistenceUnit.setDescription("");
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description to null, test equality
+ persistenceUnit.setDescription(null);
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+
+ // set description back to non-null, test equality
+ persistenceUnit.setDescription("newDescription");
+
+ assertEquals(xmlPersistenceUnit.getDescription(), persistenceUnit.getDescription());
+ }
+
+ public void testUpdateProvider() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that providers are initially equal
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider to different provider, test equality
+ xmlPersistenceUnit.setProvider("newProvider");
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider to empty string, test equality
+ xmlPersistenceUnit.setProvider("");
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider to null, test equality
+ xmlPersistenceUnit.setProvider(null);
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider back to non-null, test equality
+ xmlPersistenceUnit.setProvider("newProvider");
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+ }
+
+ public void testModifyProvider() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that providers are initially equal
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider to different provider, test equality
+ persistenceUnit.setProvider("newProvider");
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider to empty string, test equality
+ persistenceUnit.setProvider("");
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider to null, test equality
+ persistenceUnit.setProvider(null);
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+
+ // set provider back to non-null, test equality
+ persistenceUnit.setProvider("newProvider");
+
+ assertEquals(xmlPersistenceUnit.getProvider(), persistenceUnit.getProvider());
+ }
+
+ public void testUpdateJtaDataSource() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that jtaDataSources are initially equal
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource to different jtaDataSource, test equality
+ xmlPersistenceUnit.setJtaDataSource("newJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource to empty string, test equality
+ xmlPersistenceUnit.setJtaDataSource("");
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource to null, test equality
+ xmlPersistenceUnit.setJtaDataSource(null);
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource back to non-null, test equality
+ xmlPersistenceUnit.setJtaDataSource("newJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+ }
+
+ public void testModifyJtaDataSource() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that jtaDataSources are initially equal
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource to different jtaDataSource, test equality
+ persistenceUnit.setJtaDataSource("newJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource to empty string, test equality
+ persistenceUnit.setJtaDataSource("");
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource to null, test equality
+ persistenceUnit.setJtaDataSource(null);
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+
+ // set jtaDataSource back to non-null, test equality
+ persistenceUnit.setJtaDataSource("newJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getJtaDataSource(), persistenceUnit.getJtaDataSource());
+ }
+
+ public void testUpdateNonJtaDataSource() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that nonJtaDataSources are initially equal
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource to different nonJtaDataSource, test equality
+ xmlPersistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource to empty string, test equality
+ xmlPersistenceUnit.setNonJtaDataSource("");
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource to null, test equality
+ xmlPersistenceUnit.setNonJtaDataSource(null);
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource back to non-null, test equality
+ xmlPersistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+ }
+
+ public void testModifyNonJtaDataSource() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that nonJtaDataSources are initially equal
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource to different nonJtaDataSource, test equality
+ persistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource to empty string, test equality
+ persistenceUnit.setNonJtaDataSource("");
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource to null, test equality
+ persistenceUnit.setNonJtaDataSource(null);
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+
+ // set nonJtaDataSource back to non-null, test equality
+ persistenceUnit.setNonJtaDataSource("newNonJtaDataSource");
+
+ assertEquals(xmlPersistenceUnit.getNonJtaDataSource(), persistenceUnit.getNonJtaDataSource());
+ }
+
+ public void testUpdateJarFileRefs1() {
+ // TODO
+ }
+
+ public void testUpdateJarFileRefs2() {
+ // TODO
+ }
+
+ public void testUpdateImpliedMappingFileRef1() throws Exception {
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that there is one initially
+ JptXmlResource ormResource = getOrmXmlResource();
+ assertTrue(ormResource.fileExists());
+ assertNotNull(persistenceUnit.getImpliedMappingFileRef());
+
+ // remove orm.xml
+ deleteResource(ormResource);
+
+ assertFalse(ormResource.fileExists());
+ assertNull(persistenceUnit.getImpliedMappingFileRef());
+ }
+
+ public void testUpdateImpliedMappingFileRef2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test that there is one initially
+ JptXmlResource ormResource = getOrmXmlResource();
+ assertTrue(ormResource.fileExists());
+ assertNotNull(persistenceUnit.getImpliedMappingFileRef());
+
+ // add specified orm.xml
+ XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("META-INF/orm.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+
+ assertEquals(1, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ assertTrue(ormResource.fileExists());
+ assertNull(persistenceUnit.getImpliedMappingFileRef());
+ }
+
+ public void testUpdateSpecifiedMappingFileRefs1() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test there are none initially
+ assertEquals(0, xmlPersistenceUnit.getMappingFiles().size());
+ assertEquals(0, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ // add mapping file ref, test that it's added to context
+ XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("orm.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+
+ assertEquals(1, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ // add another ...
+ xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("orm2.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+
+ assertEquals(2, persistenceUnit.getSpecifiedMappingFileRefsSize());
+ }
+
+ public void testUpdateSpecifiedMappingFileRefs2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two mapping file refs and test that there are two existing in xml and context
+ XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("orm.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+ xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("orm2.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+
+ assertEquals(xmlPersistenceUnit.getMappingFiles().size(), 2);
+ assertEquals(2, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ // remove mapping file ref from xml, test that it's removed from context
+ xmlMappingFileRef = xmlPersistenceUnit.getMappingFiles().get(0);
+ xmlPersistenceUnit.getMappingFiles().remove(xmlMappingFileRef);
+
+ assertEquals(1, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ // remove another one ...
+ xmlMappingFileRef = xmlPersistenceUnit.getMappingFiles().get(0);
+ xmlPersistenceUnit.getMappingFiles().remove(xmlMappingFileRef);
+
+ assertEquals(0, persistenceUnit.getSpecifiedMappingFileRefsSize());
+ }
+
+ public void testModifySpecifiedMappingFileRefs1() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test there are none initially
+ assertEquals(0, xmlPersistenceUnit.getMappingFiles().size());
+ assertEquals(0, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ // add mapping file ref, test that it's added to resource
+ persistenceUnit.addSpecifiedMappingFileRef("foo");
+
+ assertEquals(1, xmlPersistenceUnit.getMappingFiles().size());
+ assertEquals("foo", xmlPersistenceUnit.getMappingFiles().get(0).getFileName());
+
+ // add another ...
+ persistenceUnit.addSpecifiedMappingFileRef("bar");
+ assertEquals("foo", xmlPersistenceUnit.getMappingFiles().get(0).getFileName());
+ assertEquals("bar", xmlPersistenceUnit.getMappingFiles().get(1).getFileName());
+
+ assertEquals(2, xmlPersistenceUnit.getMappingFiles().size());
+
+ // add another, testing order
+ persistenceUnit.addSpecifiedMappingFileRef(0, "baz");
+ assertEquals(3, xmlPersistenceUnit.getMappingFiles().size());
+ assertEquals("baz", xmlPersistenceUnit.getMappingFiles().get(0).getFileName());
+ assertEquals("foo", xmlPersistenceUnit.getMappingFiles().get(1).getFileName());
+ assertEquals("bar", xmlPersistenceUnit.getMappingFiles().get(2).getFileName());
+ }
+
+ public void testModifySpecifiedMappingFileRefs2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two mapping file refs and test that there are two existing in xml and context
+ XmlMappingFileRef xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("orm.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+ xmlMappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
+ xmlMappingFileRef.setFileName("orm2.xml");
+ xmlPersistenceUnit.getMappingFiles().add(xmlMappingFileRef);
+
+ assertEquals(2, xmlPersistenceUnit.getMappingFiles().size());
+ assertEquals(2, persistenceUnit.getSpecifiedMappingFileRefsSize());
+
+ // remove mapping file ref from context, test that it's removed from xml
+ persistenceUnit.removeSpecifiedMappingFileRef(0);
+
+ assertEquals(1, xmlPersistenceUnit.getMappingFiles().size());
+
+ // remove another one ...
+ persistenceUnit.removeSpecifiedMappingFileRef(0);
+
+ assertEquals(0, xmlPersistenceUnit.getMappingFiles().size());
+ }
+
+ public void testUpdateClassRefs1() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test there are none initially
+ assertEquals(0, xmlPersistenceUnit.getClasses().size());
+ assertEquals(0, persistenceUnit.getSpecifiedClassRefsSize());
+
+ // add mapping file ref, test that it's added to context
+ XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Bar");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+
+ assertEquals(1, persistenceUnit.getSpecifiedClassRefsSize());
+
+ // add another ...
+ xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Baz");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+
+ assertEquals(2, persistenceUnit.getSpecifiedClassRefsSize());
+ }
+
+ public void testUpdateClassRefs2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two class refs and test that there are two existing in xml and context
+ XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Bar");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+ xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Baz");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+
+ assertEquals(2, xmlPersistenceUnit.getClasses().size());
+ assertEquals(2, persistenceUnit.getSpecifiedClassRefsSize());
+
+ // remove class ref from xml, test that it's removed from context
+ xmlClassRef = xmlPersistenceUnit.getClasses().get(0);
+ xmlPersistenceUnit.getClasses().remove(xmlClassRef);
+
+ assertEquals(1, persistenceUnit.getSpecifiedClassRefsSize());
+
+ // remove another one ...
+ xmlClassRef = xmlPersistenceUnit.getClasses().get(0);
+ xmlPersistenceUnit.getClasses().remove(xmlClassRef);
+
+ assertEquals(0, persistenceUnit.getSpecifiedClassRefsSize());
+ }
+
+ public void testModifyClassRefs1() throws Exception {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test there are none initially
+ assertEquals(0, xmlPersistenceUnit.getClasses().size());
+ assertEquals(0, persistenceUnit.getSpecifiedClassRefsSize());
+
+ // add class ref, test that it's added to context
+ persistenceUnit.addSpecifiedClassRef("Foo");
+
+ getPersistenceXmlResource().save(null);
+ assertEquals(1, xmlPersistenceUnit.getClasses().size());
+ assertEquals("Foo", xmlPersistenceUnit.getClasses().get(0).getJavaClass());
+
+ // add another ...
+ persistenceUnit.addSpecifiedClassRef("Bar");
+
+ assertEquals(2, xmlPersistenceUnit.getClasses().size());
+ assertEquals("Foo", xmlPersistenceUnit.getClasses().get(0).getJavaClass());
+ assertEquals("Bar", xmlPersistenceUnit.getClasses().get(1).getJavaClass());
+
+
+ persistenceUnit.addSpecifiedClassRef(0, "Baz");
+
+ assertEquals(3, xmlPersistenceUnit.getClasses().size());
+ assertEquals("Baz", xmlPersistenceUnit.getClasses().get(0).getJavaClass());
+ assertEquals("Foo", xmlPersistenceUnit.getClasses().get(1).getJavaClass());
+ assertEquals("Bar", xmlPersistenceUnit.getClasses().get(2).getJavaClass());
+ }
+
+ public void testModifyClassRefs2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two class refs and test that there are two existing in xml and context
+ XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Bar");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+ xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ xmlClassRef.setJavaClass("com.foo.Baz");
+ xmlPersistenceUnit.getClasses().add(xmlClassRef);
+
+ assertEquals(2, xmlPersistenceUnit.getClasses().size());
+ assertEquals(2, persistenceUnit.getSpecifiedClassRefsSize());
+
+ // remove class ref from context, test that it's removed from xml
+ persistenceUnit.removeSpecifiedClassRef(0);
+
+ assertEquals(1, xmlPersistenceUnit.getClasses().size());
+
+ // remove another one ...
+ persistenceUnit.removeSpecifiedClassRef(0);
+
+ assertEquals(0, xmlPersistenceUnit.getClasses().size());
+ }
+
+ public void testImpliedClassRefs1() throws Exception {
+ createTestEntityWithPersistentInnerClass();
+
+ getJpaProject().setDiscoversAnnotatedClasses(false);
+ getPersistenceUnit().setSpecifiedExcludeUnlistedClasses(Boolean.TRUE);
+ assertEquals(0, getPersistenceUnit().getImpliedClassRefsSize());
+
+ getJpaProject().setDiscoversAnnotatedClasses(true);
+ getPersistenceUnit().setSpecifiedExcludeUnlistedClasses(Boolean.FALSE);
+ assertEquals(2, getPersistenceUnit().getImpliedClassRefsSize());
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+
+ addXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(1, getPersistenceUnit().getImpliedClassRefsSize());
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+
+ removeXmlClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(2, getPersistenceUnit().getImpliedClassRefsSize());
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(1, getPersistenceUnit().getImpliedClassRefsSize());
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+
+ addXmlClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+ assertEquals(0, getPersistenceUnit().getImpliedClassRefsSize());
+
+ removeXmlClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+ assertEquals(1, getPersistenceUnit().getImpliedClassRefsSize());
+ this.verifyVirtualClassRef(FULLY_QUALIFIED_INNER_CLASS_NAME);
+
+ getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_INNER_CLASS_NAME);
+ assertEquals(0, getPersistenceUnit().getImpliedClassRefsSize());
+ }
+
+ protected void verifyVirtualClassRef(String className) {
+ if (this.getVirtualClassRef(className) == null) {
+ fail("missing virtual class ref: " + className);
+ }
+ }
+
+ protected ClassRef getVirtualClassRef(String className) {
+ for (ClassRef ref : this.getPersistenceUnit().getImpliedClassRefs()) {
+ if (ObjectTools.equals(ref.getClassName(), className)) {
+ return ref;
+ }
+ }
+ return null;
+ }
+
+ public void testImpliedClassRefs2() throws Exception {
+ createTestEntity();
+ getJpaProject().setDiscoversAnnotatedClasses(true);
+ JavaResourceType javaType = (JavaResourceType) getJpaProject().getJavaResourceType(FULLY_QUALIFIED_TYPE_NAME);
+
+ assertEquals(1, IterableTools.size(getPersistenceUnit().getImpliedClassRefs()));
+
+ javaType.removeAnnotation(JPA.ENTITY);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(0, getPersistenceUnit().getImpliedClassRefsSize());
+
+ javaType.addAnnotation(JPA.EMBEDDABLE);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(1, getPersistenceUnit().getImpliedClassRefsSize());
+
+ javaType.removeAnnotation(JPA.EMBEDDABLE);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(0, getPersistenceUnit().getImpliedClassRefsSize());
+
+ javaType.addAnnotation(JPA.MAPPED_SUPERCLASS);
+ getJpaProject().synchronizeContextModel();
+ assertEquals(1, getPersistenceUnit().getImpliedClassRefsSize());
+ }
+
+ public void testRenamePersistentTypeImpliedClassRefs() throws Exception {
+ getJavaProject().getJpaProject().setDiscoversAnnotatedClasses(true);
+ ICompilationUnit testType = createTestEntity();
+ @SuppressWarnings("unused")
+ ICompilationUnit otherTestType = this.createTestOtherTypeEntity();
+
+ ClassRef testTypeClassRef = this.getVirtualClassRef(FULLY_QUALIFIED_TYPE_NAME);
+ ClassRef otherTestTypeClassRef = this.getVirtualClassRef(FULLY_QUALIFIED_OTHER_TYPE_NAME);
+
+ assertNotNull(testTypeClassRef);
+ assertNotNull(otherTestTypeClassRef);
+
+ JavaPersistentType testJavaPersistentType = testTypeClassRef.getJavaPersistentType();
+ JavaPersistentType otherTestJavaPersistentType = otherTestTypeClassRef.getJavaPersistentType();
+
+ testType.findPrimaryType().rename("TestType2", false, null);
+
+ testTypeClassRef = this.getVirtualClassRef("test.TestType2");
+ otherTestTypeClassRef = this.getVirtualClassRef(FULLY_QUALIFIED_OTHER_TYPE_NAME);
+
+ assertNotNull(testTypeClassRef);
+ assertNotNull(otherTestTypeClassRef);
+
+ assertEquals(otherTestJavaPersistentType, otherTestTypeClassRef.getJavaPersistentType());
+ assertNotSame(testJavaPersistentType, testTypeClassRef.getJavaPersistentType());
+ }
+
+ public void testUpdateExcludeUnlistedClasses() throws Exception {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // 1 - initial value is default
+ assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertFalse(persistenceUnit.excludesUnlistedClasses());
+ assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
+
+ // 2 - set value, context changed
+ xmlPersistenceUnit.setExcludeUnlistedClasses(Boolean.TRUE);
+
+ assertEquals(Boolean.TRUE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertTrue(persistenceUnit.excludesUnlistedClasses());
+ assertEquals(Boolean.TRUE, xmlPersistenceUnit.getExcludeUnlistedClasses());
+
+ xmlPersistenceUnit.setExcludeUnlistedClasses(Boolean.FALSE);
+
+ assertEquals(Boolean.FALSE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertFalse(persistenceUnit.excludesUnlistedClasses());
+ assertEquals(Boolean.FALSE, xmlPersistenceUnit.getExcludeUnlistedClasses());
+
+ // 3 - unset value, context changed
+ xmlPersistenceUnit.setExcludeUnlistedClasses(null);
+
+ assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertFalse(persistenceUnit.excludesUnlistedClasses());
+ assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
+ }
+
+ public void testModifyExcludeUnlistedClasses() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // 1 - initial value is default
+ assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertFalse(persistenceUnit.excludesUnlistedClasses());
+ assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
+
+ // 2 - set value, resource changed
+ persistenceUnit.setSpecifiedExcludeUnlistedClasses(Boolean.TRUE);
+
+ assertEquals(Boolean.TRUE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertTrue(persistenceUnit.excludesUnlistedClasses());
+ assertEquals(Boolean.TRUE, xmlPersistenceUnit.getExcludeUnlistedClasses());
+
+ persistenceUnit.setSpecifiedExcludeUnlistedClasses(Boolean.FALSE);
+
+ assertEquals(Boolean.FALSE, persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertFalse(persistenceUnit.excludesUnlistedClasses());
+ assertEquals(Boolean.FALSE, xmlPersistenceUnit.getExcludeUnlistedClasses());
+
+ // 3 - set context to default, resource unset
+ persistenceUnit.setSpecifiedExcludeUnlistedClasses(null);
+
+ assertNull(persistenceUnit.getSpecifiedExcludeUnlistedClasses());
+ assertFalse(persistenceUnit.excludesUnlistedClasses());
+ assertNull(xmlPersistenceUnit.getExcludeUnlistedClasses());
+ }
+
+ public void testUpdateProperties1() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test there are none initially
+ assertNull(xmlPersistenceUnit.getProperties());
+ assertEquals(0, persistenceUnit.getPropertiesSize());
+
+ // add "properties", test that there's no real change to context
+ XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
+ xmlPersistenceUnit.setProperties(xmlProperties);
+ assertEquals(0, persistenceUnit.getPropertiesSize());
+
+ // add property, test that it's added to context
+ XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("foo");
+ xmlProperty.setValue("bar");
+ xmlProperties.getProperties().add(xmlProperty);
+
+ assertEquals(1, persistenceUnit.getPropertiesSize());
+
+ // add another ...
+ xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("FOO");
+ xmlProperty.setValue("BAR");
+ xmlProperties.getProperties().add(xmlProperty);
+
+ assertEquals(2, persistenceUnit.getPropertiesSize());
+ }
+
+ public void testUpdateProperties2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two properties and test that there are two existing in xml and context
+ XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
+ xmlPersistenceUnit.setProperties(xmlProperties);
+ XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("foo");
+ xmlProperty.setValue("bar");
+ xmlProperties.getProperties().add(xmlProperty);
+ xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("FOO");
+ xmlProperty.setValue("BAR");
+ xmlProperties.getProperties().add(xmlProperty);
+
+ assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals(2, persistenceUnit.getPropertiesSize());
+
+ // remove property from xml, test that it's removed from context
+ xmlProperty = xmlProperties.getProperties().get(0);
+ xmlProperties.getProperties().remove(xmlProperty);
+
+ assertEquals(1, persistenceUnit.getPropertiesSize());
+
+ // remove another one ...
+ xmlProperty = xmlProperties.getProperties().get(0);
+ xmlProperties.getProperties().remove(xmlProperty);
+
+ assertEquals(0, persistenceUnit.getPropertiesSize());
+ }
+
+ public void testModifyProperties1() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // test there are none initially
+ assertNull(xmlPersistenceUnit.getProperties());
+ assertEquals(0, persistenceUnit.getPropertiesSize());
+
+ // add property, test that it's added to resource
+ persistenceUnit.addProperty().setName("foo");
+
+ assertNotNull(xmlPersistenceUnit.getProperties());
+ assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals("foo", xmlPersistenceUnit.getProperties().getProperties().get(0).getName());
+
+ // add another ...
+ persistenceUnit.addProperty().setName("bar");
+
+ assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals("foo", xmlPersistenceUnit.getProperties().getProperties().get(0).getName());
+ assertEquals("bar", xmlPersistenceUnit.getProperties().getProperties().get(1).getName());
+
+ // add another testing order
+ persistenceUnit.addProperty(0).setName("baz");
+
+ assertEquals(3, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals("baz", xmlPersistenceUnit.getProperties().getProperties().get(0).getName());
+ assertEquals("foo", xmlPersistenceUnit.getProperties().getProperties().get(1).getName());
+ assertEquals("bar", xmlPersistenceUnit.getProperties().getProperties().get(2).getName());
+ }
+
+ public void testModifyProperties2() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two properties and test that there are two existing in xml and context
+ XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
+ xmlPersistenceUnit.setProperties(xmlProperties);
+ XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("foo");
+ xmlProperty.setValue("bar");
+ xmlProperties.getProperties().add(xmlProperty);
+ xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("FOO");
+ xmlProperty.setValue("BAR");
+ xmlProperties.getProperties().add(xmlProperty);
+
+ assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals(2, persistenceUnit.getPropertiesSize());
+
+ // remove property from context, test that it's removed from resource
+ persistenceUnit.removeProperty("foo");
+
+ assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
+
+ // remove another one. test that properties object is nulled
+ persistenceUnit.removeProperty("FOO", "BAR");
+
+ assertNull(xmlPersistenceUnit.getProperties());
+ }
+
+ public void testModifyProperties3() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two properties and test that there are two existing in xml and context
+ persistenceUnit.setProperty("foo", "bar", false);
+ persistenceUnit.setProperty("FOO", "BAR", false);
+
+ assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals(2, persistenceUnit.getPropertiesSize());
+
+ // remove property from context, test that it's removed from resource
+ persistenceUnit.removeProperty("foo", "bar");
+
+ assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
+
+ // remove another one, test that properties object is nulled
+ persistenceUnit.removeProperty("FOO");
+
+ assertNull(xmlPersistenceUnit.getProperties());
+ }
+
+ public void testModifyProperties4() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two properties and test that there are two existing in xml and context
+ persistenceUnit.setProperty("foo", "bar", false);
+ persistenceUnit.setProperty("FOO", "BAR", false);
+
+ assertEquals(2, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals(2, persistenceUnit.getPropertiesSize());
+
+ // modify a property, test its value
+ persistenceUnit.setProperty("foo", "", false);
+ assertEquals("", persistenceUnit.getProperty("foo").getValue());
+
+ persistenceUnit.setProperty("foo", "BAR", false);
+ assertEquals("BAR", persistenceUnit.getProperty("foo").getValue());
+
+ // remove property from context, test that it's removed from resource
+ persistenceUnit.removeProperty("FOO");
+ assertNull(persistenceUnit.getProperty("FOO"));
+ assertEquals(1, xmlPersistenceUnit.getProperties().getProperties().size());
+
+ // remove by setting value to null, test that properties object is nulled
+ persistenceUnit.setProperty("notExist", null, false);
+ assertNull(persistenceUnit.getProperty("notExist"));
+
+ persistenceUnit.setProperty("foo", null, false);
+ assertNull(persistenceUnit.getProperty("foo"));
+ assertNull(xmlPersistenceUnit.getProperties());
+ }
+
+ public void testModifyProperties5() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // testing duplicate keys, add four properties and test that there are four existing in xml and context
+ persistenceUnit.setProperty("FOO", "BAR", false);
+ persistenceUnit.setProperty("foo", "bar 3", true);
+ persistenceUnit.setProperty("foo", "bar 2", true);
+ persistenceUnit.setProperty("foo", "bar 1", true);
+
+ assertEquals(4, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals(4, persistenceUnit.getPropertiesSize());
+
+ // remove a property, test that there are four existing in xml and context
+ persistenceUnit.removeProperty("foo", "bar 1");
+ assertEquals(3, xmlPersistenceUnit.getProperties().getProperties().size());
+ assertEquals(3, persistenceUnit.getPropertiesSize());
+ }
+
+ public void testAccessProperty() {
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ // add two properties and try to access it.
+ persistenceUnit.setProperty("foo", "bar", false);
+ persistenceUnit.setProperty("FOO", "BAR", false);
+
+ PersistenceUnit.Property property = persistenceUnit.getProperty("foo");
+ assertNotNull(property);
+ assertEquals("bar", property.getValue());
+ assertNotNull(persistenceUnit.getProperty("FOO"));
+ assertEquals("BAR", persistenceUnit.getProperty("FOO").getValue());
+ assertNull(persistenceUnit.getProperty("notExist"));
+ }
+
+ private PersistenceUnit.Property persistenceUnitFirstProperty() {
+ return getPersistenceUnit().getProperties().iterator().next();
+ }
+
+ public void testUpdatePropertyName() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+
+ // add property for testing
+ XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
+ xmlPersistenceUnit.setProperties(xmlProperties);
+ XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperties.getProperties().add(xmlProperty);
+
+ // test that names are initially equal
+ assertEquals(xmlProperty.getName(), persistenceUnitFirstProperty().getName());
+
+ // set name to different name, test equality
+ xmlProperty.setName("newName");
+
+ assertEquals(xmlProperty.getName(), persistenceUnitFirstProperty().getName());
+
+ // set name to empty string, test equality
+ xmlProperty.setName("");
+
+ assertEquals(xmlProperty.getName(), persistenceUnitFirstProperty().getName());
+
+ // set name back to non-null, test equality
+ xmlProperty.setName("newName");
+
+ assertEquals(xmlProperty.getName(), persistenceUnitFirstProperty().getName());
+ }
+
+ public void testUpdatePropertyValue() {
+ XmlPersistenceUnit xmlPersistenceUnit = getXmlPersistenceUnit();
+
+ // add property for testing
+ XmlProperties xmlProperties = PersistenceFactory.eINSTANCE.createXmlProperties();
+ xmlPersistenceUnit.setProperties(xmlProperties);
+ XmlProperty xmlProperty = PersistenceFactory.eINSTANCE.createXmlProperty();
+ xmlProperty.setName("foo");
+ xmlProperties.getProperties().add(xmlProperty);
+
+ // test that values are initially equal
+ assertEquals(xmlProperty.getValue(), persistenceUnitFirstProperty().getValue());
+
+ // set value to different value, test equality
+ xmlProperty.setValue("newValue");
+
+ assertEquals(xmlProperty.getValue(), persistenceUnitFirstProperty().getValue());
+
+ // set value to empty string, test equality
+ xmlProperty.setValue("");
+
+ assertEquals(xmlProperty.getValue(), persistenceUnitFirstProperty().getValue());
+
+ // set value to null, test equality
+ xmlProperty.setValue(null);
+
+ assertEquals(xmlProperty.getValue(), persistenceUnitFirstProperty().getValue());
+
+ // set value back to non-null, test equality
+ xmlProperty.setValue("newValue");
+
+ assertEquals(xmlProperty.getValue(), persistenceUnitFirstProperty().getValue());
+ }
+
+ public void testGetDefaultAccess() throws Exception {
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+ ListIterator<MappingFileRef> mappingFileRefs = getPersistenceUnit().getMappingFileRefs().iterator();
+ OrmXml ormMappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
+ OrmXml orm2MappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
+
+ assertEquals(null, persistenceUnit.getDefaultAccess());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedAccess(AccessType.PROPERTY);
+ assertEquals(AccessType.PROPERTY, persistenceUnit.getDefaultAccess());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedAccess(AccessType.FIELD);
+ assertEquals(AccessType.FIELD, persistenceUnit.getDefaultAccess());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedAccess(null);
+ assertFalse(ormMappingFile.getRoot().getPersistenceUnitMetadata().resourceExists());
+ assertEquals(null, persistenceUnit.getDefaultAccess());
+
+ orm2MappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedAccess(AccessType.FIELD);
+ assertEquals(AccessType.FIELD, persistenceUnit.getDefaultAccess());
+ }
+
+ public void testGetDefaultSchema() throws Exception {
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+ ListIterator<MappingFileRef> mappingFileRefs = getPersistenceUnit().getMappingFileRefs().iterator();
+ OrmXml ormMappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
+ OrmXml orm2MappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
+
+ assertEquals(null, persistenceUnit.getDefaultSchema());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema("FOO");
+ assertEquals("FOO", persistenceUnit.getDefaultSchema());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema(null);
+ assertFalse(ormMappingFile.getRoot().getPersistenceUnitMetadata().resourceExists());
+ assertEquals(null, persistenceUnit.getDefaultSchema());
+
+ orm2MappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedSchema("BAR");
+ assertEquals("BAR", persistenceUnit.getDefaultSchema());
+ }
+
+ public void testGetDefaultCatalog() throws Exception {
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+ ListIterator<MappingFileRef> mappingFileRefs = getPersistenceUnit().getMappingFileRefs().iterator();
+ OrmXml ormMappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
+ OrmXml orm2MappingFile = (OrmXml) mappingFileRefs.next().getMappingFile();
+
+ assertEquals(null, persistenceUnit.getDefaultCatalog());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog("FOO");
+ assertEquals("FOO", persistenceUnit.getDefaultCatalog());
+
+ ormMappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog(null);
+ assertFalse(ormMappingFile.getRoot().getPersistenceUnitMetadata().resourceExists());
+ assertEquals(null, persistenceUnit.getDefaultCatalog());
+
+ orm2MappingFile.getRoot().getPersistenceUnitMetadata().getPersistenceUnitDefaults().setSpecifiedCatalog("BAR");
+ assertEquals("BAR", persistenceUnit.getDefaultCatalog());
+ }
+
+ protected void createOrmXmlFile(String fileName) throws Exception {
+ IDataModel config =
+ DataModelFactory.createDataModel(new OrmFileCreationDataModelProvider());
+ config.setProperty(JptFileCreationDataModelProperties.CONTAINER_PATH,
+ getJpaProject().getProject().getFolder("src/META-INF").getFullPath());
+ config.setProperty(JptFileCreationDataModelProperties.FILE_NAME, fileName);
+ config.getDefaultOperation().execute(null, null);
+
+ addXmlMappingFileRef("META-INF/" + fileName);
+ getPersistenceXmlResource().save(null);
+ }
+
+ private ICompilationUnit createTestEntity() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+ });
+ }
+
+ private ICompilationUnit createTestOtherTypeEntity() throws Exception {
+ return this.createTestType(PACKAGE_NAME, OTHER_TYPE_NAME + ".java", OTHER_TYPE_NAME, new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity");
+ }
+
+ });
+ }
+
+ private ICompilationUnit createTestEntityWithPersistentInnerClass() throws Exception {
+ return this.createTestType(new DefaultAnnotationWriter() {
+ @Override
+ public Iterator<String> imports() {
+ return IteratorTools.iterator(JPA.ENTITY);
+ }
+ @Override
+ public void appendTypeAnnotationTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ }
+
+ @Override
+ public void appendMemberTypeTo(StringBuilder sb) {
+ sb.append("@Entity").append(CR);
+ sb.append(" public static class " + INNER_CLASS_NAME + " {}").append(CR);
+ }
+ });
+ }
+
+ public void testPersistentType() throws Exception {
+ getJpaProject().setDiscoversAnnotatedClasses(false);
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+ createTestEntity();
+
+ //persistentType not listed in persistence.xml and discoverAnnotatedClasses is false
+ //still find the persistentType because of changes for bug 190317
+ assertFalse(getJpaProject().discoversAnnotatedClasses());
+ assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
+
+ //test persistentType not listed in persistence.xml, discover annotated classes set to true
+ getJpaProject().setDiscoversAnnotatedClasses(true);
+ assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
+
+ //test persistentType list as class in persistence.xml
+ getJpaProject().setDiscoversAnnotatedClasses(false);
+ XmlJavaClassRef classRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
+ classRef.setJavaClass(FULLY_QUALIFIED_TYPE_NAME);
+ getXmlPersistenceUnit().getClasses().add(classRef);
+ assertNotNull(persistenceUnit.getPersistentType(FULLY_QUALIFIED_TYPE_NAME));
+
+
+ //test persistentType from orm.xml file that is specified in the persistence.xml
+ addXmlMappingFileRef(XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
+ OrmPersistentType ormPersistentType = getEntityMappings().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, "model.Foo");
+ assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
+ assertEquals(ormPersistentType, persistenceUnit.getPersistentType("model.Foo"));
+
+ //test persistentType from orm.xml file that is implied(not specified) in the persistence.xml
+ getXmlPersistenceUnit().getMappingFiles().remove(0);
+ assertNotNull(persistenceUnit.getPersistentType("model.Foo"));
+ }
+
+ public void testGetMappingFileRefsContaining() throws Exception {
+ createOrmXmlFile(ORM2_XML_FILE_NAME);
+ createOrmXmlFile(ORM3_XML_FILE_NAME);
+ createOrmXmlFile(ORM4_XML_FILE_NAME);
+ PersistenceUnit persistenceUnit = getPersistenceUnit();
+
+ Iterable<MappingFileRef> mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(true, IterableTools.isEmpty(mappingFileRefs));
+
+ OrmXml ormXml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 0).getMappingFile();
+ OrmXml orm2Xml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 1).getMappingFile();
+ OrmXml orm3Xml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 2).getMappingFile();
+ OrmXml orm4Xml = (OrmXml) IterableTools.get(persistenceUnit.getMappingFileRefs(), 3).getMappingFile();
+
+ ormXml.getRoot().addPersistentType(MappingKeys.ENTITY_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(1, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+
+ orm2Xml.getRoot().addPersistentType(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(2, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+ assertEquals(orm2Xml, IterableTools.get(mappingFileRefs, 1).getMappingFile());
+
+ orm3Xml.getRoot().addPersistentType(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY, FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(3, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+ assertEquals(orm2Xml, IterableTools.get(mappingFileRefs, 1).getMappingFile());
+ assertEquals(orm3Xml, IterableTools.get(mappingFileRefs, 2).getMappingFile());
+
+ ((EntityMappings2_1) orm4Xml.getRoot()).addConverterType(FULLY_QUALIFIED_TYPE_NAME);
+
+ mappingFileRefs = persistenceUnit.getMappingFileRefsContaining(FULLY_QUALIFIED_TYPE_NAME);
+ assertEquals(4, IterableTools.size(mappingFileRefs));
+ assertEquals(ormXml, IterableTools.get(mappingFileRefs, 0).getMappingFile());
+ assertEquals(orm2Xml, IterableTools.get(mappingFileRefs, 1).getMappingFile());
+ assertEquals(orm3Xml, IterableTools.get(mappingFileRefs, 2).getMappingFile());
+ assertEquals(orm4Xml, IterableTools.get(mappingFileRefs, 3).getMappingFile());
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLink2_5ContextModelTestCase.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLink2_5ContextModelTestCase.java
new file mode 100644
index 0000000..36e5ccd
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/EclipseLink2_5ContextModelTestCase.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context;
+
+import org.eclipse.jpt.jpa.core.jpa2_1.JpaProject2_1;
+import org.eclipse.jpt.jpa.eclipselink.core.internal.EclipseLink2_5JpaPlatformFactory;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.v2_5.EclipseLink2_5;
+
+public abstract class EclipseLink2_5ContextModelTestCase
+ extends EclipseLinkContextModelTestCase
+{
+ protected EclipseLink2_5ContextModelTestCase(String name) {
+ super(name);
+ }
+
+ @Override
+ protected String getJpaFacetVersionString() {
+ return JpaProject2_1.FACET_VERSION_STRING;
+ }
+
+ @Override
+ protected String getJpaPlatformID() {
+ return EclipseLink2_5JpaPlatformFactory.ID;
+ }
+
+ @Override
+ protected String getEclipseLinkSchemaVersion() {
+ return EclipseLink2_5.SCHEMA_VERSION;
+ }
+}
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java
index 487f501..a396352 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaEntityTests.java
@@ -85,14 +85,14 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
entity.getIdClassReference().setSpecifiedIdClassName("myIdClass");
entity.getQueryContainer().addNamedNativeQuery(0);
entity.getQueryContainer().addNamedQuery(0);
- entity.getConverterContainer().addCustomConverter(0);
- entity.getConverterContainer().addCustomConverter(1);
- entity.getConverterContainer().addObjectTypeConverter(0);
- entity.getConverterContainer().addObjectTypeConverter(1);
- entity.getConverterContainer().addTypeConverter(0);
- entity.getConverterContainer().addTypeConverter(1);
- entity.getConverterContainer().addStructConverter(0);
- entity.getConverterContainer().addStructConverter(1);
+ entity.getConverterContainer().addCustomConverter("customConverter", 0);
+ entity.getConverterContainer().addCustomConverter("customConverter2", 1);
+ entity.getConverterContainer().addObjectTypeConverter("customConverter", 0);
+ entity.getConverterContainer().addObjectTypeConverter("objectTypeConverter2", 1);
+ entity.getConverterContainer().addTypeConverter("customConverter", 0);
+ entity.getConverterContainer().addTypeConverter("typeConverter2", 1);
+ entity.getConverterContainer().addStructConverter("structConverter", 0);
+ entity.getConverterContainer().addStructConverter("structConverter2", 1);
entity.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
getJavaPersistentType().setMappingKey(MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
@@ -142,14 +142,14 @@ public class EclipseLink2_2JavaEntityTests extends EclipseLink2_2ContextModelTes
entity.getIdClassReference().setSpecifiedIdClassName("myIdClass");
entity.getQueryContainer().addNamedNativeQuery(0);
entity.getQueryContainer().addNamedQuery(0);
- entity.getConverterContainer().addCustomConverter(0);
- entity.getConverterContainer().addCustomConverter(1);
- entity.getConverterContainer().addObjectTypeConverter(0);
- entity.getConverterContainer().addObjectTypeConverter(1);
- entity.getConverterContainer().addTypeConverter(0);
- entity.getConverterContainer().addTypeConverter(1);
- entity.getConverterContainer().addStructConverter(0);
- entity.getConverterContainer().addStructConverter(1);
+ entity.getConverterContainer().addCustomConverter("customConverter", 0);
+ entity.getConverterContainer().addCustomConverter("customConverter2", 1);
+ entity.getConverterContainer().addObjectTypeConverter("objectTypeConverter", 0);
+ entity.getConverterContainer().addObjectTypeConverter("objectTypeConverter2", 1);
+ entity.getConverterContainer().addTypeConverter("ctypeConverter", 0);
+ entity.getConverterContainer().addTypeConverter("typeConverter2", 1);
+ entity.getConverterContainer().addStructConverter("structConverter", 0);
+ entity.getConverterContainer().addStructConverter("structConverter2", 1);
entity.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
getJavaPersistentType().setMappingKey(MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
assertTrue(getJavaPersistentType().getMapping() instanceof Embeddable);
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java
index ff3c166..5e226dd 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_2JavaMappedSuperclassTests.java
@@ -63,14 +63,14 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
mappedSuperclass.getIdClassReference().setSpecifiedIdClassName("myIdClass");
- mappedSuperclass.getConverterContainer().addCustomConverter(0);
- mappedSuperclass.getConverterContainer().addCustomConverter(1);
- mappedSuperclass.getConverterContainer().addObjectTypeConverter(0);
- mappedSuperclass.getConverterContainer().addObjectTypeConverter(1);
- mappedSuperclass.getConverterContainer().addTypeConverter(0);
- mappedSuperclass.getConverterContainer().addTypeConverter(1);
- mappedSuperclass.getConverterContainer().addStructConverter(0);
- mappedSuperclass.getConverterContainer().addStructConverter(1);
+ mappedSuperclass.getConverterContainer().addCustomConverter("customConverter", 0);
+ mappedSuperclass.getConverterContainer().addCustomConverter("customConverter2", 1);
+ mappedSuperclass.getConverterContainer().addObjectTypeConverter("objectTypeConverter", 0);
+ mappedSuperclass.getConverterContainer().addObjectTypeConverter("objectTypeConverter2", 1);
+ mappedSuperclass.getConverterContainer().addTypeConverter("typeConverter", 0);
+ mappedSuperclass.getConverterContainer().addTypeConverter("typeConverter2", 1);
+ mappedSuperclass.getConverterContainer().addStructConverter("structConverter", 0);
+ mappedSuperclass.getConverterContainer().addStructConverter("structConverter2", 1);
mappedSuperclass.getGeneratorContainer().addTableGenerator();
mappedSuperclass.getGeneratorContainer().addSequenceGenerator();
mappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
@@ -99,14 +99,14 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
mappedSuperclass.getIdClassReference().setSpecifiedIdClassName("myIdClass");
- mappedSuperclass.getConverterContainer().addCustomConverter(0);
- mappedSuperclass.getConverterContainer().addCustomConverter(1);
- mappedSuperclass.getConverterContainer().addObjectTypeConverter(0);
- mappedSuperclass.getConverterContainer().addObjectTypeConverter(1);
- mappedSuperclass.getConverterContainer().addTypeConverter(0);
- mappedSuperclass.getConverterContainer().addTypeConverter(1);
- mappedSuperclass.getConverterContainer().addStructConverter(0);
- mappedSuperclass.getConverterContainer().addStructConverter(1);
+ mappedSuperclass.getConverterContainer().addCustomConverter("customConverter", 0);
+ mappedSuperclass.getConverterContainer().addCustomConverter("customConverter2", 1);
+ mappedSuperclass.getConverterContainer().addObjectTypeConverter("objectTypeConverter", 0);
+ mappedSuperclass.getConverterContainer().addObjectTypeConverter("objectTypeConverter2", 1);
+ mappedSuperclass.getConverterContainer().addTypeConverter("typeConverter", 0);
+ mappedSuperclass.getConverterContainer().addTypeConverter("typeConverter2", 1);
+ mappedSuperclass.getConverterContainer().addStructConverter("structConverter", 0);
+ mappedSuperclass.getConverterContainer().addStructConverter("structConverter2", 1);
mappedSuperclass.getGeneratorContainer().addTableGenerator();
mappedSuperclass.getGeneratorContainer().addSequenceGenerator();
mappedSuperclass.getReadOnly().setSpecifiedReadOnly(Boolean.TRUE);
@@ -136,14 +136,14 @@ public class EclipseLink2_2JavaMappedSuperclassTests extends EclipseLink2_2Conte
EclipseLinkMappedSuperclass mappedSuperclass = (EclipseLinkMappedSuperclass) getJavaPersistentType().getMapping();
mappedSuperclass.getIdClassReference().setSpecifiedIdClassName("myIdClass");
- mappedSuperclass.getConverterContainer().addCustomConverter(0);
- mappedSuperclass.getConverterContainer().addCustomConverter(1);
- mappedSuperclass.getConverterContainer().addObjectTypeConverter(0);
- mappedSuperclass.getConverterContainer().addObjectTypeConverter(1);
- mappedSuperclass.getConverterContainer().addTypeConverter(0);
- mappedSuperclass.getConverterContainer().addTypeConverter(1);
- mappedSuperclass.getConverterContainer().addStructConverter(0);
- mappedSuperclass.getConverterContainer().addStructConverter(1);
+ mappedSuperclass.getConverterContainer().addCustomConverter("customConverter", 0);
+ mappedSuperclass.getConverterContainer().addCustomConverter("customConverter2", 1);
+ mappedSuperclass.getConverterContainer().addObjectTypeConverter("objectTypeConverter", 0);
+ mappedSuperclass.getConverterContainer().addObjectTypeConverter("objectTypeConverter2", 1);
+ mappedSuperclass.getConverterContainer().addTypeConverter("typeConverter", 0);
+ mappedSuperclass.getConverterContainer().addTypeConverter("typeConverter2", 1);
+ mappedSuperclass.getConverterContainer().addStructConverter("structConverter", 0);
+ mappedSuperclass.getConverterContainer().addStructConverter("structConverter2", 1);
getJavaPersistentType().setMappingKey(MappingKeys.NULL_TYPE_MAPPING_KEY);
assertTrue(getJavaPersistentType().getMapping() instanceof JavaNullTypeMapping);
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_3JavaMultitenancyTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_3JavaMultitenancyTests.java
index 066ffb7..d161e2a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_3JavaMultitenancyTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/java/EclipseLink2_3JavaMultitenancyTests.java
@@ -621,7 +621,7 @@ public class EclipseLink2_3JavaMultitenancyTests extends EclipseLink2_3ContextMo
assertEquals(1, multitenancy.getTenantDiscriminatorColumnsSize());
assertEquals("EM_TENANT_ID", multitenancy.getTenantDiscriminatorColumns().iterator().next().getName());
- entityMappings.removePersistentType(0);
+ entityMappings.removeManagedType(0);
multitenancy = getJavaMultitenancy();
assertEquals(1, multitenancy.getTenantDiscriminatorColumnsSize());
assertEquals("PU_TENANT_ID", multitenancy.getTenantDiscriminatorColumns().iterator().next().getName());
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java
index e367224..576aa0a 100644
--- a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_0OrmMappedSuperclassTests.java
@@ -1608,9 +1608,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
//add a converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter(0);
+ EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter("myConverter", 0);
contextConverter.setConverterClass("Foo");
- contextConverter.setName("myConverter");
assertEquals(1, resourceMappedSuperclass.getConverters().size());
assertEquals("Foo", resourceMappedSuperclass.getConverters().get(0).getClassName());
@@ -1623,7 +1622,7 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
//add another converter to the context model, check resource model
- EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter(0);
+ EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter("myConverter2", 0);
contextConverter2.setConverterClass("Foo2");
contextConverter2.setName("myConverter2");
@@ -1772,9 +1771,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
//add a converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter(0);
+ EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter("myTypeConverter", 0);
contextTypeConverter.setDataType("Foo");
- contextTypeConverter.setName("myTypeConverter");
assertEquals(1, resourceMappedSuperclass.getTypeConverters().size());
assertEquals("Foo", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
@@ -1787,9 +1785,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
//add another converter to the context model, check resource model
- EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter(0);
+ EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter("myTypeConverter2", 0);
contextTypeConverter2.setDataType("Foo2");
- contextTypeConverter2.setName("myTypeConverter2");
assertEquals(2, resourceMappedSuperclass.getTypeConverters().size());
assertEquals("Foo2", resourceMappedSuperclass.getTypeConverters().get(0).getDataType());
@@ -1936,9 +1933,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
//add a converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter(0);
+ EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter("myObjectTypeConverter", 0);
contextObjectTypeConverter.setDataType("Foo");
- contextObjectTypeConverter.setName("myObjectTypeConverter");
assertEquals(1, resourceMappedSuperclass.getObjectTypeConverters().size());
assertEquals("Foo", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
@@ -1951,9 +1947,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
//add another converter to the context model, check resource model
- EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter(0);
+ EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter("myObjectTypeConverter2", 0);
contextObjectTypeConverter2.setDataType("Foo2");
- contextObjectTypeConverter2.setName("myObjectTypeConverter2");
assertEquals(2, resourceMappedSuperclass.getObjectTypeConverters().size());
assertEquals("Foo2", resourceMappedSuperclass.getObjectTypeConverters().get(0).getDataType());
@@ -2100,9 +2095,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
//add a converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter(0);
+ EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter("myStructConverter", 0);
contextStructConverter.setConverterClass("Foo");
- contextStructConverter.setName("myStructConverter");
assertEquals(1, resourceMappedSuperclass.getStructConverters().size());
assertEquals("Foo", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
@@ -2115,9 +2109,8 @@ public class EclipseLink2_0OrmMappedSuperclassTests
assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
//add another converter to the context model, check resource model
- EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter(0);
+ EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter("myStructConverter2", 0);
contextStructConverter2.setConverterClass("Foo2");
- contextStructConverter2.setName("myStructConverter2");
assertEquals(2, resourceMappedSuperclass.getStructConverters().size());
assertEquals("Foo2", resourceMappedSuperclass.getStructConverters().get(0).getConverter());
diff --git a/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_5EntityMappingsTests.java b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_5EntityMappingsTests.java
new file mode 100644
index 0000000..ee76674
--- /dev/null
+++ b/jpa/tests/org.eclipse.jpt.jpa.eclipselink.core.tests/src/org/eclipse/jpt/jpa/eclipselink/core/tests/internal/context/orm/EclipseLink2_5EntityMappingsTests.java
@@ -0,0 +1,714 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Oracle. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0, which accompanies this distribution
+ * and is available at http://www.eclipse.org/legal/epl-v10.html.
+ *
+ * Contributors:
+ * Oracle - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.orm;
+
+import java.util.ListIterator;
+
+import org.eclipse.jpt.common.utility.internal.iterable.IterableTools;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.EntityMappings2_1;
+import org.eclipse.jpt.jpa.core.jpa2_1.context.orm.OrmConverterType2_1;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkCustomConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkObjectTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkStructConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.EclipseLinkTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.context.orm.EclipseLinkEntityMappings;
+import org.eclipse.jpt.jpa.eclipselink.core.context.orm.OrmEclipseLinkConverterContainer;
+import org.eclipse.jpt.jpa.eclipselink.core.context.persistence.EclipseLinkPersistenceUnit;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmFactory;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlEntityMappings;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlObjectTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlStructConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlTypeConverter;
+import org.eclipse.jpt.jpa.eclipselink.core.tests.internal.context.EclipseLink2_5ContextModelTestCase;
+
+@SuppressWarnings("nls")
+public class EclipseLink2_5EntityMappingsTests
+ extends EclipseLink2_5ContextModelTestCase
+{
+ public EclipseLink2_5EntityMappingsTests(String name) {
+ super(name);
+ }
+
+
+ public void testUpdateCustomConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ assertEquals(0, resourceEntityMappings.getConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the resource model, check context model
+ XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
+ resourceEntityMappings.getConverters().add(resourceConverter);
+ resourceConverter.setClassName("Foo");
+ resourceConverter.setName("myConverter");
+
+ assertEquals(1, ormContextConverterHolder.getCustomConvertersSize());
+ ListIterator<? extends EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ assertEquals(1, resourceEntityMappings.getConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the resource model, check context model
+ XmlConverter resourceConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
+ resourceEntityMappings.getConverters().add(0, resourceConverter2);
+ resourceConverter2.setClassName("Foo2");
+ resourceConverter2.setName("myConverter2");
+
+ assertEquals(2, ormContextConverterHolder.getCustomConvertersSize());
+ ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo2", ormContextConverter.getConverterClass());
+ assertEquals("myConverter2", ormContextConverter.getName());
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ assertEquals(2, resourceEntityMappings.getConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the resource model, check context model
+ resourceEntityMappings.getConverters().move(0, 1);
+
+ assertEquals(2, ormContextConverterHolder.getCustomConvertersSize());
+ ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo2", ormContextConverter.getConverterClass());
+ assertEquals("myConverter2", ormContextConverter.getName());
+ assertEquals(2, resourceEntityMappings.getConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getConverters().remove(0);
+
+ assertEquals(1, ormContextConverterHolder.getCustomConvertersSize());
+ ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo2", ormContextConverter.getConverterClass());
+ assertEquals("myConverter2", ormContextConverter.getName());
+ assertEquals(1, resourceEntityMappings.getConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getConverters().remove(resourceConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ assertFalse(ormContextConverterHolder.getCustomConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testModifyCustomConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ assertEquals(0, resourceEntityMappings.getConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the context model, check resource model
+ EclipseLinkCustomConverter contextConverter = ormContextConverterHolder.addCustomConverter("myConverter", 0);
+ contextConverter.setConverterClass("Foo");
+
+ assertEquals(1, resourceEntityMappings.getConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getConverters().get(0).getClassName());
+ assertEquals("myConverter", ((XmlConverter) resourceEntityMappings.getConverters().get(0)).getName());
+ assertEquals(1, ormContextConverterHolder.getCustomConvertersSize());
+ ListIterator<? extends EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the context model, check resource model
+ EclipseLinkCustomConverter contextConverter2 = ormContextConverterHolder.addCustomConverter("myConverter2", 0);
+ contextConverter2.setConverterClass("Foo2");
+
+ assertEquals(2, resourceEntityMappings.getConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getConverters().get(0).getClassName());
+ assertEquals("myConverter2", ((XmlConverter) resourceEntityMappings.getConverters().get(0)).getName());
+ assertEquals("Foo", resourceEntityMappings.getConverters().get(1).getClassName());
+ assertEquals("myConverter", ((XmlConverter) resourceEntityMappings.getConverters().get(1)).getName());
+ assertEquals(2, ormContextConverterHolder.getCustomConvertersSize());
+ ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo2", ormContextConverter.getConverterClass());
+ assertEquals("myConverter2", ormContextConverter.getName());
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the context model, check resource model
+ ormContextConverterHolder.moveCustomConverter(0, 1);
+
+ assertEquals(2, resourceEntityMappings.getConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getConverters().get(0).getClassName());
+ assertEquals("myConverter", ((XmlConverter) resourceEntityMappings.getConverters().get(0)).getName());
+ assertEquals("Foo2", resourceEntityMappings.getConverters().get(1).getClassName());
+ assertEquals("myConverter2", ((XmlConverter) resourceEntityMappings.getConverters().get(1)).getName());
+ assertEquals(2, ormContextConverterHolder.getCustomConvertersSize());
+ ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo2", ormContextConverter.getConverterClass());
+ assertEquals("myConverter2", ormContextConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeCustomConverter(0);
+
+ assertEquals(1, resourceEntityMappings.getConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getConverters().get(0).getClassName());
+ assertEquals("myConverter2", ((XmlConverter) resourceEntityMappings.getConverters().get(0)).getName());
+ assertEquals(1, ormContextConverterHolder.getCustomConvertersSize());
+ ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ ormContextConverter = ormContextConverters.next();
+ assertEquals("Foo2", ormContextConverter.getConverterClass());
+ assertEquals("myConverter2", ormContextConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeCustomConverter(contextConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ assertFalse(ormContextConverterHolder.getCustomConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testMorphEclipseLinkConvertersAndJpa2_1Converters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ assertEquals(0, resourceEntityMappings.getConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the resource model, check context model
+ XmlConverter resourceConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlConverter();
+ resourceEntityMappings.getConverters().add(resourceConverter);
+ resourceConverter.setClassName("model.FooConverter");
+
+ //no 'name' set so the converter is a JPA 2.1 converter
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ OrmConverterType2_1 ormConverterType2_1 = ((EntityMappings2_1) contextEntityMappings).getConverterTypes().iterator().next();
+ assertEquals("FooConverter", ormConverterType2_1.getSimpleName());
+ assertEquals("model.FooConverter", ormConverterType2_1.getName());
+
+ resourceConverter.setName("myConverter");
+ //'name' now set so the converter is an EclipseLink converter
+ assertEquals(1, ormContextConverterHolder.getCustomConvertersSize());
+ ListIterator<? extends EclipseLinkCustomConverter> ormContextConverters = ormContextConverterHolder.getCustomConverters().iterator();
+ EclipseLinkCustomConverter ormContextConverter = ormContextConverters.next();
+ assertEquals("model.FooConverter", ormContextConverter.getConverterClass());
+ assertEquals("myConverter", ormContextConverter.getName());
+ assertEquals(1, resourceEntityMappings.getConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+ assertEquals(0, IterableTools.size(((EntityMappings2_1) contextEntityMappings).getConverterTypes()));
+
+ resourceConverter.setName(null);
+ //no 'name' set so the converter is a JPA 2.1 converter
+ assertEquals(0, ormContextConverterHolder.getCustomConvertersSize());
+ ormConverterType2_1 = ((EntityMappings2_1) contextEntityMappings).getConverterTypes().iterator().next();
+ assertEquals("FooConverter", ormConverterType2_1.getSimpleName());
+ assertEquals("model.FooConverter", ormConverterType2_1.getName());
+ }
+
+ public void testUpdateTypeConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getTypeConvertersSize());
+ assertEquals(0, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the resource model, check context model
+ XmlTypeConverter resourceTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
+ resourceEntityMappings.getTypeConverters().add(resourceTypeConverter);
+ resourceTypeConverter.setDataType("Foo");
+ resourceTypeConverter.setName("myTypeConverter");
+
+ assertEquals(1, ormContextConverterHolder.getTypeConvertersSize());
+ ListIterator<? extends EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter", ormContextTypeConverter.getName());
+ assertEquals(1, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the resource model, check context model
+ XmlTypeConverter resourceTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlTypeConverter();
+ resourceEntityMappings.getTypeConverters().add(0, resourceTypeConverter2);
+ resourceTypeConverter2.setDataType("Foo2");
+ resourceTypeConverter2.setName("myTypeConverter2");
+
+ assertEquals(2, ormContextConverterHolder.getTypeConvertersSize());
+ ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo2", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter", ormContextTypeConverter.getName());
+ assertEquals(2, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the resource model, check context model
+ resourceEntityMappings.getTypeConverters().move(0, 1);
+
+ assertEquals(2, ormContextConverterHolder.getTypeConvertersSize());
+ ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter", ormContextTypeConverter.getName());
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo2", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
+ assertEquals(2, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getTypeConverters().remove(0);
+
+ assertEquals(1, ormContextConverterHolder.getTypeConvertersSize());
+ ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo2", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
+ assertEquals(1, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getTypeConverters().remove(resourceTypeConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getTypeConvertersSize());
+ assertFalse(ormContextConverterHolder.getTypeConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testModifyTypeConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getTypeConvertersSize());
+ assertEquals(0, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the context model, check resource model
+ EclipseLinkTypeConverter contextTypeConverter = ormContextConverterHolder.addTypeConverter("myTypeConverter", 0);
+ contextTypeConverter.setDataType("Foo");
+
+ assertEquals(1, resourceEntityMappings.getTypeConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getTypeConverters().get(0).getDataType());
+ assertEquals("myTypeConverter", resourceEntityMappings.getTypeConverters().get(0).getName());
+ assertEquals(1, ormContextConverterHolder.getTypeConvertersSize());
+ ListIterator<? extends EclipseLinkTypeConverter> ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ EclipseLinkTypeConverter ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter", ormContextTypeConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the context model, check resource model
+ EclipseLinkTypeConverter contextTypeConverter2 = ormContextConverterHolder.addTypeConverter("myTypeConverter2", 0);
+ contextTypeConverter2.setDataType("Foo2");
+
+ assertEquals(2, resourceEntityMappings.getTypeConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getTypeConverters().get(0).getDataType());
+ assertEquals("myTypeConverter2", resourceEntityMappings.getTypeConverters().get(0).getName());
+ assertEquals("Foo", resourceEntityMappings.getTypeConverters().get(1).getDataType());
+ assertEquals("myTypeConverter", resourceEntityMappings.getTypeConverters().get(1).getName());
+ assertEquals(2, ormContextConverterHolder.getTypeConvertersSize());
+ ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo2", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter", ormContextTypeConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the context model, check resource model
+ ormContextConverterHolder.moveTypeConverter(0, 1);
+
+ assertEquals(2, resourceEntityMappings.getTypeConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getTypeConverters().get(0).getDataType());
+ assertEquals("myTypeConverter", resourceEntityMappings.getTypeConverters().get(0).getName());
+ assertEquals("Foo2", resourceEntityMappings.getTypeConverters().get(1).getDataType());
+ assertEquals("myTypeConverter2", resourceEntityMappings.getTypeConverters().get(1).getName());
+ assertEquals(2, ormContextConverterHolder.getTypeConvertersSize());
+ ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter", ormContextTypeConverter.getName());
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo2", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeTypeConverter(0);
+
+ assertEquals(1, resourceEntityMappings.getTypeConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getTypeConverters().get(0).getDataType());
+ assertEquals("myTypeConverter2", resourceEntityMappings.getTypeConverters().get(0).getName());
+ assertEquals(1, ormContextConverterHolder.getTypeConvertersSize());
+ ormContextTypeConverters = ormContextConverterHolder.getTypeConverters().iterator();
+ ormContextTypeConverter = ormContextTypeConverters.next();
+ assertEquals("Foo2", ormContextTypeConverter.getDataType());
+ assertEquals("myTypeConverter2", ormContextTypeConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeTypeConverter(contextTypeConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getTypeConvertersSize());
+ assertFalse(ormContextConverterHolder.getTypeConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testUpdateObjectTypeConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getObjectTypeConvertersSize());
+ assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the resource model, check context model
+ XmlObjectTypeConverter resourceObjectTypeConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
+ resourceEntityMappings.getObjectTypeConverters().add(resourceObjectTypeConverter);
+ resourceObjectTypeConverter.setDataType("Foo");
+ resourceObjectTypeConverter.setName("myObjectTypeConverter");
+
+ assertEquals(1, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ListIterator<? extends EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
+ assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the resource model, check context model
+ XmlObjectTypeConverter resourceObjectTypeConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlObjectTypeConverter();
+ resourceEntityMappings.getObjectTypeConverters().add(0, resourceObjectTypeConverter2);
+ resourceObjectTypeConverter2.setDataType("Foo2");
+ resourceObjectTypeConverter2.setName("myObjectTypeConverter2");
+
+ assertEquals(2, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
+ assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the resource model, check context model
+ resourceEntityMappings.getObjectTypeConverters().move(0, 1);
+
+ assertEquals(2, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
+ assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getObjectTypeConverters().remove(0);
+
+ assertEquals(1, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
+ assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getObjectTypeConverters().remove(resourceObjectTypeConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getObjectTypeConvertersSize());
+ assertFalse(ormContextConverterHolder.getObjectTypeConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testModifyObjectTypeConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getObjectTypeConvertersSize());
+ assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the context model, check resource model
+ EclipseLinkObjectTypeConverter contextObjectTypeConverter = ormContextConverterHolder.addObjectTypeConverter("myObjectTypeConverter", 0);
+ contextObjectTypeConverter.setDataType("Foo");
+ contextObjectTypeConverter.setName("myObjectTypeConverter");
+
+ assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
+ assertEquals("myObjectTypeConverter", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
+ assertEquals(1, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ListIterator<? extends EclipseLinkObjectTypeConverter> ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ EclipseLinkObjectTypeConverter ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the context model, check resource model
+ EclipseLinkObjectTypeConverter contextObjectTypeConverter2 = ormContextConverterHolder.addObjectTypeConverter("myObjectTypeConverter2", 0);
+ contextObjectTypeConverter2.setDataType("Foo2");
+ contextObjectTypeConverter2.setName("myObjectTypeConverter2");
+
+ assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
+ assertEquals("myObjectTypeConverter2", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
+ assertEquals("Foo", resourceEntityMappings.getObjectTypeConverters().get(1).getDataType());
+ assertEquals("myObjectTypeConverter", resourceEntityMappings.getObjectTypeConverters().get(1).getName());
+ assertEquals(2, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the context model, check resource model
+ ormContextConverterHolder.moveObjectTypeConverter(0, 1);
+
+ assertEquals(2, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
+ assertEquals("myObjectTypeConverter", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
+ assertEquals("Foo2", resourceEntityMappings.getObjectTypeConverters().get(1).getDataType());
+ assertEquals("myObjectTypeConverter2", resourceEntityMappings.getObjectTypeConverters().get(1).getName());
+ assertEquals(2, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter", ormContextObjectTypeConverter.getName());
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeObjectTypeConverter(0);
+
+ assertEquals(1, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getObjectTypeConverters().get(0).getDataType());
+ assertEquals("myObjectTypeConverter2", resourceEntityMappings.getObjectTypeConverters().get(0).getName());
+ assertEquals(1, ormContextConverterHolder.getObjectTypeConvertersSize());
+ ormContextObjectTypeConverters = ormContextConverterHolder.getObjectTypeConverters().iterator();
+ ormContextObjectTypeConverter = ormContextObjectTypeConverters.next();
+ assertEquals("Foo2", ormContextObjectTypeConverter.getDataType());
+ assertEquals("myObjectTypeConverter2", ormContextObjectTypeConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeObjectTypeConverter(contextObjectTypeConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getObjectTypeConvertersSize());
+ assertFalse(ormContextConverterHolder.getObjectTypeConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getObjectTypeConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testUpdateStructConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getStructConvertersSize());
+ assertEquals(0, resourceEntityMappings.getStructConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the resource model, check context model
+ XmlStructConverter resourceStructConverter = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
+ resourceEntityMappings.getStructConverters().add(resourceStructConverter);
+ resourceStructConverter.setConverter("Foo");
+ resourceStructConverter.setName("myStructConverter");
+
+ assertEquals(1, ormContextConverterHolder.getStructConvertersSize());
+ ListIterator<? extends EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter", ormContextStructConverter.getName());
+ assertEquals(1, resourceEntityMappings.getStructConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the resource model, check context model
+ XmlStructConverter resourceStructConverter2 = EclipseLinkOrmFactory.eINSTANCE.createXmlStructConverter();
+ resourceEntityMappings.getStructConverters().add(0, resourceStructConverter2);
+ resourceStructConverter2.setConverter("Foo2");
+ resourceStructConverter2.setName("myStructConverter2");
+
+ assertEquals(2, ormContextConverterHolder.getStructConvertersSize());
+ ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo2", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter2", ormContextStructConverter.getName());
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter", ormContextStructConverter.getName());
+ assertEquals(2, resourceEntityMappings.getStructConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the resource model, check context model
+ resourceEntityMappings.getStructConverters().move(0, 1);
+
+ assertEquals(2, ormContextConverterHolder.getStructConvertersSize());
+ ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter", ormContextStructConverter.getName());
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo2", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter2", ormContextStructConverter.getName());
+ assertEquals(2, resourceEntityMappings.getStructConverters().size());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getStructConverters().remove(0);
+
+ assertEquals(1, ormContextConverterHolder.getStructConvertersSize());
+ ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo2", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter2", ormContextStructConverter.getName());
+ assertEquals(1, resourceEntityMappings.getStructConverters().size());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the resource model, check context model
+ resourceEntityMappings.getStructConverters().remove(resourceStructConverter2);
+
+ assertEquals(0, ormContextConverterHolder.getStructConvertersSize());
+ assertFalse(ormContextConverterHolder.getStructConverters().iterator().hasNext());
+ assertEquals(0, resourceEntityMappings.getStructConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+ }
+
+ public void testModifyStructConverters() throws Exception {
+ XmlEntityMappings resourceEntityMappings = getXmlEntityMappings();
+ EclipseLinkPersistenceUnit persistenceUnit = getPersistenceUnit();
+ EclipseLinkEntityMappings contextEntityMappings = getEntityMappings();
+ OrmEclipseLinkConverterContainer ormContextConverterHolder = contextEntityMappings.getConverterContainer();
+
+ assertEquals(0, ormContextConverterHolder.getStructConvertersSize());
+ assertEquals(0, resourceEntityMappings.getStructConverters().size());
+ assertEquals(0, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add a converter to the context model, check resource model
+ EclipseLinkStructConverter contextStructConverter = ormContextConverterHolder.addStructConverter("myStructConverter", 0);
+ contextStructConverter.setConverterClass("Foo");
+
+ assertEquals(1, resourceEntityMappings.getStructConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getStructConverters().get(0).getConverter());
+ assertEquals("myStructConverter", resourceEntityMappings.getStructConverters().get(0).getName());
+ assertEquals(1, ormContextConverterHolder.getStructConvertersSize());
+ ListIterator<? extends EclipseLinkStructConverter> ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ EclipseLinkStructConverter ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter", ormContextStructConverter.getName());
+ assertEquals(1, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //add another converter to the context model, check resource model
+ EclipseLinkStructConverter contextStructConverter2 = ormContextConverterHolder.addStructConverter("myStructConverter2", 0);
+ contextStructConverter2.setConverterClass("Foo2");
+
+ assertEquals(2, resourceEntityMappings.getStructConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getStructConverters().get(0).getConverter());
+ assertEquals("myStructConverter2", resourceEntityMappings.getStructConverters().get(0).getName());
+ assertEquals("Foo", resourceEntityMappings.getStructConverters().get(1).getConverter());
+ assertEquals("myStructConverter", resourceEntityMappings.getStructConverters().get(1).getName());
+ assertEquals(2, ormContextConverterHolder.getStructConvertersSize());
+ ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo2", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter2", ormContextStructConverter.getName());
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter", ormContextStructConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //move a converter in the context model, check resource model
+ ormContextConverterHolder.moveStructConverter(0, 1);
+
+ assertEquals(2, resourceEntityMappings.getStructConverters().size());
+ assertEquals("Foo", resourceEntityMappings.getStructConverters().get(0).getConverter());
+ assertEquals("myStructConverter", resourceEntityMappings.getStructConverters().get(0).getName());
+ assertEquals("Foo2", resourceEntityMappings.getStructConverters().get(1).getConverter());
+ assertEquals("myStructConverter2", resourceEntityMappings.getStructConverters().get(1).getName());
+ assertEquals(2, ormContextConverterHolder.getStructConvertersSize());
+ ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterator();
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter", ormContextStructConverter.getName());
+ ormContextStructConverter = ormContextStructConverters.next();
+ assertEquals("Foo2", ormContextStructConverter.getConverterClass());
+ assertEquals("myStructConverter2", ormContextStructConverter.getName());
+ assertEquals(2, IterableTools.size(persistenceUnit.getAllConverters()));
+
+ //remove a converter from the context model, check resource model
+ ormContextConverterHolder.removeStructConverter(0);
+
+ assertEquals(1, resourceEntityMappings.getStructConverters().size());
+ assertEquals("Foo2", resourceEntityMappings.getStructConverters().get(0).getConverter());
+ assertEquals("myStructConverter2", resourceEntityMappings.getStructConverters().get(0).getName());
+ assertEquals(1, ormContextConverterHolder.getStructConvertersSize());
+ ormContextStructConverters = ormContextConverterHolder.getStructConverters().iterat