Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetya Sabeva2013-03-06 09:28:44 +0000
committerPetya Sabeva2013-03-08 09:23:15 +0000
commit92ed2e9eb64fcb68d009c49df281f861cd18b0b7 (patch)
treed6c62964fc0d1220371b9cc55c0cf889cc8f52b8 /jpa_diagram_editor
parent74c6b4d13f9ed8b65dce2acbe63eb9636f358f2c (diff)
downloadwebtools.dali-92ed2e9eb64fcb68d009c49df281f861cd18b0b7.tar.gz
webtools.dali-92ed2e9eb64fcb68d009c49df281f861cd18b0b7.tar.xz
webtools.dali-92ed2e9eb64fcb68d009c49df281f861cd18b0b7.zip
[344742] - Adding support for xml defined persistent types.
Diffstat (limited to 'jpa_diagram_editor')
-rw-r--r--jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml4
-rw-r--r--jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.feature/feature.xml4
-rw-r--r--jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.tests.feature/feature.xml74
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java83
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java34
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java64
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/CreateEntityTypeHierarchy.java24
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java18
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java56
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java16
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/SetMappedByNewValueCommand.java80
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java81
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAttributeFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java131
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java72
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java19
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java94
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CollapseEntityFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java10
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java39
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java23
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java23
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java21
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java11
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyRelationFeature.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java8
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java63
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java13
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java21
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java46
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java22
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java70
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java56
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandAllEntitiesFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandEntityFeature.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java148
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java24
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java29
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java112
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java23
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java15
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityWithoutUIFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/SaveEntityFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java14
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties17
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/JPAEditorMatchingStrategy.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java5
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java9
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java269
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java41
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java14
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java103
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java60
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/AbstractRelation.java34
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasCollectionReferenceRelation.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasReferanceRelation.java36
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasSingleReferenceRelation.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java15
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IRelation.java26
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IUnidirectionalRelation.java14
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java28
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java28
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyRelation.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java18
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java35
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneRelation.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java19
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyRelation.java4
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java16
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java29
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneRelation.java6
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java18
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java47
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java8
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPACheckSum.java9
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java52
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java108
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java8
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java519
-rw-r--r--jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java1512
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java25
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPAEditorTestsActivator.java2
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/Utils.java1
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java186
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java148
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java305
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java16
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java7
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java3
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddAttributeFeatureTest.java6
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java11
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java11
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java61
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java6
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DirectEditAttributeFeatureTest.java20
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/OpenMiniatureViewFeatureTest.java4
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RefactorAttributeTypeFeatureTest.java10
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RemoveAttributeFeatureTest.java4
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java14
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java9
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java11
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorFeatureProviderTest.java22
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorToolBehaviorProviderTest.java46
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java148
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java187
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java181
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java20
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPASolverTest.java17
-rw-r--r--jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JpaArtifactFactoryTest.java17
119 files changed, 3695 insertions, 2768 deletions
diff --git a/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml b/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml
index 8864b72772..88a28e53f9 100644
--- a/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml
+++ b/jpa_diagram_editor/development/org.eclipse.jpt.jpadiagrameditor.releng/pom.xml
@@ -12,9 +12,9 @@
<eclipse-site>http://download.eclipse.org/eclipse/updates/4.3milestones/</eclipse-site>
<emf-site>http://download.eclipse.org/modeling/emf/emf/updates/2.9milestones/</emf-site>
<modeling-site>http://download.eclipse.org/modeling/emf/updates/releases</modeling-site>
- <dtp-site>http://download.eclipse.org/datatools/downloads/drops/M_updates_1.10.1/</dtp-site>
+ <dtp-site>http://download.eclipse.org/datatools/downloads/drops/M_updates_1.10.2/</dtp-site>
<gef-site>http://download.eclipse.org/tools/gef/updates/milestones/</gef-site>
- <wtp-site>http://build.eclipse.org/webtools/committers/wtp4x-R3.5.0-I/20121022195619/I-3.5.0-20121022195619/repository/</wtp-site>
+ <wtp-site>http://build.eclipse.org/webtools/committers/wtp4x-R3.5.0-I/20130307051714/I-3.5.0-20130307051714/repository/</wtp-site>
<graphiti-site>http://download.eclipse.org/graphiti/updates/milestones/</graphiti-site>
<swtbot-site>http://download.eclipse.org/technology/swtbot/helios/dev-build/update-site</swtbot-site>
<tycho.testArgLine>-Xmx512m -Xms128m -XX:PermSize=32m -XX:MaxPermSize=256m -DenableDebug -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=1044</tycho.testArgLine>
diff --git a/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.feature/feature.xml b/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.feature/feature.xml
index b7e0322f18..1f37570f9d 100644
--- a/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.feature/feature.xml
+++ b/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.feature/feature.xml
@@ -22,7 +22,7 @@
<requires>
<import feature="org.eclipse.graphiti.feature" version="0.10.0" match="greaterOrEqual"/>
- <import feature="org.eclipse.jpt.jpa.feature" version="3.2.0" match="greaterOrEqual"/>
+ <import feature="org.eclipse.jpt.jpa.feature" version="3.3.0" match="greaterOrEqual"/>
</requires>
<plugin
@@ -46,4 +46,4 @@
version="0.0.0"
unpack="false"/>
-</feature>
+</feature>
diff --git a/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.tests.feature/feature.xml b/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.tests.feature/feature.xml
index 869f38e1e3..ba82dfb546 100644
--- a/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.tests.feature/feature.xml
+++ b/jpa_diagram_editor/features/org.eclipse.jpt.jpadiagrameditor.tests.feature/feature.xml
@@ -1,40 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<feature
- id="org.eclipse.jpt.jpadiagrameditor.tests.feature"
- label="%featureName"
- version="1.2.0.qualifier"
- provider-name="%providerName"
- license-feature="org.eclipse.license"
- license-feature-version="1.0.0.qualifier">
-
- <description>
- %description
- </description>
-
- <copyright>
- %copyright
- </copyright>
-
- <license url="license.html">
- %license
- </license>
-
- <requires>
- <import plugin="org.easymock" version="2.4.0" match="compatible"/>
- <import feature="org.eclipse.graphiti.feature" version="0.10.0" match="greaterOrEqual"/>
- <import feature="org.eclipse.jpt.jpa.feature" version="3.2.0" match="greaterOrEqual"/>
- </requires>
-
- <plugin
- id="org.eclipse.jpt.jpadiagrameditor.ui.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-<!--
- <plugin
- id="org.eclipse.jpt.jpadiagrameditor.swtbot.tests"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
--->
-</feature>
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.eclipse.jpt.jpadiagrameditor.tests.feature"
+ label="%featureName"
+ version="1.2.0.qualifier"
+ provider-name="%providerName"
+ license-feature="org.eclipse.license"
+ license-feature-version="1.0.0.qualifier">
+
+ <description>
+ %description
+ </description>
+
+ <copyright>
+ %copyright
+ </copyright>
+
+ <license url="license.html">
+ %license
+ </license>
+
+ <requires>
+ <import plugin="org.easymock" version="2.4.0" match="compatible"/>
+ <import feature="org.eclipse.graphiti.feature" version="0.10.0" match="greaterOrEqual"/>
+ <import feature="org.eclipse.jpt.jpa.feature" version="3.3.0" match="greaterOrEqual"/>
+ </requires>
+
+ <plugin
+ id="org.eclipse.jpt.jpadiagrameditor.ui.tests"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
+</feature>
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java
index 0d9b1c8bb9..3bb53796cd 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/JPADiagramEditor.java
@@ -24,6 +24,7 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.transaction.RecordingCommand;
@@ -47,6 +48,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jpt.common.core.internal.utility.PlatformTools;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
import org.eclipse.jpt.common.utility.internal.model.value.DoublePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.SimplePropertyValueModel;
import org.eclipse.jpt.common.utility.internal.model.value.TransformationPropertyValueModel;
@@ -55,9 +57,13 @@ 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.JpaFile;
+import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
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.persistence.MappingFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.ui.JpaFileModel;
import org.eclipse.jpt.jpa.ui.selection.JpaEditorManager;
@@ -93,7 +99,7 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
public final static String ID = "org.eclipse.jpt.jpadiagrameditor.ui"; //$NON-NLS-1$
- private JavaPersistentType inputJptType;
+ private PersistentType inputJptType;
private ISelectionManagerFactory jpaSelectionManagerFactory;
private final ModifiablePropertyValueModel<IFile> fileModel = new SimplePropertyValueModel<IFile>();
@@ -148,7 +154,7 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
boolean save = true;
while (chIt.hasNext()) {
ContainerShape sh = (ContainerShape)chIt.next();
- JavaPersistentType jpt = (JavaPersistentType) getFeatureProvider()
+ PersistentType jpt = (PersistentType) getFeatureProvider()
.getBusinessObjectForPictogramElement(sh);
String entName = JPAEditorUtil.getText(jpt);
ICompilationUnit cu = JPAEditorUtil.getCompilationUnit(jpt);
@@ -181,13 +187,19 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- JPACheckSum.INSTANCE().assignEntityShapesMD5Strings(d, ModelIntegrationUtil.getProjectByDiagram(d.getName()));
+
+ JpaProject jpaProject = ModelIntegrationUtil.getProjectByDiagram(d.getName());
+
+ saveAllExistingOrmXmlsIfNecessary(jpaProject);
+
+ JPACheckSum.INSTANCE().assignEntityShapesMD5Strings(d, jpaProject);
List<Shape> children = d.getChildren();
Iterator<Shape> chIt = children.iterator();
while (chIt.hasNext()) {
Shape sh = chIt.next();
- JavaPersistentType jpt = (JavaPersistentType) getFeatureProvider()
+ PersistentType jpt = (PersistentType) getFeatureProvider()
.getBusinessObjectForPictogramElement(sh);
+
if (jpt != null)
JpaArtifactFactory.instance().forceSaveEntityClass(jpt, (IJPAEditorFeatureProvider) getFeatureProvider());
}
@@ -213,6 +225,20 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
super.doSave(monitor);
}
+
+ private void saveAllExistingOrmXmlsIfNecessary(JpaProject jpaProject) {
+ PersistenceUnit unit = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
+ for(MappingFileRef fileRef : unit.getMappingFileRefs()){
+ JptXmlResource ormXmlRes = jpaProject.getMappingFileXmlResource(new Path(fileRef.getFileName()));
+ if(ormXmlRes != null) {
+ try {
+ ormXmlRes.saveIfNecessary();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
@Override
protected ContextMenuProvider createContextMenuProvider() {
@@ -313,15 +339,17 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
.getBusinessObjectForPictogramElement(
(PictogramElement) m);
if ((bo == null) || (!(bo instanceof JpaStructureNode))){
+ if(jpaSelectionModel == null)
+ return;
jpaSelectionModel.setValue(null);
setFileModel(null);
return;
}
JpaStructureNode jpaStructureNode = (JpaStructureNode) bo;
- jpaSelectionModel.setValue(jpaStructureNode);
setFileModel(jpaStructureNode);
- selectionManager.setSelection(jpaStructureNode);
-// jpaStructureNode.getJpaPlatform().buildJpaFile(jpaStructureNode.getJpaProject(), jpaFileModel.getValue().getFile());
+ jpaSelectionModel.setValue(selectedNode);
+
+ selectionManager.setSelection(selectedNode);
return;
}
}
@@ -377,16 +405,43 @@ public class JPADiagramEditor extends DiagramEditor implements JpaEditorManager{
}
private void setFileModel(JpaStructureNode node) {
- this.fileModel.setValue(getSelectedEntityFile(node));
+ this.fileModel.setValue(getSelectedEntityFile(node, false));
}
- private IFile getSelectedEntityFile(JpaStructureNode node) {
+ private JpaStructureNode selectedNode;
+
+ private IFile getSelectedEntityFile(JpaStructureNode node, boolean fromAttribte) {
IResource resource = null;
if (node != null) {
- if (node.getType().isAssignableFrom(JavaPersistentType.class)) {
- resource = ((JavaPersistentType) node).getResource();
- } else if (node.getType().isAssignableFrom(JavaSpecifiedPersistentAttribute.class)) {
- resource = ((JavaSpecifiedPersistentAttribute) node).getResource();
+ if (node instanceof PersistentType) {
+ PersistentType pt = (PersistentType) node;
+ if(pt instanceof JavaPersistentType) {
+ JavaPersistentType jpt = (JavaPersistentType) pt;
+ MappingFileRef mappingFileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(!fromAttribte)
+ selectedNode = jpt;
+ if(mappingFileRef != null){
+ PersistentType type = mappingFileRef.getMappingFile().getPersistentType(jpt.getName());
+ if(!fromAttribte)
+ selectedNode = type;
+ return getSelectedEntityFile(type, false);
+ }
+
+ resource = ((JavaPersistentType) pt).getResource();
+ } else if (pt instanceof OrmPersistentType) {
+ OrmPersistentType ormPt = (OrmPersistentType) pt;
+ resource = ormPt.getParent().getResource();
+ }
+ } else if (node instanceof PersistentAttribute) {
+ PersistentType pt = ((PersistentAttribute) node).getDeclaringPersistentType();
+ selectedNode = node;
+
+ MappingFileRef mappingFileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(((PersistentAttribute) node).getDeclaringPersistentType());
+ if(mappingFileRef != null){
+ PersistentType type = mappingFileRef.getMappingFile().getPersistentType(((PersistentAttribute) node).getDeclaringPersistentType().getName());
+ selectedNode = type.getAttributeNamed(((PersistentAttribute) node).getName());
+ }
+ return getSelectedEntityFile(pt, true);
}
if (resource != null && resource.exists() && (resource instanceof IFile)) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java
index 1aea5768ec..31d2e3a384 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddAttributeCommand.java
@@ -26,9 +26,9 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -46,7 +46,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class AddAttributeCommand implements Command {
private IJPAEditorFeatureProvider fp;
- private JavaPersistentType jpt;
+ private PersistentType jpt;
private String attributeType;
private String mapKeyType;
private String attributeName;
@@ -69,7 +69,7 @@ public class AddAttributeCommand implements Command {
* @param cu
*/
public AddAttributeCommand(IJPAEditorFeatureProvider fp,
- JavaPersistentType jpt, String attributeType, String mapKeyType,
+ PersistentType jpt, String attributeType, String mapKeyType,
String attributeName, String actName, String[] attrTypes,
List<String> annotations,
boolean isCollection, ICompilationUnit cu) {
@@ -92,6 +92,9 @@ public class AddAttributeCommand implements Command {
public void execute() {
IType type = null;
try {
+// if(jpt != null){
+// cu = JPAEditorUtil.getCompilationUnit(jpt);
+// }
JPAEditorUtil.createImport(cu, attributeType);
attributeType = JPAEditorUtil.returnSimpleName(attributeType);
type = cu.findPrimaryType();
@@ -113,21 +116,10 @@ public class AddAttributeCommand implements Command {
actName, cu, type, isCollection, attrTypes, contents);
if(jpt != null) {
- JavaSpecifiedPersistentAttribute attr = jpt.getAttributeNamed(actName);
- int cnt = 0;
- while ((attr == null) && (cnt < 25)) {
- try {
- Thread.sleep(250);
- } catch (InterruptedException e) {
- JPADiagramEditorPlugin.logError("Cannnot create a new attribute with name " + attributeName, e); //$NON-NLS-1$
- }
- jpt.getJavaResourceType().getJavaResourceCompilationUnit()
- .synchronizeWithJavaSource();
- jpt.update();
- jpt.synchronizeWithResourceModel();
- attr = jpt.getAttributeNamed(actName);
- cnt++;
- }
+ jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.update();
}
} catch (JavaModelException e) {
@@ -152,7 +144,7 @@ public class AddAttributeCommand implements Command {
* @throws JavaModelException
*/
private void createAttribute(IJPAEditorFeatureProvider fp,
- JavaPersistentType jpt, String attrTypeName, String mapKeyType,
+ PersistentType jpt, String attrTypeName, String mapKeyType,
String attrName, String actName, ICompilationUnit cu, IType type,
boolean isCollection, String[] attrTypeElementNames, String annotationContents) throws JavaModelException {
@@ -216,7 +208,7 @@ public class AddAttributeCommand implements Command {
* @throws JavaModelException
*/
private void createAttributeOfCollectiontype(IJPAEditorFeatureProvider fp,
- JavaPersistentType jpt, String attributeType, String mapKeyType,
+ PersistentType jpt, String attributeType, String mapKeyType,
String attributeName, String actName, ICompilationUnit cu,
IType type) throws JavaModelException {
IProject project = jpt.getJpaProject().getProject();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java
new file mode 100644
index 0000000000..ac8051ade1
--- /dev/null
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/AddPersistentTypeToOrmXmlCommand.java
@@ -0,0 +1,64 @@
+package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
+
+import java.util.Iterator;
+
+import org.eclipse.jpt.common.utility.command.Command;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+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.MappingFileRef;
+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
+
+/**
+ * A new {@link Command} class that is called to add the {@link PersistentType}
+ * to the XML mapping file, specified in the project's Properties page.
+ *
+ * @author i045693
+ *
+ */
+public class AddPersistentTypeToOrmXmlCommand implements Command {
+
+ private JpaProject jpaProject;
+ private String mapping;
+ private String persistentTypeName;
+
+ /**
+ * Constructor for the add Persistent type to the mapping file command.
+ * @param jpaProject - the project, which the persistent type will be created
+ * @param mapping - the mapping of the persistent type
+ * @param persistentTypeName - the persistent type to be added
+ */
+ public AddPersistentTypeToOrmXmlCommand(JpaProject jpaProject, String mapping, String persistentTypeName) {
+ super();
+ this.jpaProject = jpaProject;
+ this.persistentTypeName = persistentTypeName;
+ this.mapping = mapping;
+ }
+
+ /**
+ * Adds the given persistent type to the specified mapping file.
+ */
+ public void execute() {
+ PersistenceUnit unit = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
+ if(unit.getMappingFileRefsSize() == 0)
+ return;
+
+ String ormFileName = JPADiagramPropertyPage.getOrmXmlFileName(jpaProject.getProject());
+ Iterator<MappingFileRef> iter = unit.getMappingFileRefs().iterator();
+ while(iter.hasNext()){
+ MappingFileRef mapFile = iter.next();
+ if(mapFile.getFileName().equals(ormFileName)){
+ OrmXml ormXml = (OrmXml) mapFile.getMappingFile();
+ OrmPersistentType type = ormXml.getRoot().addPersistentType(mapping, persistentTypeName);
+ for(PersistentAttribute pa : type.getDefaultAttributes()){
+ type.addAttributeToXml(type.getAttributeNamed(pa.getName()));
+ }
+ }
+ }
+ }
+
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/CreateEntityTypeHierarchy.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/CreateEntityTypeHierarchy.java
index 74e195a222..b3b71e178e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/CreateEntityTypeHierarchy.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/CreateEntityTypeHierarchy.java
@@ -20,8 +20,9 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.text.Document;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.text.edits.DeleteEdit;
@@ -33,11 +34,11 @@ import org.eclipse.text.edits.TextEditCopier;
public class CreateEntityTypeHierarchy implements Command {
- private JavaPersistentType subclass;
- private JavaPersistentType superclass;
+ private PersistentType subclass;
+ private PersistentType superclass;
private boolean shouldCreate;
- public CreateEntityTypeHierarchy(JavaPersistentType superclass, JavaPersistentType subclass, boolean shouldCreate) {
+ public CreateEntityTypeHierarchy(PersistentType superclass, PersistentType subclass, boolean shouldCreate) {
super();
this.superclass = superclass;
this.subclass = subclass;
@@ -47,12 +48,15 @@ public class CreateEntityTypeHierarchy implements Command {
public void execute() {
buildHierarchy(superclass, subclass, shouldCreate);
- this.subclass.getJavaResourceType().getJavaResourceCompilationUnit()
- .synchronizeWithJavaSource();
+ subclass.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = subclass.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ subclass.update();
+
}
- private void buildHierarchy(JavaPersistentType superclass,
- JavaPersistentType subclass, boolean build) {
+ private void buildHierarchy(PersistentType superclass,
+ PersistentType subclass, boolean build) {
try {
ICompilationUnit subCU = JPAEditorUtil.getCompilationUnit(subclass);
@@ -60,8 +64,8 @@ public class CreateEntityTypeHierarchy implements Command {
final Document document = new Document(subCU.getBuffer()
.getContents());
MultiTextEdit edit = new MultiTextEdit();
- String str = document.get();
-
+ String str = document.get();
+
if (build) {
int offset = str.indexOf(subclass.getSimpleName())
+ subclass.getSimpleName().length();
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java
index 5c0d7a41b9..d59139de15 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/DeleteAttributeCommand.java
@@ -24,8 +24,9 @@ import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -35,12 +36,12 @@ import org.eclipse.ui.IWorkbenchSite;
public class DeleteAttributeCommand implements Command {
- private JavaPersistentType jpt;
+ private PersistentType jpt;
private String attributeName;
private IJPAEditorFeatureProvider fp;
private ICompilationUnit unit;
- public DeleteAttributeCommand(ICompilationUnit unit, JavaPersistentType jpt, String attributeName,
+ public DeleteAttributeCommand(ICompilationUnit unit, PersistentType jpt, String attributeName,
IJPAEditorFeatureProvider fp) {
super();
this.jpt = jpt;
@@ -52,6 +53,9 @@ public class DeleteAttributeCommand implements Command {
public void execute() {
boolean isMethodAnnotated = false;
if(jpt != null) {
+
+ JpaArtifactFactory.instance().removeOrmPersistentAttribute(jpt, attributeName);
+
unit = fp.getCompilationUnit(jpt);
isMethodAnnotated = JpaArtifactFactory.instance()
.isMethodAnnotated(jpt);
@@ -139,8 +143,12 @@ public class DeleteAttributeCommand implements Command {
IWorkbenchSite ws = ((IEditorPart) fp.getDiagramTypeProvider().getDiagramEditor()).getSite();
JPAEditorUtil.organizeImports(unit, ws);
- if(jpt != null)
- jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ if(jpt != null) {
+ jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.update();
+ }
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java
index db274a4220..6fc85cd5a9 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameAttributeCommand.java
@@ -17,8 +17,9 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
import java.lang.reflect.InvocationTargetException;
+import java.util.Iterator;
+import java.util.List;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
@@ -26,8 +27,14 @@ import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.refactoring.RenameSupport;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+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.persistence.MappingFileRef;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -37,14 +44,14 @@ import org.eclipse.ui.IWorkbenchWindow;
public class RenameAttributeCommand implements Command {
- private JavaPersistentType jpt;
+ private PersistentType jpt;
private ICompilationUnit jptCompilationUnit;
private String oldName;
private String newName;
private IJPAEditorFeatureProvider fp;
- public RenameAttributeCommand(ICompilationUnit jptCompilationUnit, JavaPersistentType jpt, String oldName,
+ public RenameAttributeCommand(ICompilationUnit jptCompilationUnit, PersistentType jpt, String oldName,
String newName, IJPAEditorFeatureProvider fp){
super();
@@ -63,18 +70,53 @@ public class RenameAttributeCommand implements Command {
try {
boolean isMethodAnnotated = false;
if(jpt!= null){
+ renameAttribute(jpt, oldName, newName);
isMethodAnnotated = JpaArtifactFactory.instance().isMethodAnnotated(jpt);
}
- renameAttribute(jptCompilationUnit, oldName, this.newName, fp, isMethodAnnotated);
+ renameAttribute(jptCompilationUnit, oldName, newName, fp, isMethodAnnotated);
if(jpt != null) {
- jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- jpt.getJpaPlatform().buildJpaFile(jpt.getJpaProject(), (IFile) jptCompilationUnit.getResource());
+ jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.update();
}
} catch (InterruptedException e) {
JPADiagramEditorPlugin.logError("Cannot rename attribute", e); //$NON-NLS-1$
}
}
+
+ private void renameAttribute(PersistentType jpt, String oldName, String newName) {
+ MappingFileRef mapFileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(mapFileRef != null) {
+ EntityMappings root = (EntityMappings) mapFileRef.getMappingFile().getRoot();
+// XmlEntityMappings xmlEntities = root.getXmlEntityMappings();
+ Iterator<OrmManagedType> managedTypesIter = root.getManagedTypes().iterator();
+ while(managedTypesIter.hasNext()) {
+ XmlTypeMapping xmlType = (XmlTypeMapping) managedTypesIter.next().getXmlManagedType();
+ if(xmlType.getAttributes() == null)
+ return;
+ List<XmlAttributeMapping> attributeMappings = xmlType.getAttributes().getAttributeMappings();
+ for(XmlAttributeMapping attr : attributeMappings){
+ if(attr.getName().equals(oldName)){
+ attr.setName(newName);
+ }
+ }
+ }
+
+// List<XmlTypeMapping> typeMappings = xmlEntities.getTypeMappings();
+// for(XmlTypeMapping xmlType : typeMappings){
+// if(xmlType.getAttributes() == null)
+// return;
+// List<XmlAttributeMapping> attributeMappings = xmlType.getAttributes().getAttributeMappings();
+// for(XmlAttributeMapping attr : attributeMappings){
+// if(attr.getName().equals(oldName)){
+// attr.setName(newName);
+// }
+// }
+// }
+ }
+ }
private void renameAttribute(ICompilationUnit cu, String oldName,
String newName, IJPAEditorFeatureProvider fp, boolean isMethodAnnotated) throws InterruptedException {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java
index 6039cc507c..ed882764b7 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/RenameEntityCommand.java
@@ -19,8 +19,9 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.ui.refactoring.RenameSupport;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.swt.widgets.Shell;
@@ -28,11 +29,11 @@ import org.eclipse.ui.IWorkbenchWindow;
public class RenameEntityCommand implements Command {
- private JavaPersistentType jpt;
+ private PersistentType jpt;
private String newEntityName;
private IJPAEditorFeatureProvider fp;
- public RenameEntityCommand(JavaPersistentType jpt, String newEntityName, IJPAEditorFeatureProvider fp){
+ public RenameEntityCommand(PersistentType jpt, String newEntityName, IJPAEditorFeatureProvider fp){
super();
this.jpt = jpt;
this.newEntityName = newEntityName;
@@ -40,10 +41,11 @@ public class RenameEntityCommand implements Command {
}
public void execute() {
- renameEntityClass(this.fp.getCompilationUnit(this.jpt), this.newEntityName);
- if(jpt.getResource() != null && jpt.getResource().exists()) {
- this.jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- }
+ renameEntityClass(fp.getCompilationUnit(jpt), newEntityName);
+ jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.update();
}
private void renameEntityClass(ICompilationUnit cu, String newName) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/SetMappedByNewValueCommand.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/SetMappedByNewValueCommand.java
index cc768c5909..f5601c6a7a 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/SetMappedByNewValueCommand.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/command/SetMappedByNewValueCommand.java
@@ -18,60 +18,90 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.command;
import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.EntityChangeListener;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
-public class SetMappedByNewValueCommand implements Command {
+public class SetMappedByNewValueCommand implements Command{
private IJPAEditorFeatureProvider fp;
private PersistenceUnit pu;
private String inverseEntityName;
- private String inverseAttributeName;
- private JavaSpecifiedPersistentAttribute newAt;
- private JavaSpecifiedPersistentAttribute oldAt;
- private IRelation rel;
-
+ private String inverseAttributeName;
+ private String newAtName;
+ private PersistentAttribute oldAt;
+
public SetMappedByNewValueCommand(IJPAEditorFeatureProvider fp,
- PersistenceUnit pu, String inverseEntityName,
- String inverseAttributeName, JavaSpecifiedPersistentAttribute newAt,
- JavaSpecifiedPersistentAttribute oldAt,
- IRelation rel) {
+ PersistenceUnit pu, String inverseEntityName,
+ String inverseAttributeName, String newAt,
+ PersistentAttribute oldAt) {
super();
this.fp =fp;
this.pu = pu;
this.inverseEntityName = inverseEntityName;
this.inverseAttributeName = inverseAttributeName;
- this.newAt = newAt;
+ this.newAtName = newAt;
this.oldAt = oldAt;
- this.rel = rel;
}
public void execute() {
fp.addAttribForUpdate(pu, inverseEntityName
+ EntityChangeListener.SEPARATOR + inverseAttributeName
- + EntityChangeListener.SEPARATOR + newAt.getName()
+ + EntityChangeListener.SEPARATOR + newAtName
+ EntityChangeListener.SEPARATOR + oldAt.getName());
- Annotation a = rel.getInverseAnnotatedAttribute().getMapping().getMappingAnnotation();
- if (OwnableRelationshipMappingAnnotation.class.isInstance(a)) {
- String mappedBy = ((OwnableRelationshipMappingAnnotation)a).getMappedBy();
- String[] mappedByAttrs = mappedBy.split("\\."); //$NON-NLS-1$
+
+ PersistentType pt = pu.getPersistentType(inverseEntityName);
+ if(pt == null) {
+ return;
+ }
+
+ PersistentAttribute pa = pt.getAttributeNamed(inverseAttributeName);
+ if(pa == null) {
+ return;
+ }
+
+ AttributeMapping m = JpaArtifactFactory.instance().getAttributeMapping(pa);
+
+ if(m != null && m instanceof RelationshipMapping) {
+
+ MappedByRelationship mappedByrelationShip = (MappedByRelationship) ((RelationshipMapping)m).getRelationship();
+ SpecifiedMappedByRelationshipStrategy mappedByStrategy = mappedByrelationShip.getMappedByStrategy();
+ String mappedBy = mappedByStrategy.getMappedByAttribute();
+ if (mappedBy == null)
+ return;
+ String[] mappedByAttrs = mappedBy.split(JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR);
if(mappedByAttrs.length > 1){
if(mappedByAttrs[0].equals(oldAt.getName())){
- mappedBy = newAt.getName() + "." + mappedByAttrs[1]; //$NON-NLS-1$
+ mappedBy = newAtName + JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SEPARATOR + mappedByAttrs[1];
} else if(mappedByAttrs[1].equals(oldAt.getName())){
- mappedBy = mappedByAttrs[0] + "." + newAt.getName(); //$NON-NLS-1$
+ mappedBy = mappedByAttrs[0] + JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SEPARATOR + newAtName;
}
} else {
- mappedBy = newAt.getName();
+ mappedBy = newAtName;
}
- ((OwnableRelationshipMappingAnnotation)a).setMappedBy(mappedBy);
-
- rel.getInverse().getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+
+ mappedByStrategy.setMappedByAttribute(mappedBy);
+
+ if(pa.getJavaPersistentAttribute() != null && (JpaArtifactFactory.instance().getORMPersistentAttribute(pa) == null)) {
+ JavaAttributeMapping attrM = pa.getJavaPersistentAttribute().getMapping();
+ Annotation a = attrM.getMappingAnnotation();
+ if(a != null) {
+ ((OwnableRelationshipMappingAnnotation)a).setMappedBy(mappedBy);
+ }
+ }
+ mappedByrelationShip.synchronizeWithResourceModel();
}
+
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
index 9b83179c8a..277932d082 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAllEntitiesFeature.java
@@ -37,8 +37,9 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
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.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
@@ -96,42 +97,66 @@ public class AddAllEntitiesFeature extends AbstractCustomFeature implements IAdd
lowerEdges[0] = lowestRightestPointOfExistingDiagram.y + ((lowestRightestPointOfExistingDiagram.y == 0) ? DIST_FROM_EDGE_V : DIST_V);
TransactionalEditingDomain ted = ModelIntegrationUtil.getTransactionalEditingDomain(d);
+ showAllJavaPersistentTypes(d, unit, ted);
+
+ for(MappingFileRef mappingFileRef : unit.getMappingFileRefs()) {
+ showAllOrmPersistentTypes(d, mappingFileRef, ted);
+ }
+
+ ted.getCommandStack().execute(new RecordingCommand(ted) {
+ @Override
+ protected void doExecute() {
+ JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
+ }
+ });
+
+ }
+
+ private void showAllJavaPersistentTypes(Diagram d, PersistenceUnit unit,
+ TransactionalEditingDomain ted) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) { // null if
- JavaPersistentType jpt = classRef.getJavaPersistentType();
- if (JpaArtifactFactory.instance().hasAnyAnnotationType(jpt)) {
- PictogramElement pe = getFeatureProvider().getPictogramElementForBusinessObject(jpt);
- if (pe != null)
- continue;
-
- final AddContext ctx = new AddContext();
- ctx.setTargetContainer(d);
- ctx.setNewObject(jpt);
-
- IndexAndLowerEdge ie = getMinLowerEdge();
-
- int x = DIST_FROM_EDGE_H + ie.index * (JPAEditorConstants.ENTITY_WIDTH + DIST_H);
- ctx.setLocation(x, ie.lowerEdge);
- final AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider(), false);
-
- ted.getCommandStack().execute(new RecordingCommand(ted) {
- @Override
- protected void doExecute() {
- ft.add(ctx);
- }
- });
- ContainerShape entityShape = (ContainerShape)getFeatureProvider().getPictogramElementForBusinessObject(jpt);
- lowerEdges[ie.index] = entityShape.getGraphicsAlgorithm().getY() + entityShape.getGraphicsAlgorithm().getHeight() + DIST_V;
+ PersistentType jpt = classRef.getJavaPersistentType();
+ if (JpaArtifactFactory.instance().isAnyKindPersistentType(jpt)) {
+ addPersistentTypeInDiagram(d, ted, jpt);
}
}
- }
+ }
+ }
+
+ private void showAllOrmPersistentTypes(Diagram d, MappingFileRef ormlXml,
+ TransactionalEditingDomain ted) {
+ for (PersistentType jpt : ormlXml.getPersistentTypes()) {
+ if (JpaArtifactFactory.instance().isAnyKindPersistentType(jpt)) {
+ addPersistentTypeInDiagram(d, ted, jpt);
+ }
+ }
+ }
+
+ private void addPersistentTypeInDiagram(Diagram d,
+ TransactionalEditingDomain ted, PersistentType jpt) {
+ PictogramElement pe = getFeatureProvider().getPictogramElementForBusinessObject(jpt);
+ if (pe != null)
+ return;
+
+ final AddContext ctx = new AddContext();
+ ctx.setTargetContainer(d);
+ ctx.setNewObject(jpt);
+
+ IndexAndLowerEdge ie = getMinLowerEdge();
+
+ int x = DIST_FROM_EDGE_H + ie.index * (JPAEditorConstants.ENTITY_WIDTH + DIST_H);
+ ctx.setLocation(x, ie.lowerEdge);
+ final AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider(), false);
+
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
+ ft.add(ctx);
}
});
-
+ ContainerShape entityShape = (ContainerShape)getFeatureProvider().getPictogramElementForBusinessObject(jpt);
+ lowerEdges[ie.index] = entityShape.getGraphicsAlgorithm().getY() + entityShape.getGraphicsAlgorithm().getHeight() + DIST_V;
}
private IndexAndLowerEdge getMinLowerEdge() {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAttributeFeature.java
index e9712c625a..803aa09c34 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddAttributeFeature.java
@@ -31,7 +31,7 @@ import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.Wrp;
@@ -41,10 +41,14 @@ public class AddAttributeFeature extends AbstractAddShapeFeature {
private IAddFeature graphicalAdd;
private ICustomFeature expandCompartmentFeature;
-
+
public AddAttributeFeature(IFeatureProvider fp) {
this(fp, new GraphicalAddAttributeFeature(fp), new ExpandCompartmentShapeFeature(fp));
}
+
+ public AddAttributeFeature(IFeatureProvider fp, GraphicalAddAttributeFeature attrF) {
+ this(fp, attrF, new ExpandCompartmentShapeFeature(fp));
+ }
public AddAttributeFeature(IFeatureProvider fp, IAddFeature graphicalAdd, ICustomFeature expandFeature) {
super(fp);
@@ -54,10 +58,10 @@ public class AddAttributeFeature extends AbstractAddShapeFeature {
public PictogramElement add(final IAddContext context) {
Object o = context.getNewObject();
- if (!(o instanceof JavaSpecifiedPersistentAttribute)) {
+ if (!(o instanceof PersistentAttribute)) {
return null;
}
- final JavaSpecifiedPersistentAttribute newAttr = (JavaSpecifiedPersistentAttribute) o;
+ final PersistentAttribute newAttr = (PersistentAttribute) o;
getFeatureProvider().putKeyToBusinessObject(getFeatureProvider().getKeyForBusinessObject(newAttr), newAttr);
PictogramElement pe = getFeatureProvider().getPictogramElementForBusinessObject(newAttr);
@@ -78,14 +82,15 @@ public class AddAttributeFeature extends AbstractAddShapeFeature {
return (PictogramElement)wrp.getObj();
}
- private void expand(JavaSpecifiedPersistentAttribute jpa) {
+ private void expand(PersistentAttribute jpa) {
ContainerShape attributeShape = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(jpa);
ICustomContext customContext = new CustomContext(new PictogramElement[] { attributeShape.getContainer() });
expandCompartmentFeature.execute(customContext);
}
- private ContainerShape graphicalAdd(ContainerShape entityShape, JavaSpecifiedPersistentAttribute newAttr) {
+
+ private ContainerShape graphicalAdd(ContainerShape entityShape, PersistentAttribute newAttr) {
AddContext context = new AddContext();
context.setNewObject(newAttr);
context.setTargetContainer(entityShape);
@@ -112,7 +117,6 @@ public class AddAttributeFeature extends AbstractAddShapeFeature {
public boolean canAdd(IAddContext context) {
Object o = context.getNewObject();
- return o instanceof JavaSpecifiedPersistentAttribute;
+ return o instanceof PersistentAttribute;
}
-
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
index 8bcec94fc8..4479556018 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddJPAEntityFeature.java
@@ -16,7 +16,7 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.emf.transaction.RecordingCommand;
@@ -46,8 +46,12 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.SourceType;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
@@ -84,28 +88,28 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
public boolean canAdd(IAddContext context) {
Object newObj = context.getNewObject();
- if (newObj instanceof JavaPersistentType) {
+ if (newObj instanceof PersistentType) {
if (context.getTargetContainer() instanceof Diagram) {
- JavaPersistentType jpt = (JavaPersistentType) newObj;
+ PersistentType jpt = (PersistentType) newObj;
return checkJPTForAdding(jpt);
}
} else if (newObj instanceof ICompilationUnit) {
if (context.getTargetContainer() instanceof Diagram) {
ICompilationUnit cu = (ICompilationUnit) newObj;
- JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
+ PersistentType jpt = JPAEditorUtil.getJPType(cu);
return checkJPTForAdding(jpt);
}
} if (newObj instanceof SourceType) {
if (context.getTargetContainer() instanceof Diagram) {
ICompilationUnit cu = ((SourceType)newObj).getCompilationUnit();
- JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
+ PersistentType jpt = JPAEditorUtil.getJPType(cu);
return checkJPTForAdding(jpt);
}
}
return false;
}
- private boolean checkJPTForAdding(JavaPersistentType jpt) {
+ private boolean checkJPTForAdding(PersistentType jpt) {
if (jpt == null)
return false;
@@ -126,9 +130,9 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
public PictogramElement add(final IAddContext context) {
final IJPAEditorFeatureProvider fp = getFeatureProvider();
Object newObj = context.getNewObject();
- JavaPersistentType jpt = null;
- if (newObj instanceof JavaPersistentType) {
- jpt = (JavaPersistentType) newObj;
+ PersistentType jpt = null;
+ if (newObj instanceof PersistentType) {
+ jpt = (PersistentType) newObj;
} else if (newObj instanceof ICompilationUnit) {
ICompilationUnit cu = (ICompilationUnit) newObj;
jpt = JPAEditorUtil.getJPType(cu);
@@ -137,11 +141,29 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
ICompilationUnit cu = ((SourceType)newObj).getCompilationUnit();
jpt = JPAEditorUtil.getJPType(cu);
}
+
+// MappingFileRef fileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+// if(fileRef != null) {
+// if(fileRef.getPersistentType(jpt.getName()) != null){
+// jpt = fileRef.getPersistentType(jpt.getName());
+// }
+// }
+
//TODO this is wrong, should not need to do any of these updates or syncs.
//should be changing the dali model synchronously so that all the syncs/updates are completed
- //take a look at the JpaProjectManager.execute(Command, ExtendedCommandExecutor)
- jpt.getJavaResourceType().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ //take a look at the JpaProjectManager.execute(Command, ExtendedCommandExecutor)
+// JavaResourceType jrt = null;
+// if(jpt instanceof JavaPersistentType) {
+// jrt = ((JavaPersistentType)jpt).getJavaResourceType();
+// } else if (jpt instanceof OrmPersistentType){
+// jrt = ((OrmPersistentType)jpt).getJavaPersistentType().getJavaResourceType();
+// }
+//
+// if(jrt != null) {
+// jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+// }
+//
jpt.update();
jpt.synchronizeWithResourceModel();
@@ -152,7 +174,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
private void createEntity(final IAddContext context, final IJPAEditorFeatureProvider fp, final Diagram targetDiagram,
- final Wrp wrp, final JavaPersistentType jpt) {
+ final Wrp wrp, final PersistentType jpt) {
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(targetDiagram);
@@ -193,7 +215,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
});
}
- private void createCompartments(IAddContext context, JavaPersistentType jpt,
+ private void createCompartments(IAddContext context, PersistentType jpt,
ContainerShape entityShape) {
JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
primaryShape = createCompartmentRectangle(entityShape,
@@ -220,20 +242,32 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
}
- private void fillCompartments(JavaPersistentType jpt, ContainerShape entityShape) {
- String[] primaryKeyAnnotations = new String[] {JPAEditorConstants.ANNOTATION_ID, JPAEditorConstants.ANNOTATION_EMBEDDED_ID, JPAEditorConstants.ANNOTATION_MAPS_ID};
- for(String annotation : primaryKeyAnnotations){
- addCompartmentChildren(primaryShape, jpt, annotation, null);
+ private void fillCompartments(PersistentType jpt, ContainerShape entityShape) {
+ String[] primaryMappingKeys = new String[] {MappingKeys.ID_ATTRIBUTE_MAPPING_KEY, MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY, "derived-id"}; //$NON-NLS-1$
+ for(String mappingKey : primaryMappingKeys){
+ addCompartmentChildren(primaryShape, jpt, mappingKey);
}
- String[] relationAnnotations = new String[] {JPAEditorConstants.ANNOTATION_MANY_TO_MANY,
- JPAEditorConstants.ANNOTATION_MANY_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_MANY,
- JPAEditorConstants.ANNOTATION_ONE_TO_ONE};
- for(String annotation : relationAnnotations){
- addCompartmentChildren(relationShape, jpt, annotation, primaryKeyAnnotations);
+ String[] relationMappingKeys = new String[] {MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY,
+ MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY};
+ for(String mappingKey : relationMappingKeys){
+ addCompartmentChildren(relationShape, jpt, mappingKey);
}
- addBasicAttributes(basicShape, jpt);
+
+ addBasicAttributes(basicShape, jpt, Arrays.asList(primaryMappingKeys), Arrays.asList(relationMappingKeys));
GraphicsUpdater.updateEntityShape(entityShape);
}
+
+ private String getMappingKey(PersistentAttribute attr) {
+ AttributeMapping attrMapping = JpaArtifactFactory.instance().getAttributeMapping(attr);
+ if(attrMapping instanceof SingleRelationshipMapping2_0){
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attrMapping).getDerivedIdentity();
+ if(identity.usesIdDerivedIdentityStrategy() || identity.usesMapsIdDerivedIdentityStrategy()){
+ return "derived-id"; //$NON-NLS-1$
+ }
+ }
+ return attrMapping.getKey();
+ }
private ContainerShape createCompartmentRectangle(
ContainerShape entityShape, int y, String attribTxt,
@@ -283,38 +317,25 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
private void addCompartmentChildren(
- ContainerShape containerShape, JavaPersistentType jpt,
- String attributeAnnotations, String[] excludeAnnotations) {
- List<JavaSpecifiedPersistentAttribute> attributes = new ArrayList<JavaSpecifiedPersistentAttribute>();
+ ContainerShape containerShape, PersistentType jpt,
+ String attributeMappingKey) {
+ List<PersistentAttribute> attributes = new ArrayList<PersistentAttribute>();
- for (JavaSpecifiedPersistentAttribute attribute : jpt.getAttributes()) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(attribute);
- if (annotations.contains(attributeAnnotations) && canAddAttribute(annotations, excludeAnnotations)) {
+ for (PersistentAttribute attribute : jpt.getAttributes()) {
+ String mappingKey = getMappingKey(attribute);
+ if (attributeMappingKey.equals(mappingKey)) {
attributes.add(attribute);
}
}
addAttributes(containerShape, attributes);
}
- private boolean canAddAttribute(HashSet<String> annotations, String[] excludeAnnotations){
- if(excludeAnnotations == null || excludeAnnotations.length == 0)
- return true;
- for(String annotation : excludeAnnotations){
- if(annotations.contains(annotation))
- return false;
- }
-
- return true;
- }
-
- private void addBasicAttributes(ContainerShape containerShape, JavaPersistentType jpt){
- List<JavaSpecifiedPersistentAttribute> attributes = new ArrayList<JavaSpecifiedPersistentAttribute>();
-
- for (JavaSpecifiedPersistentAttribute attribute : jpt.getAttributes()){
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(attribute);
- if(!(annotations.contains(JPAEditorConstants.ANNOTATION_ID))&& !(annotations.contains(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) && !(annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) &&
- !(annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) && !(annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_MANY))&&
- !(annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)) && !(annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)) || annotations.isEmpty()){
+ private void addBasicAttributes(ContainerShape containerShape, PersistentType jpt, List<String> primaryKeyMappings, List<String> relationshipMappings){
+ List<PersistentAttribute> attributes = new ArrayList<PersistentAttribute>();
+
+ for (PersistentAttribute attribute : jpt.getAttributes()){
+ String mappingKey = getMappingKey(attribute);
+ if(!(primaryKeyMappings.contains(mappingKey)) && !(relationshipMappings.contains(mappingKey))){
attributes.add(attribute);
}
}
@@ -322,9 +343,9 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
private void addAttributes(ContainerShape entityShape,
- List<JavaSpecifiedPersistentAttribute> attributes) {
+ List<PersistentAttribute> attributes) {
for (int i = 0; i < attributes.size(); i++) {
- JavaSpecifiedPersistentAttribute jpa = attributes.get(i);
+ PersistentAttribute jpa = attributes.get(i);
addAttribute(jpa, entityShape);
}
}
@@ -371,7 +392,7 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
return typeIconId;
}
- private ContainerShape addHeader(JavaPersistentType addedWrapper,
+ private ContainerShape addHeader(PersistentType addedWrapper,
ContainerShape entityShape,
int width,
JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot) {
@@ -433,11 +454,11 @@ public class AddJPAEntityFeature extends AbstractAddShapeFeature {
}
- private void addAttribute(JavaSpecifiedPersistentAttribute pa,
+ private void addAttribute(PersistentAttribute pa,
ContainerShape compartmentShape) {
IJPAEditorFeatureProvider fp = getFeatureProvider();
fp.putKeyToBusinessObject(fp.getKeyForBusinessObject(pa), pa);
- JavaPersistentType jpt = (JavaPersistentType)pa.getParent();
+ PersistentType jpt = (PersistentType) pa.getParent();
String key = fp.getKeyForBusinessObject(jpt);
if (fp.getBusinessObjectForKey(key) == null)
fp.putKeyToBusinessObject(key, jpt);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java
index 68906ac2d3..82b70c722b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/AddRelationFeature.java
@@ -21,7 +21,6 @@ import static org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.R
import static org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelType.ONE_TO_MANY;
import static org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation.RelType.ONE_TO_ONE;
-import java.util.HashSet;
import java.util.List;
import org.eclipse.emf.transaction.RecordingCommand;
@@ -38,10 +37,12 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorImageCreator;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageCreator;
@@ -115,7 +116,7 @@ public class AddRelationFeature extends AbstractAddFeature {
AddBendpointContext ctx = new AddBendpointContext(connection, p.x, p.y, i);
IAddBendpointFeature ft =getFeatureProvider().getAddBendpointFeature(ctx);
ft.addBendpoint(ctx);
- }
+ }
addDecorators(connection, relation);
addTextDecorators(connection, relation);
return connection;
@@ -195,33 +196,24 @@ public class AddRelationFeature extends AbstractAddFeature {
}
private void addOneToOneTextDecorator(FreeFormConnection c, RelDir direction, IRelation rel) {
- OneToOneAnnotation a = null;
- Boolean optional;
boolean isOptional = false;
- if (RelDir.UNI.equals(direction)) {
- isOptional = true;
- } else {
- JavaSpecifiedPersistentAttribute inverse = rel.getInverse().getAttributeNamed(rel.getInverseAttributeName());
- JavaAttributeMapping mapping = inverse.getMapping();
- a = (OneToOneAnnotation)mapping.getMappingAnnotation();
- if (a != null) {
- optional = a.getOptional();
- isOptional = (optional == null) ? true : optional.booleanValue();
- imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, isOptional ? JPAEditorConstants.CARDINALITY_ZERO_ONE : JPAEditorConstants.CARDINALITY_ONE, 0.0);
+ if (RelDir.BI.equals(direction)) {
+ PersistentAttribute inverse = rel.getInverse().getAttributeNamed(rel.getInverseAttributeName());
+ AttributeMapping mapping = JpaArtifactFactory.instance().getAttributeMapping(inverse);
+ if(mapping instanceof OneToOneMapping){
+ isOptional = ((OneToOneMapping)mapping).isOptional();
}
+ imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, isOptional ? JPAEditorConstants.CARDINALITY_ZERO_ONE : JPAEditorConstants.CARDINALITY_ONE, 0.0);
}
- JavaSpecifiedPersistentAttribute owner = rel.getOwner().getAttributeNamed(rel.getOwnerAttributeName());
+ PersistentAttribute owner = rel.getOwner().getAttributeNamed(rel.getOwnerAttributeName());
owner.update();
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(owner);
- if(isDerivedId(annotations)){
+ if(isDerivedId(owner)){
isOptional = false;
} else {
- JavaAttributeMapping mapping = owner.getMapping();
- a = (OneToOneAnnotation) mapping.getMappingAnnotation();
- if (a == null)
- return;
- optional = a.getOptional();
- isOptional = (optional == null) ? true : optional.booleanValue();
+ AttributeMapping mapping = JpaArtifactFactory.instance().getAttributeMapping(owner);
+ if(mapping instanceof OneToOneMapping){
+ isOptional = ((OneToOneMapping)mapping).isOptional();
+ }
}
imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, isOptional ? JPAEditorConstants.CARDINALITY_ZERO_ONE : JPAEditorConstants.CARDINALITY_ONE, 1.0);
imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, rel.getOwnerAttributeName(), 0.0);
@@ -230,9 +222,13 @@ public class AddRelationFeature extends AbstractAddFeature {
}
}
- private boolean isDerivedId(HashSet<String> annotations){
- if(annotations.contains(JPAEditorConstants.ANNOTATION_ID) || annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)){
- return true;
+ private boolean isDerivedId(PersistentAttribute attr){
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(attr);
+ if(attributeMapping instanceof SingleRelationshipMapping2_0){
+ DerivedIdentity2_0 derivedIdentity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdentity.usesIdDerivedIdentityStrategy() || derivedIdentity.usesMapsIdDerivedIdentityStrategy()){
+ return true;
+ }
}
return false;
}
@@ -247,18 +243,16 @@ public class AddRelationFeature extends AbstractAddFeature {
boolean isOptional = false;
imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, JPAEditorConstants.CARDINALITY_ZERO_N, 0.0);
imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, rel.getOwnerAttributeName(), 0.0);
- JavaSpecifiedPersistentAttribute owner = rel.getOwner().getAttributeNamed(rel.getOwnerAttributeName());
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(owner);
- if(isDerivedId(annotations)){
+ PersistentAttribute owner = rel.getOwner().getAttributeNamed(rel.getOwnerAttributeName());
+
+ if(isDerivedId(owner)){
isOptional = false;
} else {
- JavaAttributeMapping mapping = owner.getMapping();
- ManyToOneAnnotation a = (ManyToOneAnnotation) mapping.getMappingAnnotation();
- if (a == null)
- return;
- Boolean optional = a.getOptional();
- isOptional = (optional == null) ? true : optional.booleanValue();
+ AttributeMapping mapping = JpaArtifactFactory.instance().getAttributeMapping(owner);
+ if(mapping instanceof ManyToOneMapping) {
+ isOptional = ((ManyToOneMapping)mapping).isOptional();
+ }
}
imageCreator.createCardinalityConnectionDecorator(getDiagram(), c, isOptional ?
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java
index 6e0dcd5bfe..05a6f234be 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddAttributeButtonFeature.java
@@ -21,8 +21,8 @@ import org.eclipse.graphiti.features.context.ICreateContext;
import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -52,12 +52,13 @@ public class ClickAddAttributeButtonFeature extends AbstractCreateFeature {
public Object[] create(ICreateContext context) {
ContainerShape entityShape = context.getTargetContainer();
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(entityShape);
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(entityShape);
String newAttrName = JpaArtifactFactory.instance().createNewAttribute(jpt, false, getFeatureProvider());
- JavaSpecifiedPersistentAttribute newAttr = (JavaSpecifiedPersistentAttribute) jpt.resolveAttribute(newAttrName);
+ PersistentAttribute newAttr = jpt.resolveAttribute(newAttrName);
- getFeatureProvider().addAddIgnore((JavaPersistentType)newAttr.getParent(), newAttr.getName());
+ getFeatureProvider().addAddIgnore((PersistentType) newAttr.getParent(), newAttr.getName());
+ JpaArtifactFactory.instance().addOrmPersistentAttribute(jpt, newAttr, newAttr.getMappingKey());
addGraphicalRepresentation(context, newAttr);
getFeatureProvider().getDirectEditingInfo().setActive(true);
@@ -88,4 +89,4 @@ public class ClickAddAttributeButtonFeature extends AbstractCreateFeature {
return (IJPAEditorFeatureProvider)super.getFeatureProvider();
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java
index 3961e3f492..0336248bda 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickAddElementCollectionButtonFeature.java
@@ -22,10 +22,9 @@ import org.eclipse.graphiti.features.context.ICreateContext;
import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -54,14 +53,14 @@ public class ClickAddElementCollectionButtonFeature extends AbstractCreateFeatur
public Object[] create(ICreateContext context) {
ContainerShape entityShape = context.getTargetContainer();
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(entityShape);
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(entityShape);
String newAttrName = JpaArtifactFactory.instance().createNewAttribute(jpt, true, getFeatureProvider());
-
- JavaSpecifiedPersistentAttribute newAttr = (JavaSpecifiedPersistentAttribute) jpt.resolveAttribute(newAttrName);
- newAttr.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- newAttr.getResourceAttribute().addAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
-
- getFeatureProvider().addAddIgnore((JavaPersistentType)newAttr.getParent(), newAttr.getName());
+
+ PersistentAttribute newAttr = jpt.resolveAttribute(newAttrName);
+ newAttr.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ JpaArtifactFactory.instance().addOrmPersistentAttribute(jpt, newAttr, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+
+ getFeatureProvider().addAddIgnore((PersistentType) newAttr.getParent(), newAttr.getName());
addGraphicalRepresentation(context, newAttr);
getFeatureProvider().getDirectEditingInfo().setActive(true);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java
index a1c703c51c..5b62fc1cb5 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ClickRemoveAttributeButtonFeature.java
@@ -29,20 +29,19 @@ import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.ui.internal.utility.SynchronousUiCommandExecutor;
import org.eclipse.jpt.common.utility.command.Command;
import org.eclipse.jpt.jpa.core.JpaProjectManager;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation;
+import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.DeleteAttributeCommand;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -73,7 +72,7 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
}
private void deleteAttribute(ContainerShape pe, String attrName) {
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(pe.getContainer().getContainer());
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(pe.getContainer().getContainer());
deleteFieldFromCompositePKClass(attrName, jpt);
JpaArtifactFactory.instance().deleteAttribute(jpt, attrName, getFeatureProvider());
}
@@ -146,13 +145,13 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* @param fqn - te fully qualified name of the composite primary key class
* @return a collection of java persistent types that uses the same composite primary key class.
*/
- private Set<JavaPersistentType> getAllJPTWithSameIDClassOrEmbeddedId(JavaPersistentType jpt, String fqn){
- HashSet<JavaPersistentType> persistentTypes = new HashSet<JavaPersistentType>();
+ private Set<PersistentType> getAllJPTWithSameIDClassOrEmbeddedId(PersistentType jpt, String fqn){
+ HashSet<PersistentType> persistentTypes = new HashSet<PersistentType>();
ListIterator<PersistenceUnit> lit = jpt.getJpaProject().getContextModelRoot().getPersistenceXml().getRoot().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
for(PersistentType persistentType : pu.getPersistentTypes()){
- if(!persistentType.equals(jpt) && ((hasSameEmbeddedId((JavaPersistentType) persistentType, fqn)) || hasSameIdClass((JavaPersistentType) persistentType, fqn))){
- persistentTypes.add((JavaPersistentType) persistentType);
+ if(!persistentType.getName().equals(jpt.getName()) && ((hasSameEmbeddedId(persistentType, fqn)) || hasSameIdClass(persistentType, fqn))){
+ persistentTypes.add(persistentType);
}
}
return persistentTypes;
@@ -166,9 +165,9 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* @return true if the java persistent type has an id class annotation with the given
* fully qualified name, false otherwise.
*/
- private boolean hasSameIdClass(JavaPersistentType jpt, String fqn){
+ private boolean hasSameIdClass(PersistentType jpt, String fqn){
JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
- if(jpaFactory.hasIDClassAnnotation(jpt) && jpaFactory.getIdType(jpt).equals(fqn)){
+ if(jpaFactory.hasIDClass(jpt) && jpaFactory.getIdType(jpt).equals(fqn)){
return true;
}
@@ -183,9 +182,9 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* @return true, if the java persistent type has an embedded id attribute with the
* given fully qualified name.
*/
- private boolean hasSameEmbeddedId(JavaPersistentType jpt, String fqn){
+ private boolean hasSameEmbeddedId(PersistentType jpt, String fqn){
JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
- for(JavaSpecifiedPersistentAttribute jpa : ((JavaPersistentType)jpt).getAttributes()){
+ for(PersistentAttribute jpa : jpt.getAttributes()){
if(jpaFactory.isEmbeddedId(jpa) && JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa).equals(fqn)){
return true;
}
@@ -202,13 +201,14 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* @param jpt - the java persistent type from which the attribute is originally deleted
*/
private void deleteFieldFromCompositePKClass(String attrName,
- JavaPersistentType jpt) {
- JavaSpecifiedPersistentAttribute jpa = jpt.getAttributeNamed(attrName);
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
- if(annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE) || annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)){
- if(annotations.contains(JPAEditorConstants.ANNOTATION_ID)){
+ PersistentType jpt) {
+ PersistentAttribute jpa = jpt.getAttributeNamed(attrName);
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ if(attributeMapping instanceof SingleRelationshipMapping2_0){
+ DerivedIdentity2_0 derivedIdentity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdentity.usesIdDerivedIdentityStrategy()){
deleteFieldFromIdClassCompositePK(attrName, jpt);
- } else if(annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)){
+ } else if(derivedIdentity.usesMapsIdDerivedIdentityStrategy()){
deleteFieldFromEmbeddedIDCompositePK(jpt, jpa);
}
}
@@ -220,21 +220,25 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* @param jpt - the java persistent type from which the attribute is originally deleted
* @param jpa - the attribute to be deleted
*/
- private void deleteFieldFromEmbeddedIDCompositePK(JavaPersistentType jpt,
- JavaSpecifiedPersistentAttribute jpa) {
- Annotation ann = jpa.getResourceAttribute().getAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
- if(ann != null) {
- String attribName = ((MapsId2_0Annotation)ann).getValue();
- if(attribName == null)
- return;
- JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
- for(JavaSpecifiedPersistentAttribute jpa1 : jpt.getAttributes()){
- if(jpaFactory.isEmbeddedId(jpa1)){
- String fqn = JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa1);
- if(isDeleteAttributeAllowed(jpt, fqn)){
- JavaPersistentType embeddedJPT = jpaFactory.getContextPersistentType(jpt.getJpaProject(), fqn);
- if(embeddedJPT != null)
- jpaFactory.deleteAttribute(embeddedJPT, attribName, getFeatureProvider());
+ private void deleteFieldFromEmbeddedIDCompositePK(PersistentType jpt,
+ PersistentAttribute jpa) {
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ if(attributeMapping instanceof SingleRelationshipMapping2_0){
+ DerivedIdentity2_0 derivedIdentity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdentity.usesMapsIdDerivedIdentityStrategy()){
+ String attribName = derivedIdentity.getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName();
+ if(attribName == null)
+ return;
+ JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
+ for(PersistentAttribute jpa1 : jpt.getAttributes()){
+ if(jpaFactory.isEmbeddedId(jpa1)){
+ String fqn = JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa1);
+ if(isDeleteAttributeAllowed(jpt, fqn)){
+ PersistentType embeddedJPT = jpaFactory.getContextPersistentType(jpt.getJpaProject(), fqn);
+ if(embeddedJPT != null)
+ jpaFactory.deleteAttribute(embeddedJPT, attribName, getFeatureProvider());
+ }
}
}
}
@@ -247,7 +251,7 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* @param jpt - the java persistent type from which the attribute is originally deleted
*/
private void deleteFieldFromIdClassCompositePK(String attrName,
- JavaPersistentType jpt) {
+ PersistentType jpt) {
JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
String idClassFQN = jpaFactory.getIdType(jpt);
if(idClassFQN != null && isDeleteAttributeAllowed(jpt, idClassFQN)){
@@ -273,14 +277,16 @@ public class ClickRemoveAttributeButtonFeature extends DefaultDeleteFeature {
* with the given fully qualified name and an derived identifiers; false - if there is at least
* one java persistent type with composite primary class, that has an derived id.
*/
- private boolean isDeleteAttributeAllowed(JavaPersistentType jpt, String fqn){
- Set<JavaPersistentType> jpts = getAllJPTWithSameIDClassOrEmbeddedId(jpt, fqn);
- for(JavaPersistentType perType : jpts){
- for(JavaSpecifiedPersistentAttribute jpa : perType.getAttributes()){
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
- if((annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE) || annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) &&
- (annotations.contains(JPAEditorConstants.ANNOTATION_ID) || annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID))){
- return false;
+ private boolean isDeleteAttributeAllowed(PersistentType jpt, String fqn){
+ Set<PersistentType> jpts = getAllJPTWithSameIDClassOrEmbeddedId(jpt, fqn);
+ for(PersistentType perType : jpts){
+ for(PersistentAttribute jpa : perType.getAttributes()){
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ if(attributeMapping instanceof SingleRelationshipMapping2_0){
+ DerivedIdentity2_0 derivedIdentity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(derivedIdentity.usesIdDerivedIdentityStrategy() || derivedIdentity.usesMapsIdDerivedIdentityStrategy()){
+ return false;
+ }
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CollapseEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CollapseEntityFeature.java
index b1d1d64abe..8e269eceb3 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CollapseEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CollapseEntityFeature.java
@@ -28,7 +28,7 @@ import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
@@ -77,7 +77,7 @@ public class CollapseEntityFeature extends AbstractCustomFeature implements ICus
for (int i = 0; i < pes.length; i++) {
PictogramElement pe = pes[i];
Object bo = getBusinessObjectForPictogramElement(pe);
- if (!(bo instanceof JavaPersistentType)) {
+ if (!(bo instanceof PersistentType)) {
return false;
}
if (!collapsePossible) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java
index 84f76a6cfb..e568f85100 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateEmbeddableFeature.java
@@ -27,7 +27,8 @@ import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -62,7 +63,7 @@ public class CreateEmbeddableFeature extends AbstractCreateFeature {
targetProject = jpaProject.getProject();
} else {
Shape sh = shapes.get(0);
- JavaPersistentType jpt = (JavaPersistentType) getFeatureProvider()
+ PersistentType jpt = (PersistentType) getFeatureProvider()
.getBusinessObjectForPictogramElement(sh);
if (jpt == null)
return new Object[] {};
@@ -93,10 +94,13 @@ public class CreateEmbeddableFeature extends AbstractCreateFeature {
// jpaProject.updateAndWait();
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(
jpaProject);
- JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT(
+ PersistentType jpt = JpaArtifactFactory.instance().getJPT(
embeddableName, pu);
if (jpt != null) {
+ if(JPADiagramPropertyPage.doesSupportOrmXml(targetProject)) {
+ JpaArtifactFactory.instance().addPersistentTypeToORMXml(jpaProject, embeddableName, MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
+ }
addGraphicalRepresentation(context, jpt);
IWorkbenchSite ws = ((IEditorPart) getDiagramEditor()).getSite();
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java
index 09f4bf9f15..1aaacb2d4e 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateInheritedEntityFeature.java
@@ -28,7 +28,6 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.Embeddable;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-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.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
@@ -50,7 +49,7 @@ public class CreateInheritedEntityFeature extends AbstractCreateConnectionFeatur
}
public boolean canCreate(ICreateConnectionContext context) {
- JavaPersistentType superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ PersistentType superclass = getPersistentType(context.getSourceAnchor());
if (superclass == null)
return false;
if (context.getTargetAnchor() == null)
@@ -61,7 +60,7 @@ public class CreateInheritedEntityFeature extends AbstractCreateConnectionFeatur
}
public Connection create(ICreateConnectionContext context) {
- JavaPersistentType mappedSuperclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ PersistentType mappedSuperclass = getPersistentType(context.getSourceAnchor());
CreateJPAEntityFeature createEntityFeature = null;
try {
createEntityFeature = new CreateJPAEntityFeature(
@@ -72,7 +71,7 @@ public class CreateInheritedEntityFeature extends AbstractCreateConnectionFeatur
}
ICreateContext ctx = new CreateContext();
Object[] res = createEntityFeature.create(ctx);
- JavaPersistentType newEntity = (JavaPersistentType)res[0];
+ PersistentType newEntity = (PersistentType)res[0];
AddJPAEntityFeature ft = new AddJPAEntityFeature(getFeatureProvider(), true);
AddContext cont = new AddContext();
cont.setTargetContainer(getFeatureProvider().getDiagram());
@@ -83,7 +82,7 @@ public class CreateInheritedEntityFeature extends AbstractCreateConnectionFeatur
}
public boolean canStartConnection(ICreateConnectionContext context) {
- JavaPersistentType superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ PersistentType superclass = getPersistentType(context.getSourceAnchor());
if (superclass == null)
return false;
return true;
@@ -137,8 +136,8 @@ public class CreateInheritedEntityFeature extends AbstractCreateConnectionFeatur
private void disableAllEmbeddables(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt))
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isEmbeddable(jpt))
getFeatureProvider().setGrayColor(jpt);
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java
index da0d7ee679..08b39f44ad 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateIsARelationFeature.java
@@ -26,9 +26,8 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-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.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -41,7 +40,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class CreateIsARelationFeature extends AbstractCreateConnectionFeature {
- private JavaPersistentType superclass;
+ private PersistentType superclass;
public CreateIsARelationFeature(IFeatureProvider fp) {
this(fp, JPAEditorMessages.CreateIsARelationFeature_CreateIsARelationFeatureName, JPAEditorMessages.CreateIsARelationFeature_CreateIsARelationFeatureDescription);
@@ -53,33 +52,33 @@ public class CreateIsARelationFeature extends AbstractCreateConnectionFeature {
}
public boolean canCreate(ICreateConnectionContext context) {
- superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType subclass = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ superclass = getPersistentType(context.getSourceAnchor());
+ PersistentType subclass = getPersistentType(context.getTargetAnchor());
if ((superclass == null) || (subclass == null))
return false;
- if(superclass.equals(subclass))
+ if(superclass.getName().equals(subclass.getName()))
return false;
- if (!JpaArtifactFactory.instance().hasEntityAnnotation(subclass) || subclass.getSuperPersistentType() != null)
+ if (!JpaArtifactFactory.instance().isEntity(subclass) || subclass.getSuperPersistentType() != null)
return false;
- if(!JpaArtifactFactory.instance().hasEntityAnnotation(superclass) &&
- !JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(superclass))
+ if(!JpaArtifactFactory.instance().isEntity(superclass) &&
+ !JpaArtifactFactory.instance().isMappedSuperclass(superclass))
return false;
return true;
}
public Connection create(ICreateConnectionContext context) {
- superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType subclass = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ superclass = getPersistentType(context.getSourceAnchor());
+ PersistentType subclass = getPersistentType(context.getTargetAnchor());
- if(JpaArtifactFactory.instance().hasOrInheritsPrimaryKey(superclass)){
- for(JavaSpecifiedPersistentAttribute jpa : subclass.getAttributes()){
+ if(JpaArtifactFactory.instance().hasOrInheritsPrimaryKey(superclass)){
+ for(PersistentAttribute jpa : subclass.getAttributes()){
if(jpa.getMappingKey().equals(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY)){
- jpa.setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
} else if(jpa.getMappingKey().equals(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY)) {
- jpa.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
}
}
}
@@ -100,7 +99,7 @@ public class CreateIsARelationFeature extends AbstractCreateConnectionFeature {
}
public boolean canStartConnection(ICreateConnectionContext context) {
- superclass = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ superclass = getPersistentType(context.getSourceAnchor());
if (superclass == null)
return false;
@@ -159,8 +158,8 @@ public class CreateIsARelationFeature extends AbstractCreateConnectionFeature {
getRoot().getPersistenceUnits().iterator().next();
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(!JpaArtifactFactory.instance().hasEntityAnnotation(jpt) || superclass.equals(jpt) || jpt.getSuperPersistentType() != null){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(!JpaArtifactFactory.instance().isEntity(jpt) || superclass.getName().equals(jpt.getName()) || jpt.getSuperPersistentType() != null){
getFeatureProvider().setGrayColor(jpt);
}
}
@@ -179,8 +178,8 @@ public class CreateIsARelationFeature extends AbstractCreateConnectionFeature {
getRoot().getPersistenceUnits().iterator().next();
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt)){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isEmbeddable(jpt)){
getFeatureProvider().setGrayColor(jpt);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
index 998e273ae6..73b0900efe 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateJPAEntityFeature.java
@@ -17,6 +17,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.util.List;
import java.util.ListIterator;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -34,7 +35,8 @@ import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
@@ -53,7 +55,7 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
private IPreferenceStore jpaPreferenceStore = JPADiagramEditorPlugin.getDefault().getPreferenceStore();
private boolean isMappedSuperclassChild;
- private JavaPersistentType mappedSuperclass;
+ private PersistentType mappedSuperclass;
private String mappedSuperclassName;
private String mappedSuperclassPackage;
private boolean superHasPrimarykey;
@@ -86,7 +88,7 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
}
public CreateJPAEntityFeature(IJPAEditorFeatureProvider fp,
- JavaPersistentType mappedSuperclass) throws JavaModelException {
+ PersistentType mappedSuperclass) throws JavaModelException {
this(fp);
this.isMappedSuperclassChild = true;
this.mappedSuperclass = mappedSuperclass;
@@ -109,7 +111,7 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
targetProject = jpaProject.getProject();
} else {
Shape sh = shapes.get(0);
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(sh);
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(sh);
if (jpt == null)
return new Object[] {};
jpaProject = jpt.getJpaProject();
@@ -142,7 +144,7 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
getJPAEditorUtil().
createEntityInProject(targetProject, entityName, jpaPreferenceStore,
isMappedSuperclassChild, mappedSuperclassName,
- mappedSuperclassPackage, "id", superHasPrimarykey); //$NON-NLS-1$
+ mappedSuperclassPackage, "id", superHasPrimarykey); //$NON-NLS-1$
}
} catch (Exception e1) {
JPADiagramEditorPlugin.logError("Cannot create an entity in the project " + targetProject.getName(), e1); //$NON-NLS-1$
@@ -157,7 +159,7 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
ListIterator<PersistenceUnit> lit = jpaProject.getContextModelRoot().getPersistenceXml().getRoot().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
- JavaPersistentType jpt = (JavaPersistentType)pu.getPersistentType(entityName);
+ PersistentType jpt = pu.getPersistentType(entityName);
int cnt = 0;
while ((jpt == null) && (cnt < 25)) {
@@ -166,11 +168,16 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
} catch (InterruptedException e) {
JPADiagramEditorPlugin.logError("Thread sleep interrupted", e); //$NON-NLS-1$
}
- jpt = (JavaPersistentType)pu.getPersistentType(entityName);
+ jpt = pu.getPersistentType(entityName);
cnt++;
}
if (jpt != null) {
+ if(JPADiagramPropertyPage.doesSupportOrmXml(targetProject)) {
+ JpaArtifactFactory.instance().addPersistentTypeToORMXml(jpaProject, entityName, MappingKeys.ENTITY_TYPE_MAPPING_KEY);
+ }
+// jpt = pu.getPersistentType(entityName);
+
addGraphicalRepresentation(context, jpt);
IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
@@ -195,4 +202,4 @@ public class CreateJPAEntityFeature extends AbstractCreateFeature {
return getFeatureProvider().getMoinIntegrationUtil().getProjectByDiagram(getDiagram());
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java
index 06faadc59b..b64de9f168 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyBiDirRelationFeature.java
@@ -15,17 +15,18 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToManyBiDirRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -39,9 +40,9 @@ public class CreateManyToManyBiDirRelationFeature extends CreateManyToManyRelati
}
@Override
- public ManyToManyBiDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source, PictogramElement target, JavaPersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ public ManyToManyBiDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source, PictogramElement target, PersistentType embeddingEntity) {
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String ownerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = ownerAttributeName;
@@ -70,16 +71,14 @@ public class CreateManyToManyBiDirRelationFeature extends CreateManyToManyRelati
*/
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if (refs.size() != 1)
return false;
- for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION) || annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
+ for (HasReferanceRelation ref : refs) {
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if ((attributeMapping instanceof ElementCollectionMapping2_0) || ( attributeMapping instanceof EmbeddedIdMapping)) {
return false;
- }
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java
index a1050dd361..d667bdb13b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToManyUniDirRelationFeature.java
@@ -15,17 +15,18 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToManyUniDirRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -39,9 +40,9 @@ public class CreateManyToManyUniDirRelationFeature extends CreateManyToManyRelat
}
@Override
- public ManyToManyUniDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source, PictogramElement target, JavaPersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ public ManyToManyUniDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source, PictogramElement target, PersistentType embeddingEntity) {
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String attributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = attributeName;
@@ -59,17 +60,15 @@ public class CreateManyToManyUniDirRelationFeature extends CreateManyToManyRelat
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if (refs.isEmpty()) {
return false;
} else {
for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION) || annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if ((attributeMapping instanceof ElementCollectionMapping2_0) || ( attributeMapping instanceof EmbeddedIdMapping)) {
return false;
- }
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java
index 54cb460f80..720a406146 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneBiDirRelationFeature.java
@@ -15,17 +15,17 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToOneBiDirRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -40,9 +40,9 @@ public class CreateManyToOneBiDirRelationFeature extends CreateManyToOneRelation
@Override
public ManyToOneBiDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source,
- PictogramElement target, JavaPersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ PictogramElement target, PersistentType embeddingEntity) {
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String ownerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = ownerAttributeName;
@@ -69,17 +69,15 @@ public class CreateManyToOneBiDirRelationFeature extends CreateManyToOneRelation
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if (refs.size() != 1){
return false;
} else {
for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
- return false;
- }
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if (attributeMapping instanceof EmbeddedIdMapping) {
+ return false;
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java
index 102366cd5b..3a78762f08 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateManyToOneUniDirRelationFeature.java
@@ -15,17 +15,17 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToOneUniDirRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -40,9 +40,9 @@ public class CreateManyToOneUniDirRelationFeature extends CreateManyToOneRelatio
}
@Override
- public ManyToOneUniDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source, PictogramElement target, JavaPersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ public ManyToOneUniDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source, PictogramElement target, PersistentType embeddingEntity) {
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String attributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = attributeName;
@@ -62,17 +62,15 @@ public class CreateManyToOneUniDirRelationFeature extends CreateManyToOneRelatio
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if (refs.isEmpty()){
return false;
} else {
for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
- return false;
- }
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if (attributeMapping instanceof EmbeddedIdMapping) {
+ return false;
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java
index f1a657f75b..34be661496 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateMappedSuperclassFeature.java
@@ -16,6 +16,7 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.util.List;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICreateContext;
@@ -25,7 +26,8 @@ import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -63,7 +65,7 @@ public class CreateMappedSuperclassFeature extends
targetProject = jpaProject.getProject();
} else {
Shape sh = shapes.get(0);
- JavaPersistentType jpt = (JavaPersistentType) getFeatureProvider()
+ PersistentType jpt = (PersistentType) getFeatureProvider()
.getBusinessObjectForPictogramElement(sh);
if (jpt == null)
return new Object[] {};
@@ -89,9 +91,12 @@ public class CreateMappedSuperclassFeature extends
}
// jpaProject.updateAndWait();
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
- JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT(mappedSuperclassName, pu);
+ PersistentType jpt = JpaArtifactFactory.instance().getJPT(mappedSuperclassName, pu);
if (jpt != null) {
+ if(JPADiagramPropertyPage.doesSupportOrmXml(targetProject)) {
+ JpaArtifactFactory.instance().addPersistentTypeToORMXml(jpaProject, mappedSuperclassName, MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
+ }
addGraphicalRepresentation(context, jpt);
IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyRelationFeature.java
index 58b58b455f..0558f8cc0f 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyRelationFeature.java
@@ -15,12 +15,13 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
abstract class CreateOneToManyRelationFeature
@@ -35,17 +36,15 @@ abstract class CreateOneToManyRelationFeature
*/
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if(refs.isEmpty()){
return false;
} else {
for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION) || annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if ((attributeMapping instanceof ElementCollectionMapping2_0) || ( attributeMapping instanceof EmbeddedIdMapping)) {
return false;
- }
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java
index f6810ea83c..96dcd9dc9f 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToManyUniDirRelationFeature.java
@@ -16,7 +16,7 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
@@ -35,9 +35,9 @@ public class CreateOneToManyUniDirRelationFeature extends CreateOneToManyRelatio
@Override
public OneToManyUniDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source,
- PictogramElement target, JavaPersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ PictogramElement target, PersistentType embeddingEntity) {
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String attributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = attributeName;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java
index b082a473eb..1506e2c3e1 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneBiDirRelationFeature.java
@@ -15,17 +15,17 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.OneToOneBiDirRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -40,9 +40,9 @@ public class CreateOneToOneBiDirRelationFeature extends CreateOneToOneRelationFe
@Override
public OneToOneBiDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source,
- PictogramElement target, JavaPersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ PictogramElement target, PersistentType embeddingEntity) {
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String ownerAttributeName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = ownerAttributeName;
@@ -72,17 +72,15 @@ public class CreateOneToOneBiDirRelationFeature extends CreateOneToOneRelationFe
*/
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if (refs.size() != 1){
return false;
} else {
for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
- return false;
- }
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if (attributeMapping instanceof EmbeddedIdMapping) {
+ return false;
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java
index bcc7831ba9..f4ecc05e92 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateOneToOneUniDirRelationFeature.java
@@ -15,17 +15,17 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
import java.util.Set;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.OneToOneUniDirRelation;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -40,10 +40,10 @@ public class CreateOneToOneUniDirRelationFeature extends CreateOneToOneRelationF
@Override
public OneToOneUniDirRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source,
- PictogramElement target, JavaPersistentType embeddingEntity) {
+ PictogramElement target, PersistentType embeddingEntity) {
- JavaPersistentType owner = (JavaPersistentType)(getBusinessObjectForPictogramElement(source));
- JavaPersistentType inverse = (JavaPersistentType)(getBusinessObjectForPictogramElement(target));
+ PersistentType owner = (PersistentType)(getBusinessObjectForPictogramElement(source));
+ PersistentType inverse = (PersistentType)(getBusinessObjectForPictogramElement(target));
String name = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(inverse));
String nameWithNonCapitalLetter = name;
@@ -66,17 +66,15 @@ public class CreateOneToOneUniDirRelationFeature extends CreateOneToOneRelationF
*/
@Override
protected boolean isRelationshipPossible() {
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelsByEmbeddableWithEntity(owner, getFeatureProvider());
if (refs.isEmpty()){
return false;
} else {
for (HasReferanceRelation ref : refs) {
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ref.getEmbeddedAnnotatedAttribute());
- for (String annotationName : annotations) {
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)) {
- return false;
- }
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ref.getEmbeddedAnnotatedAttribute());
+ if (attributeMapping instanceof EmbeddedIdMapping) {
+ return false;
}
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java
index 027a411f96..981ab721cf 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/CreateRelationFeature.java
@@ -28,7 +28,6 @@ import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.Embeddable;
import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-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.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
@@ -41,7 +40,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
abstract public class CreateRelationFeature extends AbstractCreateConnectionFeature {
- protected JavaPersistentType owner;
+ protected PersistentType owner;
protected boolean isDerivedIdFeature;
@@ -51,30 +50,30 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
}
public boolean canCreate(ICreateConnectionContext context) {
- owner = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType inverse = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ owner = getPersistentType(context.getSourceAnchor());
+ PersistentType inverse = getPersistentType(context.getTargetAnchor());
if ((owner == null) || (inverse == null))
return false;
- if (JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(inverse)
- || JpaArtifactFactory.instance().hasEmbeddableAnnotation(inverse))
+ if (JpaArtifactFactory.instance().isMappedSuperclass(inverse)
+ || JpaArtifactFactory.instance().isEmbeddable(inverse))
return false;
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
if(!isRelationshipPossible() || isParentEntity(inverse)
|| JPAEditorUtil.checkJPAFacetVersion(owner.getJpaProject(), JPAEditorUtil.JPA_PROJECT_FACET_10))
return false;
}
if ((this instanceof ICreateBiDirRelationFeature) &&
- (JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(owner)))
+ (JpaArtifactFactory.instance().isMappedSuperclass(owner)))
return false;
- if(isDerivedIdFeature && (!JpaArtifactFactory.instance().hasEntityAnnotation(owner)
- || !JpaArtifactFactory.instance().hasEntityAnnotation(inverse))){
+ if(isDerivedIdFeature && (!JpaArtifactFactory.instance().isEntity(owner)
+ || !JpaArtifactFactory.instance().isEntity(inverse))){
return false;
}
return true;
}
public boolean canStartConnection(ICreateConnectionContext context) {
- owner = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ owner = getPersistentType(context.getSourceAnchor());
if (owner == null)
return false;
return true;
@@ -82,16 +81,16 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
public Connection create(ICreateConnectionContext context) {
Connection newConnection = null;
- JavaPersistentType owner = (JavaPersistentType) getPersistentType(context.getSourceAnchor());
- JavaPersistentType inverse = (JavaPersistentType) getPersistentType(context.getTargetAnchor());
+ PersistentType owner = getPersistentType(context.getSourceAnchor());
+ PersistentType inverse = getPersistentType(context.getTargetAnchor());
if (owner != null && inverse != null) {
-// List<JavaPersistentType> embeddingEntities = new ArrayList<JavaPersistentType>();
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner) && (this instanceof ICreateBiDirRelationFeature)){
+// List<PersistentType> embeddingEntities = new ArrayList<PersistentType>();
+ if(JpaArtifactFactory.instance().isEmbeddable(owner) && (this instanceof ICreateBiDirRelationFeature)){
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelationsByEmbeddable(owner, getFeatureProvider());
// if(refs.size()>1){
// SelectEmbeddingEntitiesDialog dlg = new SelectEmbeddingEntitiesDialog(owner, getFeatureProvider());
-// List<JavaPersistentType> selectedJPTs = dlg.selectInverseRelationshipEntities();
+// List<PersistentType> selectedJPTs = dlg.selectInverseRelationshipEntities();
// if(selectedJPTs == null || selectedJPTs.isEmpty()){
// return null;
// }
@@ -100,7 +99,7 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
// embeddingEntities.add(refs.iterator().next().getEmbeddingEntity());
// }
-// for(JavaPersistentType embeddingJPT : embeddingEntities) {
+// for(PersistentType embeddingJPT : embeddingEntities) {
newConnection = makeRelation(context, refs.iterator().next().getEmbeddingEntity());
// }
} else {
@@ -111,7 +110,7 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
}
private Connection makeRelation(ICreateConnectionContext context,
- JavaPersistentType embeddingJPT) {
+ PersistentType embeddingJPT) {
Connection newConnection;
AbstractRelation rel = createRelation(getFeatureProvider(), context.getSourceAnchor().getParent(),
context.getTargetAnchor().getParent(), embeddingJPT);
@@ -143,7 +142,7 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
* Creates a new OneToOneRelation between two PersistentType classes.
*/
abstract protected AbstractRelation createRelation(IJPAEditorFeatureProvider fp, PictogramElement source,
- PictogramElement target, JavaPersistentType type);
+ PictogramElement target, PersistentType type);
@Override
public IJPAEditorFeatureProvider getFeatureProvider() {
@@ -186,17 +185,17 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
JpaProject project = ModelIntegrationUtil.getProjectByDiagram(d.getName());
PersistenceUnit unit = project.getContextModelRoot().getPersistenceXml().
getRoot().getPersistenceUnits().iterator().next();
- if(JpaArtifactFactory.instance().hasEntityAnnotation(owner)){
+ if(JpaArtifactFactory.instance().isEntity(owner)){
disableAllJPTsThatAreNotEntities(unit);
}
- else if(JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(owner)){
+ else if(JpaArtifactFactory.instance().isMappedSuperclass(owner)){
if (isDerivedIdFeature || (this instanceof ICreateBiDirRelationFeature)){
disableAllPersistentTypes(unit);
} else {
disableAllJPTsThatAreNotEntities(unit);
}
}
- else if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)) {
+ else if(JpaArtifactFactory.instance().isEmbeddable(owner)) {
if(isDerivedIdFeature || !isRelationshipPossible() || JPAEditorUtil.checkJPAFacetVersion(owner.getJpaProject(), JPAEditorUtil.JPA_PROJECT_FACET_10)) {
disableAllPersistentTypes(unit);
} else {
@@ -213,8 +212,8 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
private void disableAllJPTsThatAreNotEntities(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt) || JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(jpt) || isParentEntity(jpt)){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isEmbeddable(jpt) || JpaArtifactFactory.instance().isMappedSuperclass(jpt) || isParentEntity(jpt)){
getFeatureProvider().setGrayColor(jpt);
}
@@ -223,14 +222,14 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
}
/**
- * Disable (color in gray) all {@link JavaPersistentType}s registered in the
+ * Disable (color in gray) all {@link PersistentType}s registered in the
* persistence unit.
* @param unit
*/
private void disableAllPersistentTypes(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
+ final PersistentType jpt = classRef.getJavaPersistentType();
getFeatureProvider().setGrayColor(jpt);
}
}
@@ -250,9 +249,9 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if((isJPA10Project && JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt))
- || (isDerivedIdFeature && !JpaArtifactFactory.instance().hasEntityAnnotation(jpt))){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if((isJPA10Project && JpaArtifactFactory.instance().isEmbeddable(jpt))
+ || (isDerivedIdFeature && !JpaArtifactFactory.instance().isEntity(jpt))){
getFeatureProvider().setGrayColor(jpt);
}
@@ -260,12 +259,12 @@ abstract public class CreateRelationFeature extends AbstractCreateConnectionFeat
}
}
- private boolean isParentEntity(JavaPersistentType jpt) {
- if(JpaArtifactFactory.instance().hasEntityAnnotation(jpt)){
+ private boolean isParentEntity(PersistentType jpt) {
+ if(JpaArtifactFactory.instance().isEntity(jpt)){
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelationsByEmbeddable(owner, getFeatureProvider());
if(!refs.isEmpty()){
for(HasReferanceRelation ref : refs){
- if(ref.getEmbeddingEntity().equals(jpt)){
+ if(ref.getEmbeddingEntity().getName().equals(jpt.getName())){
return true;
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java
index 5499d13fd3..6570762398 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteJPAEntityFeature.java
@@ -16,6 +16,7 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.text.MessageFormat;
+
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -27,7 +28,7 @@ import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -47,7 +48,7 @@ public class DeleteJPAEntityFeature extends DefaultDeleteFeature {
public void delete(final IDeleteContext context) {
PictogramElement pe = context.getPictogramElement();
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(pe);
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(pe);
entityClassName = jpt.getName();
entityName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt));
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(pe);
@@ -66,15 +67,15 @@ public class DeleteJPAEntityFeature extends DefaultDeleteFeature {
@Override
protected void deleteBusinessObject(Object bo) {
- JavaPersistentType jpt = null;
- if (bo instanceof JavaPersistentType) {
- jpt = (JavaPersistentType) bo;
+ PersistentType jpt = null;
+ if (bo instanceof PersistentType) {
+ jpt = (PersistentType) bo;
JpaProject jpaProject = jpt.getJpaProject();
String name = jpt.getName();
-
+ JpaArtifactFactory.instance().deletePersistentTypeFromORMXml(jpaProject, jpt);
// JpaArtifactFactory.instance().forceSaveEntityClass(jpt, getFeatureProvider());
JpaArtifactFactory.instance().deleteEntityClass(jpt, getFeatureProvider());
if (! JpaPreferences.getDiscoverAnnotatedClasses(jpt.getJpaProject().getProject())) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
index bcf725bf9d..4fd388b487 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DeleteRelationFeature.java
@@ -22,8 +22,8 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.features.DefaultDeleteFeature;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
@@ -93,8 +93,8 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
private void deleteInheritanceRelation(Object businessObjectForPictogramElement) {
IsARelation rel = (IsARelation)businessObjectForPictogramElement;
- JavaPersistentType superclass = rel.getSuperclass();
- JavaPersistentType subclass = rel.getSubclass();
+ PersistentType superclass = rel.getSuperclass();
+ PersistentType subclass = rel.getSubclass();
JpaArtifactFactory.instance().buildHierarchy(superclass, subclass, false);
JPAEditorUtil.getCompilationUnit(subclass);
@@ -105,7 +105,7 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
private void deleteEmbeddedRelation(Object businessObjectForPictogramElement) {
HasReferanceRelation rel = (HasReferanceRelation)businessObjectForPictogramElement;
- JavaSpecifiedPersistentAttribute attribute = rel.getEmbeddedAnnotatedAttribute();
+ PersistentAttribute attribute = rel.getEmbeddedAnnotatedAttribute();
PictogramElement textShape = getFeatureProvider().getPictogramElementForBusinessObject(attribute);
if(textShape == null)
return;
@@ -119,7 +119,7 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
if (rel instanceof IUnidirectionalRelation) {
IUnidirectionalRelation relation = (IUnidirectionalRelation)rel;
- JavaSpecifiedPersistentAttribute attribute = relation.getAnnotatedAttribute();
+ PersistentAttribute attribute = relation.getAnnotatedAttribute();
PictogramElement textShape = getFeatureProvider().getPictogramElementForBusinessObject(attribute);
if(textShape == null)
return;
@@ -131,15 +131,14 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
if (rel instanceof IBidirectionalRelation) {
IBidirectionalRelation relation = (IBidirectionalRelation)(rel);
ClickRemoveAttributeButtonFeature feat = new ClickRemoveAttributeButtonFeature(getFeatureProvider());
-
- JavaSpecifiedPersistentAttribute ownerAttribute = relation.getOwnerAnnotatedAttribute();
+ PersistentAttribute ownerAttribute = relation.getOwnerAnnotatedAttribute();
PictogramElement ownerAttributeTextShape = getFeatureProvider().getPictogramElementForBusinessObject(ownerAttribute);
if(ownerAttributeTextShape == null)
return;
IDeleteContext deleteOwnerAttributeContext = new DeleteContext(ownerAttributeTextShape);
feat.delete(deleteOwnerAttributeContext, false);
-
- JavaSpecifiedPersistentAttribute inverseAttribute = relation.getInverseAnnotatedAttribute();
+
+ PersistentAttribute inverseAttribute = relation.getInverseAnnotatedAttribute();
PictogramElement inverseAttributeTextShape = getFeatureProvider().getPictogramElementForBusinessObject(inverseAttribute);
if(inverseAttributeTextShape == null)
return;
@@ -184,4 +183,4 @@ public class DeleteRelationFeature extends DefaultDeleteFeature{
JPAEditorMessages.DeleteFeature_deleteConfirm, JPAEditorMessages.DeleteRelationFeature_deleteRelationQuestion);
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java
index af51a762cf..65228c286c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditAttributeFeature.java
@@ -16,6 +16,8 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.text.MessageFormat;
+import java.util.Iterator;
+import java.util.Set;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -30,8 +32,8 @@ import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -60,7 +62,7 @@ public class DirectEditAttributeFeature extends AbstractDirectEditingFeature {
public String getInitialValue(IDirectEditingContext context) {
PictogramElement pe = context.getPictogramElement();
- JavaSpecifiedPersistentAttribute jpa = (JavaSpecifiedPersistentAttribute)getFeatureProvider().
+ PersistentAttribute jpa = (PersistentAttribute)getFeatureProvider().
getBusinessObjectForPictogramElement(pe);
isMethodAnnotated = JpaArtifactFactory.instance().isMethodAnnotated(jpa);
Text txt = (Text) pe.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0);
@@ -85,8 +87,8 @@ public class DirectEditAttributeFeature extends AbstractDirectEditingFeature {
private IStatus checkDuplicateAttribute(String value, IDirectEditingContext context) {
PictogramElement pe = context.getPictogramElement();
- JavaSpecifiedPersistentAttribute oldAt = (JavaSpecifiedPersistentAttribute) getBusinessObjectForPictogramElement(pe);
- JavaSpecifiedPersistentAttribute newAl = ((JavaPersistentType)oldAt.getParent()).getAttributeNamed(value);
+ PersistentAttribute oldAt = (PersistentAttribute) getBusinessObjectForPictogramElement(pe);
+ PersistentAttribute newAl = ((PersistentType) oldAt.getParent()).getAttributeNamed(value);
if (newAl != null && !newAl.equals(oldAt)) {
String message = MessageFormat.format(JPAEditorMessages.DirectEditAttributeFeature_attributeExists, value);
return new Status(IStatus.ERROR, JPADiagramEditorPlugin.PLUGIN_ID, message);
@@ -104,18 +106,30 @@ public class DirectEditAttributeFeature extends AbstractDirectEditingFeature {
if (isMethodAnnotated)
value = JPAEditorUtil.produceValidAttributeName(value);
PictogramElement pe = context.getPictogramElement();
- JavaSpecifiedPersistentAttribute oldAt = (JavaSpecifiedPersistentAttribute) getBusinessObjectForPictogramElement(pe);
+ PersistentAttribute oldAt = (PersistentAttribute) getBusinessObjectForPictogramElement(pe);
- IRelation rel = getFeatureProvider().getRelationRelatedToAttribute(oldAt);
- String inverseJPTName = null;
- if (IBidirectionalRelation.class.isInstance(rel))
- inverseJPTName = rel.getInverse().getName();
- if (oldAt.getName().equals(value))
- return;
- try {
- JpaArtifactFactory.instance().renameAttribute((JavaPersistentType)oldAt.getParent(), oldAt.getName(), value, inverseJPTName, getFeatureProvider());
- } catch (InterruptedException e) {
- return;
+ Set<IRelation> rels = getFeatureProvider().getRelationRelatedToAttribute(oldAt, JpaArtifactFactory.instance().getRelTypeName(oldAt));
+ if(!rels.isEmpty()) {
+ Iterator<IRelation> iter = rels.iterator();
+ while(iter.hasNext()) {
+ IRelation rel = iter.next();
+ String inverseJPTName = null;
+ if (IBidirectionalRelation.class.isInstance(rel))
+ inverseJPTName = rel.getInverse().getName();
+ if (oldAt.getName().equals(value))
+ return;
+ try {
+ JpaArtifactFactory.instance().renameAttribute((PersistentType) oldAt.getParent(), oldAt.getName(), value, inverseJPTName, getFeatureProvider());
+ } catch (InterruptedException e) {
+ return;
+ }
+ }
+ } else {
+ try {
+ JpaArtifactFactory.instance().renameAttribute((PersistentType) oldAt.getParent(), oldAt.getName(), value, null, getFeatureProvider());
+ } catch (InterruptedException e) {
+ return;
+ }
}
if (pe.getGraphicsAlgorithm() == null)
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java
index 3750b999c6..a6fb095be6 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/DirectEditJPAEntityFeature.java
@@ -32,8 +32,8 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jdt.core.Signature;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
@@ -65,7 +65,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
public String getInitialValue(IDirectEditingContext context) {
Shape sh = (Shape)context.getPictogramElement();
ContainerShape csh = sh.getContainer();
- JavaPersistentType jpt = (JavaPersistentType)getBusinessObjectForPictogramElement(csh);
+ PersistentType jpt = (PersistentType)getBusinessObjectForPictogramElement(csh);
return JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt));
}
@@ -74,7 +74,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
//CSN #1305664 2010
PictogramElement pe = context.getPictogramElement();
ContainerShape csh = ((Shape)pe).getContainer();
- JavaPersistentType jpt = (JavaPersistentType) getFeatureProvider().getBusinessObjectForPictogramElement(csh);
+ PersistentType jpt = (PersistentType) getFeatureProvider().getBusinessObjectForPictogramElement(csh);
String packageName = Signature.getQualifier(jpt.getName());
PersistenceUnit unit = jpt.getPersistenceUnit();
@@ -104,7 +104,7 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
public void setValue(final String value, IDirectEditingContext context) {
PictogramElement pe = context.getPictogramElement();
ContainerShape csh = ((Shape)pe).getContainer();
- JavaPersistentType jpt = (JavaPersistentType)getBusinessObjectForPictogramElement(csh);
+ PersistentType jpt = (PersistentType)getBusinessObjectForPictogramElement(csh);
Properties props = JPADiagramPropertyPage.loadProperties(jpt.getJpaProject().getProject());
String specifiedEntityMappingName = JpaArtifactFactory.instance().getSpecifiedEntityName(jpt);
@@ -116,9 +116,9 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
JpaArtifactFactory.instance().renameEntity(jpt, value);
// Properties props = JPADiagramPropertyPage.loadProperties(jpt.getJpaProject().getProject());
- if ((JpaArtifactFactory.instance().hasEntityAnnotation(jpt) && JPADiagramPropertyPage.doesDirecteEditingAffectClassNameByDefault(jpt.getJpaProject().getProject(), props))
- || JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(jpt)
- || JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt)) {
+ if ((JpaArtifactFactory.instance().isEntity(jpt) && JPADiagramPropertyPage.doesDirecteEditingAffectClassNameByDefault(jpt.getJpaProject().getProject(), props))
+ || JpaArtifactFactory.instance().isMappedSuperclass(jpt)
+ || JpaArtifactFactory.instance().isEmbeddable(jpt)) {
RenameEntityWithoutUIFeature ft = new RenameEntityWithoutUIFeature(getFeatureProvider(), value);
ft.execute(jpt);
return;
@@ -135,10 +135,10 @@ public class DirectEditJPAEntityFeature extends AbstractDirectEditingFeature {
}
});
- Set<JavaSpecifiedPersistentAttribute> ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
- Iterator<JavaSpecifiedPersistentAttribute> it = ats.iterator();
+ Set<PersistentAttribute> ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
+ Iterator<PersistentAttribute> it = ats.iterator();
while (it.hasNext()) {
- JavaSpecifiedPersistentAttribute at = it.next();
+ PersistentAttribute at = it.next();
PictogramElement pel = getFeatureProvider().getPictogramElementForBusinessObject(at);
String newAtName = JPAEditorUtil.decapitalizeFirstLetter(value);
if (JpaArtifactFactory.instance().isMethodAnnotated(at))
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java
index eaba8d2e47..32facd617b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedCollectionOfObjectsFeature.java
@@ -29,14 +29,11 @@ import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.Embeddable;
import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
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.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.ElementCollection2_0Annotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
@@ -45,12 +42,13 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvi
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasCollectionReferenceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation.HasReferenceType;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFeature {
- private JavaPersistentType embeddingEntity;
+ private PersistentType embeddingEntity;
public EmbedCollectionOfObjectsFeature(IFeatureProvider fp) {
this(fp, JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureDescription);
@@ -62,16 +60,16 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
}
public boolean canCreate(ICreateConnectionContext context) {
- JavaPersistentType embeddingEntity = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType embeddable = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ PersistentType embeddingEntity = getPersistentType(context.getSourceAnchor());
+ PersistentType embeddable = getPersistentType(context.getTargetAnchor());
if ((embeddable == null) || (embeddingEntity == null))
return false;
- if (!JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddable))
+ if (!JpaArtifactFactory.instance().isEmbeddable(embeddable))
return false;
- if(!JpaArtifactFactory.instance().hasEntityAnnotation(embeddingEntity) &&
- !JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity))
+ if(!JpaArtifactFactory.instance().isEntity(embeddingEntity) &&
+ !JpaArtifactFactory.instance().isEmbeddable(embeddingEntity))
return false;
if(isNotAllowed(embeddingEntity, embeddable)){
return false;
@@ -80,18 +78,18 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
}
public Connection create(ICreateConnectionContext context) {
- JavaPersistentType embeddingEntity = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType embeddable = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ PersistentType embeddingEntity = getPersistentType(context.getSourceAnchor());
+ PersistentType embeddable = getPersistentType(context.getTargetAnchor());
boolean isMap = JPADiagramPropertyPage.isMapType(embeddingEntity.getJpaProject().getProject());
String mapKeyType = null;
if(isMap){
- mapKeyType = "java.lang.String"; //$NON-NLS-1$
+ mapKeyType = JPAEditorConstants.STRING_TYPE;
}
-
- JavaSpecifiedPersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(getFeatureProvider(), embeddingEntity, embeddable, true, mapKeyType);
- embeddedAttribute.setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- embeddedAttribute.getResourceAttribute().addAnnotation(ElementCollection2_0Annotation.ANNOTATION_NAME);
+
+ PersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(getFeatureProvider(), embeddingEntity, embeddable, true, mapKeyType);
+ embeddedAttribute.getJavaPersistentAttribute().setMappingKey(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
+ JpaArtifactFactory.instance().addOrmPersistentAttribute(embeddingEntity, embeddedAttribute, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
HasReferanceRelation rel = new HasCollectionReferenceRelation(embeddingEntity, embeddable);
rel.setEmbeddedAnnotatedAttribute(embeddedAttribute);
@@ -107,7 +105,7 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
}
public boolean canStartConnection(ICreateConnectionContext context) {
- embeddingEntity = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ embeddingEntity = getPersistentType(context.getSourceAnchor());
if (embeddingEntity == null)
return false;
return true;
@@ -138,14 +136,14 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
* @return true if the given emebddable is embedded as element collection in an entity or it embed in itself
* an element collection of another embeddable.
*/
- private boolean isEmbeddableAlreadyEmbeddedAsElementCollection(JavaPersistentType jpt, boolean isEmbedded){
+ private boolean isEmbeddableAlreadyEmbeddedAsElementCollection(PersistentType jpt, boolean isEmbedded){
Set<HasReferanceRelation> refs = JpaArtifactFactory.instance().findAllHasReferenceRelationsByEmbeddable(jpt, getFeatureProvider());
if(!refs.isEmpty()){
for(HasReferanceRelation ref : refs){
if(ref.getReferenceType().equals(HasReferenceType.COLLECTION)){
- if(!isEmbedded && ref.getEmbeddable().equals(jpt)){
+ if(!isEmbedded && ref.getEmbeddable().getName().equals(jpt.getName())){
return true;
- } else if(isEmbedded && ref.getEmbeddingEntity().equals(jpt)){
+ } else if(isEmbedded && ref.getEmbeddingEntity().getName().equals(jpt.getName())){
return true;
}
}
@@ -163,18 +161,18 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
* @param embeddable - the target entity of the connection
* @return true if the connection is possible, false otherwise.
*/
- private boolean isNotAllowed(JavaPersistentType embeddingEntity, JavaPersistentType embeddable){
- boolean notAllowed = false;
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddable)){
+ private boolean isNotAllowed(PersistentType embeddingEntity, PersistentType embeddable){
+ boolean notAllowed = false;
+ if(JpaArtifactFactory.instance().isEmbeddable(embeddable)){
for(PersistentAttribute attr : embeddable.getAllAttributes()){
if(attr.getMappingKey().equals(MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY)){
return true;
}
}
}
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity)){
+ if(JpaArtifactFactory.instance().isEmbeddable(embeddingEntity)){
notAllowed = isEmbeddableAlreadyEmbeddedAsElementCollection(embeddingEntity, false);
- } else if(JpaArtifactFactory.instance().hasEntityAnnotation(embeddingEntity)){
+ } else if(JpaArtifactFactory.instance().isEntity(embeddingEntity)){
notAllowed = isEmbeddableAlreadyEmbeddedAsElementCollection(embeddable, true);
}
return notAllowed;
@@ -213,11 +211,11 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
JpaProject project = ModelIntegrationUtil.getProjectByDiagram(d.getName());
PersistenceUnit unit = project.getContextModelRoot().getPersistenceXml().
getRoot().getPersistenceUnits().iterator().next();
- if(JpaArtifactFactory.instance().hasEntityAnnotation(embeddingEntity)
- || JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity)){
+ if(JpaArtifactFactory.instance().isEntity(embeddingEntity)
+ || JpaArtifactFactory.instance().isEmbeddable(embeddingEntity)){
disableAllNotEmbeddablesOrEmbedAsElementCollection(unit);
}
- else if(JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(embeddingEntity)){
+ else if(JpaArtifactFactory.instance().isMappedSuperclass(embeddingEntity)){
disableAllPersistentType(unit);
}
}
@@ -230,9 +228,9 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
private void disableAllNotEmbeddablesOrEmbedAsElementCollection(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasEntityAnnotation(jpt) || JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(jpt)
- || embeddingEntity.equals(jpt) || isNotAllowed(embeddingEntity, jpt)){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isEntity(jpt) || JpaArtifactFactory.instance().isMappedSuperclass(jpt)
+ || embeddingEntity.getName().equals(jpt.getName()) || isNotAllowed(embeddingEntity, jpt)){
getFeatureProvider().setGrayColor(jpt);
}
@@ -241,14 +239,14 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
}
/**
- * Disable (color in gray) all {@link JavaPersistentType}s registered in the
+ * Disable (color in gray) all {@link PersistentType}s registered in the
* persistence unit.
* @param unit
*/
private void disableAllPersistentType(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
+ final PersistentType jpt = classRef.getJavaPersistentType();
getFeatureProvider().setGrayColor(jpt);
}
}
@@ -266,8 +264,8 @@ public class EmbedCollectionOfObjectsFeature extends AbstractCreateConnectionFea
getRoot().getPersistenceUnits().iterator().next();
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(jpt)){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isMappedSuperclass(jpt)){
getFeatureProvider().setGrayColor(jpt);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java
index 241056c97d..4fb57392a0 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/EmbedSingleObjectFeature.java
@@ -27,12 +27,10 @@ import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.Entity;
import org.eclipse.jpt.jpa.core.context.MappedSuperclass;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-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.resource.java.EmbeddedAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.ModelIntegrationUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -44,7 +42,7 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
- private JavaPersistentType embeddingEntity;
+ private PersistentType embeddingEntity;
public EmbedSingleObjectFeature(IFeatureProvider fp) {
this(fp, JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureDescription);
@@ -56,31 +54,31 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
}
public boolean canCreate(ICreateConnectionContext context) {
- embeddingEntity = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType embeddable = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
+ embeddingEntity = getPersistentType(context.getSourceAnchor());
+ PersistentType embeddable = getPersistentType(context.getTargetAnchor());
if ((embeddingEntity == null) || (embeddable == null))
return false;
- if (!JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddable))
+ if (!JpaArtifactFactory.instance().isEmbeddable(embeddable))
return false;
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity) &&
+ if(JpaArtifactFactory.instance().isEmbeddable(embeddingEntity) &&
JPAEditorUtil.checkJPAFacetVersion(embeddable.getJpaProject(), JPAEditorUtil.JPA_PROJECT_FACET_10))
return false;
- if(!JpaArtifactFactory.instance().hasEntityAnnotation(embeddingEntity) &&
- !JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity))
+ if(!JpaArtifactFactory.instance().isEntity(embeddingEntity) &&
+ !JpaArtifactFactory.instance().isEmbeddable(embeddingEntity))
return false;
return true;
}
public Connection create(ICreateConnectionContext context) {
- JavaPersistentType embeddingEntity = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
- JavaPersistentType embeddable = (JavaPersistentType)getPersistentType(context.getTargetAnchor());
-
- JavaSpecifiedPersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(getFeatureProvider(), embeddingEntity, embeddable, false, null);
- embeddedAttribute.setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- embeddedAttribute.getResourceAttribute().addAnnotation(EmbeddedAnnotation.ANNOTATION_NAME);
+ PersistentType embeddingEntity = getPersistentType(context.getSourceAnchor());
+ PersistentType embeddable = getPersistentType(context.getTargetAnchor());
+
+ PersistentAttribute embeddedAttribute = JPAEditorUtil.addAnnotatedAttribute(getFeatureProvider(), embeddingEntity, embeddable, false, null);
+ embeddedAttribute.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+ JpaArtifactFactory.instance().addOrmPersistentAttribute(embeddingEntity, embeddedAttribute, MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
HasReferanceRelation rel = new HasSingleReferenceRelation(embeddingEntity, embeddable);
rel.setEmbeddedAnnotatedAttribute(embeddedAttribute);
@@ -96,7 +94,7 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
}
public boolean canStartConnection(ICreateConnectionContext context) {
- embeddingEntity = (JavaPersistentType)getPersistentType(context.getSourceAnchor());
+ embeddingEntity = getPersistentType(context.getSourceAnchor());
if (embeddingEntity == null)
return false;
@@ -154,12 +152,12 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
PersistenceUnit unit = project.getContextModelRoot().getPersistenceXml().
getRoot().getPersistenceUnits().iterator().next();
boolean isJPA10Project = JPAEditorUtil.checkJPAFacetVersion(embeddingEntity.getJpaProject(), JPAEditorUtil.JPA_PROJECT_FACET_10);
- if(JpaArtifactFactory.instance().hasEntityAnnotation(embeddingEntity)
- || (!isJPA10Project && JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity))){
+ if(JpaArtifactFactory.instance().isEntity(embeddingEntity)
+ || (!isJPA10Project && JpaArtifactFactory.instance().isEmbeddable(embeddingEntity))){
disableAllJPTsThatAreNotEmbeddables(unit);
}
- else if(JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(embeddingEntity)
- || (isJPA10Project && JpaArtifactFactory.instance().hasEmbeddableAnnotation(embeddingEntity))){
+ else if(JpaArtifactFactory.instance().isMappedSuperclass(embeddingEntity)
+ || (isJPA10Project && JpaArtifactFactory.instance().isEmbeddable(embeddingEntity))){
disableAllPersistenTypes(unit);
}
}
@@ -172,8 +170,8 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
private void disableAllJPTsThatAreNotEmbeddables(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasEntityAnnotation(jpt) || JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(jpt)){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isEntity(jpt) || JpaArtifactFactory.instance().isMappedSuperclass(jpt)){
getFeatureProvider().setGrayColor(jpt);
}
@@ -194,9 +192,9 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
boolean isJPA10Project = JPAEditorUtil.checkJPAFacetVersion(ModelIntegrationUtil.getProjectByDiagram(getDiagram().getName()), JPAEditorUtil.JPA_PROJECT_FACET_10);
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- if(JpaArtifactFactory.instance().hasMappedSuperclassAnnotation(jpt) ||
- (isJPA10Project && JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt))){
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ if(JpaArtifactFactory.instance().isMappedSuperclass(jpt) ||
+ (isJPA10Project && JpaArtifactFactory.instance().isEmbeddable(jpt))){
getFeatureProvider().setGrayColor(jpt);
}
@@ -205,17 +203,17 @@ public class EmbedSingleObjectFeature extends AbstractCreateConnectionFeature {
}
/**
- * Disable (color in gray) all {@link JavaPersistentType}s registered in the
+ * Disable (color in gray) all {@link PersistentType}s registered in the
* persistence unit.
* @param unit
*/
private void disableAllPersistenTypes(PersistenceUnit unit) {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
+ final PersistentType jpt = classRef.getJavaPersistentType();
getFeatureProvider().setGrayColor(jpt);
}
}
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandAllEntitiesFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandAllEntitiesFeature.java
index 229465629e..4cefe9561d 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandAllEntitiesFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandAllEntitiesFeature.java
@@ -28,7 +28,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
@@ -54,7 +54,7 @@ public class ExpandAllEntitiesFeature extends AbstractCustomFeature{
String collapseFeatures = Graphiti.getPeService().getPropertyValue(el, JPAEditorConstants.COLLAPSE_FEATURES);
if (collapseFeatures != null) {
Object bo = getBusinessObjectForPictogramElement(el);
- if(bo instanceof JavaPersistentType){
+ if(bo instanceof PersistentType){
ContainerShape containerShape = (ContainerShape) el;
GraphicsUpdater.updateEntityShape(containerShape);
GraphicsUpdater.updateEntityHeigth(containerShape);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandEntityFeature.java
index eb359895c9..40f31f9d45 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/ExpandEntityFeature.java
@@ -26,7 +26,7 @@ import org.eclipse.graphiti.mm.Property;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
@@ -44,7 +44,7 @@ public class ExpandEntityFeature extends AbstractCustomFeature{
final PictogramElement el = context.getPictogramElements()[0];
Object bo = getBusinessObjectForPictogramElement(el);
- if(bo instanceof JavaPersistentType){
+ if(bo instanceof PersistentType){
final ContainerShape containerShape = (ContainerShape) el;
TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(containerShape);
@@ -77,7 +77,7 @@ public class ExpandEntityFeature extends AbstractCustomFeature{
for (int i = 0; i < pes.length; i++) {
PictogramElement pe = pes[i];
Object bo = getBusinessObjectForPictogramElement(pe);
- if (!(bo instanceof JavaPersistentType)) {
+ if (!(bo instanceof PersistentType)) {
return false;
}
if (!expandPossible) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java
index caea634a59..984d066860 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalAddAttributeFeature.java
@@ -15,8 +15,6 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
-import java.util.HashSet;
-
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
@@ -29,17 +27,23 @@ import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaNullAttributeMapping;
+import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmNullAttributeMapping;
+import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorImageProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.Wrp;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType;
-
public class GraphicalAddAttributeFeature extends AbstractAddShapeFeature {
@@ -50,88 +54,120 @@ public class GraphicalAddAttributeFeature extends AbstractAddShapeFeature {
public PictogramElement add(final IAddContext context) {
final ContainerShape entityShape = context.getTargetContainer();
final Wrp wrp = new Wrp();
- TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(entityShape);
+ TransactionalEditingDomain ted = TransactionUtil
+ .getEditingDomain(entityShape);
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- JavaSpecifiedPersistentAttribute newAttr = (JavaSpecifiedPersistentAttribute) context.getNewObject();
+ PersistentAttribute newAttr = (PersistentAttribute) context
+ .getNewObject();
String txt = JPAEditorUtil.getText(newAttr);
- HashSet<String> annots = JpaArtifactFactory.instance().getAnnotationNames(newAttr);
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(newAttr);
+ if(!attributeMapping.getKey().equals(newAttr.getJavaPersistentAttribute().getMappingKey())){
+// newAttr.getJavaPersistentAttribute().setMappingKey(attributeMapping.getKey());
+ }
ContainerShape textShape = null;
- ContainerShape primaryShape = GraphicsUpdater.getPrimaryShape(entityShape);
- ContainerShape relationShape = GraphicsUpdater.getRelationShape(entityShape);
- ContainerShape basicShape = GraphicsUpdater.getBasicShape(entityShape);
- textShape = addAttributeToProperlyShape(entityShape, txt, annots, primaryShape, relationShape, basicShape);
+ ContainerShape primaryShape = GraphicsUpdater
+ .getPrimaryShape(entityShape);
+ ContainerShape relationShape = GraphicsUpdater
+ .getRelationShape(entityShape);
+ ContainerShape basicShape = GraphicsUpdater
+ .getBasicShape(entityShape);
+ textShape = addAttributeToProperlyShape(entityShape, txt,
+ attributeMapping, primaryShape, relationShape, basicShape);
link(textShape, newAttr);
layoutPictogramElement(entityShape);
wrp.setObj(textShape);
}
-
+
});
- return (PictogramElement)wrp.getObj();
+ return (PictogramElement) wrp.getObj();
}
- private ContainerShape addAttributeToProperlyShape(ContainerShape entityShape, String txt, HashSet<String> annots,
- ContainerShape primaryShape, ContainerShape relationShape, ContainerShape basicShape) {
+ private ContainerShape addAttributeToProperlyShape(
+ ContainerShape entityShape, String txt, AttributeMapping attributeMapping,
+ ContainerShape primaryShape, ContainerShape relationShape,
+ ContainerShape basicShape) {
ContainerShape textShape = null;
- if (annots.contains(JPAEditorConstants.ANNOTATION_ID) || annots.contains(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)
- || annots.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)) {
- textShape = addAttributeToShape(entityShape, txt, annots, primaryShape);
- } else if (!annots.contains(JPAEditorConstants.ANNOTATION_ID) && !annots.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)
- && (annots.contains(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)
- || annots.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)
- || annots.contains(JPAEditorConstants.ANNOTATION_ONE_TO_MANY)
- || annots.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE))) {
- textShape = addAttributeToShape(entityShape, txt, annots, relationShape);
+ if((attributeMapping instanceof IdMapping) || (attributeMapping instanceof EmbeddedIdMapping)) {
+ textShape = addAttributeToShape(entityShape, txt, attributeMapping,
+ primaryShape);
+ } else if (attributeMapping instanceof SingleRelationshipMapping2_0) {
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(identity.usesIdDerivedIdentityStrategy() || identity.usesMapsIdDerivedIdentityStrategy()){
+ textShape = addAttributeToShape(entityShape, txt, attributeMapping,
+ primaryShape);
+ } else {
+ textShape = addAttributeToShape(entityShape, txt, attributeMapping,
+ relationShape);
+ }
+ } else if (attributeMapping instanceof RelationshipMapping) {
+ textShape = addAttributeToShape(entityShape, txt, attributeMapping,
+ relationShape);
} else {
- textShape = addAttributeToShape(entityShape, txt, annots, basicShape);
+ textShape = addAttributeToShape(entityShape, txt, attributeMapping,
+ basicShape);
}
return textShape;
}
- private ContainerShape addAttributeToShape(ContainerShape entityShape, String txt, HashSet<String> annots,
- ContainerShape containerShape) {
+ private ContainerShape addAttributeToShape(ContainerShape entityShape,
+ String txt, AttributeMapping attributeMapping, ContainerShape containerShape) {
ContainerShape textShape = null;
int childrenSizeBefore = containerShape.getChildren().size();
- int containerHeightBefore = containerShape.getGraphicsAlgorithm().getHeight();
- textShape = addAttribute(getFeatureProvider(), containerShape, txt, annots);
+ int containerHeightBefore = containerShape.getGraphicsAlgorithm()
+ .getHeight();
+ textShape = addAttribute(getFeatureProvider(), containerShape, txt,
+ attributeMapping);
- GraphicsUpdater.updateContainer(containerShape, childrenSizeBefore, containerHeightBefore);
+ GraphicsUpdater.updateContainer(containerShape, childrenSizeBefore,
+ containerHeightBefore);
GraphicsUpdater.updateEntityShape(entityShape);
return textShape;
}
- private static ContainerShape addAttribute(IJPAEditorFeatureProvider fp, ContainerShape containerShape,
- String attribTxt, HashSet<String> annotations) {
+ @SuppressWarnings("restriction")
+ private static ContainerShape addAttribute(IJPAEditorFeatureProvider fp,
+ ContainerShape containerShape, String attribTxt,
+ AttributeMapping attributeMapping) {
- int width = containerShape.getContainer().getGraphicsAlgorithm().getWidth();
- ContainerShape iconShape = Graphiti.getPeService().createContainerShape(containerShape, false);
- Graphiti.getPeService().setPropertyValue(iconShape, JPAEditorConstants.PROP_SHAPE_TYPE, ShapeType.ICON.toString());
+ int width = containerShape.getContainer().getGraphicsAlgorithm()
+ .getWidth();
+ ContainerShape iconShape = Graphiti.getPeService()
+ .createContainerShape(containerShape, false);
+ Graphiti.getPeService().setPropertyValue(iconShape,
+ JPAEditorConstants.PROP_SHAPE_TYPE, ShapeType.ICON.toString());
int attribIndex = fp.getAttribsNum(containerShape);
- Rectangle iconRect = UpdateAttributeFeature.addRectangleForIcon(iconShape, attribIndex);
+ Rectangle iconRect = UpdateAttributeFeature.addRectangleForIcon(
+ iconShape, attribIndex);
Image icon = null;
- Object ob = fp.getBusinessObjectForPictogramElement(containerShape.getContainer());
- JavaPersistentType jpt = (JavaPersistentType)ob;
- boolean isMethodAnnotated = JpaArtifactFactory.instance().isMethodAnnotated(jpt);
- boolean isCollection = isMethodAnnotated ?
- JpaArtifactFactory.instance().isGetterMethodReturnTypeCollection(containerShape.getContainer(), fp, attribTxt) :
- JpaArtifactFactory.instance().isCollection(containerShape.getContainer(), fp, attribTxt);
- if (isCollection && annotations.isEmpty()) {
- icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_UNMAPPED);
- } else{
- icon = JPAEditorUtil.createAttributeIcon(iconRect, annotations);
+ boolean isCollection = JpaArtifactFactory.instance().isCollection(attributeMapping);
+ if (isCollection && ((attributeMapping instanceof GenericJavaNullAttributeMapping)
+ || (attributeMapping instanceof GenericOrmNullAttributeMapping))) {
+ icon = Graphiti.getGaService().createImage(iconRect,
+ JPAEditorImageProvider.ICON_UNMAPPED);
+ } else {
+ icon = JPAEditorUtil.createAttributeIcon(iconRect, attributeMapping);
}
- Graphiti.getGaService().setLocationAndSize(icon, JPAEditorConstants.ICON_X, JPAEditorConstants.ICON_Y,
+ Graphiti.getGaService().setLocationAndSize(icon,
+ JPAEditorConstants.ICON_X, JPAEditorConstants.ICON_Y,
JPAEditorConstants.ICON_WIDTH, JPAEditorConstants.ICON_HEIGHT);
- ContainerShape textShape = Graphiti.getPeService().createContainerShape(containerShape, false);
- Graphiti.getPeService().setPropertyValue(textShape, JPAEditorConstants.PROP_SHAPE_TYPE, ShapeType.ATTRIBUTE.toString());
- Rectangle textRectangle = UpdateAttributeFeature.addRectangleForText(textShape, attribIndex, width);
+ ContainerShape textShape = Graphiti.getPeService()
+ .createContainerShape(containerShape, false);
+ Graphiti.getPeService().setPropertyValue(textShape,
+ JPAEditorConstants.PROP_SHAPE_TYPE,
+ ShapeType.ATTRIBUTE.toString());
+ Rectangle textRectangle = UpdateAttributeFeature.addRectangleForText(
+ textShape, attribIndex, width);
textShape.setActive(true);
- Text text = UpdateAttributeFeature.addText(fp, textRectangle, attribTxt);
- Graphiti.getGaService().setWidth(text, width - JPAEditorConstants.ATTRIBUTE_TEXT_RECT_WIDTH_REDUCER);
- Graphiti.getGaService().setLocationAndSize(text, 1, -2, width
- - JPAEditorConstants.ATTRIBUTE_TEXT_RECT_WIDTH_REDUCER, JPAEditorConstants.ATTRIBUTE_RECT_HEIGHT);
+ Text text = UpdateAttributeFeature
+ .addText(fp, textRectangle, attribTxt);
+ Graphiti.getGaService().setWidth(text,
+ width - JPAEditorConstants.ATTRIBUTE_TEXT_RECT_WIDTH_REDUCER);
+ Graphiti.getGaService().setLocationAndSize(text, 1, -2,
+ width - JPAEditorConstants.ATTRIBUTE_TEXT_RECT_WIDTH_REDUCER,
+ JPAEditorConstants.ATTRIBUTE_RECT_HEIGHT);
fp.increaseAttribsNum(containerShape);
return textShape;
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
index 4a29f255f9..2ecdd197ca 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/GraphicalRemoveAttributeFeature.java
@@ -29,8 +29,8 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
@@ -55,7 +55,7 @@ public class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
protected void doExecute() {
Shape sh = (Shape) pe;
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(sh);
- if ((bo == null) || (!JavaPersistentType.class.isInstance(bo)))
+ if ((bo == null) || (!PersistentType.class.isInstance(bo)))
return;
ContainerShape entityShape = (ContainerShape) pe;
ContainerShape primShape = GraphicsUpdater.getPrimaryShape(entityShape);
@@ -67,23 +67,23 @@ public class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
removeCompartmentChildren(basicShape);
- readdCompartmentsChildren((JavaPersistentType) bo, entityShape, primShape, relationShape, basicShape);
+ readdCompartmentsChildren((PersistentType) bo, entityShape, primShape, relationShape, basicShape);
layoutPictogramElement(entityShape);
- reconnect((JavaPersistentType) bo);
+ reconnect((PersistentType) bo);
}
});
}
- public void reconnect(JavaPersistentType jpt) {
+ public void reconnect(PersistentType jpt) {
JpaArtifactFactory.instance().addNewRelations(getFeatureProvider(), jpt);
JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
}
- private void readdCompartmentsChildren(JavaPersistentType javaPersistentType, ContainerShape entityShape,
+ private void readdCompartmentsChildren(PersistentType persistentType, ContainerShape entityShape,
ContainerShape primaryShape, ContainerShape relationShape, ContainerShape basicShape) {
- JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(javaPersistentType);
+ JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(persistentType);
UpdateAttributeFeature updateFeature = new UpdateAttributeFeature(getFeatureProvider());
updateFeature.addSeparatorsToShape(primaryShape, dot);
updateFeature.addSeparatorsToShape(relationShape, dot);
@@ -93,14 +93,14 @@ public class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
AddContext addContext = new AddContext();
addContext.setTargetContainer(entityShape);
- for (JavaSpecifiedPersistentAttribute attribute : javaPersistentType.getAttributes()) {
+ for (PersistentAttribute attribute : persistentType.getAttributes()) {
addContext.setNewObject(attribute);
graphicalAdd.execute(addContext);
getFeatureProvider().renewAttributeJoiningStrategyPropertyListener(attribute);
-// getFeatureProvider().addJPTForUpdate(javaPersistentType.getName());
+// getFeatureProvider().addJPTForUpdate(persistentType.getName());
}
GraphicsUpdater.updateEntityShape(entityShape);
- getFeatureProvider().addJPTForUpdate(javaPersistentType.getName());
+ getFeatureProvider().addJPTForUpdate(persistentType.getName());
}
@@ -142,4 +142,4 @@ public class GraphicalRemoveAttributeFeature extends AbstractCustomFeature {
}
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java
index 87fb5b1a60..1cbbc601fc 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/LayoutJPAEntityFeature.java
@@ -32,7 +32,7 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IGraphicsUpdater;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IPeServiceUtil;
@@ -51,7 +51,7 @@ public class LayoutJPAEntityFeature extends AbstractLayoutFeature {
public boolean canLayout(ILayoutContext context) {
PictogramElement pe = context.getPictogramElement();
Object bo = getBusinessObjectForPictogramElement(pe);
- return (bo instanceof JavaPersistentType);
+ return (bo instanceof PersistentType);
}
public boolean layout(ILayoutContext context) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
index 8085c61899..eeaacebab2 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorAttributeTypeFeature.java
@@ -25,10 +25,8 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.dialog.SelectTypeDialog;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -52,12 +50,12 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature {
public void execute(ICustomContext context) {
PictogramElement pe = context.getPictogramElements()[0];
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
- if ((bo == null) || (!(bo instanceof JavaSpecifiedPersistentAttribute)))
+ if ((bo == null) || (!(bo instanceof PersistentAttribute)))
return;
- JavaSpecifiedPersistentAttribute jpa = (JavaSpecifiedPersistentAttribute)bo;
+ PersistentAttribute jpa = (PersistentAttribute)bo;
String typeName = JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa);
String msg = MessageFormat.format(JPAEditorMessages.SelectTypeDialog_chooseAttributeTypeDialogText,
- jpa.getName(), JPAEditorUtil.returnSimpleName(((PersistentType)jpa.getParent()).getName()));
+ jpa.getName(), JPAEditorUtil.returnSimpleName(((PersistentType) jpa.getParent()).getName()));
SelectTypeDialog d = new SelectTypeDialog(msg, typeName);
if (d.open() != IDialogConstants.OK_ID)
return;
@@ -66,25 +64,28 @@ public class RefactorAttributeTypeFeature extends AbstractCustomFeature {
if (attributeTypeTypeNames != null)
newTypeName = newTypeName.substring(0, newTypeName.indexOf('<')).trim();
- getFeatureProvider().addAddIgnore((JavaPersistentType)jpa.getParent(), jpa.getName());
- JavaResourceAttribute jra = jpa.getResourceAttribute();
- getFeatureProvider().addRemoveIgnore((JavaPersistentType)jpa.getParent(), jra.getName());
+ getFeatureProvider().addAddIgnore((PersistentType) jpa.getParent(), jpa.getName());
+ getFeatureProvider().addRemoveIgnore((PersistentType) jpa.getParent(), jpa.getName());
+
+ String mappingKey = jpa.getMappingKey();
List<String> annotations = JpaArtifactFactory.instance().getAnnotationStrings(jpa);
- JpaArtifactFactory.instance().deleteAttribute((JavaPersistentType)jpa.getParent(), jpa.getName(),
+ JpaArtifactFactory.instance().deleteAttribute((PersistentType) jpa.getParent(), jpa.getName(),
getFeatureProvider());
-
- JavaSpecifiedPersistentAttribute newAt = JpaArtifactFactory.instance().makeNewAttribute(getFeatureProvider(), (JavaPersistentType)jpa.getParent(),
+
+ PersistentAttribute newAt = JpaArtifactFactory.instance().makeNewAttribute(getFeatureProvider(), (PersistentType) jpa.getParent(),
null, jpa.getName(), newTypeName, jpa.getName(), newTypeName, attributeTypeTypeNames, annotations, false);
getFeatureProvider().replaceAttribute(jpa, newAt);
+ JpaArtifactFactory.instance().addOrmPersistentAttribute((PersistentType) newAt.getParent(), newAt, mappingKey);
+
IWorkbenchSite ws = ((IEditorPart)getDiagramEditor()).getSite();
- ICompilationUnit cu = getFeatureProvider().getCompilationUnit((JavaPersistentType)newAt.getParent());
+ ICompilationUnit cu = getFeatureProvider().getCompilationUnit((PersistentType) newAt.getParent());
getFeatureProvider().getJPAEditorUtil().formatCode(cu, ws);
JPAEditorUtil.organizeImports(cu, ws);
JpaArtifactFactory.instance().remakeRelations(getFeatureProvider(),
- ((Shape)pe).getContainer(), (JavaPersistentType)newAt.getParent());
+ ((Shape)pe).getContainer(), (PersistentType) newAt.getParent());
}
@Override
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
index 4aa18c9ab8..680c518205 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RefactorEntityFeature.java
@@ -39,7 +39,6 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.ui.actions.SelectionDispatchAction;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jpt.common.core.JptResourceModel;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
@@ -49,11 +48,12 @@ import org.eclipse.jpt.common.utility.model.listener.CollectionChangeListener;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaPreferences;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.GraphicsUpdater;
@@ -68,8 +68,9 @@ import org.eclipse.ui.IWorkbenchSite;
public abstract class RefactorEntityFeature extends AbstractCustomFeature {
- protected Set<JavaSpecifiedPersistentAttribute> ats = null;
- protected boolean hasNameAnnotation = false;
+ protected Set<PersistentAttribute> ats = null;
+ protected boolean hasEntitySpecifiedName = false;
+ private static final String REGEX_PATTERN = "(_[\\d]+)*"; //$NON-NLS-1$
public RefactorEntityFeature(IFeatureProvider fp) {
super(fp);
@@ -82,10 +83,10 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
ICustomContext ctx = (ICustomContext)context;
PictogramElement pe = ctx.getInnerPictogramElement();
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType)bo;
+ if (bo instanceof PersistentType) {
+ PersistentType jpt = (PersistentType)bo;
ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
- hasNameAnnotation = JpaArtifactFactory.instance().hasNameAnnotation(jpt);
+ hasEntitySpecifiedName = JpaArtifactFactory.instance().hasEntitySpecifiedName(jpt);
return true;
}
if (pe instanceof Shape) {
@@ -93,10 +94,10 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
if (cs == null)
return false;
bo = getFeatureProvider().getBusinessObjectForPictogramElement(cs);
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType)bo;
+ if (bo instanceof PersistentType) {
+ PersistentType jpt = (PersistentType)bo;
ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
- hasNameAnnotation = JpaArtifactFactory.instance().hasNameAnnotation(jpt);
+ hasEntitySpecifiedName = JpaArtifactFactory.instance().hasEntitySpecifiedName(jpt);
return true;
}
}
@@ -111,7 +112,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
public void execute(ICustomContext context, SelectionDispatchAction action) {
PictogramElement pe = context.getInnerPictogramElement();
final ContainerShape pict = ((Shape)pe).getContainer();
- final JavaPersistentType jpt = (JavaPersistentType)getBusinessObjectForPictogramElement(pict);
+ final PersistentType jpt = (PersistentType)getBusinessObjectForPictogramElement(pict);
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
StructuredSelection sel = new StructuredSelection(cu);
final PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt);
@@ -141,9 +142,9 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
});
}
- public void execute(ICustomContext context, String newName, ICompilationUnit cu, JavaPersistentType originalJPT) {
+ public void execute(ICustomContext context, String newName, ICompilationUnit cu, PersistentType originalJPT) {
final Shape pict = (Shape)getFeatureProvider().getPictogramElementForBusinessObject(originalJPT);
- final JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().
+ final PersistentType jpt = (PersistentType)getFeatureProvider().
getBusinessObjectForPictogramElement(pict);
final PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt);
final Semaphore s = new Semaphore(0);
@@ -164,7 +165,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
});
}
- public static void remapEntity(final JavaPersistentType oldJPT,
+ public void remapEntity(final PersistentType oldJPT,
final Shape pict,
final PersistenceUnit pu,
final boolean rename,
@@ -175,15 +176,22 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
fp.getDiagramTypeProvider().getDiagramEditor().selectPictogramElements(new PictogramElement[] {});
String newJPTName = lsnr.getNewJPTName();
- JavaPersistentType newJPT = JpaArtifactFactory.instance().getJPT(newJPTName, pu);
+ lsnr.setOldJptName(oldJPT.getSimpleName());
+
+ if (!JpaPreferences.getDiscoverAnnotatedClasses(oldJPT.getJpaProject().getProject())) {
+ JPAEditorUtil.createUnregisterEntityFromXMLJob(oldJPT.getJpaProject(), oldJPT.getName());
+ JPAEditorUtil.createRegisterEntityInXMLJob(oldJPT.getJpaProject(), newJPTName);
+ }
+
+ PersistentType newJPT = JpaArtifactFactory.instance().getJPT(newJPTName, pu);
if(newJPT == null)
return;
- if (!JpaPreferences.getDiscoverAnnotatedClasses(newJPT.getJpaProject().getProject())) {
- JPAEditorUtil.createUnregisterEntityFromXMLJob(newJPT.getJpaProject(), oldJPT.getName());
- JPAEditorUtil.createRegisterEntityInXMLJob(newJPT.getJpaProject(), newJPTName);
- }
+// if (!JpaPreferences.getDiscoverAnnotatedClasses(oldJPT.getJpaProject().getProject())) {
+// JPAEditorUtil.createUnregisterEntityFromXMLJob(oldJPT.getJpaProject(), oldJPT.getName());
+// JPAEditorUtil.createRegisterEntityInXMLJob(oldJPT.getJpaProject(), newJPTName);
+// }
if (rename) {
String tableName = JPAEditorUtil.formTableName(newJPT);
@@ -192,11 +200,11 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
GraphicsUpdater.updateHeader((ContainerShape)pict, newJPT.getSimpleName());
linkNewElement(oldJPT, pict, fp, newJPT);
-
- for(JavaSpecifiedPersistentAttribute oldAttr : oldJPT.getAttributes()){
+
+ for(PersistentAttribute oldAttr : oldJPT.getAttributes()){
PictogramElement attrPict = fp.getPictogramElementForBusinessObject(oldAttr);
if(attrPict != null){
- for(JavaSpecifiedPersistentAttribute newAttr : newJPT.getAttributes()){
+ for(PersistentAttribute newAttr : newJPT.getAttributes()){
if(newAttr.getName().equals(oldAttr.getName())){
linkNewElement(oldAttr, attrPict, fp, newAttr);
}
@@ -263,6 +271,7 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
public class JPAProjectListener implements CollectionChangeListener {
private Semaphore s = null;
private String newJptName = null;
+ private String oldJptName = null;
public JPAProjectListener(Semaphore s) {
this.s = s;
@@ -282,27 +291,35 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
IType type = jrcu.getCompilationUnit().findPrimaryType();
newJptName = type.getFullyQualifiedName();
s.release();
- if ((ats == null) || hasNameAnnotation)
+ if ((ats == null) || hasEntitySpecifiedName)
return;
- final Iterator<JavaSpecifiedPersistentAttribute> iter = ats.iterator();
+
+ final Iterator<PersistentAttribute> iter = ats.iterator();
Runnable r = new Runnable() {
public void run() {
Hashtable<String, String> atOldToNewName = new Hashtable<String, String>();
- Set<JavaSpecifiedPersistentAttribute> newSelfAts = new HashSet<JavaSpecifiedPersistentAttribute>();
+ Set<PersistentAttribute> newSelfAts = new HashSet<PersistentAttribute>();
while (iter.hasNext()) {
- JavaSpecifiedPersistentAttribute at = iter.next();
- JavaPersistentType atParent = (JavaPersistentType) at.getParent();
+ PersistentAttribute at = iter.next();
+
+ String attributeNamPattern = JPAEditorUtil.decapitalizeFirstLetter(oldJptName) + REGEX_PATTERN;
+ boolean isSame = at.getName().matches(attributeNamPattern);
+ if(!isSame)
+ continue;
+
+ PersistentType atParent = (PersistentType) at.getParent();
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(atParent);
if (!cu.exists()) {
- at = (JavaSpecifiedPersistentAttribute)at.getPersistenceUnit().getPersistentType(newJptName).getAttributeNamed(at.getName());
- JavaSpecifiedPersistentAttribute newAt = null;
+ at = at.getPersistenceUnit().getPersistentType(newJptName).getAttributeNamed(at.getName());
try {
- newAt = JpaArtifactFactory.instance().renameAttribute(atParent, at.getName(), JPAEditorUtil.returnSimpleName(newJptName), newJptName, getFeatureProvider());
+ PersistentAttribute newAt = JpaArtifactFactory.instance().renameAttribute(atParent, at.getName(), JPAEditorUtil.returnSimpleName(newJptName), newJptName, getFeatureProvider());
+ if(newAt != null) {
+ atOldToNewName.put(at.getName(), newAt.getName());
+ newSelfAts.add(newAt);
+ }
} catch (InterruptedException e) {
JPADiagramEditorPlugin.logError(e);
}
- atOldToNewName.put(at.getName(), newAt.getName());
- newSelfAts.add(newAt);
} else {
try {
JpaArtifactFactory.instance().renameAttribute(atParent, at.getName(), JPAEditorUtil.returnSimpleName(newJptName), newJptName, getFeatureProvider());
@@ -311,20 +328,19 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
}
}
}
- Iterator<JavaSpecifiedPersistentAttribute> itr = newSelfAts.iterator();
+
+ Iterator<PersistentAttribute> itr = newSelfAts.iterator();
while (itr.hasNext()) {
- JavaSpecifiedPersistentAttribute at = itr.next();
- JavaAttributeMapping m = at.getMapping();
- Annotation mappingAnnotation = m.getMappingAnnotation();
- if (mappingAnnotation == null)
- return;
- if (OwnableRelationshipMappingAnnotation.class.isInstance(mappingAnnotation)) {
- OwnableRelationshipMappingAnnotation ownableMappingAnnotation = (OwnableRelationshipMappingAnnotation)mappingAnnotation;
- String oldMappedBy = ownableMappingAnnotation.getMappedBy();
+ PersistentAttribute at = itr.next();
+ AttributeMapping m = JpaArtifactFactory.instance().getAttributeMapping(at);
+ if(m instanceof RelationshipMapping){
+ SpecifiedMappedByRelationshipStrategy mappedByRelationShipStrategy = (SpecifiedMappedByRelationshipStrategy)((RelationshipMapping)m).getRelationship().getStrategy();
+ String oldMappedBy = mappedByRelationShipStrategy.getMappedByAttribute();
if (oldMappedBy != null) {
String newMappedBy = atOldToNewName.get(oldMappedBy);
- if (newMappedBy != null)
- ownableMappingAnnotation.setMappedBy(newMappedBy);
+ if(newMappedBy != null) {
+ mappedByRelationShipStrategy.setMappedByAttribute(newMappedBy);
+ }
}
}
}
@@ -347,6 +363,10 @@ public abstract class RefactorEntityFeature extends AbstractCustomFeature {
return newJptName;
}
+ public void setOldJptName(String oldJptName) {
+ this.oldJptName = oldJptName;
+ }
+
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java
index 630bd24f1f..b2370c761f 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAndSaveEntityFeature.java
@@ -31,8 +31,8 @@ import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -55,7 +55,7 @@ public class RemoveAndSaveEntityFeature extends DefaultRemoveFeature {
for (int i = lst.size() - 1; i >= 0; i--) {
Shape textShape = lst.get(i);
Object o = fp.getBusinessObjectForPictogramElement(textShape);
- if ((o != null) && (o instanceof JavaSpecifiedPersistentAttribute)) {
+ if ((o != null) && (o instanceof PersistentAttribute)) {
shapesForDeletion.add(textShape);
}
}
@@ -99,4 +99,4 @@ public class RemoveAndSaveEntityFeature extends DefaultRemoveFeature {
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java
index 4a6d81a316..b0ea4023d8 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveAttributeFeature.java
@@ -17,6 +17,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Set;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IContext;
@@ -28,8 +29,8 @@ import org.eclipse.graphiti.features.impl.DefaultRemoveFeature;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorFeatureProvider;
@@ -41,7 +42,7 @@ public class RemoveAttributeFeature extends DefaultRemoveFeature {
private boolean skipRemoveRelations = false;
private boolean skipCreateRelations = false;
- private JavaPersistentType jpt = null;
+ private PersistentType jpt = null;
private ICustomFeature graphicalRemove;
public RemoveAttributeFeature(IFeatureProvider fp) {
@@ -88,10 +89,8 @@ public class RemoveAttributeFeature extends DefaultRemoveFeature {
Object bo = fp.getBusinessObjectForPictogramElement(pe);
if(bo == null)
return;
-
- if (bo instanceof JavaSpecifiedPersistentAttribute) {
- JavaSpecifiedPersistentAttribute jpa = (JavaSpecifiedPersistentAttribute) bo;
-
+ if (bo instanceof PersistentAttribute) {
+ PersistentAttribute jpa = (PersistentAttribute) bo;
HashSet<String> ignores = ((JPAEditorFeatureProvider) getFeatureProvider()).getAddIgnore();
if (!ignores.isEmpty()) {
Iterator<String> iter = ignores.iterator();
@@ -103,11 +102,13 @@ public class RemoveAttributeFeature extends DefaultRemoveFeature {
}
}
- jpt = (JavaPersistentType)jpa.getParent();
+ jpt = (PersistentType) jpa.getParent();
fp.remove(fp.getKeyForBusinessObject(bo));
if (!skipRemoveRelations) {
- IRelation rel = fp.getRelationRelatedToAttribute(jpa);
- if(rel != null) {
+ Set<IRelation> rels = fp.getRelationRelatedToAttribute(jpa, JpaArtifactFactory.instance().getRelTypeName(jpa));
+ Iterator<IRelation> iter = rels.iterator();
+ while(iter.hasNext()){
+ IRelation rel = iter.next();
removeRelation(rel);
}
@@ -151,4 +152,4 @@ public class RemoveAttributeFeature extends DefaultRemoveFeature {
JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java
index 909fae7555..cdbffb9cd1 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RemoveJPAEntityFeature.java
@@ -32,9 +32,8 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -58,15 +57,15 @@ public class RemoveJPAEntityFeature extends DefaultRemoveFeature {
PictogramElement pe = context.getPictogramElement();
final Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
Set<Shape> shapesForDeletion = new HashSet<Shape>();
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType)bo;
+ if (bo instanceof PersistentType) {
+ PersistentType jpt = (PersistentType)bo;
JpaArtifactFactory.instance().restoreEntityClass(jpt, getFeatureProvider());
IFeatureProvider fp = getFeatureProvider();
List<Shape> lst = ((ContainerShape)pe).getChildren();
for (int i = lst.size() - 1; i >= 0; i--) {
Shape textShape = lst.get(i);
Object o = fp.getBusinessObjectForPictogramElement(textShape);
- if ((o != null) && (o instanceof JavaSpecifiedPersistentAttribute)) {
+ if ((o != null) && (o instanceof PersistentAttribute)) {
shapesForDeletion.add(textShape);
}
}
@@ -94,9 +93,9 @@ public class RemoveJPAEntityFeature extends DefaultRemoveFeature {
final IRemoveContext context = (IRemoveContext)ctx;
PictogramElement pe = context.getPictogramElement();
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
- if (!JavaPersistentType.class.isInstance(bo))
+ if (!PersistentType.class.isInstance(bo))
return;
- JavaPersistentType jpt = (JavaPersistentType)bo;
+ PersistentType jpt = (PersistentType)bo;
if (JPAEditorUtil.isEntityOpenElsewhere(jpt, true)) {
String shortEntName = JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt));
String message = NLS.bind(JPAEditorMessages.RemoveJPAEntityFeature_discardWarningMsg, shortEntName);
@@ -132,4 +131,4 @@ public class RemoveJPAEntityFeature extends DefaultRemoveFeature {
JpaArtifactFactory.instance().rearrangeIsARelations(getFeatureProvider());
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityWithoutUIFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityWithoutUIFeature.java
index 928be7c13f..a093a81efe 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityWithoutUIFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RenameEntityWithoutUIFeature.java
@@ -19,7 +19,7 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.context.impl.CustomContext;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -32,7 +32,7 @@ public class RenameEntityWithoutUIFeature extends RefactorEntityFeature {
this.newName = newName;
}
- public void execute(JavaPersistentType jpt) {
+ public void execute(PersistentType jpt) {
ICompilationUnit cu = getFeatureProvider().getCompilationUnit(jpt);
ats = JpaArtifactFactory.instance().getRelatedAttributes(jpt);
execute(new CustomContext(), newName, cu, jpt);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java
index f1f0da4e2e..b7a408c88a 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/RestoreEntityFeature.java
@@ -19,7 +19,7 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -41,7 +41,7 @@ public class RestoreEntityFeature extends AbstractCustomFeature {
}
public void execute(ICustomContext context) {
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
if (JPAEditorUtil.isEntityOpenElsewhere(jpt, true)) {
String shortEntName = JPAEditorUtil
.returnSimpleName(JpaArtifactFactory.instance()
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/SaveEntityFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/SaveEntityFeature.java
index ec95e989e0..0907aab9fe 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/SaveEntityFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/SaveEntityFeature.java
@@ -18,7 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.feature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.features.custom.AbstractCustomFeature;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -36,7 +36,7 @@ public class SaveEntityFeature extends AbstractCustomFeature {
}
public void execute(ICustomContext context) {
- JavaPersistentType jpt = (JavaPersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
+ PersistentType jpt = (PersistentType)getFeatureProvider().getBusinessObjectForPictogramElement(context.getPictogramElements()[0]);
JpaArtifactFactory.instance().forceSaveEntityClass(jpt, getFeatureProvider());
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java
index 583045686f..f4ac9bc7a7 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/feature/UpdateAttributeFeature.java
@@ -28,7 +28,7 @@ import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.util.IColorConstant;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -40,7 +40,7 @@ public class UpdateAttributeFeature extends AbstractCustomFeature {
super(fp);
}
- public void reconnect(JavaPersistentType jpt) {
+ public void reconnect(PersistentType jpt) {
IJPAEditorFeatureProvider fp = getFeatureProvider();
JpaArtifactFactory.instance().addNewRelations(fp, jpt);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java
index 1c90f37ac1..d586cf0973 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/JPAEditorMessages.java
@@ -111,9 +111,23 @@ public class JPAEditorMessages extends NLS {
public static String JPADiagramEditor_waitingForMoin;
+ public static String JPADiagramPropertyPage_ChooseXmlBrowseButton;
+
+ public static String JPADiagramPropertyPage_ChooseXMLCheckboxTooltip;
+
+ public static String JPADiagramPropertyPage_ChooseXMLGroupTooltip;
+
+ public static String JPADiagramPropertyPage_ChooseXMLLabel;
+
+ public static String JPADiagramPropertyPage_ChooseXMLTooltip;
+
public static String JPADiagramPropertyPage_errSavePropsMsgTitle;
public static String JPADiagramPropertyPage_errSavePropsMsgText;
+ public static String JPADiagramPropertyPage_NotAddedXMLErrorMsg;
+
+ public static String JPADiagramPropertyPage_NotExistsXmlErrorMsg;
+
public static String JPAEditorPreferencesPage_pageDescription;
public static String JPAEditorPreferencesPage_DefaultCollectionTypeSectionDescription;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties
index c6d1c982ee..b25035456d 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/i18n/messages.properties
@@ -89,8 +89,15 @@ JpaArtifactFactory_CanNotCheckReturnType=Cannot check the return type
JPADiagramEditor_openDiagramErrorMSG=Could not open editor, because {0} is not a valid JPA project. Use Open With to open this file with a different editor.
JPADiagramEditor_waitingForMoin=Waiting for MOIN connection initialization...
+JPADiagramPropertyPage_ChooseXmlBrowseButton=Bro&wse...
+JPADiagramPropertyPage_ChooseXMLCheckboxTooltip=If this option is chekced, the persistent types, which you generate using the JPA \neditor palette, will be automatically added in the specified XML mapping file.
+JPADiagramPropertyPage_ChooseXMLGroupTooltip=The persistent types, which you generate using the JPA editor palette,\nwill be automatically added in the specified XML mapping file
+JPADiagramPropertyPage_ChooseXMLLabel=Ma&pping file:
+JPADiagramPropertyPage_ChooseXMLTooltip=Specify the XML mapping file, in wich the persistent types, genrated \nusing the JPA editor palette, will be automatically added.
JPADiagramPropertyPage_errSavePropsMsgTitle=Cannot Save Properties
JPADiagramPropertyPage_errSavePropsMsgText=The JPA diagram properties could not be saved
+JPADiagramPropertyPage_NotAddedXMLErrorMsg=The selected mapping file has not been added to the persistence unit.
+JPADiagramPropertyPage_NotExistsXmlErrorMsg=The mapping file does not exist
JPAEditorPreferencesPage_pageDescription=Default settings for the JPA diagram editor:
JPAEditorPreferencesPage_DefaultCollectionTypeSectionDescription=Relation attributes, which you generate using the JPA editor,\nare automatically created to be of the specified collection type.
@@ -98,17 +105,17 @@ JPAEditorPreferencesPage_DefaultCollectionTypeSectionTittle=Default Collection T
JPAEditorPreferencesPage_DefaultPackageMsg=Persistent types, which you generate using the JPA editor palette,\nare automatically created in the specified package.
JPAEditorPreferencesPage_DefaultTableNamePrefixMsg=Entities, which you have created, using the JPA editor palette, are automatically\nannotated with @Table(name=...), where the name of the table is a result of\nconcatenation of the given prefix and the name of the entity. If you set\na blank prefix, the newly created entities are not annotated with @Table.
JPAEditorPreferencesPage_DefaultTableNameLabel=Default &table name prefix:
-JPAEditorPreferencesPage_DefaultPackageToUse=Default &Java package for new entities:
+JPAEditorPreferencesPage_DefaultPackageToUse=Default &Java package for new persistent types:
JPAEditorPreferencesPage_invalidPackage="{0}" is not a valid Java identifier.
JPAEditorPreferencesPage_invalidTableNamePrefix=Table name prefix may contain letters, digits and underscores only, and must not start with a digit.
-JPAEditorPreferencesPage_directEditAffectsClass=&Editing the entity name in the diagram affects the class name in the source file
-JPAEditorPreferencesPage_directEditAffectsClassTooltip=If this option is checked and the entity name is appointed\nby the @Entity annotation, direct entity name editing will\naffect the annotation and will cause class name refactoring.\nIf this option is unchecked, direct editing will affect the\nannotation only. If the entity name is not appointed by the\n@Entity annotation, direct editing will cause class name\nrefactoring regardless this option is checked or not.
+JPAEditorPreferencesPage_directEditAffectsClass=&Editing the persistent type name in the diagram affects the class name in the source file
+JPAEditorPreferencesPage_directEditAffectsClassTooltip=If this option is checked and the persistent type name is appointed\nby the respective persistent type annotation, direct persistent type \nname editing will affect the annotation and will cause class name \nefactoring. If this option is unchecked, direct editing will affect the\nannotation only. If the persistent type name is not appointed by the\nrespective annotation, direct editing will cause class name\nrefactoring regardless this option is checked or not.
JPAEditorPreferencesPage_entityAccessTypeButtonGroupTooltip=Persistent types, which you generate using the JPA editor palette,\nare automatically created with the specified access.
JPAEditorPreferencesPage_entityAccessTypeButtonGroupLabel=Persistent type access type
JPAEditorPreferencesPage_entityFieldBasedAccessButtonLabel=&Field-based
-JPAEditorPreferencesPage_entityPropertyBasedAccessButtonLabel=&Property-based
+JPAEditorPreferencesPage_entityPropertyBasedAccessButtonLabel=P&roperty-based
JPAEditorPreferencesPage_defaultFolderControlTooltip=The newly created diagram file(s) will be stored in this folder
-JPAEditorPreferencesPage_defaultFolderControlLabel=Folder for &diagrams:
+JPAEditorPreferencesPage_defaultFolderControlLabel=Folder for d&iagrams:
JPAEditorPreferencesPage_invalidFolder=The folder name must be preceded by "{0}".
JPAEditorPreferencesPage_emptyFolder=The folder name for diagrams must not be empty.
JPAEditorPreferencesPage_oneToManyOldStyle=&One-to-Many unidirectional old (JPA 1.0) style relations in JPA 2.0 projects
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/JPAEditorMatchingStrategy.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/JPAEditorMatchingStrategy.java
index 68c0979430..b488991ee9 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/JPAEditorMatchingStrategy.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/modelintegration/ui/JPAEditorMatchingStrategy.java
@@ -25,7 +25,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.IModelIntegrationUtil;
@@ -75,7 +75,7 @@ public class JPAEditorMatchingStrategy implements IEditorMatchingStrategy {
} catch (CoreException e1) {
JPADiagramEditorPlugin.logError("Cannot get session property DOUBLE_CLICK", e1); //$NON-NLS-1$
}
- JavaPersistentType inputJptType = null;
+ PersistentType inputJptType = null;
if (fp == null) {
inputJptType = JPAEditorUtil.getJPType(JavaCore.createCompilationUnitFrom(entityFile));
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java
index 53441b5eb5..9e5d342e8b 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferenceInitializer.java
@@ -17,6 +17,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
public class JPAEditorPreferenceInitializer extends
@@ -30,6 +31,8 @@ public class JPAEditorPreferenceInitializer extends
public static final String PROPERTY_DEFAULT_COLLECTION_TYPE = "org.eclipse.jpt.jpadiagrameditor.ui.entity.defaultCollectionType"; //$NON-NLS-1$
public static final String PROPERTY_ONE_TO_MANY_OLD_STYLE = "org.eclipse.jpt.jpadiagrameditor.ui.entity.defaultOneToManyOldStyle"; //$NON-NLS-1$
+ public static final String PROPERTY_DEFAULT_SUPPORT_ORM_XML = "org.eclipse.jpt.jpadiagrameditor.ui.supportOrmXml"; //$NON-NLS-1$
+ public static final String PROPERTY_DEFAULT_ORM_XML_FILE_NAME = "org.eclipse.jpt.jpadiagrameditor.ui.ormXmlFileName"; //$NON-NLS-1$
@@ -72,6 +75,8 @@ public class JPAEditorPreferenceInitializer extends
store.setDefault(PROPERTY_ENTITY_ACCESS_TYPE, PROPERTY_VAL_ACCESS_FIELD_BASED);
store.setDefault(PROPERTY_DEFAULT_COLLECTION_TYPE, PROPERTY_VAL_COLLECTION_TYPE);
store.setDefault(PROPERTY_ONE_TO_MANY_OLD_STYLE, false);
+ store.setDefault(PROPERTY_DEFAULT_SUPPORT_ORM_XML, false);
+ store.setDefault(PROPERTY_DEFAULT_ORM_XML_FILE_NAME, XmlEntityMappings.DEFAULT_RUNTIME_PATH_NAME);
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java
index 0677ba4f83..31d347d8ef 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/preferences/JPAEditorPreferencesPage.java
@@ -33,7 +33,6 @@ import org.eclipse.jpt.common.utility.internal.StringTools;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Button;
@@ -97,10 +96,10 @@ public class JPAEditorPreferencesPage extends FieldEditorPreferencePage
JPAEditorMessages.JPAEditorPreferencesPage_DefaultCollectionTypeSectionTittle,
1,
new String[][] {
- {JPAEditorConstants.COLLECTION_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE},
- {JPAEditorConstants.LIST_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE},
- {JPAEditorConstants.SET_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE},
- {JPAEditorConstants.MAP_TYPE, JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE}},
+ {"java.util.&Collection", JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE}, //$NON-NLS-1$
+ {"java.util.&List", JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE}, //$NON-NLS-1$
+ {"java.util.&Set", JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE}, //$NON-NLS-1$
+ {"java.util.&Map", JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE}}, //$NON-NLS-1$
parent, true);
defaultCollectionTypeChooser.setPreferenceStore(getPreferenceStore());
defaultCollectionTypeChooser.getRadioBoxControl(parent).setToolTipText(JPAEditorMessages.JPAEditorPreferencesPage_DefaultCollectionTypeSectionDescription);
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java
index 534b317a04..f946537b04 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/propertypage/JPADiagramPropertyPage.java
@@ -28,19 +28,31 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
+import org.eclipse.jpt.common.utility.internal.StringTools;
+import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.resource.ResourceMappingFile;
+import org.eclipse.jpt.jpa.ui.internal.jface.XmlMappingFileViewerFilter;
+import org.eclipse.jpt.jpa.ui.internal.wizards.SelectMappingFileDialog;
+import org.eclipse.jpt.jpa.ui.wizards.entity.JptJpaUiWizardsEntityMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.preferences.JPAEditorPreferenceInitializer;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.preferences.JPAEditorPreferencesPage;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
@@ -53,7 +65,10 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.PropertyPage;
+import org.eclipse.ui.model.WorkbenchContentProvider;
+import org.eclipse.ui.model.WorkbenchLabelProvider;
+@SuppressWarnings("restriction")
public class JPADiagramPropertyPage extends PropertyPage {
public static final String PROJECT_SETTINGS_PATH = "/.settings/org.eclipse.jpt.jpadiagrameditor.ui"; //$NON-NLS-1$;
@@ -75,6 +90,12 @@ public class JPADiagramPropertyPage extends PropertyPage {
private Button btnSetType;
private Button btnMapType;
private Button checkOneToManyOldStyle;
+
+
+ private Label displayNameLabel;
+ private Button xmlSupportButton;
+ private Text ormXmlName;
+ private Button browseButton;
private boolean propsModified = false;
@@ -85,7 +106,9 @@ public class JPADiagramPropertyPage extends PropertyPage {
static public final QualifiedName PROP_DIRECT_EDIT_AFFECTS_CLASS = new QualifiedName(QUALIFIER, "directEditAffectsClass"); //$NON-NLS-1$;
static public final QualifiedName PROP_ACCESS_TYPE = new QualifiedName(QUALIFIER, "accessType"); //$NON-NLS-1$;
static public final QualifiedName PROP_COLLECTION_TYPE = new QualifiedName(QUALIFIER, "collectionType"); //$NON-NLS-1$;
- static public final QualifiedName PROP_ONE_TO_MANY_OLD_STYLE = new QualifiedName(QUALIFIER, "oneToManyOldStyle"); //$NON-NLS-1$;
+ static public final QualifiedName PROP_ONE_TO_MANY_OLD_STYLE = new QualifiedName(QUALIFIER, "oneToManyOldStyle"); //$NON-NLS-1$;
+ static public final QualifiedName PROP_ORM_XML_FILE_NAME = new QualifiedName(QUALIFIER, "ormXmlFileName"); //$NON-NLS-1$;
+ static public final QualifiedName PROP_SUPPORT_ORM_XML = new QualifiedName(QUALIFIER, "supportOrmXml"); //$NON-NLS-1$;
private IPreferenceStore store = JPADiagramEditorPlugin.getDefault().getPreferenceStore();
@@ -103,6 +126,9 @@ public class JPADiagramPropertyPage extends PropertyPage {
createDefaultCollectionTypeControl(composite);
if (!isJPA10Project)
createOneToManyOldStyleControl(composite);
+
+ createXMLstorageControl(composite);
+
Dialog.applyDialogFont(composite);
validatePage();
return composite;
@@ -264,7 +290,7 @@ public class JPADiagramPropertyPage extends PropertyPage {
private void createCollectionTypeButton(Composite composite, GridData gd, String defaultCollectionType) {
btnCollectionType = new Button(groupCollectionType, SWT.RADIO | SWT.FLAT);
- btnCollectionType.setText(JPAEditorConstants.COLLECTION_TYPE);
+ btnCollectionType.setText("java.util.&Collection"); //$NON-NLS-1$
gd = new GridData();
btnCollectionType.setLayoutData(gd);
btnCollectionType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_COLLECTION_TYPE));
@@ -278,7 +304,7 @@ public class JPADiagramPropertyPage extends PropertyPage {
private void createListTypeButton(Composite composite, GridData gd, String defaultCollectionType) {
btnListType = new Button(groupCollectionType, SWT.RADIO | SWT.FLAT);
- btnListType.setText(JPAEditorConstants.LIST_TYPE);
+ btnListType.setText("java.util.&List"); //$NON-NLS-1$
gd = new GridData();
btnListType.setLayoutData(gd);
btnListType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_LIST_TYPE));
@@ -292,7 +318,7 @@ public class JPADiagramPropertyPage extends PropertyPage {
private void createSetTypeButton(Composite composite, GridData gd, String defaultCollectionType) {
btnSetType = new Button(groupCollectionType, SWT.RADIO | SWT.FLAT);
- btnSetType.setText(JPAEditorConstants.SET_TYPE);
+ btnSetType.setText("java.util.&Set"); //$NON-NLS-1$
gd = new GridData();
btnSetType.setLayoutData(gd);
btnSetType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_SET_TYPE));
@@ -306,7 +332,7 @@ public class JPADiagramPropertyPage extends PropertyPage {
private void createMapTypeButton(Composite composite, GridData gd, String defaultCollectionType) {
btnMapType = new Button(groupCollectionType, SWT.RADIO | SWT.FLAT);
- btnMapType.setText(JPAEditorConstants.MAP_TYPE);
+ btnMapType.setText("java.util.&Map"); //$NON-NLS-1$
gd = new GridData();
btnMapType.setLayoutData(gd);
btnMapType.setSelection(defaultCollectionType.equals(JPAEditorPreferenceInitializer.PROPERTY_VAL_MAP_TYPE));
@@ -367,6 +393,15 @@ public class JPADiagramPropertyPage extends PropertyPage {
boolean defaultOneToManyOldStyle = store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_ONE_TO_MANY_OLD_STYLE);
if (!isJPA10Project)
checkOneToManyOldStyle.setSelection(defaultOneToManyOldStyle);
+
+
+ boolean xmlSupport = store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_SUPPORT_ORM_XML);
+ if(xmlSupport){
+ String ormXml = store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_ORM_XML_FILE_NAME);
+ ormXmlName.setText(ormXml);
+ }
+
+
super.performDefaults();
}
@@ -375,6 +410,9 @@ public class JPADiagramPropertyPage extends PropertyPage {
project.getName());
IStatus statPack = JPAEditorPreferencesPage.validateDefaultPackage(txtDefaultEntityPackageField.getText().trim());
IStatus statPref = JPAEditorPreferencesPage.validateTableNamePrefix(txtDefaultTableNamePrefix.getText().trim());
+
+ IStatus statOrmXml = validateXmlName(ormXmlName.getText().trim());
+
if (statFolder.getSeverity() == IStatus.ERROR) {
setErrorMessage(statFolder.getMessage());
setValid(false);
@@ -390,6 +428,11 @@ public class JPADiagramPropertyPage extends PropertyPage {
setValid(false);
return;
}
+ if(statOrmXml.getSeverity() == IStatus.ERROR){
+ setErrorMessage(statOrmXml.getMessage());
+ setValid(false);
+ return;
+ }
setErrorMessage(null);
setValid(true);
if (statPack.getSeverity() == IStatus.WARNING) {
@@ -449,8 +492,12 @@ public class JPADiagramPropertyPage extends PropertyPage {
editorProps.put(PROP_DIRECT_EDIT_AFFECTS_CLASS.getLocalName(), "" + checkDirectEditAffectsClass.getSelection()); //$NON-NLS-1$;
editorProps.put(PROP_ACCESS_TYPE.getLocalName(), btnFieldBasedAccess.getSelection() ? JPAEditorPreferenceInitializer.PROPERTY_VAL_ACCESS_FIELD_BASED : JPAEditorPreferenceInitializer.PROPERTY_VAL_ACCESS_PROPERTY_BASED);
editorProps.put(PROP_COLLECTION_TYPE.getLocalName(), getCollectionProperty());
+
if (!isJPA10Project)
editorProps.put(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName(), "" + checkOneToManyOldStyle.getSelection()); //$NON-NLS-1$;
+
+ editorProps.put(PROP_SUPPORT_ORM_XML.getLocalName(), "" + xmlSupportButton.getSelection()); //$NON-NLS-1$
+ editorProps.put(PROP_ORM_XML_FILE_NAME.getLocalName(), ormXmlName.getText().trim());
}
@@ -479,6 +526,9 @@ public class JPADiagramPropertyPage extends PropertyPage {
editorDefaultProps.setProperty(PROP_ACCESS_TYPE.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_ENTITY_ACCESS_TYPE));
editorDefaultProps.setProperty(PROP_COLLECTION_TYPE.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_COLLECTION_TYPE));
editorDefaultProps.setProperty(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName(), "" + store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_ONE_TO_MANY_OLD_STYLE)); //$NON-NLS-1$;
+
+ editorDefaultProps.setProperty(PROP_SUPPORT_ORM_XML.getLocalName(), "" + store.getBoolean(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_SUPPORT_ORM_XML)); //$NON-NLS-1$;
+ editorDefaultProps.setProperty(PROP_ORM_XML_FILE_NAME.getLocalName(), store.getString(JPAEditorPreferenceInitializer.PROPERTY_DEFAULT_ORM_XML_FILE_NAME));
return editorDefaultProps;
@@ -579,7 +629,16 @@ public class JPADiagramPropertyPage extends PropertyPage {
Properties props = JPADiagramPropertyPage.loadProperties(project);
return shouldOneToManyUnidirBeOldStyle(project, props);
}
+
+ public static String getOrmXmlFileName(IProject project) {
+ Properties props = JPADiagramPropertyPage.loadProperties(project);
+ return getOrmXmlFileName(project, props);
+ }
+ public static boolean doesSupportOrmXml(IProject project) {
+ Properties props = JPADiagramPropertyPage.loadProperties(project);
+ return doesSupportOrmXml(project, props);
+ }
//---------------------------------------------------------------------------------------------------
public static String getDefaultFolder(IProject project, Properties props) {
@@ -626,5 +685,203 @@ public class JPADiagramPropertyPage extends PropertyPage {
public static boolean shouldOneToManyUnidirBeOldStyle(IProject project, Properties props) {
return Boolean.parseBoolean(props.getProperty(PROP_ONE_TO_MANY_OLD_STYLE.getLocalName()));
}
+
+ public static String getOrmXmlFileName(IProject project, Properties props) {
+ return props.getProperty(PROP_ORM_XML_FILE_NAME.getLocalName());
+ }
+
+ public static boolean doesSupportOrmXml(IProject project, Properties props) {
+ return Boolean.parseBoolean(props.getProperty(PROP_SUPPORT_ORM_XML.getLocalName()));
+ }
+
+ /**
+ * Create the group, which manage entity mapping registration
+ * @param parent the main composite
+ */
+ private void createXMLstorageControl(Composite parent) {
+ Group group = createGroup(parent, JptJpaUiWizardsEntityMessages.XML_STORAGE_GROUP);
+ this.xmlSupportButton = createCheckButton(group, JptJpaUiWizardsEntityMessages.XML_SUPPORT);
+ createBrowseGroup(group, JPAEditorMessages.JPADiagramPropertyPage_ChooseXMLLabel);
+ this.xmlSupportButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean isChecked = xmlSupportButton.getSelection();
+ enableMappingXMLChooseGroup(isChecked);
+ validatePage();
+ propsModified = true;
+ }
+ });
+ }
+
+ /**
+ * @param parent the main composite
+ * @param text the name/title of the group
+ * @return the created group
+ */
+ private Group createGroup(Composite parent, String text) {
+ Group group = new Group(parent, SWT.NONE);
+ GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL);
+ groupGridData.horizontalSpan = 3;
+ group.setLayoutData(groupGridData);
+ group.setLayout(new GridLayout(3, false));
+ group.setText(text);
+ group.setToolTipText(JPAEditorMessages.JPADiagramPropertyPage_ChooseXMLGroupTooltip);
+ return group;
+ }
+
+ /**
+ * Create check button
+ * @param parent the main composite - inheritance group
+ * @param text the label of the button
+ * @return the created button
+ */
+ private Button createCheckButton(Composite parent, String text) {
+ final Button button = new Button(parent, SWT.CHECK);
+ GridData groupGridData = new GridData(GridData.FILL_HORIZONTAL);
+ groupGridData.horizontalSpan = 3;
+ button.setLayoutData(groupGridData);
+ button.setText(text);
+ button.setToolTipText(JPAEditorMessages.JPADiagramPropertyPage_ChooseXMLCheckboxTooltip);
+ button.setSelection(doesSupportOrmXml(project));
+ return button;
+ }
+
+ /**
+ * Create XML group
+ * @param parent the main composite
+ * @param label the name of the group
+ * @param property the related property to which this group will be synchronized
+ * @return the created group
+ */
+ private void createBrowseGroup(Composite parent, String label) {
+ Composite composite = new Composite(parent, SWT.NULL);
+ composite.setLayout(new GridLayout(3, false));
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ this.displayNameLabel = new Label(composite, SWT.LEFT);
+ this.displayNameLabel.setText(label);
+ this.displayNameLabel.setToolTipText(JPAEditorMessages.JPADiagramPropertyPage_ChooseXMLTooltip);
+ this.displayNameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
+
+ this.ormXmlName = new Text(composite, SWT.SINGLE | SWT.BORDER);
+ this.ormXmlName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ String ormXmlFileName = editorProps.getProperty(PROP_ORM_XML_FILE_NAME.getLocalName());
+ this.ormXmlName.setText(ormXmlFileName);
+ this.ormXmlName.setToolTipText(JPAEditorMessages.JPADiagramPropertyPage_ChooseXMLTooltip);
+
+ this.browseButton = new Button(composite, SWT.PUSH);
+ this.browseButton.setText(JPAEditorMessages.JPADiagramPropertyPage_ChooseXmlBrowseButton);
+ this.browseButton.setToolTipText(JPAEditorMessages.JPADiagramPropertyPage_ChooseXMLTooltip);
+ GridData browseButtonData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
+ browseButtonData.horizontalSpan = 1;
+ this.browseButton.setLayoutData(browseButtonData);
+ this.browseButton.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ handleChooseXmlButtonPressed();
+ propsModified = true;
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ });
+
+ this.ormXmlName.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ validatePage();
+ propsModified = true;
+ }
+ });
+
+ enableMappingXMLChooseGroup(xmlSupportButton.getSelection());
+ }
+
+ /**
+ * Process browsing when the Browse... button have been pressed. Allow choosing of
+ * XML for entity mapping registration
+ *
+ */
+ private void handleChooseXmlButtonPressed() {
+ if (project == null) {
+ return;
+ }
+ JpaProject jpaProject = this.getJpaProject(project);
+ if (jpaProject == null) {
+ return;
+ }
+ ViewerFilter filter = getDialogViewerFilter(jpaProject);
+ ITreeContentProvider contentProvider = new WorkbenchContentProvider();
+ ILabelProvider labelProvider = new WorkbenchLabelProvider();
+ SelectMappingFileDialog dialog = new SelectMappingFileDialog(getShell(), project, labelProvider, contentProvider);
+ dialog.setTitle(JptJpaUiWizardsEntityMessages.MAPPING_XML_TITLE);
+ dialog.setMessage(JptJpaUiWizardsEntityMessages.CHOOSE_MAPPING_XML_MESSAGE);
+ dialog.addFilter(filter);
+
+ String ormFileName = this.ormXmlName.getText();
+ JptXmlResource resource = jpaProject.getMappingFileXmlResource(new Path(ormFileName));
+ IFile initialSelection = (resource != null) ? resource.getFile() : null;
+ dialog.setInput(project);
+
+ if (initialSelection != null) {
+ dialog.setInitialSelection(initialSelection);
+ }
+ if (dialog.open() == Window.OK) {
+ boolean noNameChange = false;
+ if (ormXmlName.getText().equals(dialog.getChosenName())) {
+ noNameChange = true;
+ }
+ ormXmlName.setText(dialog.getChosenName());
+ if (noNameChange) {
+ this.validatePage();
+ }
+ }
+ }
+
+
+ /**
+ * This method create filter for the browse/add alternative mapping XML
+ * @return new instance of viewer filter for the SelectMappingXMLDialog
+ */
+ protected ViewerFilter getDialogViewerFilter(JpaProject jpaProject) {
+ return new XmlMappingFileViewerFilter(jpaProject, ResourceMappingFile.Root.CONTENT_TYPE);
+ }
+
+ private void enableMappingXMLChooseGroup(boolean enabled) {
+ this.displayNameLabel.setEnabled(enabled);
+ this.ormXmlName.setEnabled(enabled);
+ this.browseButton.setEnabled(enabled);
+ }
+
+ protected JpaProject getJpaProject(IProject project) {
+ return (JpaProject) project.getAdapter(JpaProject.class);
+ }
+
+ /**
+ * This method will be used to validate the correctness of xml file location.
+ * This method will accept a null parameter.
+ */
+ private IStatus validateXmlName(String xmlName) {
+ if (xmlSupportButton.getSelection()) {
+ JptXmlResource ormXmlResource = StringTools.isBlank(xmlName) ? null : getOrmXmlResource(xmlName);
+ if (ormXmlResource == null) {
+
+ return new Status(IStatus.ERROR,
+ JPADiagramEditorPlugin.PLUGIN_ID,
+ JPAEditorMessages.JPADiagramPropertyPage_NotExistsXmlErrorMsg);
+ }
+ JpaProject jpaProject = this.getJpaProject(project);
+ if ((jpaProject == null) || jpaProject.getJpaFile(ormXmlResource.getFile()).getRootStructureNodesSize() == 0) {
+ return new Status(IStatus.ERROR,
+ JPADiagramEditorPlugin.PLUGIN_ID,
+ JPAEditorMessages.JPADiagramPropertyPage_NotAddedXMLErrorMsg);
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
+ private JptXmlResource getOrmXmlResource(String xmlName) {
+ JpaProject jpaProject = this.getJpaProject(project);
+ return (jpaProject == null) ? null : jpaProject.getMappingFileXmlResource(new Path(xmlName));
+ }
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java
index a8526f23ea..8ac38f1ca6 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/IJPAEditorFeatureProvider.java
@@ -18,6 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.provider;
import java.util.Collection;
import java.util.HashSet;
import java.util.Properties;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
@@ -29,8 +30,8 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.IPeService;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.IModelIntegrationUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation;
@@ -52,7 +53,7 @@ public interface IJPAEditorFeatureProvider extends IFeatureProvider{
public HashSet<HasReferanceRelation> getAllExistingHasReferenceRelations();
- public ICompilationUnit getCompilationUnit(JavaPersistentType jpt);
+ public ICompilationUnit getCompilationUnit(PersistentType jpt);
public boolean hasObjectWithName(String name);
@@ -62,28 +63,28 @@ public interface IJPAEditorFeatureProvider extends IFeatureProvider{
public Object remove(String key, boolean save);
- public IRelation getRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa);
-
- public HasReferanceRelation getEmbeddedRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa);
+ public Set<IRelation> getRelationRelatedToAttribute(PersistentAttribute jpa, String typeName);
+
+ public HasReferanceRelation getEmbeddedRelationRelatedToAttribute(PersistentAttribute jpa);
public Object getBusinessObjectForKey(String key);
public void addJPTForUpdate(String jptName);
- public boolean doesRelationExist(JavaPersistentType owner,
- JavaPersistentType inverse,
+ public boolean doesRelationExist(PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
String inverseAttributeName,
RelType relType,
RelDir relDir);
- public boolean doesEmbeddedRelationExist(JavaPersistentType embeddable, JavaPersistentType embeddingEntity, String embeddedAttributeName, HasReferenceType relType);
+ public boolean doesEmbeddedRelationExist(PersistentType embeddable, PersistentType embeddingEntity, String embeddedAttributeName, HasReferenceType relType);
- public void restoreEntity(JavaPersistentType jpt);
+ public void restoreEntity(PersistentType jpt);
- public void addRemoveIgnore(JavaPersistentType jpt, String atName);
+ public void addRemoveIgnore(PersistentType jpt, String atName);
- public void addAddIgnore(JavaPersistentType jpt, String atName);
+ public void addAddIgnore(PersistentType jpt, String atName);
public void putKeyToBusinessObject(String key, Object bo);
@@ -92,10 +93,10 @@ public interface IJPAEditorFeatureProvider extends IFeatureProvider{
public int increaseAttribsNum(Shape sh);
public int decreaseAttribsNum(Shape sh);
-
- public void replaceAttribute(JavaSpecifiedPersistentAttribute oldAt, JavaSpecifiedPersistentAttribute newAt);
-
- public void renewAttributeJoiningStrategyPropertyListener(JavaSpecifiedPersistentAttribute jpa);
+
+ public void replaceAttribute(PersistentAttribute oldAt, PersistentAttribute newAt);
+
+ public void renewAttributeJoiningStrategyPropertyListener(PersistentAttribute jpa);
public IPeService getPeService();
@@ -117,16 +118,16 @@ public interface IJPAEditorFeatureProvider extends IFeatureProvider{
public Properties loadProperties(IProject project);
- public Collection<JavaPersistentType> getPersistentTypes();
+ public Collection<PersistentType> getPersistentTypes();
- public JavaPersistentType getFirstSuperclassBelongingToTheDiagram(JavaPersistentType subclass);
+ public PersistentType getFirstSuperclassBelongingToTheDiagram(PersistentType subclass);
public void removeAllRedundantIsARelations();
public boolean existRedundantIsARelations();
- public void setGrayColor(final JavaPersistentType jpt);
+ public void setGrayColor(final PersistentType jpt);
public void setOriginalPersistentTypeColor();
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
index a89576ef04..d3550e8fba 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorDiagramTypeProvider.java
@@ -47,8 +47,7 @@ import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor;
@@ -114,12 +113,11 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) {
- JavaPersistentType jpt = classRef.getJavaPersistentType();
- if (jpt.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) {
+ PersistentType jpt = classRef.getJavaPersistentType();
PictogramElement pe = getFeatureProvider().getPictogramElementForBusinessObject(jpt);
if (pe == null)
return true;
- }
+// }
}
}
return false;
@@ -253,8 +251,10 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
// create new pictograms
while (itr.hasMoreElements()) {
String entityName = itr.nextElement();
- JavaPersistentType jpt = JpaArtifactFactory.instance().getContextPersistentType(proj, entityName);
+ PersistentType jpt = JpaArtifactFactory.instance().getContextPersistentType(proj, entityName);
if (jpt != null) {
+ if(getFeatureProvider().getPictogramElementForBusinessObject(jpt) != null)
+ continue;
SizePosition sp = marks.get(entityName);
AddContext ctx = new AddEntityContext(sp.primaryCollapsed,
sp.relationCollapsed, sp.basicCollapsed);
@@ -313,4 +313,4 @@ public class JPAEditorDiagramTypeProvider extends AbstractDiagramTypeProvider {
setFeatureProvider(null);
isDisposed = true;
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
index 7b2959ad29..3d8eec9878 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorFeatureProvider.java
@@ -22,6 +22,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.emf.common.util.EList;
@@ -55,6 +56,7 @@ import org.eclipse.graphiti.internal.services.GraphitiInternal;
import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.Rectangle;
import org.eclipse.graphiti.mm.algorithms.Text;
+import org.eclipse.graphiti.mm.algorithms.styles.AdaptedGradientColoredAreas;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
@@ -62,6 +64,7 @@ import org.eclipse.graphiti.mm.pictograms.Diagram;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
+import org.eclipse.graphiti.services.IGaService;
import org.eclipse.graphiti.services.IPeService;
import org.eclipse.graphiti.ui.features.DefaultFeatureProvider;
import org.eclipse.graphiti.util.IColorConstant;
@@ -71,11 +74,9 @@ import org.eclipse.jdt.internal.core.CompilationUnit;
import org.eclipse.jdt.internal.core.SourceType;
import org.eclipse.jpt.jpa.core.JpaModel;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.SpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-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.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
@@ -238,7 +239,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
} catch (NullPointerException e) {
return true;
}
- if (!rel.getSuperclass().equals(getFirstSuperclassBelongingToTheDiagram(rel.getSubclass()))) {
+ if (!rel.getSuperclass().getName().equals(getFirstSuperclassBelongingToTheDiagram(rel.getSubclass()).getName())) {
return true;
}
}
@@ -246,7 +247,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
return false;
}
- public JavaPersistentType getFirstSuperclassBelongingToTheDiagram(JavaPersistentType subclass) {
+ public PersistentType getFirstSuperclassBelongingToTheDiagram(PersistentType subclass) {
Iterable<PersistentType> h = subclass.getInheritanceHierarchy();
Iterator<PersistentType> iter = h.iterator();
@@ -257,7 +258,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
while (iter.hasNext()) {
PersistentType superclass = iter.next();
if (hasObjectWithName(getKeyForBusinessObject(superclass))) {
- return (JavaPersistentType) superclass;
+ return superclass;
}
if (!cycleChecker.add(superclass))
return null;
@@ -271,11 +272,11 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
}
- public void addRemoveIgnore(JavaPersistentType jpt, String atName) {
+ public void addRemoveIgnore(PersistentType jpt, String atName) {
((JPASolver)getIndependenceSolver()).addRemoveIgnore(jpt.getName() + "." + atName); //$NON-NLS-1$
}
- public void addAddIgnore(JavaPersistentType jpt, String atName) {
+ public void addAddIgnore(PersistentType jpt, String atName) {
((JPASolver)getIndependenceSolver()).addAddIgnore(jpt.getName() + "." + atName); //$NON-NLS-1$
}
@@ -291,20 +292,20 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
@Override
public IAddFeature getAddFeature(IAddContext context) {
Object newObj = context.getNewObject();
- if (newObj instanceof JavaPersistentType) {
+ if (newObj instanceof PersistentType) {
return new AddJPAEntityFeature(this, true);
} else if (newObj instanceof AbstractRelation) {
return new AddRelationFeature(this);
} else if (newObj instanceof HasReferanceRelation) {
return new AddHasReferenceRelationFeature(this);
- } else if (newObj instanceof SpecifiedPersistentAttribute) {
+ } else if (newObj instanceof PersistentAttribute) {
if (Diagram.class.isInstance(context.getTargetContainer())) {
return null;
}
return new AddAttributeFeature(this);
} else if (newObj instanceof CompilationUnit) {
CompilationUnit cu = (CompilationUnit)newObj;
- JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
+ PersistentType jpt = JPAEditorUtil.getJPType(cu);
if (jpt != null) return new AddJPAEntityFeature(this, true);
} else if ((newObj instanceof JpaModel)) {
return new AddAllEntitiesFeature(this);
@@ -326,12 +327,12 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
public IDeleteFeature getDeleteFeature(IDeleteContext context) {
PictogramElement pe = context.getPictogramElement();
Object bo = getBusinessObjectForPictogramElement(pe);
- if (bo instanceof JavaPersistentType) {
+ if (bo instanceof PersistentType) {
return new DeleteJPAEntityFeature(this);
} else if ((bo instanceof AbstractRelation) ||
(bo instanceof HasReferanceRelation || (bo instanceof IsARelation))) {
return new DeleteRelationFeature(this);
- } else if (bo instanceof JavaSpecifiedPersistentAttribute) {
+ } else if (bo instanceof PersistentAttribute) {
return new ClickRemoveAttributeButtonFeature(this);
}
return null;
@@ -361,7 +362,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
@Override
public IResizeShapeFeature getResizeShapeFeature(IResizeShapeContext context) {
PictogramElement pe = context.getPictogramElement();
- if (getBusinessObjectForPictogramElement(pe) instanceof JavaPersistentType) {
+ if (getBusinessObjectForPictogramElement(pe) instanceof PersistentType) {
return new ResizeJPAEntityFeature(this);
}
GraphicsAlgorithm ga = pe.getGraphicsAlgorithm();
@@ -382,7 +383,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
public ILayoutFeature getLayoutFeature(ILayoutContext context) {
PictogramElement pictogramElement = context.getPictogramElement();
Object bo = getBusinessObjectForPictogramElement(pictogramElement);
- if (bo instanceof JavaPersistentType) {
+ if (bo instanceof PersistentType) {
return new LayoutJPAEntityFeature(this);
}
return super.getLayoutFeature(context);
@@ -395,7 +396,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
Object bo = getBusinessObjectForPictogramElement(pe);
if (bo == null)
super.getRemoveFeature(context);
- if (bo instanceof JavaPersistentType) {
+ if (bo instanceof PersistentType) {
return new RemoveJPAEntityFeature(this, true);
} else if ((bo instanceof AbstractRelation) ||
(bo instanceof HasReferanceRelation) || (bo instanceof IsARelation)){
@@ -437,7 +438,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
public IMoveShapeFeature getMoveShapeFeature(IMoveShapeContext context) {
PictogramElement pe = context.getPictogramElement();
Object bo = getBusinessObjectForPictogramElement(pe);
- if (JavaPersistentType.class.isInstance(bo)) {
+ if (PersistentType.class.isInstance(bo)) {
return new MoveEntityShapeFeature(this);
}
if(bo == null){
@@ -470,7 +471,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
return super.getDirectEditingFeature(context);
Object bo = getBusinessObjectForPictogramElement(pe);
if (bo != null) {
- if (bo instanceof JavaSpecifiedPersistentAttribute) {
+ if (bo instanceof PersistentAttribute) {
return new DirectEditAttributeFeature(this);
}
}
@@ -481,13 +482,13 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
if (csh == null)
return super.getDirectEditingFeature(context);
bo = getBusinessObjectForPictogramElement(csh);
- if (bo instanceof JavaPersistentType){
+ if (bo instanceof PersistentType){
return new DirectEditJPAEntityFeature(this);
}
return super.getDirectEditingFeature(context);
}
-
- public void renewAttributeJoiningStrategyPropertyListener(JavaSpecifiedPersistentAttribute jpa) {
+
+ public void renewAttributeJoiningStrategyPropertyListener(PersistentAttribute jpa) {
((JPASolver)getIndependenceSolver()).renewAttributeJoiningStrategyPropertyListener(jpa);
}
@@ -536,11 +537,11 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
public Object remove(String key, boolean save) {
Object res = getBusinessObjectForKey(key);
- if (res instanceof JavaPersistentType) {
- final JavaPersistentType jpt = (JavaPersistentType)res;
+ if (res instanceof PersistentType) {
+ final PersistentType jpt = (PersistentType)res;
if (save)
JpaArtifactFactory.instance().forceSaveEntityClass(jpt, this);
- if(!(jpt.getMapping() instanceof JavaEntity)){
+ if(!(jpt.getMapping() instanceof Entity)){
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
removeFromDiagramIfNotPersistentType(jpt);
@@ -551,7 +552,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
return ((JPASolver)getIndependenceSolver()).remove(key);
}
- public Collection<JavaPersistentType> getPersistentTypes() {
+ public Collection<PersistentType> getPersistentTypes() {
return ((JPASolver)getIndependenceSolver()).getPersistentTypes();
}
@@ -573,7 +574,7 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
}
- private void removeFromDiagramIfNotPersistentType(final JavaPersistentType jpt) {
+ private void removeFromDiagramIfNotPersistentType(final PersistentType jpt) {
final PictogramElement cs = this.getPictogramElementForBusinessObject(jpt);
if (cs != null) {
final Shape shape = (Shape) cs;
@@ -594,8 +595,8 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
public boolean hasObjectWithName(String name) {
return ((JPASolver)getIndependenceSolver()).containsKey(name);
}
-
- public void replaceAttribute(final JavaSpecifiedPersistentAttribute oldAt, final JavaSpecifiedPersistentAttribute newAt) {
+
+ public void replaceAttribute(final PersistentAttribute oldAt, final PersistentAttribute newAt) {
final PictogramElement pe = this.getPictogramElementForBusinessObject(oldAt);
if (pe == null) {
//System.err.println("PictogramElement is null\n");
@@ -623,8 +624,8 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
});
}
- public boolean doesRelationExist(JavaPersistentType owner,
- JavaPersistentType inverse,
+ public boolean doesRelationExist(PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
String inverseAttributeName,
RelType relType,
@@ -634,28 +635,28 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
return (getBusinessObjectForKey(id) != null);
}
- public boolean doesEmbeddedRelationExist(JavaPersistentType embeddable, JavaPersistentType embeddingEntity, String embeddedAttributeName, HasReferenceType relType){
+ public boolean doesEmbeddedRelationExist(PersistentType embeddable, PersistentType embeddingEntity, String embeddedAttributeName, HasReferenceType relType){
String id = HasReferanceRelation.generateId(embeddingEntity, embeddable, embeddedAttributeName, relType);
return (getBusinessObjectForKey(id) != null);
}
-
- public boolean isRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa) {
+
+ public boolean isRelationRelatedToAttribute(PersistentAttribute jpa) {
return ((JPASolver)getIndependenceSolver()).isRelationRelatedToAttribute(jpa);
}
- public IRelation getRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa) {
- return ((JPASolver)getIndependenceSolver()).getRelationRelatedToAttribute(jpa, this);
+ public Set<IRelation> getRelationRelatedToAttribute(PersistentAttribute jpa, String typeName) {
+ return ((JPASolver)getIndependenceSolver()).getRelationRelatedToAttribute(jpa, typeName, this);
}
-
- public HasReferanceRelation getEmbeddedRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa) {
+
+ public HasReferanceRelation getEmbeddedRelationRelatedToAttribute(PersistentAttribute jpa) {
return ((JPASolver)getIndependenceSolver()).getEmbeddedRelationToAttribute(jpa);
}
- public ICompilationUnit getCompilationUnit(JavaPersistentType jpt) {
+ public ICompilationUnit getCompilationUnit(PersistentType jpt) {
return ((JPASolver)getIndependenceSolver()).getCompilationUnit(jpt);
}
- public void restoreEntity(JavaPersistentType jpt) {
+ public void restoreEntity(PersistentType jpt) {
((JPASolver)getIndependenceSolver()).restoreEntity(jpt);
}
@@ -754,9 +755,9 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
/**
* Color the given persistent type in gray.
- * @param jpt - the {@link JavaPersistentType} to be colored.
+ * @param jpt - the {@link PersistentType} to be colored.
*/
- public void setGrayColor(final JavaPersistentType jpt) {
+ public void setGrayColor(final PersistentType jpt) {
final PictogramElement pe = getPictogramElementForBusinessObject(jpt);
if(pe == null)
return;
@@ -781,30 +782,32 @@ public class JPAEditorFeatureProvider extends DefaultFeatureProvider implements
* type.
*/
public void setOriginalPersistentTypeColor(){
- Diagram d = getDiagram();
+ final Diagram d = getDiagram();
JpaProject project = ModelIntegrationUtil.getProjectByDiagram(d.getName());
PersistenceUnit unit = project.getContextModelRoot().getPersistenceXml().
getRoot().getPersistenceUnits().iterator().next();
for (ClassRef classRef : unit.getClassRefs()) {
if (classRef.getJavaPersistentType() != null) { // null if
- final JavaPersistentType jpt = classRef.getJavaPersistentType();
- final PictogramElement pe = getPictogramElementForBusinessObject(jpt);
+ final PersistentType jpt = classRef.getJavaPersistentType();
+ PictogramElement pe = getPictogramElementForBusinessObject(jpt);
if(pe == null)
continue;
- TransactionalEditingDomain ted = getTransactionalEditingDomain();
+ final GraphicsAlgorithm algo = pe.getGraphicsAlgorithm();
+ TransactionalEditingDomain ted = TransactionUtil.getEditingDomain(algo);
JPAEditorConstants.DIAGRAM_OBJECT_TYPE dot = JpaArtifactFactory.instance().determineDiagramObjectType(jpt);
- final String renderingStyle = JpaArtifactFactory.instance().getRenderingStyle(dot);
+ String renderingStyle = JpaArtifactFactory.instance().getRenderingStyle(dot);
final IColorConstant foreground = JpaArtifactFactory.instance().getForeground(dot);
+ final AdaptedGradientColoredAreas gradientColoredArea = JPAEditorPredefinedColoredAreas.getAdaptedGradientColoredAreas(renderingStyle);
+ final IGaService gaService = Graphiti.getGaService();
if(ted == null)
continue;
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- Graphiti.getGaService().setRenderingStyle(pe.getGraphicsAlgorithm(),
- JPAEditorPredefinedColoredAreas.getAdaptedGradientColoredAreas(renderingStyle));
- pe.getGraphicsAlgorithm().setForeground(Graphiti.getGaService().manageColor(getDiagram(), foreground));
+ gaService.setRenderingStyle(algo, gradientColoredArea);
+ algo.setForeground(gaService.manageColor(d, foreground));
}
});
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java
index 6c3d8b5298..679a08f98c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/provider/JPAEditorToolBehaviorProvider.java
@@ -60,8 +60,8 @@ import org.eclipse.graphiti.tb.IContextMenuEntry;
import org.eclipse.graphiti.tb.IDecorator;
import org.eclipse.graphiti.tb.ImageDecorator;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.facade.EclipseFacade;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.AddAllEntitiesFeature;
@@ -364,8 +364,8 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
IFeatureProvider featureProvider = getFeatureProvider();
Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType persistentType = (JavaPersistentType) bo;
+ if (bo instanceof PersistentType) {
+ PersistentType persistentType = (PersistentType) bo;
IFile file = (IFile) persistentType.getResource();
if(!file.exists()){
return new IDecorator[0];
@@ -459,15 +459,15 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(pe);
if (bo != null) {
- if (bo instanceof JavaPersistentType) {
+ if (bo instanceof PersistentType) {
String superPersistentTypeName = null;
- if (((JavaPersistentType) bo).getSuperPersistentType() != null) {
- superPersistentTypeName = ((JavaPersistentType) bo).getSuperPersistentType().getName();
+ if (((PersistentType) bo).getSuperPersistentType() != null) {
+ superPersistentTypeName = ((PersistentType) bo).getSuperPersistentType().getName();
}
- return JPAEditorUtil.getTooltipText((JavaPersistentType)bo, superPersistentTypeName);
+ return JPAEditorUtil.getTooltipText((PersistentType)bo, superPersistentTypeName);
} else {
- if (bo instanceof JavaSpecifiedPersistentAttribute) {
- return JPAEditorUtil.getTooltipText((JavaSpecifiedPersistentAttribute)bo);
+ if (bo instanceof PersistentAttribute) {
+ return JPAEditorUtil.getTooltipText((PersistentAttribute)bo);
}
}
}
@@ -478,13 +478,13 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
if (csh == null)
return null;
bo = getFeatureProvider().getBusinessObjectForPictogramElement(csh);
- if (bo instanceof JavaPersistentType) {
+ if (bo instanceof PersistentType) {
String superPersistentTypeName = null;
- if (((JavaPersistentType) bo).getSuperPersistentType() != null) {
- superPersistentTypeName = ((JavaPersistentType) bo)
+ if (((PersistentType) bo).getSuperPersistentType() != null) {
+ superPersistentTypeName = ((PersistentType) bo)
.getSuperPersistentType().getName();
}
- return JPAEditorUtil.getTooltipText((JavaPersistentType) bo,
+ return JPAEditorUtil.getTooltipText((PersistentType) bo,
superPersistentTypeName);
}
return null;
@@ -683,9 +683,8 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
PictogramElement pe = context.getPictogramElements()[0];
Object bo = getFeatureProvider().getBusinessObjectForPictogramElement(
pe);
- if (bo instanceof JavaSpecifiedPersistentAttribute) {
- JavaSpecifiedPersistentAttribute jpa = (JavaSpecifiedPersistentAttribute) bo;
- IFile file = (IFile) jpa.getResource();
+ if(bo != null) {
+ IFile file = getResourceTobeOpened(bo);
try {
file.setSessionProperty(new QualifiedName(null, JPAEditorMatchingStrategy.DOUBLE_CLICK), "true"); //$NON-NLS-1$
facade.getIDE().openEditor(file);
@@ -695,18 +694,6 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
JPADiagramEditorPlugin.logError("Cannot open editor", e); //$NON-NLS-1$
}
}
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType) bo;
- IFile file = (IFile) jpt.getResource();
- try {
- file.setSessionProperty(new QualifiedName(null, JPAEditorMatchingStrategy.DOUBLE_CLICK), "true"); //$NON-NLS-1$
- facade.getIDE().openEditor(file);
- } catch (PartInitException e) {
- JPADiagramEditorPlugin.logError("Cannot open editor", e); //$NON-NLS-1$
- } catch (CoreException e) {
- JPADiagramEditorPlugin.logError("Cannot open editor", e); //$NON-NLS-1$
- }
- }
if ((bo == null) && (pe.getGraphicsAlgorithm() instanceof Rectangle)) {
ICustomContext cont = new CustomContext(
new PictogramElement[] { pe });
@@ -723,6 +710,19 @@ public class JPAEditorToolBehaviorProvider extends DefaultToolBehaviorProvider {
}
return super.getDoubleClickFeature(context);
- }
+ }
+
+ public IFile getResourceTobeOpened(Object bo){
+ IFile file = null;
+ if (bo instanceof PersistentAttribute) {
+ PersistentAttribute jpa = (PersistentAttribute) bo;
+ file = (IFile) jpa.getJavaPersistentAttribute().getResource();
+ } else if (bo instanceof PersistentType) {
+ PersistentType jpt = (PersistentType) bo;
+ file = (IFile) jpt.getResource();
+ }
+
+ return file;
+ }
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/AbstractRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/AbstractRelation.java
index dd272dbedb..6f304f79ac 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/AbstractRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/AbstractRelation.java
@@ -17,15 +17,15 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
import java.util.Hashtable;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
abstract public class AbstractRelation implements IRelation {
protected final static String SEPARATOR = ";"; //$NON-NLS-1$
- protected JavaPersistentType owner;
- protected JavaPersistentType inverse;
- protected JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute;
- protected JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute;
+ protected PersistentType owner;
+ protected PersistentType inverse;
+ protected PersistentAttribute ownerAnnotatedAttribute;
+ protected PersistentAttribute inverseAnnotatedAttribute;
protected String ownerAttributeName;
protected String inverseAttributeName;
@@ -44,7 +44,7 @@ abstract public class AbstractRelation implements IRelation {
relDirToIdPart.put(RelDir.BI, "<->"); //$NON-NLS-1$
}
- public AbstractRelation(JavaPersistentType owner, JavaPersistentType inverse) {
+ public AbstractRelation(PersistentType owner, PersistentType inverse) {
this.owner = owner;
this.inverse = inverse;
}
@@ -53,29 +53,29 @@ abstract public class AbstractRelation implements IRelation {
return generateId(owner, inverse, getOwnerAttributeName(), getInverseAttributeName(), getRelType(), getRelDir());
}
- public JavaPersistentType getOwner() {
+ public PersistentType getOwner() {
return owner;
}
- public JavaPersistentType getInverse() {
+ public PersistentType getInverse() {
return inverse;
}
-
- public JavaSpecifiedPersistentAttribute getInverseAnnotatedAttribute() {
+
+ public PersistentAttribute getInverseAnnotatedAttribute() {
return inverseAnnotatedAttribute;
}
-
- public JavaSpecifiedPersistentAttribute getOwnerAnnotatedAttribute() {
+
+ public PersistentAttribute getOwnerAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
public void setOwnerAnnotatedAttribute(
- JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute) {
+ PersistentAttribute ownerAnnotatedAttribute) {
this.ownerAnnotatedAttribute = ownerAnnotatedAttribute;
}
public void setInverseAnnotatedAttribute(
- JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute) {
+ PersistentAttribute inverseAnnotatedAttribute) {
this.inverseAnnotatedAttribute = inverseAnnotatedAttribute;
}
@@ -115,8 +115,8 @@ abstract public class AbstractRelation implements IRelation {
public abstract RelDir getRelDir();
- public static String generateId(JavaPersistentType owner,
- JavaPersistentType inverse,
+ public static String generateId(PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
String inverseAttributeName,
RelType relType,
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasCollectionReferenceRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasCollectionReferenceRelation.java
index e4ba675db1..a1cd8ed76c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasCollectionReferenceRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasCollectionReferenceRelation.java
@@ -17,13 +17,13 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
import org.eclipse.graphiti.mm.pictograms.Connection;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
public class HasCollectionReferenceRelation extends HasReferanceRelation{
- public HasCollectionReferenceRelation(JavaPersistentType embeddingEntity,
- JavaPersistentType embeddable) {
+ public HasCollectionReferenceRelation(PersistentType embeddingEntity,
+ PersistentType embeddable) {
super(embeddingEntity, embeddable);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasReferanceRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasReferanceRelation.java
index 9e1eccb9aa..8e9547d0e3 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasReferanceRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasReferanceRelation.java
@@ -21,20 +21,20 @@ import java.util.Hashtable;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
public abstract class HasReferanceRelation {
protected final static String SEPARATOR = ";hasReference;"; //$NON-NLS-1$
- protected JavaPersistentType embeddingEntity;
- protected JavaPersistentType embeddable;
+ protected PersistentType embeddingEntity;
+ protected PersistentType embeddable;
public final static Hashtable<HasReferenceType, String> relTypeToIdPart = new Hashtable<HasReferenceType, String>();
-
- private JavaSpecifiedPersistentAttribute embeddedAnnotatedAttribute;
+
+ private PersistentAttribute embeddedAnnotatedAttribute;
public static enum HasReferenceType {
SINGLE, COLLECTION
@@ -45,8 +45,8 @@ public abstract class HasReferanceRelation {
relTypeToIdPart.put(HasReferenceType.COLLECTION, "1-N;"); //$NON-NLS-1$
}
- public HasReferanceRelation(JavaPersistentType embeddingEntity,
- JavaPersistentType embeddable) {
+ public HasReferanceRelation(PersistentType embeddingEntity,
+ PersistentType embeddable) {
this.embeddingEntity = embeddingEntity;
this.embeddable = embeddable;
}
@@ -58,18 +58,18 @@ public abstract class HasReferanceRelation {
Object endObj = fp.getBusinessObjectForPictogramElement((ContainerShape)end.eContainer());
if ((endObj == null) || (startObj == null))
throw new NullPointerException("Some of the connection ends is null"); //$NON-NLS-1$
- if (!(endObj instanceof JavaPersistentType) || !(startObj instanceof JavaPersistentType))
+ if (!(endObj instanceof PersistentType) || !(startObj instanceof PersistentType))
throw new IllegalArgumentException();
- this.embeddingEntity = (JavaPersistentType)startObj;
- this.embeddable = (JavaPersistentType)endObj;
+ this.embeddingEntity = (PersistentType)startObj;
+ this.embeddable = (PersistentType)endObj;
}
- public JavaPersistentType getEmbeddable() {
+ public PersistentType getEmbeddable() {
return embeddable;
}
- public JavaPersistentType getEmbeddingEntity() {
+ public PersistentType getEmbeddingEntity() {
return embeddingEntity;
}
@@ -77,7 +77,7 @@ public abstract class HasReferanceRelation {
return generateId(embeddingEntity, embeddable, embeddedAnnotatedAttribute.getName(), getReferenceType());
}
- public static String generateId(JavaPersistentType startJpt, JavaPersistentType endJpt, String embeddedAttributeName, HasReferenceType relType) {
+ public static String generateId(PersistentType startJpt, PersistentType endJpt, String embeddedAttributeName, HasReferenceType relType) {
return JPAEditorConstants.HAS_REFERENCE_RELATION_ID_PREFIX +
startJpt.getName() + SEPARATOR + relTypeToIdPart.get(relType) + endJpt.getName()+ "-" + embeddedAttributeName; //$NON-NLS-1$
}
@@ -95,12 +95,12 @@ public abstract class HasReferanceRelation {
}
public abstract HasReferenceType getReferenceType();
-
- public JavaSpecifiedPersistentAttribute getEmbeddedAnnotatedAttribute() {
+
+ public PersistentAttribute getEmbeddedAnnotatedAttribute() {
return embeddedAnnotatedAttribute;
}
-
- public void setEmbeddedAnnotatedAttribute(JavaSpecifiedPersistentAttribute embeddedAnnotatedAttribute) {
+
+ public void setEmbeddedAnnotatedAttribute(PersistentAttribute embeddedAnnotatedAttribute) {
this.embeddedAnnotatedAttribute = embeddedAnnotatedAttribute;
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasSingleReferenceRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasSingleReferenceRelation.java
index 807f064125..6fc394bd58 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasSingleReferenceRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/HasSingleReferenceRelation.java
@@ -17,13 +17,13 @@
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
import org.eclipse.graphiti.mm.pictograms.Connection;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
public class HasSingleReferenceRelation extends HasReferanceRelation{
- public HasSingleReferenceRelation(JavaPersistentType embeddingEntity,
- JavaPersistentType embeddable) {
+ public HasSingleReferenceRelation(PersistentType embeddingEntity,
+ PersistentType embeddable) {
super(embeddingEntity, embeddable);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java
index a95bdb2054..829a823416 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IBidirectionalRelation.java
@@ -15,16 +15,17 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+
public interface IBidirectionalRelation extends IRelation {
-
- public abstract JavaSpecifiedPersistentAttribute getOwnerAnnotatedAttribute();
- public abstract JavaSpecifiedPersistentAttribute getInverseAnnotatedAttribute();
+ public abstract PersistentAttribute getOwnerAnnotatedAttribute();
+
+ public abstract PersistentAttribute getInverseAnnotatedAttribute();
- public abstract void setOwnerAnnotatedAttribute(JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute);
+ public abstract void setOwnerAnnotatedAttribute(PersistentAttribute ownerAnnotatedAttribute);
- public abstract void setInverseAnnotatedAttribute(JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute);
+ public abstract void setInverseAnnotatedAttribute(PersistentAttribute inverseAnnotatedAttribute);
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IRelation.java
index 3384a71180..1702a87c80 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
public interface IRelation {
@@ -30,21 +30,21 @@ public interface IRelation {
public abstract String getId();
- public abstract JavaPersistentType getOwner();
+ public abstract PersistentType getOwner();
- public abstract JavaPersistentType getInverse();
-
- public void setOwnerAnnotatedAttribute(JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute);
-
- public JavaSpecifiedPersistentAttribute getOwnerAnnotatedAttribute();
-
- public void setInverseAnnotatedAttribute(JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute);
+ public abstract PersistentType getInverse();
+
+ public void setOwnerAnnotatedAttribute(PersistentAttribute ownerAnnotatedAttribute);
+
+ public PersistentAttribute getOwnerAnnotatedAttribute();
+
+ public void setInverseAnnotatedAttribute(PersistentAttribute inverseAnnotatedAttribute);
public void setOwnerAttributeName(String ownerAttributeName);
public void setInverseAttributeName(String inverseAttributeName);
-
- public abstract JavaSpecifiedPersistentAttribute getInverseAnnotatedAttribute();
+
+ public abstract PersistentAttribute getInverseAnnotatedAttribute();
public abstract String getOwnerAttributeName();
@@ -54,4 +54,4 @@ public interface IRelation {
public abstract RelDir getRelDir();
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IUnidirectionalRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IUnidirectionalRelation.java
index d2a0327b48..dc0c9e3771 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IUnidirectionalRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IUnidirectionalRelation.java
@@ -15,12 +15,14 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+
+
public interface IUnidirectionalRelation extends IRelation {
+
+ public abstract PersistentAttribute getAnnotatedAttribute();
+
+ public abstract void setAnnotatedAttribute(PersistentAttribute at);
- public abstract JavaSpecifiedPersistentAttribute getAnnotatedAttribute();
-
- public abstract void setAnnotatedAttribute(JavaSpecifiedPersistentAttribute at);
-
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java
index c218f17a4e..fc89c741b9 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/IsARelation.java
@@ -18,7 +18,7 @@ package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -29,11 +29,11 @@ public class IsARelation {
public final static String IS_A_CONNECTION_PROP_KEY = "is_is_a_connection"; //$NON-NLS-1$
- protected JavaPersistentType subclass;
- protected JavaPersistentType superclass;
+ protected PersistentType subclass;
+ protected PersistentType superclass;
- public IsARelation(JavaPersistentType subclass,
- JavaPersistentType superclass) {
+ public IsARelation(PersistentType subclass,
+ PersistentType superclass) {
this.subclass = subclass;
this.superclass = superclass;
}
@@ -45,18 +45,18 @@ public class IsARelation {
Object endObj = fp.getBusinessObjectForPictogramElement((ContainerShape)end.eContainer());
if ((startObj == null) || (endObj == null))
throw new NullPointerException("Some of the connection ends is null"); //$NON-NLS-1$
- if (!(startObj instanceof JavaPersistentType) || !(endObj instanceof JavaPersistentType))
+ if (!(startObj instanceof PersistentType) || !(endObj instanceof PersistentType))
throw new IllegalArgumentException();
- this.subclass = (JavaPersistentType)startObj;
- this.superclass = (JavaPersistentType)endObj;
+ this.subclass = (PersistentType)startObj;
+ this.superclass = (PersistentType)endObj;
}
- public JavaPersistentType getSubclass() {
+ public PersistentType getSubclass() {
return subclass;
}
- public JavaPersistentType getSuperclass() {
+ public PersistentType getSuperclass() {
return superclass;
}
@@ -77,14 +77,14 @@ public class IsARelation {
Object endObj = fp.getBusinessObjectForPictogramElement((ContainerShape)end.eContainer());
if ((startObj == null) || (endObj == null))
return null;
- if (!(startObj instanceof JavaPersistentType) || !(endObj instanceof JavaPersistentType))
+ if (!(startObj instanceof PersistentType) || !(endObj instanceof PersistentType))
return null;
- JavaPersistentType startJpt = (JavaPersistentType)startObj;
- JavaPersistentType endJpt = (JavaPersistentType)endObj;
+ PersistentType startJpt = (PersistentType)startObj;
+ PersistentType endJpt = (PersistentType)endObj;
return generateId(startJpt, endJpt);
}
- private static String generateId(JavaPersistentType startJpt, JavaPersistentType endJpt) {
+ private static String generateId(PersistentType startJpt, PersistentType endJpt) {
return JPAEditorConstants.IS_A_RELATION_ID_PREFIX +
startJpt.getName() + SEPARATOR + endJpt.getName();
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java
index 187a3faf84..5f77911ad9 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyBiDirRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -25,11 +25,11 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class ManyToManyBiDirRelation extends ManyToManyRelation implements IBidirectionalRelation {
- public ManyToManyBiDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public ManyToManyBiDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
String inverseAttributeName,
- boolean createAttribs, JavaPersistentType embeddingEntity) {
+ boolean createAttribs, PersistentType embeddingEntity) {
super(owner, inverse);
this.ownerAttributeName = ownerAttributeName;
this.inverseAttributeName = inverseAttributeName;
@@ -42,13 +42,13 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements IBidi
* @see org.eclipse.jpt.jpadiagrameditor.ui.relations.BidirectionalRelation#getOwnerAnnotatedAttribute()
*/
@Override
- public JavaSpecifiedPersistentAttribute getOwnerAnnotatedAttribute() {
+ public PersistentAttribute getOwnerAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
@Override
public void setOwnerAnnotatedAttribute(
- JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute) {
+ PersistentAttribute ownerAnnotatedAttribute) {
this.ownerAnnotatedAttribute = ownerAnnotatedAttribute;
}
@@ -56,24 +56,24 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements IBidi
* @see org.eclipse.jpt.jpadiagrameditor.ui.relations.BidirectionalRelation#getInverseAnnotatedAttribute()
*/
@Override
- public JavaSpecifiedPersistentAttribute getInverseAnnotatedAttribute() {
+ public PersistentAttribute getInverseAnnotatedAttribute() {
return inverseAnnotatedAttribute;
}
@Override
public void setInverseAnnotatedAttribute(
- JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute) {
+ PersistentAttribute inverseAnnotatedAttribute) {
this.inverseAnnotatedAttribute = inverseAnnotatedAttribute;
}
- private void createRelation(IJPAEditorFeatureProvider fp, JavaPersistentType embeddingEntity) {
+ private void createRelation(IJPAEditorFeatureProvider fp, PersistentType embeddingEntity) {
boolean isMap = JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject());
String mapKeyType = getMapKeyType(isMap, inverse, embeddingEntity);
ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, true, mapKeyType);
mapKeyType = getMapKeyType(isMap, owner, embeddingEntity);
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)){
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)){
inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, embeddingEntity, true, mapKeyType);
} else {
@@ -87,10 +87,10 @@ public class ManyToManyBiDirRelation extends ManyToManyRelation implements IBidi
return RelDir.BI;
}
- private String getMapKeyType(boolean isMap, JavaPersistentType jpt, JavaPersistentType embeddingEntity){
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt) && embeddingEntity!=null){
+ private String getMapKeyType(boolean isMap, PersistentType jpt, PersistentType embeddingEntity){
+ if(JpaArtifactFactory.instance().isEmbeddable(jpt) && embeddingEntity!=null){
return isMap ? JpaArtifactFactory.instance().getIdType(embeddingEntity) : null;
}
return isMap ? JpaArtifactFactory.instance().getIdType(jpt) : null;
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyRelation.java
index 88fe5b2494..4f29b111fd 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyRelation.java
@@ -15,11 +15,11 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
public abstract class ManyToManyRelation extends AbstractRelation {
- public ManyToManyRelation(JavaPersistentType owner, JavaPersistentType inverse) {
+ public ManyToManyRelation(PersistentType owner, PersistentType inverse) {
super(owner, inverse);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java
index 356b726ce6..6a03f344e6 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToManyUniDirRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class ManyToManyUniDirRelation extends ManyToManyRelation implements IUnidirectionalRelation {
- public ManyToManyUniDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public ManyToManyUniDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
boolean createAttribs) {
super(owner, inverse);
@@ -34,12 +34,12 @@ public class ManyToManyUniDirRelation extends ManyToManyRelation implements IUni
if (createAttribs)
createRelation(fp);
}
-
- public JavaSpecifiedPersistentAttribute getAnnotatedAttribute() {
+
+ public PersistentAttribute getAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
- public void setAnnotatedAttribute(JavaSpecifiedPersistentAttribute annotatedAttribute) {
+ public void setAnnotatedAttribute(PersistentAttribute annotatedAttribute) {
this.ownerAnnotatedAttribute = annotatedAttribute;
}
@@ -57,7 +57,7 @@ public class ManyToManyUniDirRelation extends ManyToManyRelation implements IUni
return RelDir.UNI;
}
- private String getMapKeyType(boolean isMap, JavaPersistentType jpt){
+ private String getMapKeyType(boolean isMap, PersistentType jpt){
return isMap ? JpaArtifactFactory.instance().getIdType(jpt) : null;
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java
index 467a9f3a9c..5929017761 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneBiDirRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -25,11 +25,11 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class ManyToOneBiDirRelation extends ManyToOneRelation implements IBidirectionalRelation{
- public ManyToOneBiDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public ManyToOneBiDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
String inverseAttributeName,
- boolean createAttribs, JavaPersistentType embeddingEntity,
+ boolean createAttribs, PersistentType embeddingEntity,
boolean isDerivedIdFeature) {
super(owner, inverse);
this.ownerAttributeName = ownerAttributeName;
@@ -40,40 +40,39 @@ public class ManyToOneBiDirRelation extends ManyToOneRelation implements IBidir
}
@Override
- public JavaSpecifiedPersistentAttribute getOwnerAnnotatedAttribute() {
+ public PersistentAttribute getOwnerAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
@Override
- public void setOwnerAnnotatedAttribute( JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute) {
+ public void setOwnerAnnotatedAttribute( PersistentAttribute ownerAnnotatedAttribute) {
this.ownerAnnotatedAttribute = ownerAnnotatedAttribute;
}
@Override
- public JavaSpecifiedPersistentAttribute getInverseAnnotatedAttribute() {
+ public PersistentAttribute getInverseAnnotatedAttribute() {
return inverseAnnotatedAttribute;
}
@Override
- public void setInverseAnnotatedAttribute(JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute) {
+ public void setInverseAnnotatedAttribute(PersistentAttribute inverseAnnotatedAttribute) {
this.inverseAnnotatedAttribute = inverseAnnotatedAttribute;
}
- private void createRelation(IJPAEditorFeatureProvider fp, JavaPersistentType embeddingEntity, boolean isDerivedIdFeature) {
+ private void createRelation(IJPAEditorFeatureProvider fp, PersistentType embeddingEntity, boolean isDerivedIdFeature) {
ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
- if(isDerivedIdFeature){
- JpaArtifactFactory.instance().calculateDerivedIdAnnotation(owner, inverse, ownerAnnotatedAttribute);
- }
-
+
boolean isMap = JPADiagramPropertyPage.isMapType(owner.getJpaProject().getProject());
String mapKeyType = getMapKeyType(isMap, owner, embeddingEntity);
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)){
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)){
inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, embeddingEntity, true, mapKeyType);
-
} else {
inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, owner, true, mapKeyType);
}
JpaArtifactFactory.instance().addManyToOneBidirectionalRelation(fp, owner, ownerAnnotatedAttribute, inverse, inverseAnnotatedAttribute, isMap);
+ if(isDerivedIdFeature){
+ JpaArtifactFactory.instance().calculateDerivedIdAttribute(owner, inverse, ownerAnnotatedAttribute);
+ }
}
@Override
@@ -81,8 +80,8 @@ public class ManyToOneBiDirRelation extends ManyToOneRelation implements IBidir
return RelDir.BI;
}
- private String getMapKeyType(boolean isMap, JavaPersistentType jpt, JavaPersistentType embeddingEntity){
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(jpt) && embeddingEntity!=null){
+ private String getMapKeyType(boolean isMap, PersistentType jpt, PersistentType embeddingEntity){
+ if(JpaArtifactFactory.instance().isEmbeddable(jpt) && embeddingEntity!=null){
return isMap ? JpaArtifactFactory.instance().getIdType(embeddingEntity) : null;
}
return isMap ? JpaArtifactFactory.instance().getIdType(jpt) : null;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneRelation.java
index 09c934ef15..a9d294a688 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneRelation.java
@@ -15,11 +15,11 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
abstract public class ManyToOneRelation extends AbstractRelation{
- public ManyToOneRelation(JavaPersistentType owner, JavaPersistentType inverse) {
+ public ManyToOneRelation(PersistentType owner, PersistentType inverse) {
super(owner, inverse);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java
index 15f16428cd..e609da96ed 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/ManyToOneUniDirRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -24,8 +24,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class ManyToOneUniDirRelation extends ManyToOneRelation implements IUnidirectionalRelation {
- public ManyToOneUniDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public ManyToOneUniDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
boolean createAttribs, boolean isDerivedIdFeature) {
super(owner, inverse);
@@ -33,22 +33,21 @@ public class ManyToOneUniDirRelation extends ManyToOneRelation implements IUnidi
if (createAttribs)
createRelation(fp, isDerivedIdFeature);
}
-
- public JavaSpecifiedPersistentAttribute getAnnotatedAttribute() {
+
+ public PersistentAttribute getAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
- public void setAnnotatedAttribute(JavaSpecifiedPersistentAttribute annotatedAttribute) {
+ public void setAnnotatedAttribute(PersistentAttribute annotatedAttribute) {
this.ownerAnnotatedAttribute = annotatedAttribute;
}
private void createRelation(IJPAEditorFeatureProvider fp, boolean isDerivedIdFeature) {
ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
+ JpaArtifactFactory.instance().addManyToOneUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute);
if(isDerivedIdFeature){
- JpaArtifactFactory.instance().calculateDerivedIdAnnotation(owner, inverse, ownerAnnotatedAttribute);
+ JpaArtifactFactory.instance().calculateDerivedIdAttribute(owner, inverse, ownerAnnotatedAttribute);
}
- JpaArtifactFactory.instance().addManyToOneUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute);
-
}
@Override
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyRelation.java
index 5d60ea641f..d559cac339 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyRelation.java
@@ -15,11 +15,11 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
public abstract class OneToManyRelation extends AbstractRelation {
- public OneToManyRelation(JavaPersistentType owner, JavaPersistentType inverse) {
+ public OneToManyRelation(PersistentType owner, PersistentType inverse) {
super(owner, inverse);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java
index 2635cbc1d7..c3cc5a6609 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToManyUniDirRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
@@ -25,8 +25,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class OneToManyUniDirRelation extends OneToManyRelation implements IUnidirectionalRelation {
- public OneToManyUniDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public OneToManyUniDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
boolean createAttribs) {
super(owner, inverse);
@@ -35,11 +35,11 @@ public class OneToManyUniDirRelation extends OneToManyRelation implements IUnidi
createRelation(fp);
}
- public JavaSpecifiedPersistentAttribute getAnnotatedAttribute() {
+ public PersistentAttribute getAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
- public void setAnnotatedAttribute(JavaSpecifiedPersistentAttribute annotatedAttribute) {
+ public void setAnnotatedAttribute(PersistentAttribute annotatedAttribute) {
this.ownerAnnotatedAttribute = annotatedAttribute;
}
@@ -56,8 +56,8 @@ public class OneToManyUniDirRelation extends OneToManyRelation implements IUnidi
return RelDir.UNI;
}
- private String getMapKeyType(boolean isMap, JavaPersistentType jpt){
+ private String getMapKeyType(boolean isMap, PersistentType jpt){
return isMap ? JpaArtifactFactory.instance().getIdType(jpt) : null;
}
-} \ No newline at end of file
+}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java
index 9cbb15f9de..b9b7983674 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneBiDirRelation.java
@@ -15,19 +15,19 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class OneToOneBiDirRelation extends OneToOneRelation implements IBidirectionalRelation{
- public OneToOneBiDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public OneToOneBiDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
String inverseAttributeName,
- boolean createAttribs, JavaPersistentType embeddingEntity,
+ boolean createAttribs, PersistentType embeddingEntity,
boolean isDerivedIdFeature) {
super(owner, inverse);
this.ownerAttributeName = ownerAttributeName;
@@ -37,39 +37,40 @@ public class OneToOneBiDirRelation extends OneToOneRelation implements IBidirect
}
@Override
- public JavaSpecifiedPersistentAttribute getOwnerAnnotatedAttribute() {
+ public PersistentAttribute getOwnerAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
@Override
public void setOwnerAnnotatedAttribute(
- JavaSpecifiedPersistentAttribute ownerAnnotatedAttribute) {
+ PersistentAttribute ownerAnnotatedAttribute) {
this.ownerAnnotatedAttribute = ownerAnnotatedAttribute;
}
@Override
- public JavaSpecifiedPersistentAttribute getInverseAnnotatedAttribute() {
+ public PersistentAttribute getInverseAnnotatedAttribute() {
return inverseAnnotatedAttribute;
}
@Override
public void setInverseAnnotatedAttribute(
- JavaSpecifiedPersistentAttribute inverseAnnotatedAttribute) {
+ PersistentAttribute inverseAnnotatedAttribute) {
this.inverseAnnotatedAttribute = inverseAnnotatedAttribute;
}
- private void createRelation(IJPAEditorFeatureProvider fp, JavaPersistentType embeddingEntity, boolean isDerivedIdFeature) {
+ private void createRelation(IJPAEditorFeatureProvider fp, PersistentType embeddingEntity, boolean isDerivedIdFeature) {
ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
- if(isDerivedIdFeature){
- JpaArtifactFactory.instance().calculateDerivedIdAnnotation(owner, inverse, ownerAnnotatedAttribute);
- }
- if(JpaArtifactFactory.instance().hasEmbeddableAnnotation(owner)){
+ if(JpaArtifactFactory.instance().isEmbeddable(owner)){
inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, embeddingEntity, false, null);
} else {
inverseAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, inverse, owner, false, null);
}
+
JpaArtifactFactory.instance().addOneToOneBidirectionalRelation(fp, owner, ownerAnnotatedAttribute, inverse, inverseAnnotatedAttribute);
+ if(isDerivedIdFeature){
+ JpaArtifactFactory.instance().calculateDerivedIdAttribute(owner, inverse, ownerAnnotatedAttribute);
+ }
}
@Override
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneRelation.java
index 036c1a1dda..d5af816cdd 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneRelation.java
@@ -15,12 +15,12 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
abstract public class OneToOneRelation extends AbstractRelation {
- public OneToOneRelation(JavaPersistentType owner,
- JavaPersistentType inverse) {
+ public OneToOneRelation(PersistentType owner,
+ PersistentType inverse) {
super(owner, inverse);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java
index 011caf1c8b..15e4a94360 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/relations/OneToOneUniDirRelation.java
@@ -15,8 +15,8 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.internal.relations;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -24,8 +24,8 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
public class OneToOneUniDirRelation extends OneToOneRelation implements IUnidirectionalRelation {
- public OneToOneUniDirRelation(IJPAEditorFeatureProvider fp, JavaPersistentType owner,
- JavaPersistentType inverse,
+ public OneToOneUniDirRelation(IJPAEditorFeatureProvider fp, PersistentType owner,
+ PersistentType inverse,
String ownerAttributeName,
boolean createAttribs, boolean isDerivedIdFeature) {
super(owner, inverse);
@@ -33,21 +33,21 @@ public class OneToOneUniDirRelation extends OneToOneRelation implements IUnidire
if (createAttribs)
createRelation(fp, isDerivedIdFeature);
}
-
- public JavaSpecifiedPersistentAttribute getAnnotatedAttribute() {
+
+ public PersistentAttribute getAnnotatedAttribute() {
return ownerAnnotatedAttribute;
}
- public void setAnnotatedAttribute(JavaSpecifiedPersistentAttribute annotatedAttribute) {
+ public void setAnnotatedAttribute(PersistentAttribute annotatedAttribute) {
this.ownerAnnotatedAttribute = annotatedAttribute;
}
private void createRelation(IJPAEditorFeatureProvider fp, boolean isDerivedIdFeature) {
ownerAnnotatedAttribute = JPAEditorUtil.addAnnotatedAttribute(fp, owner, inverse, false, null);
+ JpaArtifactFactory.instance().addOneToOneUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute);
if(isDerivedIdFeature){
- JpaArtifactFactory.instance().calculateDerivedIdAnnotation(owner, inverse, ownerAnnotatedAttribute);
+ JpaArtifactFactory.instance().calculateDerivedIdAttribute(owner, inverse, ownerAnnotatedAttribute);
}
- JpaArtifactFactory.instance().addOneToOneUnidirectionalRelation(fp, owner, ownerAnnotatedAttribute);
}
@Override
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java
index 9b89c23a91..dcae5948ab 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/EntityChangeListener.java
@@ -24,16 +24,14 @@ import java.util.Set;
import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.jpt.jpa.core.JpaPreferences;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.internal.context.java.JavaNullTypeMapping;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.RemoveAndSaveEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -102,7 +100,7 @@ public class EntityChangeListener extends Thread {
Iterator<String> itr = jptsToUpdate.iterator();
if (itr.hasNext()) {
String jptName = itr.next();
- JavaPersistentType jpt = (JavaPersistentType)featureProvider.getBusinessObjectForKey(jptName);
+ PersistentType jpt = (PersistentType)featureProvider.getBusinessObjectForKey(jptName);
try {
JpaArtifactFactory.instance().remakeRelations(featureProvider, null, jpt);
jptsToUpdate.remove(jptName);
@@ -113,15 +111,15 @@ public class EntityChangeListener extends Thread {
Iterator<Object> it = vals.iterator();
while (it.hasNext()) {
Object o = it.next();
- if (o instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType)o;
+ if (o instanceof PersistentType) {
+ PersistentType jpt = (PersistentType)o;
final ContainerShape entShape = (ContainerShape)featureProvider.getPictogramElementForBusinessObject(o);
if (entShape == null)
continue;
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpt);
PersistentType pt = pu.getPersistentType(jpt.getName());
- if ((pt == null) || !JpaArtifactFactory.instance().hasAnyAnnotationType(jpt)) {
+ if ((pt == null) || !JpaArtifactFactory.instance().isAnyKindPersistentType(jpt)) {
JpaArtifactFactory.instance().forceSaveEntityClass(jpt, featureProvider);
@@ -149,41 +147,28 @@ public class EntityChangeListener extends Thread {
String attribName = jptAndAttrib[1];
String mappedBy = jptAndAttrib[2];
String oldMappedBy = jptAndAttrib[3];
- JavaPersistentType jpt = (JavaPersistentType)pu.getPersistentType(entityName);
+ PersistentType jpt = pu.getPersistentType(entityName);
if (jpt != null) {
- JavaSpecifiedPersistentAttribute jpa = jpt.getAttributeNamed(attribName);
+ PersistentAttribute jpa = jpt.getAttributeNamed(attribName);
if (jpa != null) {
- JavaAttributeMapping mapping = jpa.getMapping();
- if (OwnableRelationshipMappingAnnotation.class.isInstance(mapping.getMappingAnnotation())) {
- JavaRelationshipMapping relationshipMapping = (JavaRelationshipMapping)mapping;
+ AttributeMapping mapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ if (mapping instanceof RelationshipMapping) {
+ RelationshipMapping relationshipMapping = (RelationshipMapping) mapping;
MappedByRelationship ownableRef = (MappedByRelationship)relationshipMapping.getRelationship();
- if (!ownableRef.strategyIsMappedBy()) {
- ownableRef.setStrategyToMappedBy();
- }
SpecifiedMappedByRelationshipStrategy mappedByStrategy = ownableRef.getMappedByStrategy();
String mappedByAttr = mappedByStrategy.getMappedByAttribute();
- String[] mappedByAttrs = mappedByAttr.split("\\."); //$NON-NLS-1$
+ String[] mappedByAttrs = mappedByAttr.split(JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR);
if(mappedByAttrs.length > 1){
if(mappedByAttrs[0].equals(oldMappedBy)){
- mappedByAttr = mappedBy + "." + mappedByAttrs[1]; //$NON-NLS-1$
+ mappedByAttr = mappedBy + JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SEPARATOR + mappedByAttrs[1];
} else if(mappedByAttrs[1].equals(oldMappedBy)){
- mappedByAttr = mappedByAttrs[0] + "." + mappedBy; //$NON-NLS-1$
+ mappedByAttr = mappedByAttrs[0] + JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SEPARATOR + mappedBy;
}
} else {
mappedByAttr = mappedBy;
}
mappedByStrategy.setMappedByAttribute(mappedByAttr);
-
-
-// if(mappedByAttrs.length > 1){
-// if(mappedByAttrs[0].equals(oldAt.getName())){
-// mappedBy = newAt.getName() + "." + mappedByAttrs[1];
-// } else if(mappedByAttrs[1].equals(oldAt.getName())){
-// mappedBy = mappedByAttrs[0] + "." + newAt.getName();
-// }
-// } else {
-// mappedBy = newAt.getName();
jpt.update();
attribsToUpdate.remove(jptAtMB);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java
index b43aeb0b78..ee8ab6cc9c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/IJPAEditorUtil.java
@@ -23,7 +23,7 @@ import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IWorkbenchSite;
@@ -33,11 +33,11 @@ public interface IJPAEditorUtil {
public List<Point> createBendPointList(FreeFormConnection c, boolean selfRelation);
- public JavaPersistentType getJPType(ICompilationUnit cu);
+ public PersistentType getJPType(ICompilationUnit cu);
public void organizeImports(ICompilationUnit cu, IWorkbenchSite ws);
- public ICompilationUnit getCompilationUnit(JavaPersistentType jpt);
+ public ICompilationUnit getCompilationUnit(PersistentType jpt);
public void formatCode(ICompilationUnit cu, IWorkbenchSite ws);
@@ -55,7 +55,7 @@ public interface IJPAEditorUtil {
public IFile createEntityInProject(IProject project,
String entityName,
- JavaPersistentType mappedSuperclass) throws Exception;
+ PersistentType mappedSuperclass) throws Exception;
public IFile createMappedSuperclassInProject(IProject project,
String mappedSuperclassName) throws Exception;
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPACheckSum.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPACheckSum.java
index c01c6e508e..6b0530949c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPACheckSum.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPACheckSum.java
@@ -26,7 +26,7 @@ import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
@@ -64,11 +64,12 @@ public class JPACheckSum {
while (it.hasNext()) {
Shape pict = it.next();
String name = Graphiti.getPeService().getPropertyValue(pict, JPAEditorConstants.PROP_ENTITY_CLASS_NAME);
- JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT(name, pu);
+ PersistentType jpt = JpaArtifactFactory.instance().getJPT(name, pu);
String hash = ""; //$NON-NLS-1$
if (jpt != null) {
ICompilationUnit cu = JPAEditorUtil.getCompilationUnit(jpt);
- hash = generateCompilationUnitMD5String(cu);
+ if(cu != null)
+ hash = generateCompilationUnitMD5String(cu);
}
Graphiti.getPeService().setPropertyValue(pict, JPAEditorConstants.PROP_ENTITY_CHECKSUM, hash);
}
@@ -95,7 +96,7 @@ public class JPACheckSum {
return true;
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
String name = Graphiti.getPeService().getPropertyValue(sh, JPAEditorConstants.PROP_ENTITY_CLASS_NAME);
- JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT(name, pu);
+ PersistentType jpt = JpaArtifactFactory.instance().getJPT(name, pu);
String savedMD5 = getSavedShapeMD5(sh);
String actualMD5 = ""; //$NON-NLS-1$
if (jpt != null) {
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java
index 80e9c85179..94098f090d 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorConstants.java
@@ -21,8 +21,6 @@ import java.util.Set;
import org.eclipse.graphiti.util.ColorConstant;
import org.eclipse.graphiti.util.IColorConstant;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
public class JPAEditorConstants {
@@ -35,9 +33,7 @@ public class JPAEditorConstants {
public static final String IS_A_RELATION_ID_PREFIX = "is_a_relation:"; //$NON-NLS-1$
public static final String HAS_REFERENCE_RELATION_ID_PREFIX = "has_reference_relation:"; //$NON-NLS-1$
-
- public static final String IS_A = "is-a"; //$NON-NLS-1$
-
+
public static final String HEADER_PREFIX_DIRTY = "* "; //$NON-NLS-1$
public static final String COLLECTION_TYPE = "java.util.Collection"; //$NON-NLS-1$
@@ -48,11 +44,12 @@ public class JPAEditorConstants {
public static final String MAP_TYPE = "java.util.Map"; //$NON-NLS-1$
+ public static final String STRING_TYPE = "java.lang.String"; //$NON-NLS-1$
+
public static Hashtable<String, String> PRIMITIVE_TO_WRAPPER = new Hashtable<String,String>();
public static HashSet<String> WRAPPER_SIMPLE_NAMES = new HashSet<String>();
- public static Hashtable<String, String> ANNOTATION_NAME_TO_KEY = new Hashtable<String, String>();
public static Set<String> CARDINALITY_LABELS = new HashSet<String>();
public final static String COLLAPSE_FEATURES = "collapseFeatures"; //$NON-NLS-1$
@@ -137,24 +134,9 @@ public class JPAEditorConstants {
public final static int COMPARTMENT_MIN_HEIGHT = 13;
public final static int COMPARTMENT_BUTTOM_OFFSET = 5;
- public final static String ANNOTATION_BASIC = "Basic"; //$NON-NLS-1$
- public final static String ANNOTATION_ID = "Id"; //$NON-NLS-1$
- public final static String ANNOTATION_ONE_TO_ONE = "OneToOne"; //$NON-NLS-1$
- public final static String ANNOTATION_ONE_TO_MANY = "OneToMany"; //$NON-NLS-1$
- public final static String ANNOTATION_MANY_TO_ONE = "ManyToOne"; //$NON-NLS-1$
- public final static String ANNOTATION_MANY_TO_MANY = "ManyToMany"; //$NON-NLS-1$
- public final static String ANNOTATION_VERSION = "Version"; //$NON-NLS-1$
- public final static String ANNOTATION_EMBEDDED = "Embedded"; //$NON-NLS-1$
- public final static String ANNOTATION_ELEMENT_COLLECTION = "ElementCollection"; //$NON-NLS-1$
- public final static String ANNOTATION_EMBEDDED_ID = "EmbeddedId"; //$NON-NLS-1$
- public final static String ANNOTATION_TRANSIENT = "Transient"; //$NON-NLS-1$
- public final static String ANNOTATION_MAPS_ID = "MapsId"; //$NON-NLS-1$
-
public static final int RELATION_TYPE_UNIDIRECTIONAL = 1;
public static final int RELATION_TYPE_BIDIRECTIONAL = 2;
-
- public static HashSet<String> RELATION_ANNOTATIONS = new HashSet<String>();
-
+
public static String PROP_ENTITY_CLASS_NAME = "prop_entity_class_name"; //$NON-NLS-1$
public static String PROP_SHAPE_TYPE = "prop_shape_type"; //$NON-NLS-1$
public static String PROP_ATTRIBS_NUM = "prop_attribs_num"; //$NON-NLS-1$
@@ -164,9 +146,6 @@ public class JPAEditorConstants {
CARDINALITY,
ASSOCIATION
}
-
- //public static String PROP_CON_DIR_START = "prop_con_dir_start"; //$NON-NLS-1$
- //public static String PROP_CON_DIR_END = "prop_con_dir_end"; //$NON-NLS-1$
public static String ID_VIEW_JPA_DETAILS = "org.eclipse.jpt.ui.jpaDetailsView"; //$NON-NLS-1$
public static String ID_VIEW_MINIATURE = "org.eclipse.graphiti.ui.internal.editor.thumbnailview"; //$NON-NLS-1$
@@ -177,24 +156,7 @@ public class JPAEditorConstants {
public static enum ShapeType {ICON, HEADER, ATTRIBUTE, COMPARTMENT}
- static {
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_BASIC, MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_ID, MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_ONE_TO_ONE, MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_ONE_TO_MANY, MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_MANY_TO_ONE, MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_MANY_TO_MANY, MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_VERSION, MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_EMBEDDED, MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_ELEMENT_COLLECTION, MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_EMBEDDED_ID, MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
- ANNOTATION_NAME_TO_KEY.put(ANNOTATION_TRANSIENT, MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY);
-
- RELATION_ANNOTATIONS.add(JPAEditorConstants.ANNOTATION_ONE_TO_ONE);
- RELATION_ANNOTATIONS.add(JPAEditorConstants.ANNOTATION_ONE_TO_MANY);
- RELATION_ANNOTATIONS.add(JPAEditorConstants.ANNOTATION_MANY_TO_ONE);
- RELATION_ANNOTATIONS.add(JPAEditorConstants.ANNOTATION_MANY_TO_MANY);
-
+ static {
CARDINALITY_LABELS.add(CARDINALITY_ZERO_ONE);
CARDINALITY_LABELS.add(CARDINALITY_ONE);
CARDINALITY_LABELS.add(CARDINALITY_ZERO_N);
@@ -273,5 +235,9 @@ public class JPAEditorConstants {
public static final String ENTITY_RELATION_SECTION_STATE_TAG = "relation-collapsed"; //$NON-NLS-1$
public static final String ENTITY_BASIC_SECTION_STATE_TAG = "basic-collapsed"; //$NON-NLS-1$
+
+ public static final String MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR = "\\."; //$NON-NLS-1$
+
+ public static final String MAPPED_BY_ATTRIBUTE_SEPARATOR = "."; //$NON-NLS-1$
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
index 999c330a21..f7729e6ee0 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtil.java
@@ -80,11 +80,23 @@ import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.common.core.resource.xml.JptXmlResource;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.IdMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.TransientMapping;
+import org.eclipse.jpt.jpa.core.context.VersionMapping;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
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.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ManyToOneMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.OneToOneMapping2_0;
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.XmlPersistence;
@@ -154,14 +166,14 @@ public class JPAEditorUtil {
return null;
}
- public static Anchor getAnchor(JavaPersistentType jpt, IFeatureProvider fp) {
+ public static Anchor getAnchor(PersistentType jpt, IFeatureProvider fp) {
PictogramElement pe = fp.getPictogramElementForBusinessObject(jpt);
if ((pe == null) || (!(pe instanceof ContainerShape)))
return null;
return getAnchor((ContainerShape)pe);
}
-
- public static String getText(JavaSpecifiedPersistentAttribute at) {
+
+ public static String getText(PersistentAttribute at) {
return at.getName();
}
@@ -175,7 +187,7 @@ public class JPAEditorUtil {
return s;
}
- public static String getTooltipText(JavaPersistentType jpt,
+ public static String getTooltipText(PersistentType jpt,
String superPersistentTypeName) {
String res = jpt.getName();
if (superPersistentTypeName != null) {
@@ -186,17 +198,16 @@ public class JPAEditorUtil {
new Object[] { res });
}
-
- public static String getAttributeTypeName(JavaSpecifiedPersistentAttribute at) {
- return getAttributeTypeName(at.getResourceAttribute());
+ public static String getAttributeTypeName(PersistentAttribute at) {
+ return JpaArtifactFactory.instance().getRelTypeName(at);
}
public static String getAttributeTypeName(JavaResourceAttribute at) {
return at.getTypeBinding().getQualifiedName();
}
-
- public static String getAttributeTypeNameWithGenerics(JavaSpecifiedPersistentAttribute at) {
- return getAttributeTypeNameWithGenerics(at.getResourceAttribute());
+
+ public static String getAttributeTypeNameWithGenerics(PersistentAttribute at) {
+ return getAttributeTypeNameWithGenerics(at.getJavaPersistentAttribute().getResourceAttribute());
}
private static String getAttributeTypeNameWithGenerics(JavaResourceAttribute at) {
@@ -243,16 +254,16 @@ public class JPAEditorUtil {
return res.toString();
}
- public static String getText(JavaPersistentType jpt) {
+ public static String getText(PersistentType jpt) {
return JPAEditorUtil.returnSimpleName(JpaArtifactFactory.instance().getEntityName(jpt));
}
- public static String getTooltipText(JavaPersistentType jpt) {
+ public static String getTooltipText(PersistentType jpt) {
String res = jpt.getName();
return MessageFormat.format(JPAEditorMessages.JPAEditorUtil_fullnameTooltipText, new Object[] { res });
}
- public static JavaPersistentType getJPType(ICompilationUnit cu) {
+ public static PersistentType getJPType(ICompilationUnit cu) {
String name = cu.getElementName();
if (!name.endsWith(".java")) //$NON-NLS-1$
return null;
@@ -267,9 +278,7 @@ public class JPAEditorUtil {
return null;
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(proj);
PersistentType pt = pu.getPersistentType(name);
- if ((pt == null) || (!(pt instanceof JavaPersistentType)))
- return null;
- return (JavaPersistentType)pt;
+ return pt;
}
public static void setJPTNameInShape(ContainerShape cs, String newName) {
@@ -399,41 +408,40 @@ public class JPAEditorUtil {
return returnSimpleName(typeFQN);
} catch (JavaModelException e) {}
return typeFQN;
- }
-
- public static Image createAttributeIcon(Rectangle iconRect, Set<String> annotations) {
+ }
+
+ public static Image createAttributeIcon(Rectangle iconRect, AttributeMapping attributeMapping) {
Image icon = null;
- if ((annotations == null) || (annotations.size() == 0) || annotations.contains(JPAEditorConstants.ANNOTATION_BASIC)) {
- icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_BASIC);
- } else if (annotations.contains(JPAEditorConstants.ANNOTATION_ID) &&
- !annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE) &&
- !annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) {
+
+ if(attributeMapping instanceof IdMapping){
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.PRIMARY_KEY);
- } else if (annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE) ) {
- if(annotations.contains(JPAEditorConstants.ANNOTATION_ID) || annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)){
+ }else if(attributeMapping instanceof OneToOneMapping2_0){
+ DerivedIdentity2_0 ident = ((OneToOneMapping2_0)attributeMapping).getDerivedIdentity();
+ if(ident.usesIdDerivedIdentityStrategy() || ident.usesMapsIdDerivedIdentityStrategy()){
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ONE_TO_ONE_PRIMARY_KEY);
} else {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_ONE_TO_ONE);
}
- } else if (annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_MANY)) {
+ } else if (attributeMapping instanceof OneToManyMapping) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_ONE_TO_MANY);
- } else if (annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)){
- if(annotations.contains(JPAEditorConstants.ANNOTATION_ID) || annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID)){
+ } else if(attributeMapping instanceof ManyToOneMapping2_0) {
+ DerivedIdentity2_0 ident = ((ManyToOneMapping2_0)attributeMapping).getDerivedIdentity();
+ if(ident.usesIdDerivedIdentityStrategy() || ident.usesMapsIdDerivedIdentityStrategy()){
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.MANY_TO_ONE_PRIMARY_KEY);
} else {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_MANY_TO_ONE);
}
- } else if (annotations.contains(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) {
+ } else if (attributeMapping instanceof ManyToManyMapping) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_MANY_TO_MANY);
- } else if(annotations.contains(JPAEditorConstants.ANNOTATION_EMBEDDED_ID)){
+ } else if (attributeMapping instanceof EmbeddedIdMapping) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_EMBEDDED_ID);
- } else if(annotations.contains(JPAEditorConstants.ANNOTATION_VERSION)){
+ } else if (attributeMapping instanceof VersionMapping) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_VERSION);
- } else if(annotations.contains(JPAEditorConstants.ANNOTATION_TRANSIENT)){
+ } else if (attributeMapping instanceof TransientMapping) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_TRANSIENT);
- } else if(annotations.contains(JPAEditorConstants.ANNOTATION_EMBEDDED)){
+ } else if (attributeMapping instanceof EmbeddedMapping) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_EMBEDDED);
- } else if(annotations.contains(JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION)){
+ } else if (attributeMapping instanceof ElementCollectionMapping2_0) {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_ELEMENT_COLLECTION);
} else {
icon = Graphiti.getGaService().createImage(iconRect, JPAEditorImageProvider.ICON_BASIC);
@@ -919,7 +927,7 @@ public class JPAEditorUtil {
return new Point(x, y);
}
- public static String formTableName(JavaPersistentType jpt) {
+ public static String formTableName(PersistentType jpt) {
IProject project = jpt.getJpaProject().getProject();
Properties props = JPADiagramPropertyPage.loadProperties(project);
String tableNamePrefix = JPADiagramPropertyPage.getDefaultTablePrefixName(project, props);
@@ -993,7 +1001,7 @@ public class JPAEditorUtil {
static public IFile createEntityInProject(IProject project,
String entityName,
- JavaPersistentType mappedSuperclass) throws Exception {
+ PersistentType mappedSuperclass) throws Exception {
IFolder folder = getPackageFolder(project);
return createEntity(project, folder, entityName,
true, mappedSuperclass.getName(),
@@ -1106,7 +1114,7 @@ public class JPAEditorUtil {
}
- static public String produceUniqueAttributeName(JavaPersistentType jpt,
+ static public String produceUniqueAttributeName(PersistentType jpt,
String attributeNameCandidate) {
String name = attributeNameCandidate;
for (int i = 1; i < 100000000; i++) {
@@ -1117,7 +1125,7 @@ public class JPAEditorUtil {
return name;
}
- static public String produceUniqueAttributeName(JavaPersistentType jpt, String forbiddenName, String attributeNameCandidate) {
+ static public String produceUniqueAttributeName(PersistentType jpt, String forbiddenName, String attributeNameCandidate) {
String name = attributeNameCandidate;
for (int i = 1; i < 100000000; i++) {
if ((jpt.getAttributeNamed(name) == null) && !name.equals(forbiddenName))
@@ -1128,7 +1136,7 @@ public class JPAEditorUtil {
}
- public static boolean isEntityOpenElsewhere(JavaPersistentType jpt, boolean checkDirty) {
+ public static boolean isEntityOpenElsewhere(PersistentType jpt, boolean checkDirty) {
IEditorReference[] edRefs = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (int i = 0; i < edRefs.length; i++) {
IEditorPart ed = edRefs[i].getEditor(false);
@@ -1147,7 +1155,10 @@ public class JPAEditorUtil {
return false;
}
- public static ICompilationUnit getCompilationUnit(JavaPersistentType jpt) {
+ public static ICompilationUnit getCompilationUnit(PersistentType jpt) {
+ if (jpt instanceof OrmPersistentType){
+ jpt = ((OrmPersistentType)jpt).getJavaPersistentType();
+ }
return getCompilationUnit((IFile) jpt.getResource());
}
@@ -1301,9 +1312,8 @@ public class JPAEditorUtil {
Text txt = (Text)ga;
return JPAEditorConstants.CARDINALITY_LABELS.contains(txt.getValue());
}
-
-
- public static String getTooltipText(JavaSpecifiedPersistentAttribute at) {
+
+ public static String getTooltipText(PersistentAttribute at) {
String res = getAttributeTypeName(at);
return MessageFormat.format(JPAEditorMessages.JPAEditorUtil_typeTooltipText, new Object[] { res });
}
@@ -1403,9 +1413,9 @@ public class JPAEditorUtil {
h2 = cutOffHeaderDirtyPrefix(h2);
return h1.equals(h2);
}
-
- public static JavaSpecifiedPersistentAttribute addAnnotatedAttribute(IJPAEditorFeatureProvider fp, JavaPersistentType referencingJPT,
- JavaPersistentType referencedJPT, boolean isCollection, String mapKeyType){
+
+ public static PersistentAttribute addAnnotatedAttribute(IJPAEditorFeatureProvider fp, PersistentType referencingJPT,
+ PersistentType referencedJPT, boolean isCollection, String mapKeyType){
String name = returnSimpleName(referencedJPT.getName());
String actName = returnSimpleName(JpaArtifactFactory.instance().getEntityName(referencedJPT));
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java
index 87a11d0e0b..7d42883c5c 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPAEditorUtilImpl.java
@@ -23,7 +23,7 @@ import org.eclipse.graphiti.mm.pictograms.FreeFormConnection;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.IWorkbenchSite;
@@ -35,7 +35,7 @@ public class JPAEditorUtilImpl implements IJPAEditorUtil {
return JPAEditorUtil.createBendPointList(c, selfRelation);
}
- public JavaPersistentType getJPType(ICompilationUnit cu) {
+ public PersistentType getJPType(ICompilationUnit cu) {
return JPAEditorUtil.getJPType(cu);
}
@@ -57,11 +57,11 @@ public class JPAEditorUtilImpl implements IJPAEditorUtil {
public IFile createEntityInProject(IProject project,
String entityName,
- JavaPersistentType mappedSuperclass) throws Exception {
+ PersistentType mappedSuperclass) throws Exception {
return JPAEditorUtil.createEntityInProject(project, entityName, mappedSuperclass);
}
- public ICompilationUnit getCompilationUnit(JavaPersistentType jpt) {
+ public ICompilationUnit getCompilationUnit(PersistentType jpt) {
return JPAEditorUtil.getCompilationUnit(jpt);
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
index 13d98d3553..d1525f6b36 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JPASolver.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;
+
import org.eclipse.core.internal.resources.File;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarkerDelta;
@@ -63,8 +64,8 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.core.PackageFragmentRoot;
import org.eclipse.jpt.common.core.JptResourceModel;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
+import org.eclipse.jpt.common.utility.internal.iterator.ArrayIterator;
import org.eclipse.jpt.common.utility.model.Model;
import org.eclipse.jpt.common.utility.model.event.CollectionAddEvent;
import org.eclipse.jpt.common.utility.model.event.CollectionChangeEvent;
@@ -85,24 +86,23 @@ import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaModel;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
+import org.eclipse.jpt.jpa.core.context.MappingRelationship;
import org.eclipse.jpt.jpa.core.context.OptionalMapping;
-import org.eclipse.jpt.jpa.core.context.SpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.SpecifiedRelationship;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.SingleRelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.SpecifiedRelationship;
import org.eclipse.jpt.jpa.core.context.SpecifiedRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
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.persistence.MappingFileRef;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditor;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.facade.EclipseFacade;
@@ -133,21 +133,22 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
private Hashtable<String, Object> keyToBO;
private WeakHashMap<JpaProject, WeakReference<CollectionChangeListener>> projectToEntityListener;
- private WeakHashMap<JavaPersistentType, WeakReference<PropertyChangeListener>> entityToPropListener;
- private WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributePropertyChangeListener>> attributeToPropListener;
- private WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributeMappingOptionalityChangeListener>> attributeMappingOptionalityToPropListener;
- private WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributeJoiningStrategyPropertyChangeListener>> attributeJoiningStrategyToPropListener;
- private WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributeRelationshipReferencePropertyChangeListener>> attributeRelationshipReferenceToPropListener;
- private WeakHashMap<JavaPersistentType, WeakReference<ListChangeListener>> entityToAtListener;
- private WeakHashMap<JavaPersistentType, WeakReference<StateChangeListener>> entityToStateListener;
+ private WeakHashMap<PersistentType, WeakReference<PropertyChangeListener>> entityToPropListener;
+ private WeakHashMap<PersistentAttribute, WeakReference<AttributePropertyChangeListener>> attributeToPropListener;
+ private WeakHashMap<PersistentAttribute, WeakReference<AttributeMappingOptionalityChangeListener>> attributeMappingOptionalityToPropListener;
+ private WeakHashMap<PersistentAttribute, WeakReference<AttributeJoiningStrategyPropertyChangeListener>> attributeJoiningStrategyToPropListener;
+ private WeakHashMap<PersistentAttribute, WeakReference<AttributeRelationshipReferencePropertyChangeListener>> attributeRelationshipReferenceToPropListener;
+ private WeakHashMap<PersistentType, WeakReference<ListChangeListener>> entityToAtListener;
+ private WeakHashMap<PersistentType, WeakReference<ListChangeListener>> entityToOrmAtListener;
+ private WeakHashMap<PersistentType, WeakReference<StateChangeListener>> entityToStateListener;
private EntityChangeListener entityNameListener;
private IJPAEditorFeatureProvider featureProvider;
private HashSet<String> removeIgnore = new HashSet<String>();
private HashSet<String> removeRelIgnore = new HashSet<String>();
- private Collection<JavaPersistentType> persistentTypes = new HashSet<JavaPersistentType>();
+ private Collection<PersistentType> persistentTypes = new HashSet<PersistentType>();
private HashSet<String> addIgnore = new HashSet<String>();
- private Hashtable<String, IRelation> attribToRel = new Hashtable<String, IRelation>();
+ private Hashtable<String, IRelation> attribToRel;
private Hashtable<String, HasReferanceRelation> attribToEmbeddedRel = new Hashtable<String, HasReferanceRelation>();
private Hashtable<String, IsARelation> attribToIsARel = new Hashtable<String, IsARelation>();
@@ -179,14 +180,16 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
this.eclipseFacade = eclipseFacade;
eclipseFacade.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_BUILD);
keyToBO = new Hashtable<String, Object>();
+ attribToRel = new Hashtable<String, IRelation>();
projectToEntityListener = new WeakHashMap<JpaProject, WeakReference<CollectionChangeListener>>();
- entityToPropListener = new WeakHashMap<JavaPersistentType, WeakReference<PropertyChangeListener>>();
- attributeToPropListener = new WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributePropertyChangeListener>>();
- attributeMappingOptionalityToPropListener = new WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributeMappingOptionalityChangeListener>>();
- attributeJoiningStrategyToPropListener = new WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributeJoiningStrategyPropertyChangeListener>>();
- attributeRelationshipReferenceToPropListener = new WeakHashMap<JavaSpecifiedPersistentAttribute, WeakReference<AttributeRelationshipReferencePropertyChangeListener>>();
- entityToAtListener = new WeakHashMap<JavaPersistentType, WeakReference<ListChangeListener>>();
- entityToStateListener = new WeakHashMap<JavaPersistentType, WeakReference<StateChangeListener>>();
+ entityToPropListener = new WeakHashMap<PersistentType, WeakReference<PropertyChangeListener>>();
+ attributeToPropListener = new WeakHashMap<PersistentAttribute, WeakReference<AttributePropertyChangeListener>>();
+ attributeMappingOptionalityToPropListener = new WeakHashMap<PersistentAttribute, WeakReference<AttributeMappingOptionalityChangeListener>>();
+ attributeJoiningStrategyToPropListener = new WeakHashMap<PersistentAttribute, WeakReference<AttributeJoiningStrategyPropertyChangeListener>>();
+ attributeRelationshipReferenceToPropListener = new WeakHashMap<PersistentAttribute, WeakReference<AttributeRelationshipReferencePropertyChangeListener>>();
+ entityToAtListener = new WeakHashMap<PersistentType, WeakReference<ListChangeListener>>();
+ entityToOrmAtListener = new WeakHashMap<PersistentType, WeakReference<ListChangeListener>>();
+ entityToStateListener = new WeakHashMap<PersistentType, WeakReference<StateChangeListener>>();
entityNameListener = new EntityChangeListener(this);
entityNameListener.setName("Entity Name Change Listener"); //$NON-NLS-1$
this.util = util;
@@ -210,7 +213,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
// to be update and break the iteration
boolean updateEditor = false;
FILE: for (IFile file : filesToUpdate) {
- for (JavaPersistentType jpt : entityToPropListener.keySet()) {
+ for (PersistentType jpt : entityToPropListener.keySet()) {
if (jpt.getResource().equals(file)) {
final PictogramElement element = featureProvider.getPictogramElementForBusinessObject(jpt);
if (element == null)
@@ -284,8 +287,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
public String getKeyForBusinessObject(Object bo) {
if (bo == null)
return ""; //$NON-NLS-1$
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType) bo;
+ if (bo instanceof PersistentType) {
+ PersistentType jpt = (PersistentType) bo;
String name = jpt.getName();
return name;
} else if (bo instanceof AbstractRelation) {
@@ -294,8 +297,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
return ((HasReferanceRelation)bo).getId();
} else if (bo instanceof IsARelation) {
return ((IsARelation)bo).getId();
- } else if (bo instanceof JavaSpecifiedPersistentAttribute) {
- JavaSpecifiedPersistentAttribute at = (JavaSpecifiedPersistentAttribute) bo;
+ } else if (bo instanceof PersistentAttribute) {
+ PersistentAttribute at = (PersistentAttribute) bo;
return (((PersistentType)at.getParent()).getName() + "-" + at.getName()); //$NON-NLS-1$
}
return bo.toString();
@@ -331,18 +334,21 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
return produceKeyForRel(rel.getInverse(), rel.getInverseAttributeName());
}
- private String produceKeyForRel(JavaPersistentType jpt, String attributeName) {
+ private String produceKeyForRel(PersistentType jpt, String attributeName) {
return jpt.getName() + SEPARATOR + attributeName;
}
public void addKeyBusinessObject(String key, Object bo) {
keyToBO.put(key, bo);
- if (bo instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType) bo;
+ if (bo instanceof PersistentType) {
+ PersistentType jpt = (PersistentType) bo;
JpaProject proj = jpt.getJpaProject();
addListenersToProject(proj);
addListenersToEntity(jpt);
PictogramElement pe = featureProvider.getPictogramElementForBusinessObject(jpt);
+ if(pe == null) {
+ return;
+ }
Graphiti.getPeService().setPropertyValue(pe, JPAEditorConstants.PROP_ENTITY_CLASS_NAME, jpt.getName());
persistentTypes.add(jpt);
} else if (bo instanceof AbstractRelation) {
@@ -357,8 +363,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
} else if (bo instanceof IsARelation) {
IsARelation rel = (IsARelation) bo;
attribToIsARel.put(produceKeyForIsARel(rel), rel);
- } else if (bo instanceof JavaSpecifiedPersistentAttribute) {
- addPropertiesListenerToAttribute((JavaSpecifiedPersistentAttribute)bo);
+ } else if (bo instanceof PersistentAttribute) {
+ addPropertiesListenerToAttribute((PersistentAttribute)bo);
}
}
@@ -366,9 +372,9 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (key == null)
return null;
Object o = keyToBO.remove(key);
- if (o instanceof JavaPersistentType) {
- JavaPersistentType jpt = (JavaPersistentType) o;
- for (JavaSpecifiedPersistentAttribute at : jpt.getAttributes()) {
+ if (o instanceof PersistentType) {
+ PersistentType jpt = (PersistentType) o;
+ for (PersistentAttribute at : jpt.getAttributes()) {
String k = getKeyForBusinessObject(at);
remove(k);
}
@@ -397,24 +403,29 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
} else if (o instanceof IsARelation) {
IsARelation rel = (IsARelation) o;
attribToIsARel.remove(produceKeyForIsARel(rel));
- } else if (o instanceof JavaSpecifiedPersistentAttribute) {
- removeListenersFromAttribute((JavaSpecifiedPersistentAttribute)o);
+ } else if (o instanceof PersistentAttribute) {
+ removeListenersFromAttribute((PersistentAttribute)o);
}
return o;
}
- public ICompilationUnit getCompilationUnit(JavaPersistentType jpt) {
+ public ICompilationUnit getCompilationUnit(PersistentType jpt) {
return util.getCompilationUnit(jpt);
}
- public boolean isRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa) {
- String key = produceKeyForRel((JavaPersistentType)jpa.getParent(), jpa.getName());
+ public boolean isRelationRelatedToAttribute(PersistentAttribute jpa) {
+ String key = produceKeyForRel(jpa.getDeclaringPersistentType(), jpa.getName());
return attribToRel.containsKey(key);
}
-
- public IRelation getRelationRelatedToAttribute(JavaSpecifiedPersistentAttribute jpa, IJPAEditorFeatureProvider fp) {
- String key = findRelationshipKey(jpa, fp);
- return attribToRel.get(key);
+
+ public Set<IRelation> getRelationRelatedToAttribute(PersistentAttribute jpa, String typeName, IJPAEditorFeatureProvider fp) {
+ Set<String> keys = findRelationshipKey(jpa, typeName, fp);
+ Set<IRelation> relations = new HashSet<IRelation>();
+ Iterator<String> iter = keys.iterator();
+ while(iter.hasNext()){
+ relations.add(attribToRel.get(iter.next()));
+ }
+ return relations;
}
/**
@@ -426,76 +437,76 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
* that consists of the name of the attribute which will be renamed and the name of the attribute in the embeddable class. If such an attribute
* exists, the unique key for the existing relationship must be ganerated by the target entity and the name of the found attribute.
* Otherwise the key must be generated by the name of the attribute that will be renamed and its parent entity.
- * @param jpa - the {@link JavaSpecifiedPersistentAttribute} which will be renamed
+ * @param jpa - the {@link PersistentAttribute} which will be renamed
* @param fp
* @return the unique key for the relationship.
*/
- private String findRelationshipKey(JavaSpecifiedPersistentAttribute jpa, IJPAEditorFeatureProvider fp){
+ private Set<String> findRelationshipKey(PersistentAttribute jpa, String typeName, IJPAEditorFeatureProvider fp){
JpaArtifactFactory jpaFactory = JpaArtifactFactory.instance();
+ Set<String> relationShipKeys = new HashSet<String>();
if(jpaFactory.isEmbeddedAttribute(jpa)){
- Annotation embeddedAn = null;
- Annotation[] anns = JpaArtifactFactory.instance().getAnnotations(jpa);
- if(anns != null && anns.length > 0){
- embeddedAn = anns[0];
+ PersistentType embeddableClass = null;
+ if(typeName != null){
+ embeddableClass = jpaFactory.findJPT(jpa, fp, typeName);
+ } else {
+ String attributeTypeName = jpaFactory.getRelTypeName(jpa);
+ embeddableClass = jpaFactory.findJPT(jpa, fp, attributeTypeName);
}
- JavaPersistentType embeddableClass = jpaFactory.findJPT(jpa, fp, embeddedAn);
if(embeddableClass == null)
- return ""; //$NON-NLS-1$
- for (JavaSpecifiedPersistentAttribute relEntAt : embeddableClass.getAttributes()) {
- IResource r = relEntAt.getParent().getResource();
+ return relationShipKeys; //$NON-NLS-1$
+ for (PersistentAttribute relEntAt : embeddableClass.getAttributes()) {
+ IResource r = relEntAt.getDeclaringPersistentType().getResource();
if (!r.exists())
throw new RuntimeException();
- Annotation[] ans = jpaFactory.getAnnotations(relEntAt);
- for (Annotation an : ans) {
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) {
- JavaPersistentType jpt = jpaFactory.findJPT(relEntAt, fp, an);
+
+ AttributeMapping relationAttributeMapping = jpaFactory.getAttributeMapping(relEntAt);
+ if (relationAttributeMapping instanceof RelationshipMapping) {
+ PersistentType jpt = jpaFactory.findJPT(relEntAt, fp, jpaFactory.getRelTypeName(relEntAt));
if(jpt == null)
- return ""; //$NON-NLS-1$
- for(JavaSpecifiedPersistentAttribute attribute : jpt.getAttributes()){
- Annotation[] inverseAnns = jpaFactory.getAnnotations(attribute);
- for(Annotation inverseAn : inverseAnns){
- String inverseAnName = JPAEditorUtil.returnSimpleName(inverseAn.getAnnotationName());
- if(JPAEditorConstants.RELATION_ANNOTATIONS.contains(inverseAnName)){
- String mappedBy = ((OwnableRelationshipMappingAnnotation)inverseAn).getMappedBy();
+ return relationShipKeys; //$NON-NLS-1$
+ for(PersistentAttribute attribute : jpt.getAttributes()){
+ AttributeMapping mapping = jpaFactory.getAttributeMapping(attribute);
+ if(mapping instanceof RelationshipMapping) {
+ RelationshipMapping relMapping = (RelationshipMapping) mapping;
+ MappingRelationship mappingRel = relMapping.getRelationship();
+ if(mappingRel instanceof MappedByRelationship) {
+ String mappedBy = ((MappedByRelationship)mappingRel).getMappedByStrategy().getMappedByAttribute();
if(mappedBy.equals(jpa.getName()+"."+relEntAt.getName())) //$NON-NLS-1$
- return produceKeyForRel(jpt, attribute.getName());
+ relationShipKeys.add(produceKeyForRel(jpt, attribute.getName()));
}
}
}
- }
}
}
-// } else {
-// JavaPersistentType embeddedJPT = (JavaPersistentType) jpa.getParent();
-// if(jpaFactory.hasEmbeddableAnnotation(embeddedJPT)){
-// Set<IRelation> rels = featureProvider.getAllExistingIRelations();
-// for(IRelation rel : rels){
-// if(rel.getOwnerAnnotatedAttribute().equals(jpa) && (rel instanceof IBidirectionalRelation)){
-// return findRelationshipKey(rel.getInverseAnnotatedAttribute(), featureProvider);
-// }
-// }
-// }
+ } else {
+ relationShipKeys.add(produceKeyForRel((PersistentType) jpa.getParent(), jpa.getName()));
}
- return produceKeyForRel((JavaPersistentType) jpa.getParent(), jpa.getName());
+
+ return relationShipKeys;
}
-
- public HasReferanceRelation getEmbeddedRelationToAttribute(JavaSpecifiedPersistentAttribute jpa) {
- String key = produceKeyForRel((JavaPersistentType)jpa.getParent(), jpa.getName());
+ public HasReferanceRelation getEmbeddedRelationToAttribute(PersistentAttribute jpa) {
+ String key = produceKeyForRel((PersistentType) jpa.getParent(), jpa.getName());
return attribToEmbeddedRel.get(key);
}
public Collection<Object> getVisualizedObjects() {
return keyToBO.values();
}
-
- public void renewAttributeMappingPropListener(JavaSpecifiedPersistentAttribute jpa) {
+
+ public void renewAttributeMappingPropListener(PersistentAttribute ropa) {
+ PersistentAttribute jpa = ropa.getJavaPersistentAttribute();
renewAttributeJoiningStrategyPropertyListener(jpa);
renewAttributeMappingOptPropListener(jpa);
+
+ PersistentAttribute pa = JpaArtifactFactory.instance().getORMPersistentAttribute(ropa);
+ if(pa != null) {
+ renewAttributeJoiningStrategyPropertyListener(pa);
+ renewAttributeMappingOptPropListener(pa);
+ }
}
-
- public void renewAttributeJoiningStrategyPropertyListener(JavaSpecifiedPersistentAttribute jpa) {
+
+ public void renewAttributeJoiningStrategyPropertyListener(PersistentAttribute jpa) {
AttributeJoiningStrategyPropertyChangeListener lsn = null;
if (attributeJoiningStrategyToPropListener == null)
return;
@@ -503,7 +514,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (ref != null)
lsn = ref.get();
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
return;
SpecifiedRelationship rr = ((RelationshipMapping) jam).getRelationship();
@@ -524,16 +535,16 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
attributeJoiningStrategyToPropListener.put(jpa, ref);
}
-
- public void renewAttributeMappingOptPropListener(JavaSpecifiedPersistentAttribute jpa) {
+
+ public void renewAttributeMappingOptPropListener(PersistentAttribute jpa) {
AttributeMappingOptionalityChangeListener lsn = null;
WeakReference<AttributeMappingOptionalityChangeListener> ref = attributeMappingOptionalityToPropListener.remove(jpa);
if (ref != null)
lsn = ref.get();
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if (jam == null)
return;
- if (!ManyToOneMapping.class.isInstance(jam) && !OneToOneMapping.class.isInstance(jam))
+ if (!SingleRelationshipMapping.class.isInstance(jam))
return;
try {
@@ -570,13 +581,22 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
- private void addListenersToEntity(JavaPersistentType jpt) {
+ private void addListenersToEntity(PersistentType jpt) {
addAtListenerToEntity(jpt);
+ addOrmAtListenerToEntity(jpt);
+
+ MappingFileRef fileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(fileRef != null) {
+ PersistentType pt = fileRef.getPersistentType(jpt.getName());
+ addPropertiesListenerToEntity(pt);
+ addStateListenerToEntity(pt);
+ }
+
addPropertiesListenerToEntity(jpt);
addStateListenerToEntity(jpt);
}
- private void addAtListenerToEntity(JavaPersistentType jpt) {
+ private void addAtListenerToEntity(PersistentType jpt) {
WeakReference<ListChangeListener> lsnrRef = entityToAtListener.get(jpt);
ListChangeListener lsnr = null;
if (lsnrRef != null)
@@ -588,8 +608,22 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
entityToAtListener.put(jpt, lsnrRef);
}
}
+
+ private void addOrmAtListenerToEntity(PersistentType jpt) {
+ WeakReference<ListChangeListener> lsnrRef = entityToOrmAtListener.get(jpt);
+ ListChangeListener lsnr = null;
+ if (lsnrRef != null)
+ lsnr = lsnrRef.get();
+ if (lsnr == null) {
+ lsnr = new EntityAttributesChangeListener();
+ jpt.addListChangeListener(OrmPersistentType.SPECIFIED_ATTRIBUTES_LIST, lsnr);
+ jpt.addListChangeListener(OrmPersistentType.DEFAULT_ATTRIBUTES_LIST, lsnr);
+ lsnrRef = new WeakReference<ListChangeListener>(lsnr);
+ entityToOrmAtListener.put(jpt, lsnrRef);
+ }
+ }
- private void addPropertiesListenerToEntity(JavaPersistentType jpt) {
+ private void addPropertiesListenerToEntity(PersistentType jpt) {
WeakReference<PropertyChangeListener> lsnrRef = entityToPropListener.get(jpt);
PropertyChangeListener lsnr = null;
if (lsnrRef != null)
@@ -602,48 +636,54 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
- private void addPropertiesListenerToAttribute(JavaSpecifiedPersistentAttribute jpa) {
+ private void addPropertiesListenerToAttribute(PersistentAttribute ropa) {
+ PersistentAttribute jpa = ropa.getJavaPersistentAttribute();
addPropertiesListenerToAttributeItself(jpa);
addPropertiesListenerToJoiningStrategy(jpa);
addPropertiesListenerToRelationshipReference(jpa);
- addOptPropListenerToAttributeMapping(jpa);
- }
+ addOptPropListenerToAttributeMapping(jpa);
- private void addPropertiesListenerToAttributeItself(JavaSpecifiedPersistentAttribute jpa) {
+ PersistentAttribute pa = JpaArtifactFactory.instance().getORMPersistentAttribute(ropa);
+ if(pa != null) {
+ addPropertiesListenerToAttributeItself(pa);
+ addPropertiesListenerToJoiningStrategy(pa);
+ addPropertiesListenerToRelationshipReference(pa);
+ addOptPropListenerToAttributeMapping(pa);
+ }
+ }
+
+ private void addPropertiesListenerToAttributeItself(PersistentAttribute jpa) {
WeakReference<AttributePropertyChangeListener> lsnrRef = attributeToPropListener.get(jpa);
AttributePropertyChangeListener lsnr = null;
if (lsnrRef != null)
lsnr = lsnrRef.get();
if (lsnr == null) {
lsnr = new AttributePropertyChangeListener();
- jpa.addPropertyChangeListener(SpecifiedPersistentAttribute.MAPPING_PROPERTY, lsnr);
+ jpa.addPropertyChangeListener(PersistentAttribute.MAPPING_PROPERTY, lsnr);
lsnrRef = new WeakReference<AttributePropertyChangeListener>(lsnr);
attributeToPropListener.put(jpa, lsnrRef);
}
}
-
- private void addOptPropListenerToAttributeMapping(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void addOptPropListenerToAttributeMapping(PersistentAttribute jpa) {
WeakReference<AttributeMappingOptionalityChangeListener> lsnrRef = attributeMappingOptionalityToPropListener.get(jpa);
AttributeMappingOptionalityChangeListener lsnr = null;
if (lsnrRef != null)
lsnr = lsnrRef.get();
if (lsnr == null) {
lsnr = new AttributeMappingOptionalityChangeListener();
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if (jam == null)
return;
- if (!JavaManyToOneMapping.class.isInstance(jam) &&
- !JavaOneToOneMapping.class.isInstance(jam))
+ if (SingleRelationshipMapping.class.isInstance(jam))
return;
jam.addPropertyChangeListener(OptionalMapping.SPECIFIED_OPTIONAL_PROPERTY, lsnr);
lsnrRef = new WeakReference<AttributeMappingOptionalityChangeListener>(lsnr);
attributeMappingOptionalityToPropListener.put(jpa, lsnrRef);
}
}
-
-
- private void addPropertiesListenerToJoiningStrategy(JavaSpecifiedPersistentAttribute jpa) {
-
+
+ private void addPropertiesListenerToJoiningStrategy(PersistentAttribute jpa) {
WeakReference<AttributeJoiningStrategyPropertyChangeListener> lsnrRef = attributeJoiningStrategyToPropListener.get(jpa);
AttributeJoiningStrategyPropertyChangeListener lsnr = null;
lsnrRef = attributeJoiningStrategyToPropListener.get(jpa);
@@ -651,7 +691,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
lsnr = lsnrRef.get();
if (lsnr == null) {
lsnr = new AttributeJoiningStrategyPropertyChangeListener();
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
return;
SpecifiedRelationship rr = ((RelationshipMapping) jam).getRelationship();
@@ -665,10 +705,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
-
-
- private void addPropertiesListenerToRelationshipReference(JavaSpecifiedPersistentAttribute jpa) {
-
+
+ private void addPropertiesListenerToRelationshipReference(PersistentAttribute jpa) {
WeakReference<AttributeRelationshipReferencePropertyChangeListener> lsnrRef = attributeRelationshipReferenceToPropListener.get(jpa);
AttributeRelationshipReferencePropertyChangeListener lsnr = null;
lsnrRef = attributeRelationshipReferenceToPropListener.get(jpa);
@@ -676,7 +714,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
lsnr = lsnrRef.get();
if (lsnr == null) {
lsnr = new AttributeRelationshipReferencePropertyChangeListener();
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
return;
SpecifiedRelationship rr = ((RelationshipMapping) jam).getRelationship();
@@ -690,9 +728,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
-
-
- private void addStateListenerToEntity(JavaPersistentType jpt) {
+ private void addStateListenerToEntity(PersistentType jpt) {
WeakReference<StateChangeListener> lsnrRef = entityToStateListener.get(jpt);
StateChangeListener lsnr = null;
if (lsnrRef != null)
@@ -705,17 +741,30 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
- private void removeListenersFromEntity(JavaPersistentType jpt) {
+ private void removeListenersFromEntity(PersistentType jpt) {
removeAtListenerFromEntity(jpt);
+ removeOrmAtListenerFromEntity(jpt);
+
+ MappingFileRef fileRef = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(fileRef != null) {
+ PersistentType pt = fileRef.getPersistentType(jpt.getName());
+ removePropListenerFromEntity(pt);
+ removeStateListenerFromEntity(pt);
+ }
removePropListenerFromEntity(jpt);
removeStateListenerFromEntity(jpt);
}
-
- private void removeListenersFromAttribute(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void removeListenersFromAttribute(PersistentAttribute ropa) {
+ PersistentAttribute jpa = ropa.getJavaPersistentAttribute();
removePropListenerFromAttribute(jpa);
+
+ PersistentAttribute pa = JpaArtifactFactory.instance().getORMPersistentAttribute(ropa);
+ if(pa != null)
+ removePropListenerFromAttribute(pa);
}
- private void removeAtListenerFromEntity(JavaPersistentType jpt) {
+ private void removeAtListenerFromEntity(PersistentType jpt) {
WeakReference<ListChangeListener> lsnrRef = entityToAtListener.get(jpt);
ListChangeListener lsnr = null;
if (lsnrRef != null)
@@ -725,8 +774,21 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
jpt.removeListChangeListener(JavaPersistentType.ATTRIBUTES_LIST, lsnr);
}
}
+
+ private void removeOrmAtListenerFromEntity(PersistentType jpt) {
+ WeakReference<ListChangeListener> lsnrRef = entityToOrmAtListener.get(jpt);
+ ListChangeListener lsnr = null;
+ if (lsnrRef != null)
+ lsnr = lsnrRef.get();
+ if (lsnr != null) {
+ entityToOrmAtListener.remove(jpt);
+ jpt.removeListChangeListener(OrmPersistentType.SPECIFIED_ATTRIBUTES_LIST, lsnr);
+ jpt.removeListChangeListener(OrmPersistentType.DEFAULT_ATTRIBUTES_LIST, lsnr);
+
+ }
+ }
- private void removePropListenerFromEntity(JavaPersistentType jpt) {
+ private void removePropListenerFromEntity(PersistentType jpt) {
WeakReference<PropertyChangeListener> lsnrRef = entityToPropListener.get(jpt);
PropertyChangeListener lsnr = null;
if (lsnrRef != null)
@@ -740,15 +802,15 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
}
-
- private void removePropListenerFromAttribute(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void removePropListenerFromAttribute(PersistentAttribute jpa) {
removePropListenerFromAttributeItself(jpa);
removePropListenerFromJoiningStrategy(jpa);
removePropListenerFromRelationshipReference(jpa);
removeOptPropListenerFromAttributeMapping(jpa);
}
-
- private void removePropListenerFromAttributeItself(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void removePropListenerFromAttributeItself(PersistentAttribute jpa) {
WeakReference<AttributePropertyChangeListener> lsnrRef = attributeToPropListener.get(jpa);
PropertyChangeListener lsnr = null;
if (lsnrRef != null)
@@ -756,14 +818,14 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (lsnr != null) {
attributeToPropListener.remove(jpa);
try {
- jpa.removePropertyChangeListener(SpecifiedPersistentAttribute.MAPPING_PROPERTY, lsnr);
+ jpa.removePropertyChangeListener(PersistentAttribute.MAPPING_PROPERTY, lsnr);
} catch (IllegalArgumentException e) {
//$NON-NLS-1$
}
}
}
-
- private void removePropListenerFromJoiningStrategy(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void removePropListenerFromJoiningStrategy(PersistentAttribute jpa) {
WeakReference<AttributeJoiningStrategyPropertyChangeListener> lsnrRef = attributeJoiningStrategyToPropListener.get(jpa);
PropertyChangeListener lsnr = null;
lsnrRef = attributeJoiningStrategyToPropListener.get(jpa);
@@ -772,7 +834,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (lsnr != null) {
attributeJoiningStrategyToPropListener.remove(jpa);
try {
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
return;
SpecifiedRelationship rr = ((RelationshipMapping) jam).getRelationship();
@@ -788,8 +850,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
-
- private void removeOptPropListenerFromAttributeMapping(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void removeOptPropListenerFromAttributeMapping(PersistentAttribute jpa) {
WeakReference<AttributeMappingOptionalityChangeListener> lsnrRef = attributeMappingOptionalityToPropListener.get(jpa);
PropertyChangeListener lsnr = null;
lsnrRef = attributeMappingOptionalityToPropListener.get(jpa);
@@ -798,7 +860,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (lsnr != null) {
attributeMappingOptionalityToPropListener.remove(jpa);
try {
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
return;
jam.removePropertyChangeListener(OptionalMapping.SPECIFIED_OPTIONAL_PROPERTY, lsnr);
@@ -807,9 +869,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
}
}
-
-
- private void removePropListenerFromRelationshipReference(JavaSpecifiedPersistentAttribute jpa) {
+
+ private void removePropListenerFromRelationshipReference(PersistentAttribute jpa) {
WeakReference<AttributeRelationshipReferencePropertyChangeListener> lsnrRef = attributeRelationshipReferenceToPropListener.get(jpa);
PropertyChangeListener lsnr = null;
lsnrRef = attributeRelationshipReferenceToPropListener.get(jpa);
@@ -818,7 +879,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (lsnr != null) {
attributeRelationshipReferenceToPropListener.remove(jpa);
try {
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
return;
SpecifiedRelationship rr = ((RelationshipMapping) jam).getRelationship();
@@ -832,7 +893,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
- private void removeStateListenerFromEntity(JavaPersistentType jpt) {
+ private void removeStateListenerFromEntity(PersistentType jpt) {
WeakReference<StateChangeListener> lsnrRef = entityToStateListener.get(jpt);
StateChangeListener lsnr = null;
if (lsnrRef != null)
@@ -845,13 +906,13 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
//---------------
private void removeEntityStateChangeListeners() {
- Iterator<JavaPersistentType> it = entityToStateListener.keySet().iterator();
- Set<JavaPersistentType> s = new HashSet<JavaPersistentType>();
+ Iterator<PersistentType> it = entityToStateListener.keySet().iterator();
+ Set<PersistentType> s = new HashSet<PersistentType>();
while(it.hasNext())
s.add(it.next());
it = s.iterator();
while(it.hasNext()) {
- JavaPersistentType jpt = it.next();
+ PersistentType jpt = it.next();
WeakReference<StateChangeListener> ref = entityToStateListener.remove(jpt);
StateChangeListener lsn = ref.get();
if (lsn != null)
@@ -862,13 +923,13 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
private void removeEntityPropChangeListeners() {
- Iterator<JavaPersistentType> it = entityToPropListener.keySet().iterator();
- Set<JavaPersistentType> s = new HashSet<JavaPersistentType>();
+ Iterator<PersistentType> it = entityToPropListener.keySet().iterator();
+ Set<PersistentType> s = new HashSet<PersistentType>();
while(it.hasNext())
s.add(it.next());
it = s.iterator();
while(it.hasNext()) {
- JavaPersistentType jpt = it.next();
+ PersistentType jpt = it.next();
WeakReference<PropertyChangeListener> ref = entityToPropListener.remove(jpt);
PropertyChangeListener lsn = ref.get();
if (lsn != null)
@@ -879,18 +940,18 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
private void removeAttributePropChangeListeners() {
- Iterator<JavaSpecifiedPersistentAttribute> it = attributeToPropListener.keySet().iterator();
- Set<JavaSpecifiedPersistentAttribute> s = new HashSet<JavaSpecifiedPersistentAttribute>();
+ Iterator<PersistentAttribute> it = attributeToPropListener.keySet().iterator();
+ Set<PersistentAttribute> s = new HashSet<PersistentAttribute>();
while(it.hasNext())
s.add(it.next());
it = s.iterator();
while(it.hasNext()) {
- JavaSpecifiedPersistentAttribute jpa = it.next();
+ PersistentAttribute jpa = it.next();
WeakReference<AttributePropertyChangeListener> ref = attributeToPropListener.remove(jpa);
PropertyChangeListener lsn = ref.get();
if (lsn != null)
try {
- jpa.removePropertyChangeListener(SpecifiedPersistentAttribute.MAPPING_PROPERTY, lsn);
+ jpa.removePropertyChangeListener(PersistentAttribute.MAPPING_PROPERTY, lsn);
} catch (IllegalArgumentException e) {
//$NON-NLS-1$
}
@@ -900,13 +961,13 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
private void removeAttributeJoiningStrategyPropChangeListeners() {
- Iterator<JavaSpecifiedPersistentAttribute> it = attributeJoiningStrategyToPropListener.keySet().iterator();
- Set<JavaSpecifiedPersistentAttribute> s = new HashSet<JavaSpecifiedPersistentAttribute>();
+ Iterator<PersistentAttribute> it = attributeJoiningStrategyToPropListener.keySet().iterator();
+ Set<PersistentAttribute> s = new HashSet<PersistentAttribute>();
while(it.hasNext())
s.add(it.next());
it = s.iterator();
while(it.hasNext()) {
- JavaSpecifiedPersistentAttribute jpa = it.next();
+ PersistentAttribute jpa = it.next();
WeakReference<AttributeJoiningStrategyPropertyChangeListener> ref = attributeJoiningStrategyToPropListener.remove(jpa);
PropertyChangeListener lsn = ref.get();
if (lsn != null)
@@ -921,20 +982,20 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
private void removeOptPropListeners() {
- Iterator<JavaSpecifiedPersistentAttribute> it = this.attributeMappingOptionalityToPropListener.keySet().iterator();
- Set<JavaSpecifiedPersistentAttribute> s = new HashSet<JavaSpecifiedPersistentAttribute>();
+ Iterator<PersistentAttribute> it = this.attributeMappingOptionalityToPropListener.keySet().iterator();
+ Set<PersistentAttribute> s = new HashSet<PersistentAttribute>();
while(it.hasNext())
s.add(it.next());
it = s.iterator();
while(it.hasNext()) {
- JavaSpecifiedPersistentAttribute jpa = it.next();
+ PersistentAttribute jpa = it.next();
WeakReference<AttributeMappingOptionalityChangeListener> ref = attributeMappingOptionalityToPropListener.remove(jpa);
if (ref == null)
continue;
PropertyChangeListener lsn = ref.get();
if (lsn == null)
continue;
- JavaAttributeMapping jam = jpa.getMapping();
+ AttributeMapping jam = jpa.getMapping();
if ((jam == null) || !RelationshipMapping.class.isInstance(jam))
continue;
try {
@@ -948,20 +1009,29 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
private void removeEntityAttributeChangeListeners() {
- Iterator<JavaPersistentType> it = entityToAtListener.keySet().iterator();
- Set<JavaPersistentType> s = new HashSet<JavaPersistentType>();
+ Iterator<PersistentType> it = entityToAtListener.keySet().iterator();
+ Set<PersistentType> s = new HashSet<PersistentType>();
while(it.hasNext())
s.add(it.next());
it = s.iterator();
while(it.hasNext()) {
- JavaPersistentType jpt = it.next();
+ PersistentType jpt = it.next();
WeakReference<ListChangeListener> ref = entityToAtListener.remove(jpt);
ListChangeListener lsn = ref.get();
- if (lsn != null)
+ if (lsn != null) {
jpt.removeListChangeListener(JavaPersistentType.ATTRIBUTES_LIST, lsn);
+ }
+
+ WeakReference<ListChangeListener> ref1 = entityToOrmAtListener.remove(jpt);
+ ListChangeListener lsn1 = ref1.get();
+ if (lsn1 != null) {
+ jpt.removeListChangeListener(OrmPersistentType.SPECIFIED_ATTRIBUTES_LIST, lsn1);
+ }
}
entityToAtListener.clear();
+ entityToOrmAtListener.clear();
entityToAtListener = null;
+ entityToOrmAtListener = null;
}
private void removeProjectListeners() {
@@ -996,10 +1066,11 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
Iterator<Object> it = keyToBO.values().iterator();
while (it.hasNext()) {
Object bo = it.next();
- if (!JavaPersistentType.class.isInstance(bo))
+ if (!PersistentType.class.isInstance(bo))
continue;
- ICompilationUnit cu = util.getCompilationUnit(((JavaPersistentType)bo));
- util.discardWorkingCopyOnce(cu);
+ ICompilationUnit cu = util.getCompilationUnit(((PersistentType)bo));
+ if(cu != null)
+ util.discardWorkingCopyOnce(cu);
}
util = null;
@@ -1026,7 +1097,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
return keyToBO.containsKey(key);
}
- public void restoreEntity(JavaPersistentType jpt) {
+ public void restoreEntity(PersistentType jpt) {
if (jpt == null)
return;
ICompilationUnit cu = this.getCompilationUnit(jpt);
@@ -1046,7 +1117,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
Set<ICompilationUnit> affectedCompilationUnits = getAffectedCompilationUnits(jed);
for (ICompilationUnit cu : affectedCompilationUnits) {
- JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
+ PersistentType jpt = JPAEditorUtil.getJPType(cu);
for (final JPASolver solver : solversSet) {
final ContainerShape cs = (ContainerShape)solver.featureProvider.getPictogramElementForBusinessObject(jpt);
if (cs == null)
@@ -1101,7 +1172,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
if(pu == null)
continue;
- JavaPersistentType jpt = (JavaPersistentType)pu.getPersistentType(name);
+ PersistentType jpt = pu.getPersistentType(name);
final ContainerShape cs = (ContainerShape)featureProvider.getPictogramElementForBusinessObject(jpt);
if (cs == null)
return;
@@ -1159,14 +1230,14 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
synchronized public void propertyChanged(PropertyChangeEvent event) {
String propName = event.getPropertyName();
if (propName.equals(JPAEditorConstants.PROP_SPECIFIED_NAME)) {
- final JavaEntity je = (JavaEntity)event.getSource();
+ final Entity je = (Entity)event.getSource();
Runnable job = new Runnable() {
public void run() {
TransactionalEditingDomain ted = featureProvider.getTransactionalEditingDomain();
ted.getCommandStack().execute(new RecordingCommand(ted) {
@Override
protected void doExecute() {
- JavaPersistentType jpt = je.getPersistentType();
+ PersistentType jpt = je.getPersistentType();
updateJPTName(jpt);
String tableName = JPAEditorUtil.formTableName(jpt);
JpaArtifactFactory.instance().setTableName(jpt, tableName);
@@ -1184,11 +1255,12 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
synchronized public void propertyChanged(PropertyChangeEvent event) {
Model source = event.getSource();
- if (!JavaSpecifiedPersistentAttribute.class.isInstance(source))
+
+ if (!PersistentAttribute.class.isInstance(source))
return;
PictogramElement pe = featureProvider
- .getPictogramElementForBusinessObject(((JavaSpecifiedPersistentAttribute) source)
- .getParent());
+ .getPictogramElementForBusinessObject(((PersistentAttribute) source)
+ .getDeclaringPersistentType());
final GraphicalRemoveAttributeFeature remove = new GraphicalRemoveAttributeFeature(featureProvider);
final CustomContext ctx = new CustomContext();
ctx.setInnerPictogramElement(pe);
@@ -1199,8 +1271,8 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
};
Display.getDefault().asyncExec(runnable);
String propName = event.getPropertyName();
- if (propName.equals(SpecifiedPersistentAttribute.MAPPING_PROPERTY)) {
- renewAttributeMappingPropListener((JavaSpecifiedPersistentAttribute) source);
+ if (propName.equals(PersistentAttribute.MAPPING_PROPERTY)) {
+ renewAttributeMappingPropListener((PersistentAttribute) source);
}
}
}
@@ -1223,12 +1295,12 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
if (nd == null)
return;
nd = nd.getParent();
- if ((nd == null) || !JavaSpecifiedPersistentAttribute.class.isInstance(nd))
- return;
- JavaSpecifiedPersistentAttribute at = (JavaSpecifiedPersistentAttribute)nd;
- if (!at.getParent().getParent().getResource().exists())
+ if ((nd == null) || !PersistentAttribute.class.isInstance(nd))
+ return;
+ PersistentAttribute at = (PersistentAttribute)nd;
+ if (!at.getDeclaringPersistentType().getParent().getResource().exists())
return;
- PictogramElement pe = featureProvider.getPictogramElementForBusinessObject(at.getParent());
+ PictogramElement pe = featureProvider.getPictogramElementForBusinessObject(at.getDeclaringPersistentType());
final GraphicalRemoveAttributeFeature remove = new GraphicalRemoveAttributeFeature(featureProvider);
final CustomContext ctx = new CustomContext();
ctx.setInnerPictogramElement(pe);
@@ -1256,15 +1328,15 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
p = p.getParent();
if (p == null)
return;
- if (!JavaSpecifiedPersistentAttribute.class.isInstance(p))
+ if (!PersistentAttribute.class.isInstance(p))
return;
- JavaSpecifiedPersistentAttribute jpa = (JavaSpecifiedPersistentAttribute)p;
+ PersistentAttribute jpa = (PersistentAttribute)p;
renewAttributeJoiningStrategyPropertyListener(jpa);
- if (!jpa.getParent().getParent().getResource().exists())
+ if (!jpa.getDeclaringPersistentType().getParent().getResource().exists())
return;
if (featureProvider == null)
return;
- PictogramElement pe = featureProvider.getPictogramElementForBusinessObject(jpa.getParent());
+ PictogramElement pe = featureProvider.getPictogramElementForBusinessObject(jpa.getDeclaringPersistentType());
final GraphicalRemoveAttributeFeature remove = new GraphicalRemoveAttributeFeature(featureProvider);
final CustomContext ctx = new CustomContext();
ctx.setInnerPictogramElement(pe);
@@ -1287,9 +1359,9 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
Boolean optional = (Boolean)event.getNewValue();
boolean isOptional = (optional == null) ? true : optional.booleanValue();
OptionalMapping nm = (OptionalMapping)event.getSource();
- JavaSpecifiedPersistentAttribute jpa = (JavaSpecifiedPersistentAttribute)nm.getParent();
- IRelation rel = featureProvider.getRelationRelatedToAttribute(jpa);
- boolean atBeginning = !rel.getOwner().equals(jpa.getParent()) ||
+ PersistentAttribute jpa = (PersistentAttribute)nm.getParent();
+ IRelation rel = featureProvider.getRelationRelatedToAttribute(jpa, JpaArtifactFactory.instance().getRelTypeName(jpa)).iterator().next();
+ boolean atBeginning = !rel.getOwner().getName().equals(jpa.getDeclaringPersistentType().getName()) ||
!rel.getOwnerAttributeName().equals(jpa.getName());
final Connection c = (Connection)featureProvider.getPictogramElementForBusinessObject(rel);
Collection<ConnectionDecorator> conDecs = c.getConnectionDecorators();
@@ -1331,23 +1403,23 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
@SuppressWarnings("unchecked")
synchronized public void run() {
try {
- Iterator<JavaSpecifiedPersistentAttribute> it = (Iterator<JavaSpecifiedPersistentAttribute>) event.getItems().iterator();
+ ArrayIterator<PersistentAttribute> it = (ArrayIterator<PersistentAttribute>) event.getItems().iterator();
Set<Shape> shapesToRemove = new HashSet<Shape>();
while (it.hasNext()) {
- JavaSpecifiedPersistentAttribute at = it.next();
+ PersistentAttribute at = it.next();
/*
String key = getKeyForBusinessObject(at);
remove(key);
*/
- if (removeIgnore.remove(((PersistentType)at.getParent()).getName() + "." + at.getName())) //$NON-NLS-1$
+ if (removeIgnore.remove(at.getDeclaringPersistentType().getName() + "." + at.getName())) //$NON-NLS-1$
continue;
Shape atShape = (Shape) featureProvider.getPictogramElementForBusinessObject(at);
if (atShape == null)
- continue;
+ continue;
-
- JavaPersistentType jpt = (JavaPersistentType)event.getSource();
- JavaSpecifiedPersistentAttribute newAt = jpt.getAttributeNamed(at.getName());
+ PersistentType jpt = (PersistentType)event.getSource();
+ PersistentAttribute newAt = jpt.getAttributeNamed(at.getName());
+
if (newAt != null) {
RemoveAttributeFeature ft = new RemoveAttributeFeature(featureProvider, true, true);
RemoveContext c = new RemoveContext(atShape);
@@ -1364,21 +1436,23 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
shapesToRemove.add(atShape);
- IRelation rel = featureProvider.getRelationRelatedToAttribute(at);
- if (rel == null)
- continue;
- Connection conn = (Connection) featureProvider.getPictogramElementForBusinessObject(rel);
- if(conn == null){
- HasReferanceRelation embedRel = featureProvider.getEmbeddedRelationRelatedToAttribute(at);
- if(embedRel == null)
- continue;
- conn = (Connection)featureProvider.getPictogramElementForBusinessObject(embedRel);
- }
- while (conn != null) {
- RemoveContext ctx = new RemoveContext(conn);
- RemoveRelationFeature ft = new RemoveRelationFeature(featureProvider);
- ft.remove(ctx);
- conn = (Connection) featureProvider.getPictogramElementForBusinessObject(rel);
+ Set<IRelation> rels = featureProvider.getRelationRelatedToAttribute(at, JpaArtifactFactory.instance().getRelTypeName(at));
+ Iterator<IRelation> relIter = rels.iterator();
+ while(relIter.hasNext()) {
+ IRelation rel = relIter.next();
+ Connection conn = (Connection) featureProvider.getPictogramElementForBusinessObject(rel);
+ if(conn == null){
+ HasReferanceRelation embedRel = featureProvider.getEmbeddedRelationRelatedToAttribute(at);
+ if(embedRel == null)
+ continue;
+ conn = (Connection)featureProvider.getPictogramElementForBusinessObject(embedRel);
+ }
+ while (conn != null) {
+ RemoveContext ctx = new RemoveContext(conn);
+ RemoveRelationFeature ft = new RemoveRelationFeature(featureProvider);
+ ft.remove(ctx);
+ conn = (Connection) featureProvider.getPictogramElementForBusinessObject(rel);
+ }
}
}
Iterator<Shape> itr = shapesToRemove.iterator();
@@ -1388,7 +1462,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
RemoveAttributeFeature ft = new RemoveAttributeFeature(featureProvider, true, true);
ft.remove(ctx);
}
- JpaArtifactFactory.instance().addNewRelations(featureProvider, (JavaPersistentType) event.getSource());
+ JpaArtifactFactory.instance().addNewRelations(featureProvider, (PersistentType) event.getSource());
} catch (Exception e) {
//$NON-NLS-1$
}
@@ -1406,21 +1480,14 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
@SuppressWarnings("unchecked")
synchronized public void run() {
try {
- JavaPersistentType jpt = (JavaPersistentType) event.getSource();
+ PersistentType jpt = (PersistentType) event.getSource();
ContainerShape entShape = (ContainerShape)featureProvider.getPictogramElementForBusinessObject(jpt);
// remove invalidated relations (if any)
- Iterator<JavaSpecifiedPersistentAttribute> it = (Iterator<JavaSpecifiedPersistentAttribute>) event.getItems().iterator();
+ ArrayIterator<PersistentAttribute> it = (ArrayIterator<PersistentAttribute>) event.getItems().iterator();
while (it.hasNext()) {
- JavaSpecifiedPersistentAttribute at = it.next();
- if(at.getMapping() == null || at.getMapping().getMappingAnnotation() == null){
- at.getResourceAttribute().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- }
-
- //Shape atShape = (Shape) featureProvider.getPictogramElementForBusinessObject(at);
- //if (atShape != null)
- // continue;
- if (addIgnore.remove(((PersistentType)at.getParent()).getName() + "." + at.getName())) //$NON-NLS-1$
+ PersistentAttribute at = it.next();
+ if (addIgnore.remove(at.getDeclaringPersistentType().getName() + "." + at.getName())) //$NON-NLS-1$
continue;
AddContext ctx = new AddContext();
ctx.setNewObject(at);
@@ -1442,7 +1509,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
}
- private void updateJPTName(JavaPersistentType jpt) {
+ private void updateJPTName(PersistentType jpt) {
String entName = JpaArtifactFactory.instance().getEntityName(jpt);
entName = JPAEditorUtil.returnSimpleName(entName);
ContainerShape entShape = (ContainerShape)featureProvider.getPictogramElementForBusinessObject(jpt);
@@ -1530,7 +1597,7 @@ public class JPASolver implements IResourceChangeListener, IJpaSolver {
return resources;
}
- public Collection<JavaPersistentType> getPersistentTypes() {
+ public Collection<PersistentType> getPersistentTypes() {
return persistentTypes;
}
}
diff --git a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
index 0f3ec9add2..b870be5ac6 100644
--- a/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
+++ b/jpa_diagram_editor/plugins/org.eclipse.jpt.jpadiagrameditor.ui/src/org/eclipse/jpt/jpadiagrameditor/ui/internal/util/JpaArtifactFactory.java
@@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
-import java.util.Locale;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -39,6 +38,7 @@ import org.eclipse.graphiti.features.context.impl.AddConnectionContext;
import org.eclipse.graphiti.features.context.impl.RemoveContext;
import org.eclipse.graphiti.mm.pictograms.Connection;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
+import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.graphiti.services.Graphiti;
import org.eclipse.graphiti.util.IColorConstant;
@@ -54,42 +54,57 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jpt.common.core.JptResourceModel;
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.AstNodeType;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.common.core.resource.java.JavaResourceCompilationUnit;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
-import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.common.ui.internal.utility.SynchronousUiCommandExecutor;
import org.eclipse.jpt.common.utility.command.Command;
-import org.eclipse.jpt.common.utility.internal.iterable.SubListIterableWrapper;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JpaProjectManager;
import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.AccessType;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.AttributeOverride;
+import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
+import org.eclipse.jpt.jpa.core.context.ColumnMapping;
import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping;
+import org.eclipse.jpt.jpa.core.context.EmbeddedMapping;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
+import org.eclipse.jpt.jpa.core.context.MappingFile;
+import org.eclipse.jpt.jpa.core.context.MappingRelationship;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
+import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.SpecifiedJoinColumn;
+import org.eclipse.jpt.jpa.core.context.SpecifiedJoinColumnRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.TypeMapping;
+import org.eclipse.jpt.jpa.core.context.orm.OrmManagedType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
+import org.eclipse.jpt.jpa.core.context.orm.OrmSpecifiedPersistentAttribute;
+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.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.MapsIdDerivedIdentityStrategy2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.RelationshipMappingAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TableAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.JPADiagramEditorPlugin;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.AddAttributeCommand;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.AddPersistentTypeToOrmXmlCommand;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.CreateEntityTypeHierarchy;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.DeleteAttributeCommand;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.command.RenameAttributeCommand;
@@ -100,7 +115,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.AddInheritedEntityFe
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.AddRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.RemoveRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.UpdateAttributeFeature;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasCollectionReferenceRelation;
@@ -127,7 +141,6 @@ import org.eclipse.swt.widgets.Display;
public class JpaArtifactFactory {
private static final JpaArtifactFactory INSTANCE = new JpaArtifactFactory();
- private static String MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR = "\\."; //$NON-NLS-1$
private static final int MAX_NUM_OF_ITERATIONS = 25;
private static final int PAUSE_DURATION = 200;
@@ -160,13 +173,13 @@ public class JpaArtifactFactory {
}
public Collection<IsARelation> produceAllMissingIsARelations(IJPAEditorFeatureProvider fp) {
- Collection<JavaPersistentType> persistentTypes = fp.getPersistentTypes();
+ Collection<PersistentType> persistentTypes = fp.getPersistentTypes();
Collection<IsARelation> res = new HashSet<IsARelation>();
- Iterator<JavaPersistentType> it = persistentTypes.iterator();
+ Iterator<PersistentType> it = persistentTypes.iterator();
HashSet<IsARelation> allExistingIsARelations = fp.getAllExistingIsARelations();
while (it.hasNext()) {
- JavaPersistentType jpt = it.next();
- JavaPersistentType superclass = fp.getFirstSuperclassBelongingToTheDiagram(jpt);
+ PersistentType jpt = it.next();
+ PersistentType superclass = fp.getFirstSuperclassBelongingToTheDiagram(jpt);
if (superclass == null)
continue;
IsARelation newRel = new IsARelation(jpt, superclass);
@@ -175,258 +188,268 @@ public class JpaArtifactFactory {
}
return res;
}
-
- public void addOneToOneUnidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt,
- JavaSpecifiedPersistentAttribute attribute) {
+
+ public void addOneToOneUnidirectionalRelation(IFeatureProvider fp, PersistentType jpt,
+ PersistentAttribute attribute) {
addOneToOneRelation(fp, jpt, attribute, null, null,
JPAEditorConstants.RELATION_TYPE_UNIDIRECTIONAL);
}
- public void addOneToOneBidirectionalRelation (IFeatureProvider fp, JavaPersistentType jpt1,
- JavaSpecifiedPersistentAttribute attribute1, JavaPersistentType jpt2,
- JavaSpecifiedPersistentAttribute attribute2) {
-
+ public void addOneToOneBidirectionalRelation (IFeatureProvider fp, PersistentType jpt1,
+ PersistentAttribute attribute1, PersistentType jpt2,
+ PersistentAttribute attribute2) {
addOneToOneRelation(fp, jpt1, attribute1, jpt2, attribute2,
JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL);
}
-
- public void addOneToManyUnidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt,
- JavaSpecifiedPersistentAttribute attribute, boolean isMap) {
-
+
+ public void addOneToManyUnidirectionalRelation(IFeatureProvider fp, PersistentType jpt,
+ PersistentAttribute attribute, boolean isMap) {
addOneToManyRelation(fp, jpt, attribute, null, null,
JPAEditorConstants.RELATION_TYPE_UNIDIRECTIONAL, isMap);
}
- public void addOneToManyBidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt1,
- JavaSpecifiedPersistentAttribute attribute1, JavaPersistentType jpt2,
- JavaSpecifiedPersistentAttribute attribute2, boolean isMap) {
-
+ public void addOneToManyBidirectionalRelation(IFeatureProvider fp, PersistentType jpt1,
+ PersistentAttribute attribute1, PersistentType jpt2,
+ PersistentAttribute attribute2, boolean isMap) {
addOneToManyRelation(fp, jpt1, attribute1, jpt2, attribute2,
JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL, isMap);
}
-
- public void addManyToOneBidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt1,
- JavaSpecifiedPersistentAttribute attribute1, JavaPersistentType jpt2,
- JavaSpecifiedPersistentAttribute attribute2, boolean isMap) {
+
+ public void addManyToOneBidirectionalRelation(IFeatureProvider fp, PersistentType jpt1,
+ PersistentAttribute attribute1, PersistentType jpt2,
+ PersistentAttribute attribute2, boolean isMap) {
addManyToOneRelation(fp, jpt1, attribute1, jpt2, attribute2,
JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL, isMap);
}
public void addOneToOneRelation(IFeatureProvider fp,
- JavaPersistentType ownerJPT, JavaSpecifiedPersistentAttribute ownerAttibute,
- JavaPersistentType referencedJPT,
- JavaSpecifiedPersistentAttribute referencedAttribute, int direction) {
+ PersistentType ownerJPT, PersistentAttribute ownerAttibute,
+ PersistentType referencedJPT,
+ PersistentAttribute referencedAttribute, int direction) {
setMappingKeyToAttribute(fp, ownerJPT, ownerAttibute, MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
if (direction == JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL) {
- JavaSpecifiedPersistentAttribute resolvedAttribute = setMappingKeyToAttribute(fp, referencedJPT, referencedAttribute, MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
+ PersistentAttribute resolvedAttribute = setMappingKeyToAttribute(fp, referencedJPT, referencedAttribute, MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY);
String mappedByAttr = getMappeByAttribute(fp, ownerJPT, ownerAttibute);
- setMappedByAnnotationAttribute(resolvedAttribute, referencedJPT, mappedByAttr);
+ setMappedByAttribute(resolvedAttribute, referencedJPT, mappedByAttr);
}
}
-
- public void addManyToOneRelation(IFeatureProvider fp, JavaPersistentType manySideJPT,
- JavaSpecifiedPersistentAttribute manySideAttribute, JavaPersistentType singleSideJPT,
- JavaSpecifiedPersistentAttribute singleSideAttibute, int direction, boolean isMap) {
+
+ public void addManyToOneRelation(IFeatureProvider fp, PersistentType manySideJPT,
+ PersistentAttribute manySideAttribute, PersistentType singleSideJPT,
+ PersistentAttribute singleSideAttibute, int direction, boolean isMap) {
setMappingKeyToAttribute(fp, manySideJPT, manySideAttribute, MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
if (direction == JPAEditorConstants.RELATION_TYPE_UNIDIRECTIONAL)
return;
-
- JavaSpecifiedPersistentAttribute resolvedSingleSideAttribute = setMappingKeyToAttribute(fp, singleSideJPT, singleSideAttibute, MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+
+ PersistentAttribute resolvedSingleSideAttribute = setMappingKeyToAttribute(fp, singleSideJPT, singleSideAttibute, MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
String mappedByAttr = getMappeByAttribute(fp, manySideJPT, manySideAttribute);
- setMappedByAnnotationAttribute(resolvedSingleSideAttribute, singleSideJPT, mappedByAttr);
+ setMappedByAttribute(resolvedSingleSideAttribute, singleSideJPT, mappedByAttr);
if (isMap) {
- singleSideAttibute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ if(getORMPersistentAttribute(singleSideAttibute) == null) {
+ singleSideAttibute.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
}
-
}
-
- public void addOneToManyRelation(IFeatureProvider fp, JavaPersistentType singleSideJPT,
- JavaSpecifiedPersistentAttribute singleSideAttibute,
- JavaPersistentType manySideJPT,
- JavaSpecifiedPersistentAttribute manySideAttribute, int direction, boolean isMap) {
-
- JavaSpecifiedPersistentAttribute resolvedSingleSideAttribute = setMappingKeyToAttribute(fp, singleSideJPT, singleSideAttibute, MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+
+ public void addOneToManyRelation(IFeatureProvider fp, PersistentType singleSideJPT,
+ PersistentAttribute singleSideAttibute,
+ PersistentType manySideJPT,
+ PersistentAttribute manySideAttribute, int direction, boolean isMap) {
+
+ PersistentAttribute resolvedSingleSideAttribute = setMappingKeyToAttribute(fp, singleSideJPT, singleSideAttibute, MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY);
if (direction == JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL) {
setMappingKeyToAttribute(fp, manySideJPT, manySideAttribute, MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY);
String mappedByAttr = getMappeByAttribute(fp, manySideJPT, manySideAttribute);
- setMappedByAnnotationAttribute(resolvedSingleSideAttribute, singleSideJPT, mappedByAttr);
+ setMappedByAttribute(resolvedSingleSideAttribute, singleSideJPT, mappedByAttr);
} else {
addJoinColumnIfNecessary(resolvedSingleSideAttribute, singleSideJPT);
}
- if (isMap)
- singleSideAttibute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ if (isMap) {
+ if(getORMPersistentAttribute(singleSideAttibute) == null) {
+ singleSideAttibute.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
+ }
}
private String getMappeByAttribute(IFeatureProvider fp,
- JavaPersistentType ownerSideJPT, JavaSpecifiedPersistentAttribute ownerSideAttribute) {
-
+ PersistentType ownerSideJPT, PersistentAttribute ownerSideAttribute) {
String mappedByAttr = ownerSideAttribute.getName();
- if(hasEmbeddableAnnotation(ownerSideJPT)){
+ if(isEmbeddable(ownerSideJPT)){
HasReferanceRelation ref = JpaArtifactFactory.INSTANCE.findFisrtHasReferenceRelationByEmbeddable(ownerSideJPT, (IJPAEditorFeatureProvider)fp);
if(ref != null){
- JavaSpecifiedPersistentAttribute embeddingAttribute = ref.getEmbeddedAnnotatedAttribute();
+ PersistentAttribute embeddingAttribute = ref.getEmbeddedAnnotatedAttribute();
mappedByAttr = embeddingAttribute.getName() + "." + ownerSideAttribute.getName(); //$NON-NLS-1$
}
}
return mappedByAttr;
}
-
- private void setMappedByAnnotationAttribute(JavaSpecifiedPersistentAttribute resolvedAttr, JavaPersistentType type1, String jpaName){
- JavaAttributeMapping mapping = resolvedAttr.getMapping();
- if (!(mapping instanceof RelationshipMapping)) {
- resolvedAttr.getResourceAttribute().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ private void setMappedByAttribute(PersistentAttribute resolvedAttr, PersistentType type1, String jpaName){
+ setMappedByRelationAttribute(resolvedAttr, jpaName);
+ PersistentAttribute ormAttribute = getORMPersistentAttribute(resolvedAttr);
+ if(ormAttribute != null){
+ setMappedByRelationAttribute(ormAttribute, jpaName);
}
- Annotation annotation = mapping.getMappingAnnotation();
- if (annotation == null) {
- resolvedAttr.getResourceAttribute().getJavaResourceCompilationUnit().synchronizeWithJavaSource();
- annotation = mapping.getMappingAnnotation();
- }
- if (!(annotation instanceof OwnableRelationshipMappingAnnotation))
+ }
+
+ private void setMappedByRelationAttribute(
+ PersistentAttribute resolvedAttr, String jpaName) {
+ AttributeMapping mapping = resolvedAttr.getMapping();
+ if(!(mapping instanceof RelationshipMapping))
return;
- ((OwnableRelationshipMappingAnnotation)annotation).setMappedBy(jpaName);
+ RelationshipMapping relationshipMappin = (RelationshipMapping) resolvedAttr.getMapping();
+ MappedByRelationship mappedByRel = (MappedByRelationship) relationshipMappin.getRelationship();
+ SpecifiedMappedByRelationshipStrategy mappedByStrategy = mappedByRel.getMappedByStrategy();
+ mappedByStrategy.setMappedByAttribute(jpaName);
}
- private JavaSpecifiedPersistentAttribute setMappingKeyToAttribute(IFeatureProvider fp, JavaPersistentType jpt, JavaSpecifiedPersistentAttribute jpa, String mappingKey){
- JavaSpecifiedPersistentAttribute resolvedManySideAttribute = (JavaSpecifiedPersistentAttribute) jpt.resolveAttribute(jpa.getName());
- resolvedManySideAttribute.setMappingKey(mappingKey);
+ private PersistentAttribute setMappingKeyToAttribute(IFeatureProvider fp, PersistentType jpt, PersistentAttribute jpa, String mappingKey){
+ PersistentAttribute resolvedManySideAttribute = jpt.resolveAttribute(jpa.getName());
+ resolvedManySideAttribute.getJavaPersistentAttribute().setMappingKey(mappingKey);
+ addOrmPersistentAttribute(jpt, jpa, mappingKey);
return resolvedManySideAttribute;
}
-
- private void addJoinColumnIfNecessary(JavaSpecifiedPersistentAttribute jpa,
- JavaPersistentType jpt) {
+
+ private void addJoinColumnIfNecessary(PersistentAttribute jpa,
+ PersistentType jpt) {
if (JPAEditorUtil.checkJPAFacetVersion(jpa.getJpaProject(), JPAEditorUtil.JPA_PROJECT_FACET_10) ||
JPADiagramPropertyPage.shouldOneToManyUnidirBeOldStyle(jpa
.getJpaProject().getProject()))
return;
- JavaSpecifiedPersistentAttribute[] ids = getIds(jpt);
+
+ PersistentAttribute[] ids = getIds(jpt);
if (ids.length == 0)
return;
+
+ SpecifiedJoinColumnRelationshipStrategy strategy = getJoinColumnStrategy(jpa);
+ if(strategy == null)
+ return;
+
final String tableName = getTableName(jpt);
+
if (ids.length == 1) {
if (isSimpleId(ids[0])) {
- JoinColumnAnnotation an = (JoinColumnAnnotation) jpa
- .getResourceAttribute().addAnnotation(0,
- JoinColumnAnnotation.ANNOTATION_NAME);
String idColName = getColumnName(ids[0]);
- an.setName(tableName + "_" + idColName); //$NON-NLS-1$
- an.setReferencedColumnName(idColName);
+ addJoinColumn(jpa, tableName, strategy, idColName);
} else {
Hashtable<String, String> atNameToColName = getOverriddenColNames(ids[0]);
PersistenceUnit pu = getPersistenceUnit(jpt);
- String embeddableTypeName = ids[0].getTypeName();
+ String embeddableTypeName = getRelTypeName(ids[0]);
Embeddable emb = pu.getEmbeddable(embeddableTypeName);
for (AttributeMapping am : emb.getAllAttributeMappings()) {
- JoinColumnAnnotation jc = (JoinColumnAnnotation) jpa.getResourceAttribute().addAnnotation(jpa.getResourceAttribute().getAnnotationsSize(JoinColumnAnnotation.ANNOTATION_NAME), JoinColumnAnnotation.ANNOTATION_NAME);
- JavaSpecifiedPersistentAttribute at = (JavaSpecifiedPersistentAttribute) am
- .getPersistentAttribute();
+ PersistentAttribute at = am.getPersistentAttribute();
String idColName = atNameToColName.get(at.getName());
- idColName = (idColName != null) ? idColName
- : getColumnName(at);
- jc.setName(tableName + "_" + idColName); //$NON-NLS-1$
- jc.setReferencedColumnName(idColName);
+ idColName = (idColName != null) ? idColName : getColumnName(at);
+ addJoinColumn(jpa, tableName, strategy, idColName);
}
}
} else {
- for (JavaSpecifiedPersistentAttribute idAt : ids) {
- JoinColumnAnnotation jc = (JoinColumnAnnotation) jpa.getResourceAttribute().addAnnotation( jpa.getResourceAttribute().getAnnotationsSize(JoinColumnAnnotation.ANNOTATION_NAME), JoinColumnAnnotation.ANNOTATION_NAME);
+ for (PersistentAttribute idAt : ids) {
String idColName = getColumnName(idAt);
- jc.setName(tableName + "_" + idColName); //$NON-NLS-1$
- jc.setReferencedColumnName(idColName);
+ addJoinColumn(jpa, tableName, strategy, idColName);
}
}
}
+
+ private SpecifiedJoinColumnRelationshipStrategy getJoinColumnStrategy(PersistentAttribute jpa){
+ AttributeMapping attributeMapping = getAttributeMapping(jpa);
+ if(attributeMapping instanceof RelationshipMapping) {
+ RelationshipStrategy strategy = ((RelationshipMapping) attributeMapping).getRelationship().getStrategy();
+ if(strategy instanceof SpecifiedJoinColumnRelationshipStrategy){
+ return (SpecifiedJoinColumnRelationshipStrategy) strategy;
+ }
+ }
+ return null;
+ }
- private Hashtable<String, String> getOverriddenColNames(
- JavaSpecifiedPersistentAttribute embIdAt) {
+ private void addJoinColumn(PersistentAttribute jpa,
+ final String tableName, SpecifiedJoinColumnRelationshipStrategy strategy,
+ String idColName) {
+ String name = tableName + "_" + idColName; //$NON-NLS-1$
+
+ SpecifiedJoinColumn joinColumn = strategy.addSpecifiedJoinColumn();
+ joinColumn.setSpecifiedName(name);
+ joinColumn.setSpecifiedReferencedColumnName(idColName);
+ }
+
+ @SuppressWarnings("unchecked")
+ private Hashtable<String, String> getOverriddenColNames(PersistentAttribute embIdAt) {
+ AttributeMapping attributeMapping = getAttributeMapping(embIdAt);
Hashtable<String, String> res = new Hashtable<String, String>();
- if(embIdAt.getResourceAttribute().getAnnotationsSize(AttributeOverrideAnnotation.ANNOTATION_NAME) > 0){
- AttributeOverrideAnnotation aon = (AttributeOverrideAnnotation) embIdAt
- .getResourceAttribute().getAnnotation(0,
- AttributeOverrideAnnotation.ANNOTATION_NAME);
- if (aon != null) {
- ColumnAnnotation colAn = aon.getColumn();
- if (colAn == null)
- return res;
- String colName = colAn.getName();
- if (colName == null)
- return res;
- res.put(aon.getName(), colName);
- return res;
- }
- }
- Iterable<AttributeOverrideAnnotation> it = new SubListIterableWrapper<NestableAnnotation, AttributeOverrideAnnotation>(
- embIdAt.getResourceAttribute().getAnnotations(AttributeOverrideAnnotation.ANNOTATION_NAME));
- for (AttributeOverrideAnnotation an : it) {
- ColumnAnnotation colAn = an.getColumn();
- if (colAn == null)
- continue;
- String colName = colAn.getName();
- if (colName == null)
- continue;
- res.put(an.getName(), colName);
- }
+ if(attributeMapping instanceof EmbeddedIdMapping){
+ AttributeOverrideContainer attributeOverrideContainer = ((EmbeddedIdMapping)attributeMapping).getAttributeOverrideContainer();
+ if(attributeOverrideContainer.getSpecifiedOverridesSize() > 0) {
+ Iterator<AttributeOverride> overridenAttributesIterator = (Iterator<AttributeOverride>) attributeOverrideContainer.getSpecifiedOverrides().iterator();
+ while(overridenAttributesIterator.hasNext()){
+ AttributeOverride attributeOverride = overridenAttributesIterator.next();
+ res.put(attributeOverride.getName(), attributeOverride.getColumn().getName());
+ }
+ }
+ }
return res;
- }
-
-
- public void addManyToOneUnidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt,
- JavaSpecifiedPersistentAttribute attribute) {
+ }
+
+ public void addManyToOneUnidirectionalRelation(IFeatureProvider fp, PersistentType jpt,
+ PersistentAttribute attribute) {
addManyToOneRelation(fp, jpt, attribute, null, null,
JPAEditorConstants.RELATION_TYPE_UNIDIRECTIONAL, false);
}
-
- public void addManyToManyBidirectionalRelation(IFeatureProvider fp, JavaPersistentType jpt1,
- JavaSpecifiedPersistentAttribute attribute1, JavaPersistentType jpt2,
- JavaSpecifiedPersistentAttribute attribute2, boolean isMap) {
+ public void addManyToManyBidirectionalRelation(IFeatureProvider fp, PersistentType jpt1,
+ PersistentAttribute attribute1, PersistentType jpt2,
+ PersistentAttribute attribute2, boolean isMap) {
addManyToManyRelation(fp, jpt1, attribute1, jpt2, attribute2,
JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL, isMap);
}
-
- public void addManyToManyUnidirectionalRelation(IFeatureProvider fp, JavaPersistentType annotatedJPT,
- JavaSpecifiedPersistentAttribute annotatedAttribute, boolean isMap) {
+
+ public void addManyToManyUnidirectionalRelation(IFeatureProvider fp, PersistentType annotatedJPT,
+ PersistentAttribute annotatedAttribute, boolean isMap) {
addManyToManyRelation(fp, annotatedJPT, annotatedAttribute, null, null,
JPAEditorConstants.RELATION_TYPE_UNIDIRECTIONAL, isMap);
}
-
- public void addManyToManyRelation(IFeatureProvider fp, JavaPersistentType ownerSideJPT,
- JavaSpecifiedPersistentAttribute ownerSideAttribute,
- JavaPersistentType inverseSideJPT,
- JavaSpecifiedPersistentAttribute inverseSideAttibute, int direction, boolean isMap) {
-
- JavaSpecifiedPersistentAttribute resolvedOwnerSideAttribute = setMappingKeyToAttribute(fp, ownerSideJPT, ownerSideAttribute, MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
- if (isMap)
- resolvedOwnerSideAttribute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
-
+
+ public void addManyToManyRelation(IFeatureProvider fp, PersistentType ownerSideJPT,
+ PersistentAttribute ownerSideAttribute,
+ PersistentType inverseSideJPT,
+ PersistentAttribute inverseSideAttibute, int direction, boolean isMap) {
+
+ PersistentAttribute resolvedOwnerSideAttribute = setMappingKeyToAttribute(fp, ownerSideJPT, ownerSideAttribute, MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ if (isMap) {
+ if(getORMPersistentAttribute(resolvedOwnerSideAttribute) == null) {
+ resolvedOwnerSideAttribute.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
+ }
if (direction == JPAEditorConstants.RELATION_TYPE_BIDIRECTIONAL) {
- JavaSpecifiedPersistentAttribute resolvedInverseSideAttribute = setMappingKeyToAttribute(fp, inverseSideJPT, inverseSideAttibute, MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
+ PersistentAttribute resolvedInverseSideAttribute = setMappingKeyToAttribute(fp, inverseSideJPT, inverseSideAttibute, MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY);
String mappedByAttr = getMappeByAttribute(fp, ownerSideJPT, ownerSideAttribute);
- setMappedByAnnotationAttribute(resolvedInverseSideAttribute, inverseSideJPT, mappedByAttr);
+ setMappedByAttribute(resolvedInverseSideAttribute, inverseSideJPT, mappedByAttr);
- if (isMap)
- resolvedInverseSideAttribute.getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
+ if (isMap) {
+ if(getORMPersistentAttribute(resolvedInverseSideAttribute) == null) {
+ resolvedInverseSideAttribute.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
+ }
+ }
+ }
}
- public void restoreEntityClass(JavaPersistentType jpt, IJPAEditorFeatureProvider fp) {
+ public void restoreEntityClass(PersistentType jpt, IJPAEditorFeatureProvider fp) {
fp.restoreEntity(jpt);
}
- public void forceSaveEntityClass(final JavaPersistentType jpt,
+ public void forceSaveEntityClass(final PersistentType jpt,
IJPAEditorFeatureProvider fp) {
final ICompilationUnit cu = fp.getCompilationUnit(jpt);
Display.getDefault().syncExec(new Runnable() {
@@ -443,7 +466,7 @@ public class JpaArtifactFactory {
});
}
- public boolean deleteEntityClass(JavaPersistentType jpt,
+ public boolean deleteEntityClass(PersistentType jpt,
IJPAEditorFeatureProvider fp) {
ICompilationUnit cu = fp.getCompilationUnit(jpt);
try {
@@ -464,7 +487,7 @@ public class JpaArtifactFactory {
//type.dispose();
entityResource.delete(true, new NullProgressMonitor());
int cnt = 0;
- JavaPersistentType jpt = getContextPersistentType(proj, typeName);
+ PersistentType jpt = getContextPersistentType(proj, typeName);
while ((jpt != null) && (cnt < MAX_NUM_OF_ITERATIONS)) {
try {
Thread.sleep(PAUSE_DURATION);
@@ -475,17 +498,17 @@ public class JpaArtifactFactory {
}
}
- public JavaPersistentType getContextPersistentType(JpaProject jpaProject,
+ public PersistentType getContextPersistentType(JpaProject jpaProject,
String fullyQualifiedTypeName) {
-
PersistenceUnit unit = getPersistenceUnit(jpaProject);
for (ClassRef ref : unit.getClassRefs()) {
- JavaPersistentType jpt = ref.getJavaPersistentType();
- if ((jpt != null) && jpt.getName().equals(fullyQualifiedTypeName)) {
+ PersistentType jpt = ref.getJavaPersistentType();
+ if ((jpt != null) && jpt.getName().equals(fullyQualifiedTypeName) ) {
return ref.getJavaPersistentType();
}
- }
- return null;
+ }
+
+ return getOrmXmlPersistentTypeByName(jpaProject, fullyQualifiedTypeName);
}
/*
@@ -493,33 +516,30 @@ public class JpaArtifactFactory {
* If there is no such annotation, returns the
* fully qualified name of the class
*/
- public String getEntityName(JavaPersistentType jpt) {
+ public String getEntityName(PersistentType jpt) {
if (jpt == null)
return ""; //$NON-NLS-1$
- JavaResourceType jrpt = convertJPTToJRT(jpt);
+ JavaResourceType jrpt = jpt.getJavaResourceType();
if (jrpt == null)
return ""; //$NON-NLS-1$
String name = null;
- JavaTypeMapping mapping = jpt.getMapping();
- if ((mapping != null) && JavaEntity.class.isInstance(mapping))
- name = ((JavaEntity)mapping).getSpecifiedName();
+ TypeMapping mapping = jpt.getMapping();
+ if ((mapping != null) && Entity.class.isInstance(mapping))
+ name = ((Entity)mapping).getSpecifiedName();
if (name == null)
name = jpt.getName();
return name;
}
- public boolean hasNameAnnotation(JavaPersistentType jpt) {
+ public boolean hasEntitySpecifiedName(PersistentType jpt) {
if (jpt == null)
return false;
- JavaResourceType jrpt = convertJPTToJRT(jpt);
- if (jrpt == null)
- return false;
- JavaTypeMapping jtm = jpt.getMapping();
+ TypeMapping jtm = getTypeMapping(jpt);
if (jtm == null)
return false;
- if (jtm instanceof JavaEntity) {
- JavaEntity mapping = (JavaEntity)jtm;
+ if (jtm instanceof Entity) {
+ Entity mapping = (Entity)jtm;
return (mapping.getSpecifiedName() != null);
}
return false;
@@ -531,8 +551,8 @@ public class JpaArtifactFactory {
* @param jpt
* @return true, if the given jpt is annotated, false otherwise.
*/
- public boolean hasAnyAnnotationType(JavaPersistentType jpt) {
- return hasEntityAnnotation(jpt) || hasMappedSuperclassAnnotation(jpt) || hasEmbeddableAnnotation(jpt);
+ public boolean isAnyKindPersistentType(PersistentType jpt) {
+ return isEntity(jpt) || isMappedSuperclass(jpt) || isEmbeddable(jpt);
}
/**
@@ -540,8 +560,9 @@ public class JpaArtifactFactory {
* @param jpt
* @return true, if the given jpt is an entity, false otherwise
*/
- public boolean hasEntityAnnotation(JavaPersistentType jpt) {
- return (jpt.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY);
+ public boolean isEntity(PersistentType jpt) {
+ String mappingKey = getTypeMapping(jpt).getKey();
+ return (mappingKey == MappingKeys.ENTITY_TYPE_MAPPING_KEY);
}
/**
@@ -549,8 +570,9 @@ public class JpaArtifactFactory {
* @param jpt
* @return true, if the given jpt is a mapped superclass, false, otherwise.
*/
- public boolean hasMappedSuperclassAnnotation(JavaPersistentType jpt) {
- return (jpt.getMappingKey() == MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
+ public boolean isMappedSuperclass(PersistentType jpt) {
+ String mappingKey = getTypeMapping(jpt).getKey();
+ return (mappingKey == MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY);
}
/**
@@ -558,27 +580,59 @@ public class JpaArtifactFactory {
* @param jpt
* @return true, if the given jpt is an embeddable class, false otherwise.
*/
- public boolean hasEmbeddableAnnotation(JavaPersistentType jpt){
- return (jpt.getMappingKey() == MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
+ public boolean isEmbeddable(PersistentType jpt){
+ String mappingKey = getTypeMapping(jpt).getKey();
+ return (mappingKey == MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY);
}
- public String getSpecifiedEntityName(JavaPersistentType jpt){
- JavaTypeMapping jtm = jpt.getMapping();
- if (jtm instanceof JavaEntity) {
- JavaEntity gje = (JavaEntity) jtm;
+ public String getSpecifiedEntityName(PersistentType jpt){
+ TypeMapping jtm = getTypeMapping(jpt);
+ if (jtm instanceof Entity) {
+ Entity gje = (Entity) jtm;
return gje.getSpecifiedName();
}
return jtm.getName();
}
- public void renameEntity(JavaPersistentType jpt, String newName) {
- JavaTypeMapping jtm = jpt.getMapping();
- if (jtm instanceof JavaEntity) {
- JavaEntity gje = (JavaEntity) jtm;
+ public void renameEntity(PersistentType jpt, String newName) {
+ TypeMapping jtm = getTypeMapping(jpt);
+ if (jtm instanceof Entity) {
+ Entity gje = (Entity) jtm;
gje.setSpecifiedName(newName);
}
}
+ public MappingFileRef getOrmXmlByForPersistentType(PersistentType type){
+ for(MappingFileRef mappingFileRef : type.getPersistenceUnit().getMappingFileRefs()){
+ if(mappingFileRef.getPersistentType(type.getName()) != null){
+ return mappingFileRef;
+ }
+ }
+ return null;
+ }
+
+ public PersistentType getOrmXmlPersistentTypeByName(JpaProject jpaProject, String fqnTypeName){
+ for(MappingFileRef mappingFileRef : getPersistenceUnit(jpaProject).getMappingFileRefs()){
+ PersistentType type = mappingFileRef.getPersistentType(fqnTypeName);
+ if(type != null){
+ return type;
+ }
+ }
+ return null;
+ }
+
+ public PersistentAttribute getORMPersistentAttribute(PersistentAttribute jpa){
+ PersistentType type = getOrmXmlPersistentTypeByName(jpa.getParent().getJpaProject(), jpa.getDeclaringPersistentType().getName());
+ if(type == null)
+ return null;
+ for(PersistentAttribute attr : type.getAllAttributes()){
+ if(attr.getName() != null && attr.getName().equals(jpa.getName()))
+ return attr;
+ }
+
+ return null;
+ }
+
/**
* Find the first {@link HasReferenceRelation} for the given embeddable class from all existing
* {@link HasReferanceRelation} in the diagram.
@@ -586,10 +640,10 @@ public class JpaArtifactFactory {
* @param fp
* @return the first {@link HasReferenceRelation} for the given embeddable class.
*/
- public HasReferanceRelation findFisrtHasReferenceRelationByEmbeddable(JavaPersistentType embeddable, IJPAEditorFeatureProvider fp){
+ public HasReferanceRelation findFisrtHasReferenceRelationByEmbeddable(PersistentType embeddable, IJPAEditorFeatureProvider fp){
HashSet<HasReferanceRelation> hasReferencesConnections = fp.getAllExistingHasReferenceRelations();
for(HasReferanceRelation ref : hasReferencesConnections){
- if (ref.getEmbeddable().equals(embeddable) && hasEntityAnnotation(ref.getEmbeddingEntity())){
+ if (ref.getEmbeddable().getName().equals(embeddable.getName()) && isEntity(ref.getEmbeddingEntity())){
return ref;
}
}
@@ -604,17 +658,17 @@ public class JpaArtifactFactory {
* @return a collection of all java persistent types, that have an embedded id attribute of
* the given embeddable type.
*/
- public HashSet<JavaPersistentType> findAllJPTWithTheGivenEmbeddedId(JavaPersistentType embeddable, IJPAEditorFeatureProvider fp){
- HashSet<JavaPersistentType> embeddingEntities = new HashSet<JavaPersistentType>();
- if(!hasEmbeddableAnnotation(embeddable))
+ public HashSet<PersistentType> findAllJPTWithTheGivenEmbeddedId(PersistentType embeddable, IJPAEditorFeatureProvider fp){
+ HashSet<PersistentType> embeddingEntities = new HashSet<PersistentType>();
+ if(!isEmbeddable(embeddable))
return embeddingEntities;
ListIterator<PersistenceUnit> lit = embeddable.getJpaProject().getContextModelRoot().getPersistenceXml().getRoot().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
for(PersistentType jpt : pu.getPersistentTypes()){
- if(!jpt.equals(embeddable)){
- for(JavaSpecifiedPersistentAttribute jpa : ((JavaPersistentType)jpt).getAttributes()){
+ if(!jpt.getName().equals(embeddable.getName())){
+ for(PersistentAttribute jpa : (jpt).getAttributes()){
if(isEmbeddedId(jpa) && JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa).equals(embeddable.getName())){
- embeddingEntities.add((JavaPersistentType) jpt);
+ embeddingEntities.add(jpt);
}
}
}
@@ -629,22 +683,22 @@ public class JpaArtifactFactory {
* @param fp
* @return the first {@link HasReferenceRelation} for the given embeddable class.
*/
- public Set<HasReferanceRelation> findAllHasReferenceRelationsByEmbeddable(JavaPersistentType embeddable, IJPAEditorFeatureProvider fp){
+ public Set<HasReferanceRelation> findAllHasReferenceRelationsByEmbeddable(PersistentType embeddable, IJPAEditorFeatureProvider fp){
HashSet<HasReferanceRelation> allHasRefForEmbeddable = new HashSet<HasReferanceRelation>();
HashSet<HasReferanceRelation> hasReferencesConnections = fp.getAllExistingHasReferenceRelations();
for(HasReferanceRelation ref : hasReferencesConnections){
- if (ref.getEmbeddable().equals(embeddable) || ref.getEmbeddingEntity().equals(embeddable)){
+ if (ref.getEmbeddable().getName().equals(embeddable.getName()) || ref.getEmbeddingEntity().getName().equals(embeddable.getName())){
allHasRefForEmbeddable.add(ref);
}
}
return allHasRefForEmbeddable;
}
- public Set<HasReferanceRelation> findAllHasReferenceRelsByEmbeddableWithEntity(JavaPersistentType embeddable, IJPAEditorFeatureProvider fp){
+ public Set<HasReferanceRelation> findAllHasReferenceRelsByEmbeddableWithEntity(PersistentType embeddable, IJPAEditorFeatureProvider fp){
Set<HasReferanceRelation> allRefs = findAllHasReferenceRelationsByEmbeddable(embeddable, fp);
Set<HasReferanceRelation> entityRefs = new HashSet<HasReferanceRelation>();
for(HasReferanceRelation ref : allRefs){
- if(hasEntityAnnotation(ref.getEmbeddingEntity())){
+ if(isEntity(ref.getEmbeddingEntity())){
entityRefs.add(ref);
}
}
@@ -655,92 +709,48 @@ public class JpaArtifactFactory {
/**
* Create a relationship attribute.
* @param fp
- * @param jpt - the referencing {@link JavaPersistentType}
- * @param attributeType - the referenced {@link JavaPersistentType}
+ * @param jpt - the referencing {@link PersistentType}
+ * @param attributeType - the referenced {@link PersistentType}
* @param mapKeyType
* @param attributeName - the name of the attribute
* @param actName - the actual name of the attribute
* @param isCollection - whether the attribute is of a collection type
- * @param cu - the {@link ICompilationUnit} of the referencing {@link JavaPersistentType}
+ * @param cu - the {@link ICompilationUnit} of the referencing {@link PersistentType}
* @return the newly created relationship attribute.
*/
- public JavaSpecifiedPersistentAttribute addAttribute(IJPAEditorFeatureProvider fp, JavaPersistentType jpt,
- JavaPersistentType attributeType, String mapKeyType, String attributeName,
+ public PersistentAttribute addAttribute(IJPAEditorFeatureProvider fp, PersistentType jpt,
+ PersistentType attributeType, String mapKeyType, String attributeName,
String actName, boolean isCollection, ICompilationUnit cu) {
try {
if (doesAttributeExist(jpt, actName)) {
- return (JavaSpecifiedPersistentAttribute) jpt.resolveAttribute(attributeName);
+ return jpt.resolveAttribute(attributeName);
}
} catch (JavaModelException e) {
JPADiagramEditorPlugin.logError("Cannnot create a new attribute with name " + attributeName, e); //$NON-NLS-1$
}
-
- JavaSpecifiedPersistentAttribute res = makeNewAttribute(fp, jpt, cu, attributeName, attributeType.getName(), actName, mapKeyType, null, null, isCollection);
-
+ PersistentAttribute res = makeNewAttribute(fp, jpt, cu, attributeName, attributeType.getName(), actName, mapKeyType, null, null, isCollection);
return res;
}
- /**
- * Checks whether an entity's attribute is of a collection type
- * @param entityShape - the pictogram element for the entity in the diagram
- * @param fp
- * @param attrTxt - the attribute name
- * @return true, if the entity's attribute is of a collection type, false otherwise.
- */
- public boolean isCollection(ContainerShape entityShape,
- IJPAEditorFeatureProvider fp, String attrTxt) {
- Object ob = fp.getBusinessObjectForPictogramElement(entityShape);
- if(ob instanceof JavaPersistentType){
- JavaPersistentType jpt = (JavaPersistentType) ob;
- ICompilationUnit cu = fp.getCompilationUnit(jpt);
- IType type = cu.getType(JPAEditorUtil.returnSimpleName(jpt.getName()));
- IField field = type.getField(attrTxt);
- if (field.exists()) {
- try {
- if(field.getTypeSignature().contains("List") || field.getTypeSignature().contains("Set") //$NON-NLS-1$ //$NON-NLS-2$
- || field.getTypeSignature().contains("Collection") || field.getTypeSignature().contains("Map") //$NON-NLS-1$ //$NON-NLS-2$
- || field.getTypeSignature().endsWith("[]")) //$NON-NLS-1$
- return true;
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError(JPAEditorMessages.JpaArtifactFactory_CanNotCheckReturnType +
- " " + attrTxt + "\"", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ public boolean isCollection(AttributeMapping attributeMapping) {
+ PersistentAttribute attribute = (PersistentAttribute) attributeMapping.getPersistentAttribute();
+ String attributeType = attribute.getTypeName();
+
+ if(attributeType == null) {
+ PersistentType jpt = (PersistentType) attribute.getParent();
+ jpt.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ jrt.getJavaResourceCompilationUnit().synchronizeWithJavaSource();
+ jpt.update();
+ attribute = jpt.getAttributeNamed(attribute.getName());
+ attributeType = attribute.getTypeName();
}
- return false;
- }
- /**
- * Checks whether the getter method of an entity's attribute returns a collection type.
- * @param entityShape - the pictogram element for the entity in the diagram
- * @param fp
- * @param attrTxt - the attribute name
- * @return true if the getter method of an attribute returns a collection type,
- * false otherwise.
- */
- public boolean isGetterMethodReturnTypeCollection(
- ContainerShape entityShape, IJPAEditorFeatureProvider fp,
- String attrTxt) {
- Object ob = fp.getBusinessObjectForPictogramElement(entityShape);
- if(ob instanceof JavaPersistentType){
- JavaPersistentType jpt = (JavaPersistentType) ob;
- ICompilationUnit cu = fp.getCompilationUnit(jpt);
- IType type = cu.getType(JPAEditorUtil.returnSimpleName(jpt.getName()));
- String attrNameWithCapitalLetter = attrTxt.substring(0, 1)
- .toUpperCase(Locale.ENGLISH)
- + attrTxt.substring(1);
- String methodName = "get" + attrNameWithCapitalLetter; //$NON-NLS-1$
- IMethod method = type.getMethod(methodName, new String[0]);
- try {
- if(method.getReturnType().contains("List") || method.getReturnType().contains("Set") //$NON-NLS-1$ //$NON-NLS-2$
- || method.getReturnType().contains("Collection") || method.getReturnType().contains("Map") //$NON-NLS-1$ //$NON-NLS-2$
- || method.getReturnType().endsWith("[]")) //$NON-NLS-1$
- return true;
- } catch (JavaModelException e) {
- JPADiagramEditorPlugin.logError(JPAEditorMessages.JpaArtifactFactory_CanNotCheckReturnType +
- " " + attrTxt + "\"", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ if(attributeType != null && (attributeType.equals(JPAEditorConstants.COLLECTION_TYPE) || attributeType.equals(JPAEditorConstants.LIST_TYPE)
+ || attributeType.equals(JPAEditorConstants.SET_TYPE) || attributeType.equals(JPAEditorConstants.MAP_TYPE)
+ || attributeType.endsWith("[]"))) { //$NON-NLS-1$
+ return true;
}
return false;
}
@@ -752,17 +762,15 @@ public class JpaArtifactFactory {
* @param fp
* @return the newly created attribute.
*/
- public String createNewAttribute(JavaPersistentType jpt,
+ public String createNewAttribute(PersistentType jpt,
boolean isCollection, IJPAEditorFeatureProvider fp) {
-
- String attrTypeName = "java.lang.String"; //$NON-NLS-1$
- String newAttrName = genUniqueAttrName(jpt, attrTypeName, fp);
+
+ String newAttrName = genUniqueAttrName(jpt, JPAEditorConstants.STRING_TYPE, fp);
ICompilationUnit cu = fp.getCompilationUnit(jpt);
- makeNewAttribute(fp, jpt, cu, newAttrName, attrTypeName, newAttrName, attrTypeName, null, null, isCollection);
+ makeNewAttribute(fp, jpt, cu, newAttrName, JPAEditorConstants.STRING_TYPE, newAttrName, JPAEditorConstants.STRING_TYPE, null, null, isCollection);
return newAttrName;
}
-
- public JavaSpecifiedPersistentAttribute makeNewAttribute(IJPAEditorFeatureProvider fp, JavaPersistentType jpt, ICompilationUnit cu, String attrName, String attrTypeName,
+ public PersistentAttribute makeNewAttribute(IJPAEditorFeatureProvider fp, PersistentType jpt, ICompilationUnit cu, String attrName, String attrTypeName,
String actName, String mapKeyType, String[] attrTypes, List<String> annotations, boolean isCollection) {
if(cu == null){
@@ -775,13 +783,38 @@ public class JpaArtifactFactory {
} catch (InterruptedException e) {
JPADiagramEditorPlugin.logError("Cannot create a new attribute with name " + attrName, e); //$NON-NLS-1$
}
-
- JavaSpecifiedPersistentAttribute jpa = jpt.getAttributeNamed(attrName);
+ PersistentAttribute jpa = jpt.getAttributeNamed(attrName);
if(jpa == null){
jpa = jpt.getAttributeNamed(actName);
}
return jpa;
}
+
+ public void addOrmPersistentAttribute(PersistentType jpt, PersistentAttribute jpa, String mappingKey){
+ MappingFileRef ormXml = getOrmXmlByForPersistentType(jpt);
+ if(ormXml != null && ormXml.getMappingFile() != null) {
+ OrmPersistentType ormPersistentType = (OrmPersistentType)ormXml.getMappingFile().getPersistentType(jpt.getName());
+ if(ormPersistentType == null)
+ return;
+ if(mappingKey != null) {
+ ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed(jpa.getName()), mappingKey);
+ } else {
+ if(ormPersistentType.getAttributeNamed(jpa.getName()) != null){
+ ormPersistentType.addAttributeToXml(ormPersistentType.getAttributeNamed(jpa.getName()), jpa.getMappingKey());
+ }
+ }
+ }
+ }
+
+ public void removeOrmPersistentAttribute(PersistentType jpt, String attributeName){
+ MappingFileRef ormXml = JpaArtifactFactory.instance().getOrmXmlByForPersistentType(jpt);
+ if(ormXml != null && ormXml.getMappingFile() != null) {
+ OrmPersistentType ormPersistentType = (OrmPersistentType)ormXml.getMappingFile().getPersistentType(jpt.getName());
+ OrmPersistentAttribute ormReadOnlyAttribute = ormPersistentType.getAttributeNamed(attributeName);
+ if(ormReadOnlyAttribute instanceof OrmSpecifiedPersistentAttribute)
+ ormPersistentType.removeAttributeFromXml((OrmSpecifiedPersistentAttribute) ormReadOnlyAttribute);
+ }
+ }
/**
* Delete an attribute from the entity.
@@ -789,8 +822,9 @@ public class JpaArtifactFactory {
* @param attributeName - the name of the attribute to be deleted
* @param fp
*/
- public void deleteAttribute(JavaPersistentType jpt, String attributeName,
+ public void deleteAttribute(PersistentType jpt, String attributeName,
IJPAEditorFeatureProvider fp) {
+
synchronized (jpt) {
Command deleteAttributeCommand = new DeleteAttributeCommand(null, jpt, attributeName, fp);
try {
@@ -808,7 +842,7 @@ public class JpaArtifactFactory {
* @param fp
* @return an unique attribute name.
*/
- public String genUniqueAttrName(JavaPersistentType jpt,
+ public String genUniqueAttrName(PersistentType jpt,
String attrTypeName, IJPAEditorFeatureProvider fp) {
ICompilationUnit ijl = fp.getCompilationUnit(jpt);
@@ -848,38 +882,57 @@ public class JpaArtifactFactory {
}
return name;
}
-
+
/**
- * Get all annotation for the given attribute.
- * @param persistentAttribite
- * @return an array of all current annotations of the given attribute.
+ * Gets the PersistentAttribute mapping. By priority, first, is trying to be gotten the orm xml defined mapping.
+ * If the PersistentAttribute is not added in any orm.xml, then the JavaPersistentAttribute mapping is returned.
+ * @param pa - the persistent attribute
+ * @return the persistent attribute mapping
*/
- public Annotation[] getAnnotations(JavaSpecifiedPersistentAttribute persistentAttribite) {
- JavaResourceAttribute jrpt = persistentAttribite.getResourceAttribute();
- Annotation[] res = new Annotation[jrpt.getAnnotationsSize()];
- int c = 0;
- for (Annotation annotation : jrpt.getAnnotations()) {
- res[c] = annotation;
- c++;
+ public AttributeMapping getAttributeMapping(PersistentAttribute pa) {
+ AttributeMapping mapping = null;
+ if (pa != null) {
+ PersistentType jpt = (PersistentType) pa.getParent();
+ MappingFileRef ref = getOrmXmlByForPersistentType(jpt);
+ if (ref != null) {
+ PersistentAttribute rpa = ref.getPersistentType(jpt.getName())
+ .getAttributeNamed(pa.getName());
+ if(rpa != null) {
+ mapping = rpa.getMapping();
+ } else {
+ mapping = pa.getMapping();
+ }
+ } else {
+ mapping = pa.getMapping();
+ }
}
- return res;
- }
+ return mapping;
+ }
/**
- * Get all annotations as string for the given attribute.
- * @param persistentAttribite
- * @return a set of strings of all current annotation names of the given attribute.
+ * Gets the PersistentType mapping. By priority, first, is trying to be gotten the orm xml defined mapping.
+ * If the PersistentType is not added in any orm.xml, then the JavaPersistentType mapping is returned.
+ * @param jpt - the persistent type
+ * @return the persistent type mapping
*/
- public HashSet<String> getAnnotationNames(JavaSpecifiedPersistentAttribute persistentAttribite) {
- HashSet<String> res = new HashSet<String>();
- if(persistentAttribite != null) {
- JavaResourceAttribute jrpt = persistentAttribite.getResourceAttribute();
- for (Annotation annotation : jrpt.getAnnotations()) {
- res.add(JPAEditorUtil.returnSimpleName(annotation.getAnnotationName()));
+ public TypeMapping getTypeMapping(PersistentType jpt) {
+ TypeMapping typeMapping = null;
+ if(jpt != null){
+ MappingFileRef ref = getOrmXmlByForPersistentType(jpt);
+ if (ref != null) {
+ PersistentType pt = ref.getPersistentType(jpt.getName());
+ if(pt != null) {
+ typeMapping = pt.getMapping();
+ } else {
+ typeMapping = jpt.getMapping();
+ }
+ } else {
+ typeMapping = jpt.getMapping();
}
}
- return res;
- }
+
+ return typeMapping;
+ }
/**
* Get all annotations as string for the given attribute.
@@ -887,11 +940,12 @@ public class JpaArtifactFactory {
* @return a list of strings of all current annotation names of the given attribute.
*/
public List<String> getAnnotationStrings(
- JavaSpecifiedPersistentAttribute persistentAttribite) {
+ PersistentAttribute persistentAttribite) {
- JavaPersistentType jpt = (JavaPersistentType)persistentAttribite.getParent();
- CompilationUnit jdtCU = jpt.getJavaResourceType().getJavaResourceCompilationUnit().buildASTRoot();
- JavaResourceAttribute jrpt = persistentAttribite.getResourceAttribute();
+ PersistentType jpt = (PersistentType) persistentAttribite.getParent();
+ JavaResourceType jrt = jpt.getJavaResourceType();
+ CompilationUnit jdtCU = jrt.getJavaResourceCompilationUnit().buildASTRoot();
+ JavaResourceAttribute jrpt = persistentAttribite.getJavaPersistentAttribute().getResourceAttribute();
List<String> res = new LinkedList<String>();
for (Annotation an : jrpt.getTopLevelAnnotations()) {
org.eclipse.jdt.core.dom.Annotation jdtAn = an.getAstAnnotation(jdtCU);
@@ -905,26 +959,25 @@ public class JpaArtifactFactory {
* @param at
* @return true, if the attribute is owner of the relationship, false otherwise.
*/
- private boolean isNonOwner(JavaSpecifiedPersistentAttribute at) {
- JavaAttributeMapping jam = at.getMapping();
- if (!(jam.getMappingAnnotation() instanceof OwnableRelationshipMappingAnnotation))
+ private boolean isOwner(PersistentAttribute at) {
+ AttributeMapping jam = getAttributeMapping(at);
+ if (!(jam instanceof RelationshipMapping))
return false;
- OwnableRelationshipMappingAnnotation nom = (OwnableRelationshipMappingAnnotation)jam.getMappingAnnotation();
- return nom.getMappedBy() != null;
+ return ((RelationshipMapping)jam).isRelationshipOwner();
}
/**
- * Collect all relationships for the given {@link JavaPersistentType}.
+ * Collect all relationships for the given {@link PersistentType}.
* @param newJPT
* @param fp
- * @return an collection of all relationships for the given {@link JavaPersistentType}.
+ * @return an collection of all relationships for the given {@link PersistentType}.
*/
private Collection<IRelation> produceAllIRelations(
- JavaPersistentType newJPT, IJPAEditorFeatureProvider fp) {
+ PersistentType newJPT, IJPAEditorFeatureProvider fp) {
Collection<IRelation> res = produceIRelations(newJPT, null, fp);
Iterator<IRelation> it = res.iterator();
- HashSet<JavaPersistentType> checkedEntities = new HashSet<JavaPersistentType>();
+ HashSet<PersistentType> checkedEntities = new HashSet<PersistentType>();
while (it.hasNext()) {
IRelation rel = it.next();
checkedEntities.add(rel.getOwner());
@@ -935,7 +988,7 @@ public class JpaArtifactFactory {
Iterator<Shape> iter = shapes.iterator();
while (iter.hasNext()) {
Shape sh = iter.next();
- JavaPersistentType jpt = (JavaPersistentType) fp
+ PersistentType jpt = (PersistentType) fp
.getBusinessObjectForPictogramElement(sh);
if (jpt == null)
continue;
@@ -948,16 +1001,16 @@ public class JpaArtifactFactory {
}
/**
- * Collect all "has-reference" relationships for the given {@link JavaPersistentType}.
+ * Collect all "has-reference" relationships for the given {@link PersistentType}.
* @param newJPT
* @param fp
- * @return an collection of all "has-reference" relationships for the given {@link JavaPersistentType}.
+ * @return an collection of all "has-reference" relationships for the given {@link PersistentType}.
*/
- public Collection<HasReferanceRelation> produceAllEmbeddedRelations(JavaPersistentType jpt, IJPAEditorFeatureProvider fp) {
+ public Collection<HasReferanceRelation> produceAllEmbeddedRelations(PersistentType jpt, IJPAEditorFeatureProvider fp) {
Collection<HasReferanceRelation> res = produceEmbRelations(jpt, null, fp);
Iterator<HasReferanceRelation> it = res.iterator();
- HashSet<JavaPersistentType> checkedEntities = new HashSet<JavaPersistentType>();
+ HashSet<PersistentType> checkedEntities = new HashSet<PersistentType>();
while (it.hasNext()) {
HasReferanceRelation rel = it.next();
checkedEntities.add(rel.getEmbeddable());
@@ -967,7 +1020,7 @@ public class JpaArtifactFactory {
Iterator<Shape> iter = shapes.iterator();
while (iter.hasNext()) {
Shape sh = iter.next();
- JavaPersistentType embeddingEntity = (JavaPersistentType) fp.getBusinessObjectForPictogramElement(sh);
+ PersistentType embeddingEntity = (PersistentType) fp.getBusinessObjectForPictogramElement(sh);
if (embeddingEntity == null)
continue;
Collection<HasReferanceRelation> rels = produceEmbRelations(embeddingEntity, jpt, fp);
@@ -977,43 +1030,31 @@ public class JpaArtifactFactory {
}
/**
- * Collect all "has-reference" relationships for the given {@link JavaPersistentType}.
+ * Collect all "has-reference" relationships for the given {@link PersistentType}.
* @param embeddingEntity
* @param embeddable
* @param fp
- * @return an collection of all "has-reference" relationships for the given {@link JavaPersistentType}.
+ * @return an collection of all "has-reference" relationships for the given {@link PersistentType}.
*/
- private Collection<HasReferanceRelation> produceEmbRelations(JavaPersistentType embeddingEntity,
- JavaPersistentType embeddable, IJPAEditorFeatureProvider fp) {
+ private Collection<HasReferanceRelation> produceEmbRelations(PersistentType embeddingEntity,
+ PersistentType embeddable, IJPAEditorFeatureProvider fp) {
Collection<HasReferanceRelation> resSet = new HashSet<HasReferanceRelation>();
HasReferanceRelation res = null;
- for (JavaSpecifiedPersistentAttribute embeddingAttribute : embeddingEntity.getAttributes()) {
- IResource r = embeddingAttribute.getParent().getResource();
- if (!r.exists())
- throw new RuntimeException();
+ for (PersistentAttribute embeddingAttribute : embeddingEntity.getAttributes()) {
try {
- JavaResourceAttribute jrpa = embeddingAttribute.getResourceAttribute();
- Annotation[] ans = this.getAnnotations(embeddingAttribute);
- for (Annotation an : ans) {
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- if (JPAEditorConstants.ANNOTATION_EMBEDDED.equals(annotationName) ||
- JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION.equals(annotationName)
- || JPAEditorConstants.ANNOTATION_EMBEDDED_ID.equals(annotationName)) {
- String attributeTypeName = getRelTypeName(an, jrpa);
- if(embeddable != null) {
- if (!attributeTypeName.equals(embeddable.getName()))
- continue;
- }
-
- JavaPersistentType embeddableClass = findJPT(embeddingAttribute, fp, an);
- if (embeddableClass != null) {
- res = produceEmbeddedRelation(embeddingAttribute, an, embeddableClass, fp);
- if (res != null)
- resSet.add(res);
- }
+ AttributeMapping attributeMapping = getAttributeMapping(embeddingAttribute);
+ if((attributeMapping instanceof EmbeddedMapping) || (attributeMapping instanceof ElementCollectionMapping2_0) || (attributeMapping instanceof EmbeddedIdMapping)){
+ String attributeTypeName = getRelTypeName(embeddingAttribute);
+ if(embeddable != null && !(attributeTypeName.equals(embeddable.getName()))) {
+ continue;
+ }
+ PersistentType embeddableClass = findJPT(embeddingAttribute, fp, getRelTypeName(embeddingAttribute));
+ if (embeddableClass != null) {
+ res = produceEmbeddedRelation(embeddingAttribute, attributeMapping, embeddableClass, fp);
+ if (res != null)
+ resSet.add(res);
}
-
}
} catch (Exception e) {
throw new RuntimeException();
@@ -1030,50 +1071,46 @@ public class JpaArtifactFactory {
* @param fp
* @return the newly created relationship.
*/
- public IRelation produceIRelation(JavaSpecifiedPersistentAttribute persistentAttribite, JavaPersistentType jpt2,
+ public IRelation produceIRelation(PersistentAttribute persistentAttribite, PersistentType jpt2,
IJPAEditorFeatureProvider fp) {
IRelation res = null;
- Annotation[] ans = getAnnotations(persistentAttribite);
- for (Annotation an : ans) {
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) {
- if(jpt2 != null){
- JavaResourceAttribute jrpa = persistentAttribite.getResourceAttribute();
- String relTypeName = getRelTypeName(an, jrpa);
- if (!relTypeName.equals(jpt2.getName()))
- continue;
+ AttributeMapping attributeMapping = getAttributeMapping(persistentAttribite);
+ if (attributeMapping instanceof RelationshipMapping) {
+ if(jpt2 != null && !(getRelTypeName(persistentAttribite).equals(jpt2.getName()))){
+ return res;
}
- JavaPersistentType relJPT = findJPT(persistentAttribite, fp, an);
+ PersistentType relJPT = findJPT(persistentAttribite, fp, getRelTypeName(persistentAttribite));
if (relJPT != null) {
- res = produceRelation(persistentAttribite, an, relJPT, fp);
+ res = produceRelation(persistentAttribite, attributeMapping, relJPT, fp);
}
- }
}
return res;
}
/**
- * Gets the parent {@link JavaPersistentType} of an attribute
+ * Gets the parent {@link PersistentType} of an attribute
* @param persistentAttribite
* @param fp
- * @param an - attribute's relationship annotation
- * @return the parent {@link JavaPersistentType} of an attribute.
+ * @param typeName
+ * @return the parent {@link PersistentType} of an attribute.
*/
- public JavaPersistentType findJPT(JavaSpecifiedPersistentAttribute persistentAttribite, IJPAEditorFeatureProvider fp, Annotation an) {
- JavaResourceAttribute jrpa = persistentAttribite.getResourceAttribute();
- String relTypeName = getRelTypeName(an, jrpa);
- JavaPersistentType relJPT = (JavaPersistentType)fp.getBusinessObjectForKey(relTypeName);
+ public PersistentType findJPT(PersistentAttribute persistentAttribite, IJPAEditorFeatureProvider fp, String typeName) {
+ if(persistentAttribite == null)
+ return null;
+ PersistentType relJPT = (PersistentType)fp.getBusinessObjectForKey(typeName);
return relJPT;
}
private Collection<IRelation> produceIRelations(
- JavaPersistentType newJPT, JavaPersistentType jpt2, IJPAEditorFeatureProvider fp) {
+ PersistentType newJPT, PersistentType jpt2, IJPAEditorFeatureProvider fp) {
Set<IRelation> res = new HashSet<IRelation>();
- for (JavaSpecifiedPersistentAttribute at : newJPT.getAttributes()) {
+ for (PersistentAttribute at : newJPT.getAttributes()) {
+ if(at.getJavaPersistentAttribute() == null)
+ continue;
IRelation rel = produceIRelation(at, jpt2, fp);
if (rel != null)
res.add(rel);
@@ -1082,13 +1119,16 @@ public class JpaArtifactFactory {
}
/**
- * Returns the {@link JavaPersistentType} registered in the {@link PersistenceUnit} with the given name.
+ * Returns the {@link PersistentType} registered in the {@link PersistenceUnit} with the given name.
* @param name
* @param pu
- * @return the {@link JavaPersistentType} registered in the {@link PersistenceUnit} with the given name.
+ * @return the {@link PersistentType} registered in the {@link PersistenceUnit} with the given name.
*/
- public JavaPersistentType getJPT(String name, PersistenceUnit pu) {
- JavaPersistentType jpt = (JavaPersistentType) pu.getPersistentType(name);
+ public PersistentType getJPT(String name, PersistenceUnit pu) {
+ pu.getJpaProject().getContextModelRoot().synchronizeWithResourceModel();
+ pu.synchronizeWithResourceModel();
+ pu.update();
+ PersistentType jpt = pu.getPersistentType(name);
int cnt = 0;
while ((jpt == null) && (cnt < MAX_NUM_OF_ITERATIONS)) {
try {
@@ -1097,7 +1137,7 @@ public class JpaArtifactFactory {
JPADiagramEditorPlugin.logError("Sleep interrupted", e); //$NON-NLS-1$
}
pu.synchronizeWithResourceModel();
- jpt = (JavaPersistentType)pu.getPersistentType(name);
+ jpt = pu.getPersistentType(name);
cnt++;
}
return jpt;
@@ -1109,8 +1149,8 @@ public class JpaArtifactFactory {
* @param jpt
* @return a set of all attributes of an entity involved in relationship with the given entity.
*/
- public Set<JavaSpecifiedPersistentAttribute> getRelatedAttributes(JavaPersistentType jpt) {
- Set<JavaSpecifiedPersistentAttribute> res = new HashSet<JavaSpecifiedPersistentAttribute>();
+ public Set<PersistentAttribute> getRelatedAttributes(PersistentType jpt) {
+ Set<PersistentAttribute> res = new HashSet<PersistentAttribute>();
Iterator<JpaFile> it = jpt.getJpaProject().getJpaFiles().iterator();
PersistenceUnit pu = JpaArtifactFactory.INSTANCE.getPersistenceUnit(jpt.getJpaProject());
while (it.hasNext()) {
@@ -1126,11 +1166,11 @@ public class JpaArtifactFactory {
if (jrt == null)
continue;
String name = jrt.getTypeBinding().getQualifiedName();
- JavaPersistentType jpt1 = (JavaPersistentType) pu
- .getPersistentType(name);
+ PersistentType jpt1 = pu.getPersistentType(name);
if (jpt1 == null)
continue;
- Set<JavaSpecifiedPersistentAttribute> relAts = getRelAttributes(jpt, jpt1);
+
+ Set<PersistentAttribute> relAts = getRelAttributes(jpt, jpt1);
if (relAts != null)
res.addAll(relAts);
}
@@ -1143,42 +1183,34 @@ public class JpaArtifactFactory {
* @param relJPT
* @return the attribute belonging to jpt and involved in a relationship with relJPT.
*/
- private Set<JavaSpecifiedPersistentAttribute> getRelAttributes(JavaPersistentType jpt,
- JavaPersistentType relJPT) {
+ private Set<PersistentAttribute> getRelAttributes(PersistentType jpt,
+ PersistentType relJPT) {
- Set<JavaSpecifiedPersistentAttribute> res = new HashSet<JavaSpecifiedPersistentAttribute>();
- for (JavaSpecifiedPersistentAttribute at : relJPT.getAttributes()) {
- IResource r = at.getParent().getResource();
- if (!r.exists())
- throw new RuntimeException();
- Annotation[] ans = getAnnotations(at);
- String annotationName = null;
- for (Annotation an : ans) {
- annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName) || JPAEditorConstants.ANNOTATION_EMBEDDED.equals(annotationName)
- || JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION.equals(annotationName)
- || JPAEditorConstants.ANNOTATION_EMBEDDED_ID.equals(annotationName)) {
- String relTypeName = getRelTypeName(an, at.getResourceAttribute());
- if (!relTypeName.equals(jpt.getName()))
+ Set<PersistentAttribute> res = new HashSet<PersistentAttribute>();
+ for (PersistentAttribute at : relJPT.getAttributes()) {
+ AttributeMapping attributeMapping = getAttributeMapping(at);
+ if ((attributeMapping instanceof RelationshipMapping) || (attributeMapping instanceof EmbeddedMapping) || (attributeMapping instanceof EmbeddedIdMapping)
+ || (attributeMapping instanceof ElementCollectionMapping2_0)) {
+ String relTypeName = getRelTypeName(at);
+ if (relTypeName == null || !relTypeName.equals(jpt.getName()))
continue;
res.add(at);
- }
- }
+ }
}
return res;
}
- public void renameEntityClass(JavaPersistentType jpt, String newEntityName, IJPAEditorFeatureProvider fp) {
+ public void renameEntityClass(PersistentType jpt, String newEntityName, IJPAEditorFeatureProvider fp) {
Command renameEntityCommand = new RenameEntityCommand(jpt, newEntityName, fp);
try {
- getJpaProjectManager().execute(renameEntityCommand);
+ getJpaProjectManager().execute(renameEntityCommand, SynchronousUiCommandExecutor.instance());
} catch (InterruptedException e) {
JPADiagramEditorPlugin.logError("Cannot rename entity " + jpt.getName(), e); //$NON-NLS-1$
}
}
- public JavaSpecifiedPersistentAttribute renameAttribute(JavaPersistentType jpt,
+ public PersistentAttribute renameAttribute(PersistentType jpt,
String oldName, String newName, String inverseEntityName,
IJPAEditorFeatureProvider fp) throws InterruptedException {
newName = JPAEditorUtil.decapitalizeFirstLetter(newName);
@@ -1187,21 +1219,36 @@ public class JpaArtifactFactory {
}
newName = JPAEditorUtil.produceUniqueAttributeName(jpt, newName);
PersistenceUnit pu = null;
- JavaSpecifiedPersistentAttribute oldAt = jpt.getAttributeNamed(oldName);
- fp.addAddIgnore((JavaPersistentType)oldAt.getParent(), newName);
- JavaResourceAttribute jra = oldAt
- .getResourceAttribute();
- fp.addRemoveIgnore((JavaPersistentType)oldAt.getParent(), jra.getName());
+ PersistentAttribute oldAt = null;
+
+ if(jpt instanceof OrmPersistentType){
+ oldAt = ((OrmPersistentType)jpt).getJavaPersistentType().getAttributeNamed(oldName);
+ } else {
+ oldAt = jpt.getAttributeNamed(oldName);
+ }
+
+ if(oldAt == null){
+ return null;
+ }
+
+ if(oldAt.getParent() == null){
+ oldAt.getDeclaringPersistentType();
+ }
+
+ fp.addAddIgnore((PersistentType)oldAt.getParent(), newName);
+ fp.addRemoveIgnore((PersistentType)oldAt.getParent(), oldName);
+
+ String attributeTypeName = getRelTypeName(oldAt);
Command renameAttributeCommand = new RenameAttributeCommand(null, jpt, oldName, newName, fp);
getJpaProjectManager().execute(renameAttributeCommand, SynchronousUiCommandExecutor.instance());
-
- JavaSpecifiedPersistentAttribute newAt = jpt.getAttributeNamed(newName);
+
+ PersistentAttribute newAt = jpt.getAttributeNamed(newName);
if (newAt == null) {
- JPADiagramEditorPlugin.logError("The attribute " + newName + " could not be resolved", new NullPointerException()); //$NON-NLS-1$ //$NON-NLS-2$
+ return null;
}
- fp.addRemoveIgnore(jpt, oldAt.getName());
+ fp.addRemoveIgnore(jpt, oldName);
try {
fp.replaceAttribute(oldAt, newAt);
} catch (Exception e) {
@@ -1209,33 +1256,56 @@ public class JpaArtifactFactory {
}
updateIRelationshipAttributes(jpt, inverseEntityName, fp, pu, oldAt,
- newAt);
+ newAt, attributeTypeName);
return newAt;
}
- private void updateIRelationshipAttributes(JavaPersistentType jpt,
+ private void updateIRelationshipAttributes(PersistentType jpt,
+ String inverseEntityName, IJPAEditorFeatureProvider fp,
+ PersistenceUnit pu, PersistentAttribute oldAt,
+ PersistentAttribute newAt, String typeName) throws InterruptedException {
+ Set<IRelation> rels = fp.getRelationRelatedToAttribute(oldAt, typeName);
+ Iterator<IRelation> iter = rels.iterator();
+ while(iter.hasNext()){
+ IRelation rel = iter.next();
+ updateRelationship(jpt, inverseEntityName, fp, pu, oldAt, newAt, rel);
+
+ }
+
+ HashSet<PersistentType> embeddingEntities = findAllJPTWithTheGivenEmbeddedId(jpt, fp);
+ if(embeddingEntities != null && !embeddingEntities.isEmpty()){
+ renameMapsIdAttributeValue(oldAt, newAt, embeddingEntities);
+ }
+
+ }
+
+ private void updateRelationship(PersistentType jpt,
String inverseEntityName, IJPAEditorFeatureProvider fp,
- PersistenceUnit pu, JavaSpecifiedPersistentAttribute oldAt,
- JavaSpecifiedPersistentAttribute newAt) throws InterruptedException {
- IRelation rel = fp.getRelationRelatedToAttribute(oldAt);
+ PersistenceUnit pu, PersistentAttribute oldAt,
+ PersistentAttribute newAt, IRelation rel)
+ throws InterruptedException {
String inverseAttributeName = null;
- JavaPersistentType inverseJPT = null;
+ PersistentType inverseJPT = null;
if (IBidirectionalRelation.class.isInstance(rel)) {
inverseJPT = rel.getInverse();
if (inverseJPT != oldAt.getParent()) {
pu = JpaArtifactFactory.INSTANCE.getPersistenceUnit(jpt);
inverseAttributeName = rel.getInverseAttributeName();
}
+
+ if(!inverseJPT.getResource().exists()) {
+ inverseJPT = (PersistentType) pu.getManagedType(inverseEntityName);
+ }
}
if (inverseAttributeName != null) {
- Command changeMappedByValueCommand = new SetMappedByNewValueCommand(fp, pu, inverseEntityName, inverseAttributeName, newAt, oldAt, rel);
- getJpaProjectManager().execute(changeMappedByValueCommand, SynchronousUiCommandExecutor.instance());
+ Command changeMappedByValueCommand = new SetMappedByNewValueCommand(fp, pu, inverseJPT.getName(), inverseAttributeName, newAt.getName(), oldAt);
+ getJpaProjectManager().execute(changeMappedByValueCommand, SynchronousUiCommandExecutor.instance());
}
if (rel != null) {
updateRelation(jpt, fp, rel);
- if(hasIDClassAnnotation(jpt)) {
+ if(hasIDClass(jpt)) {
String idClassFQN = getIdType(jpt);
IJavaProject javaProject = JavaCore.create(jpt.getJpaProject().getProject());
IType type = getType(javaProject, idClassFQN);
@@ -1245,25 +1315,27 @@ public class JpaArtifactFactory {
}
}
}
-
- HashSet<JavaPersistentType> embeddingEntities = findAllJPTWithTheGivenEmbeddedId(jpt, fp);
- if(embeddingEntities != null && !embeddingEntities.isEmpty()){
- renameMapsIdAnnotationValue(oldAt, newAt, embeddingEntities);
- }
-
}
- private void renameMapsIdAnnotationValue(JavaSpecifiedPersistentAttribute oldAt,
- JavaSpecifiedPersistentAttribute newAt, HashSet<JavaPersistentType> embeddingEntities) {
-
- for(JavaPersistentType embeddingEntity : embeddingEntities){
- for(JavaSpecifiedPersistentAttribute attr : embeddingEntity.getAttributes()){
- Annotation ann = attr.getResourceAttribute().getAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
- if(ann != null){
- MapsId2_0Annotation mapsIdAnn = (MapsId2_0Annotation) ann;
- if(mapsIdAnn.getValue() != null && mapsIdAnn.getValue().equals(oldAt.getName())){
- ((MapsId2_0Annotation)ann).setValue(newAt.getName());
- embeddingEntity.synchronizeWithResourceModel();
+ private void renameMapsIdAttributeValue(PersistentAttribute oldAt,
+ PersistentAttribute newAt, HashSet<PersistentType> embeddingEntities) {
+
+ for(PersistentType embeddingEntity : embeddingEntities){
+ for(PersistentAttribute attr : embeddingEntity.getAttributes()){
+
+ AttributeMapping attributeMapping = getAttributeMapping(attr);
+ if(attributeMapping instanceof SingleRelationshipMapping2_0){
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(identity.usesMapsIdDerivedIdentityStrategy()){
+ MapsIdDerivedIdentityStrategy2_0 strategy = identity.getMapsIdDerivedIdentityStrategy();
+ String attributeName = strategy.getSpecifiedIdAttributeName();
+ if(attributeName != null && attributeName.equals(oldAt.getName())){
+ strategy.setSpecifiedIdAttributeName(newAt.getName());
+ Annotation ann = attr.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
+ if(ann != null){
+ ((MapsId2_0Annotation)ann).setValue(newAt.getName());
+ }
+ }
}
}
}
@@ -1276,8 +1348,16 @@ public class JpaArtifactFactory {
return (JpaProjectManager) ResourcesPlugin.getWorkspace().getAdapter(JpaProjectManager.class);
}
- private void updateRelation(JavaPersistentType jpt,
- IJPAEditorFeatureProvider fp, IRelation rel) {
+ private void updateRelation(PersistentType jpt, IJPAEditorFeatureProvider fp, IRelation rel) {
+
+ if(!rel.getInverse().getResource().exists() || !rel.getOwner().getResource().exists()){
+ PictogramElement peRel = fp.getPictogramElementForBusinessObject(rel);
+ if(peRel != null && peRel instanceof Connection) {
+ Graphiti.getPeService().deletePictogramElement(peRel);
+ }
+
+ }
+
UpdateAttributeFeature updateFeature = new UpdateAttributeFeature(fp);
if (jpt.equals(rel.getInverse())) {
updateFeature.reconnect(rel.getOwner());
@@ -1294,18 +1374,19 @@ public class JpaArtifactFactory {
* @param fp
* @return the newly created {@link IRelation}
*/
- private IRelation produceRelation(JavaSpecifiedPersistentAttribute persistentAttribite, Annotation an,
- JavaPersistentType relJPT, IJPAEditorFeatureProvider fp) {
- Hashtable<JavaSpecifiedPersistentAttribute, Annotation> ht = getRelAttributeAnnotation(
+ private IRelation produceRelation(PersistentAttribute persistentAttribite, AttributeMapping an,
+ PersistentType relJPT, IJPAEditorFeatureProvider fp) {
+
+ Hashtable<PersistentAttribute, AttributeMapping> ht = getRelAttributeAnnotation(
persistentAttribite, relJPT, fp);
if (ht == null) {
- return produceUniDirRelation((JavaPersistentType)persistentAttribite
+ return produceUniDirRelation((PersistentType)persistentAttribite
.getParent(), persistentAttribite, an, relJPT, fp);
} else {
- JavaSpecifiedPersistentAttribute relAt = ht.keys().nextElement();
- Annotation relAn = ht.get(relAt);
- return produceBiDirRelation((JavaPersistentType)persistentAttribite
+ PersistentAttribute relAt = ht.keys().nextElement();
+ AttributeMapping relAn = ht.get(relAt);
+ return produceBiDirRelation((PersistentType)persistentAttribite
.getParent(), persistentAttribite, an, relJPT,
relAt, relAn, fp);
}
@@ -1320,20 +1401,19 @@ public class JpaArtifactFactory {
* @param fp
* @return the newly created {@link HasReferanceRelation}.
*/
- private HasReferanceRelation produceEmbeddedRelation(JavaSpecifiedPersistentAttribute embeddingAttribute, Annotation an,
- JavaPersistentType embeddable, IJPAEditorFeatureProvider fp) {
+ private HasReferanceRelation produceEmbeddedRelation(PersistentAttribute embeddingAttribute, AttributeMapping an,
+ PersistentType embeddable, IJPAEditorFeatureProvider fp) {
- if (!JPAEditorUtil.getCompilationUnit((JavaPersistentType) embeddingAttribute.getParent()).exists())
+ if (!JPAEditorUtil.getCompilationUnit((PersistentType) embeddingAttribute.getParent()).exists())
return null;
- JavaPersistentType embeddingEntity = (JavaPersistentType) embeddingAttribute.getParent();
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
+ PersistentType embeddingEntity = (PersistentType) embeddingAttribute.getParent();
String embeddedAttributeName = embeddingAttribute.getName();
HasReferanceRelation res = null;
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_EMBEDDED) || JPAEditorConstants.ANNOTATION_EMBEDDED_ID.equals(annotationName)) {
+ if ((an instanceof EmbeddedMapping) || (an instanceof EmbeddedIdMapping)) {
if (!fp.doesEmbeddedRelationExist(embeddable, embeddingEntity, embeddedAttributeName, HasReferenceType.SINGLE)) {
res = new HasSingleReferenceRelation(embeddingEntity, embeddable);
}
- } else if (annotationName.equals(JPAEditorConstants.ANNOTATION_ELEMENT_COLLECTION)) {
+ } else if (an instanceof ElementCollectionMapping2_0) {
if (!fp.doesEmbeddedRelationExist(embeddable, embeddingEntity, embeddedAttributeName, HasReferenceType.COLLECTION)){
res = new HasCollectionReferenceRelation(embeddingEntity, embeddable);
}
@@ -1349,50 +1429,40 @@ public class JpaArtifactFactory {
* If there is a mappedBy attribute, which value is the same as the given attribute,
* then the relationship is bidirectional, oderwise - unidirectional.
* @param jpa - the owner relationship attribute
- * @param relJPT - inverse {@link JavaPersistentType}.
+ * @param relJPT - inverse {@link PersistentType}.
* @param fp
* @return a {@link Hashtable} containing the pair: inverseAttribute <-> relation annotation.
*/
- private Hashtable<JavaSpecifiedPersistentAttribute, Annotation> getRelAttributeAnnotation(
- JavaSpecifiedPersistentAttribute jpa, JavaPersistentType relJPT, IJPAEditorFeatureProvider fp) {
-
- JavaPersistentType jpt = (JavaPersistentType)jpa.getParent();
- for (JavaSpecifiedPersistentAttribute relEntAt : relJPT.getAttributes()) {
- IResource r = relEntAt.getParent().getResource();
- if (!r.exists())
- throw new RuntimeException();
- JavaResourceAttribute relJRA = relEntAt.getResourceAttribute();
- Annotation[] ans = this.getAnnotations(relEntAt);
- for (Annotation an : ans) {
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(annotationName)) {
-
- JavaAttributeMapping mp = relEntAt.getMapping();
- if (!OwnableRelationshipMappingAnnotation.class.isInstance(mp.getMappingAnnotation()))
+ private Hashtable<PersistentAttribute, AttributeMapping> getRelAttributeAnnotation(
+ PersistentAttribute jpa, PersistentType relJPT, IJPAEditorFeatureProvider fp) {
+
+ PersistentType jpt = (PersistentType) jpa.getParent();
+ for (PersistentAttribute relEntAt : relJPT.getAttributes()) {
+ AttributeMapping attributeMapping = getAttributeMapping(relEntAt);
+ if (attributeMapping instanceof RelationshipMapping) {
+ MappingRelationship mappingRel = ((RelationshipMapping)attributeMapping).getRelationship();
+ if(!(mappingRel instanceof MappedByRelationship)){
+ continue;
+ } else {
+ String mappedByAttr = ((MappedByRelationship)mappingRel).getMappedByStrategy().getMappedByAttribute();
+ if(mappedByAttr == null)
continue;
- if(an instanceof OwnableRelationshipMappingAnnotation) {
- String mappedByAttr = ((OwnableRelationshipMappingAnnotation)an).getMappedBy();
- if(mappedByAttr == null)
+ String[] mappedByStrings = mappedByAttr.split(JPAEditorConstants.MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR);
+ if(mappedByStrings.length>1){
+ jpt = getInvolvedEntity(fp, jpt, relEntAt, mappedByStrings);
+ } else {
+ String mappedBy = ((MappedByRelationship)mappingRel).getMappedByStrategy().getMappedByAttribute();
+ if (!jpa.getName().equals(mappedBy))
continue;
-
- String[] mappedByStrings = mappedByAttr.split(MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR);
- if(mappedByStrings.length>1){
- jpt = getInvolvedEntity(fp, jpt, relEntAt, an, mappedByStrings);
- } else {
- String mappedBy = ((OwnableRelationshipMappingAnnotation)mp.getMappingAnnotation()).getMappedBy();
- if (!jpa.getName().equals(mappedBy))
- continue;
- }
}
-
- String relTypeName = getRelTypeName(an, relJRA);
- if (!relTypeName.equals(jpt.getName()))
- continue;
- Hashtable<JavaSpecifiedPersistentAttribute, Annotation> ht = new Hashtable<JavaSpecifiedPersistentAttribute, Annotation>();
- ht.put(relEntAt, an);
- return ht;
}
+ String relTypeName = getRelTypeName(relEntAt);
+ if (relTypeName != null && jpt != null && !relTypeName.equals(jpt.getName()))
+ continue;
+ Hashtable<PersistentAttribute, AttributeMapping> ht = new Hashtable<PersistentAttribute, AttributeMapping>();
+ ht.put(relEntAt, attributeMapping);
+ return ht;
}
}
return null;
@@ -1407,18 +1477,19 @@ public class JpaArtifactFactory {
* @param fp
* @param jpt - the embedded class
* @param relEntAt - the relation attribute in the entity class
- * @param an - the relation attribute annotation
* @param mappedByStrings - all strings in the mappedBy attribute
* @return the entity involved in the bidirectional relationship between the embeddable class and some entity.
*/
- private JavaPersistentType getInvolvedEntity(IJPAEditorFeatureProvider fp, JavaPersistentType jpt,
- JavaSpecifiedPersistentAttribute relEntAt, Annotation an, String[] mappedByStrings) {
+ private PersistentType getInvolvedEntity(IJPAEditorFeatureProvider fp, PersistentType jpt,
+ PersistentAttribute relEntAt, String[] mappedByStrings) {
String mappedBy = mappedByStrings[0];
- JavaPersistentType involvedEntity = findJPT(relEntAt, fp, an);
- JavaSpecifiedPersistentAttribute embeddedAttribute = involvedEntity.getAttributeNamed(mappedBy);
+ PersistentType involvedEntity = findJPT(relEntAt, fp, getRelTypeName(relEntAt));
+ if(involvedEntity == null)
+ return involvedEntity;
+ PersistentAttribute embeddedAttribute = involvedEntity.getAttributeNamed(mappedBy);
if(embeddedAttribute != null){
- JavaPersistentType embeddedJPT = findJPT(embeddedAttribute, fp, getAnnotations(embeddedAttribute)[0]);
- if(embeddedJPT.equals(jpt)) {
+ PersistentType embeddedJPT = findJPT(embeddedAttribute, fp, getRelTypeName(embeddedAttribute));
+ if(embeddedJPT != null && jpt != null && embeddedJPT.getName().equals(jpt.getName())) {
jpt = involvedEntity;
}
}
@@ -1435,40 +1506,36 @@ public class JpaArtifactFactory {
* @return the newly created unidirectional relationship.
*/
private IUnidirectionalRelation produceUniDirRelation(
- JavaPersistentType jpt, JavaSpecifiedPersistentAttribute at, Annotation an,
- JavaPersistentType relJPT, IJPAEditorFeatureProvider fp) {
+ PersistentType jpt, PersistentAttribute at, AttributeMapping an,
+ PersistentType relJPT, IJPAEditorFeatureProvider fp) {
- if (isNonOwner(at) || !JPAEditorUtil.getCompilationUnit((JavaPersistentType) at.getParent()).exists())
+ if (!isOwner(at) || !JPAEditorUtil.getCompilationUnit((PersistentType) at.getParent()).exists())
return null;
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- IUnidirectionalRelation res = createUniDirRelationshipDependsOnTheType(jpt, at, relJPT, fp, annotationName);
+ IUnidirectionalRelation res = createUniDirRelationshipDependsOnTheType(jpt, at, relJPT, fp, an);
if (res != null)
res.setAnnotatedAttribute(at);
return res;
}
private IUnidirectionalRelation createUniDirRelationshipDependsOnTheType(
- JavaPersistentType jpt, JavaSpecifiedPersistentAttribute at,
- JavaPersistentType relJPT, IJPAEditorFeatureProvider fp,
- String annotationName) {
+ PersistentType jpt, PersistentAttribute at,
+ PersistentType relJPT, IJPAEditorFeatureProvider fp,
+ AttributeMapping attributeMapping) {
IUnidirectionalRelation res = null;
String attrName = at.getName();
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)) {
+ if (attributeMapping instanceof OneToOneMapping) {
if (!fp.doesRelationExist(jpt, relJPT, attrName, null, RelType.ONE_TO_ONE,
RelDir.UNI))
res = new OneToOneUniDirRelation(fp, jpt, relJPT, attrName, false, false);
- } else if (annotationName
- .equals(JPAEditorConstants.ANNOTATION_ONE_TO_MANY)) {
+ } else if (attributeMapping instanceof OneToManyMapping) {
if (!fp.doesRelationExist(jpt, relJPT, attrName, null, RelType.ONE_TO_MANY,
RelDir.UNI))
res = new OneToManyUniDirRelation(fp, jpt, relJPT, attrName, false);
- } else if (annotationName
- .equals(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) {
+ } else if (attributeMapping instanceof ManyToOneMapping) {
if (!fp.doesRelationExist(jpt, relJPT, attrName, null, RelType.MANY_TO_ONE,
RelDir.UNI))
res = new ManyToOneUniDirRelation(fp, jpt, relJPT, attrName, false, false);
- } else if (annotationName
- .equals(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) {
+ } else if (attributeMapping instanceof ManyToManyMapping) {
if (!fp.doesRelationExist(jpt, relJPT, attrName, null, RelType.MANY_TO_MANY,
RelDir.UNI))
res = new ManyToManyUniDirRelation(fp, jpt, relJPT, attrName, false);
@@ -1487,51 +1554,46 @@ public class JpaArtifactFactory {
* @param fp
* @return the newly created bidirectional relationship.
*/
- private IBidirectionalRelation produceBiDirRelation(JavaPersistentType jpt,
- JavaSpecifiedPersistentAttribute at, Annotation an,
- JavaPersistentType relJPT, JavaSpecifiedPersistentAttribute relAt,
- Annotation relAn, IJPAEditorFeatureProvider fp) {
- String annotationName = JPAEditorUtil.returnSimpleName(an.getAnnotationName());
- String relAnnotationName = JPAEditorUtil.returnSimpleName(relAn.getAnnotationName());
- if (!annotationNamesMatch(annotationName, relAnnotationName))
+ private IBidirectionalRelation produceBiDirRelation(PersistentType jpt,
+ PersistentAttribute at, AttributeMapping an,
+ PersistentType relJPT, PersistentAttribute relAt,
+ AttributeMapping relAn, IJPAEditorFeatureProvider fp) {
+ if (!attributeMappingsMatch(an, relAn))
return null;
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_ONE_TO_MANY))
+ if (an instanceof OneToManyMapping)
return produceBiDirRelation(relJPT, relAt, relAn, jpt, at, an, fp);
- if (isNonOwner(at) && isNonOwner(relAt))
+ if (!isOwner(at) && !isOwner(relAt))
return null;
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) {
- if (isNonOwner(at) || !isNonOwner(relAt))
+ if (an instanceof ManyToOneMapping) {
+ if (!isOwner(at) || isOwner(relAt))
return null;
}
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) {
- if (!isNonOwner(at) && !isNonOwner(relAt))
+ if (an instanceof ManyToManyMapping) {
+ if (isOwner(at) && isOwner(relAt))
return null;
- if (isNonOwner(at))
+ if (!isOwner(at))
return produceBiDirRelation(relJPT, relAt, relAn, jpt, at, an,
fp);
}
String ownerAttrName = at.getName();
String inverseAttrName = relAt.getName();
- JavaAttributeMapping m = relAt.getMapping();
-
- if ((m != null)){
- if(m.getMappingAnnotation() instanceof OwnableRelationshipMappingAnnotation) {
+ AttributeMapping m = getAttributeMapping(relAt);
- String mappedBy = ((OwnableRelationshipMappingAnnotation)m.getMappingAnnotation()).getMappedBy();
- if (mappedBy == null)
- return null;
- String[] attrs = mappedBy.split(MAPPED_BY_ATTRIBUTE_SPLIT_SEPARATOR);
- if(attrs.length > 1) {
- mappedBy = attrs[1];
- }
- if (!mappedBy.equals(ownerAttrName))
+ if ((m != null) && (m instanceof RelationshipMapping)) {
+ RelationshipMapping relMapping = (RelationshipMapping) m;
+ MappingRelationship mappingRel = relMapping.getRelationship();
+ if(!(mappingRel instanceof MappedByRelationship)){
return null;
+ } else {
+ String mappedBy = ((MappedByRelationship)mappingRel).getMappedByStrategy().getMappedByAttribute();
+ if (mappedBy == null)
+ return null;
}
}
IBidirectionalRelation res = createBiDirRelationshipDependsOnTheType(
- jpt, relJPT, fp, annotationName, ownerAttrName, inverseAttrName);
+ jpt, relJPT, fp, an, ownerAttrName, inverseAttrName);
if (res != null) {
res.setOwnerAnnotatedAttribute(at);
res.setInverseAnnotatedAttribute(relAt);
@@ -1540,23 +1602,21 @@ public class JpaArtifactFactory {
}
private IBidirectionalRelation createBiDirRelationshipDependsOnTheType(
- JavaPersistentType jpt, JavaPersistentType relJPT,
- IJPAEditorFeatureProvider fp, String annotationName,
+ PersistentType jpt, PersistentType relJPT,
+ IJPAEditorFeatureProvider fp, AttributeMapping attributeMapping,
String ownerAttrName, String inverseAttrName) {
IBidirectionalRelation res = null;
- if (annotationName.equals(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)) {
+ if (attributeMapping instanceof OneToOneMapping) {
if (!fp.doesRelationExist(jpt, relJPT, ownerAttrName, inverseAttrName, RelType.ONE_TO_ONE,
RelDir.BI))
res = new OneToOneBiDirRelation(fp, jpt, relJPT, ownerAttrName,
inverseAttrName, false, relJPT, false);
- } else if (annotationName
- .equals(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) {
+ } else if (attributeMapping instanceof ManyToOneMapping) {
if (!fp.doesRelationExist(jpt, relJPT, ownerAttrName, inverseAttrName, RelType.MANY_TO_ONE,
RelDir.BI))
res = new ManyToOneBiDirRelation(fp, jpt, relJPT, ownerAttrName,
inverseAttrName, false, relJPT, false);
- } else if (annotationName
- .equals(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) {
+ } else if (attributeMapping instanceof ManyToManyMapping) {
if (!fp.doesRelationExist(jpt, relJPT, ownerAttrName, inverseAttrName, RelType.MANY_TO_MANY,
RelDir.BI))
res = new ManyToManyBiDirRelation(fp, jpt, relJPT, ownerAttrName,
@@ -1565,24 +1625,23 @@ public class JpaArtifactFactory {
return res;
}
- private boolean annotationNamesMatch(String an1Name, String an2Name) {
- if (an1Name.equals(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)
- && an2Name.equals(JPAEditorConstants.ANNOTATION_ONE_TO_ONE)) {
+ private boolean attributeMappingsMatch(AttributeMapping an1Name, AttributeMapping an2Name) {
+ if ((an1Name instanceof OneToOneMapping) && (an2Name instanceof OneToOneMapping)) {
return true;
- } else if (an1Name.equals(JPAEditorConstants.ANNOTATION_ONE_TO_MANY)
- && an2Name.equals(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)) {
+ } else if ((an1Name instanceof OneToManyMapping)
+ && (an2Name instanceof ManyToOneMapping)) {
return true;
- } else if (an1Name.equals(JPAEditorConstants.ANNOTATION_MANY_TO_ONE)
- && an2Name.equals(JPAEditorConstants.ANNOTATION_ONE_TO_MANY)) {
+ } else if ((an1Name instanceof ManyToOneMapping)
+ && (an2Name instanceof OneToManyMapping)) {
return true;
- } else if (an1Name.equals(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)
- && an2Name.equals(JPAEditorConstants.ANNOTATION_MANY_TO_MANY)) {
+ } else if ((an1Name instanceof ManyToManyMapping)
+ && (an2Name instanceof ManyToManyMapping)) {
return true;
}
return false;
}
- private boolean doesAttributeExist(JavaPersistentType jpt, String name)
+ private boolean doesAttributeExist(PersistentType jpt, String name)
throws JavaModelException {
boolean exists = false;
if (jpt.resolveAttribute(name) != null) {
@@ -1590,12 +1649,6 @@ public class JpaArtifactFactory {
}
return exists;
}
-
- public JavaResourceType convertJPTToJRT(JavaPersistentType jpt) {
- if (jpt == null)
- return null;
- return (JavaResourceType) jpt.getJpaProject().getJavaResourceType(jpt.getName(), AstNodeType.TYPE);
- }
public PersistenceUnit getPersistenceUnit(JpaFile jpaFile) {
JpaProject jpaProject = jpaFile.getJpaProject();
@@ -1611,23 +1664,24 @@ public class JpaArtifactFactory {
.getPersistenceUnits().iterator().next();
}
- public PersistenceUnit getPersistenceUnit(JavaPersistentType jpt) {
+ public PersistenceUnit getPersistenceUnit(PersistentType jpt) {
return jpt.getPersistenceUnit();
}
-
- public boolean isMethodAnnotated(JavaSpecifiedPersistentAttribute attr) {
- return attr.getResourceAttribute().getAstNodeType() == AstNodeType.METHOD;
+
+ public boolean isMethodAnnotated(PersistentAttribute attr) {
+ return attr.getAccess() == AccessType.PROPERTY;
}
-
- public boolean isMethodAnnotated(JavaPersistentType jpt) {
- ListIterator<JavaSpecifiedPersistentAttribute> li = jpt.getAttributes().iterator();
+
+ @SuppressWarnings("unchecked")
+ public boolean isMethodAnnotated(PersistentType jpt) {
+ ListIterator<PersistentAttribute> li = (ListIterator<PersistentAttribute>) jpt.getAttributes().iterator();
if (!li.hasNext())
return false;
return (isMethodAnnotated(li.next()));
}
public void remakeRelations(IJPAEditorFeatureProvider fp,
- ContainerShape cs, JavaPersistentType jpt) {
+ ContainerShape cs, PersistentType jpt) {
if (cs == null)
cs = (ContainerShape)fp.getPictogramElementForBusinessObject(jpt);
if (cs == null)
@@ -1636,35 +1690,24 @@ public class JpaArtifactFactory {
addNewRelations(fp, jpt);
}
- public String getTableName(JavaPersistentType jpt) {
+ public String getTableName(PersistentType jpt) {
if (jpt == null)
- return null;
- JavaResourceType jrt = convertJPTToJRT(jpt);
- if (jrt == null)
- return null;
- TableAnnotation tan = (TableAnnotation)jrt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$
- String tableName = null;
- if (tan == null){
- tableName = JPAEditorUtil.returnSimpleName(jpt.getName());
- } else {
- tableName = tan.getName();
- }
- if (tableName == null)
- tableName = JPAEditorUtil.returnSimpleName(jpt.getName());
+ return null;
+
+ TypeMapping typeMapping = getTypeMapping(jpt);
+ String tableName = typeMapping.getPrimaryTableName();
+
return tableName;
}
- public void setTableName(JavaPersistentType jpt, String tableName) {
+ public void setTableName(PersistentType jpt, String tableName) {
if (jpt == null)
- return;
- JavaResourceType jrt = convertJPTToJRT(jpt);
- if (jrt == null) {
- return;
- }
- TableAnnotation ta = (TableAnnotation)jrt.getAnnotation("javax.persistence.Table"); //$NON-NLS-1$
- if (ta != null)
- ta.setName(tableName);
+ return;
+ TypeMapping typeMapping = getTypeMapping(jpt);
+ if(typeMapping instanceof Entity){
+ ((Entity)typeMapping).getTable().setSpecifiedName(tableName);
+ }
}
private void removeOldRelations(IJPAEditorFeatureProvider fp,
@@ -1685,14 +1728,14 @@ public class JpaArtifactFactory {
}
public void addNewRelations(IJPAEditorFeatureProvider fp,
- JavaPersistentType jpt) {
+ PersistentType jpt) {
addIRelationships(fp, jpt);
addEmbeddedRelation(fp, jpt);
rearrangeIsARelations(fp);
}
private void addEmbeddedRelation(IJPAEditorFeatureProvider fp,
- JavaPersistentType jpt) {
+ PersistentType jpt) {
Collection<HasReferanceRelation> newEmbeddedRels = produceAllEmbeddedRelations(jpt, fp);
Iterator<HasReferanceRelation> relationIterator = newEmbeddedRels.iterator();
while (relationIterator.hasNext()) {
@@ -1702,7 +1745,7 @@ public class JpaArtifactFactory {
}
private void addIRelationships(IJPAEditorFeatureProvider fp,
- JavaPersistentType jpt) {
+ PersistentType jpt) {
Collection<IRelation> selfRels = new HashSet<IRelation>();
Collection<IRelation> newRels = produceAllIRelations(jpt, fp);
Iterator<IRelation> relsIt = newRels.iterator();
@@ -1759,17 +1802,28 @@ public class JpaArtifactFactory {
ft.add(ctx);
}
- private String getRelTypeName(Annotation an,
- JavaResourceAttribute jra) {
+ public String getRelTypeName(PersistentAttribute persistentAttribute) {
String relTypeName = null;
- try {
- boolean isMap = jra.getTypeBinding().getQualifiedName().equals(JPAEditorConstants.MAP_TYPE);
- relTypeName = jra.getTypeBinding().getTypeArgumentName(isMap ? 1 : 0);
- } catch (Exception e) {}
- if (relTypeName == null && an != null && (an instanceof RelationshipMappingAnnotation))
- relTypeName = ((RelationshipMappingAnnotation)an).getFullyQualifiedTargetEntityClassName();
- if (relTypeName == null)
- relTypeName = JPAEditorUtil.getAttributeTypeName(jra);
+ if(persistentAttribute != null) {
+ AttributeMapping an = getAttributeMapping(persistentAttribute);
+
+ if(!isCollection(an)){
+ relTypeName = persistentAttribute.getTypeName();
+ }
+ if(persistentAttribute.getJavaPersistentAttribute() == null) {
+ persistentAttribute.getTypeName();
+ return relTypeName;
+ }
+ JavaResourceAttribute jra = persistentAttribute.getJavaPersistentAttribute().getResourceAttribute();
+ try {
+ boolean isMap = jra.getTypeBinding().getQualifiedName().equals(JPAEditorConstants.MAP_TYPE);
+ relTypeName = jra.getTypeBinding().getTypeArgumentName(isMap ? 1 : 0);
+ } catch (Exception e) {}
+ if (relTypeName == null && an != null && (an instanceof RelationshipMapping))
+ relTypeName = ((RelationshipMapping)an).getFullyQualifiedTargetEntity();
+ if (relTypeName == null)
+ relTypeName = JPAEditorUtil.getAttributeTypeName(jra);
+ }
return relTypeName;
}
@@ -1777,39 +1831,46 @@ public class JpaArtifactFactory {
return (JpaProject) project.getAdapter(JpaProject.class);
}
- public boolean hasIDClassAnnotation(JavaPersistentType jpt){
- Annotation an = jpt.getJavaResourceType().getAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- if(an != null){
- return true;
+ public boolean hasIDClass(PersistentType jpt) {
+ TypeMapping mapping = getTypeMapping(jpt);
+ if(mapping instanceof Entity){
+ String idClass = ((Entity)mapping).getIdClassReference().getIdClassName();
+ if(idClass != null)
+ return true;
}
return false;
}
-
- public String getIdType(JavaPersistentType jpt) {
- IdClassAnnotation an = (IdClassAnnotation)jpt.getJavaResourceType().getAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- if (an != null)
- return an.getFullyQualifiedClassName();
- JavaSpecifiedPersistentAttribute[] ids = getIds(jpt);
+
+ public String getIdType(PersistentType jpt) {
+ String idClass = null;
+ TypeMapping mapping = getTypeMapping(jpt);
+ if(mapping instanceof Entity){
+ idClass = ((Entity)mapping).getIdClassReference().getFullyQualifiedIdClassName();
+ }
+
+ if (idClass != null)
+ return idClass;
+ PersistentAttribute[] ids = getIds(jpt);
if (ids.length == 0)
return null;
- String type = ids[0].getTypeName();
+ String type = getRelTypeName(ids[0]);
String wrapper = JPAEditorUtil.getPrimitiveWrapper(type);
return (wrapper != null) ? wrapper : type;
}
-
- public JavaSpecifiedPersistentAttribute[] getIds(JavaPersistentType jpt) {
- ArrayList<JavaSpecifiedPersistentAttribute> res = new ArrayList<JavaSpecifiedPersistentAttribute>();
- for (JavaSpecifiedPersistentAttribute at : jpt.getAttributes()) {
+
+ public PersistentAttribute[] getIds(PersistentType jpt) {
+ ArrayList<PersistentAttribute> res = new ArrayList<PersistentAttribute>();
+ for (PersistentAttribute at : jpt.getAttributes()) {
if (isId(at)) {
res.add(at);
}
}
- JavaSpecifiedPersistentAttribute[] ret = new JavaSpecifiedPersistentAttribute[res.size()];
+ PersistentAttribute[] ret = new PersistentAttribute[res.size()];
return res.toArray(ret);
}
// returns true even if the primary key is inherited
- public boolean hasOrInheritsPrimaryKey(JavaPersistentType jpt) {
+ public boolean hasOrInheritsPrimaryKey(PersistentType jpt) {
Iterable<PersistentAttribute> attributes = jpt.getAllAttributes();
Iterator<PersistentAttribute> it = attributes.iterator();
while (it.hasNext()) {
@@ -1819,24 +1880,24 @@ public class JpaArtifactFactory {
}
return false;
}
-
- public boolean hasPrimaryKey(JavaPersistentType jpt) {
- for (JavaSpecifiedPersistentAttribute at : jpt.getAttributes())
+
+ public boolean hasPrimaryKey(PersistentType jpt) {
+ for (PersistentAttribute at : jpt.getAttributes())
if (isId(at)) return true;
return false;
}
- private boolean hasSimplePk(JavaPersistentType jpt) {
- for(JavaSpecifiedPersistentAttribute at : jpt.getAttributes()){
- if(isSimpleId(at) && !hasIDClassAnnotation(jpt)){
+ private boolean hasSimplePk(PersistentType jpt) {
+ for(PersistentAttribute at : jpt.getAttributes()){
+ if(isSimpleId(at) && !hasIDClass(jpt)){
return true;
}
}
return false;
}
-
- private JavaSpecifiedPersistentAttribute getSimplePkAttribute(JavaPersistentType jpt){
- for(JavaSpecifiedPersistentAttribute jpa : jpt.getAttributes()){
+
+ private PersistentAttribute getSimplePkAttribute(PersistentType jpt){
+ for(PersistentAttribute jpa : jpt.getAttributes()){
if(isSimpleId(jpa)){
return jpa;
}
@@ -1847,46 +1908,48 @@ public class JpaArtifactFactory {
public boolean isId(PersistentAttribute jpa) {
return isSimpleId(jpa) || isEmbeddedId(jpa);
}
-
+
public boolean isSimpleId(PersistentAttribute jpa) {
- return (jpa.getMappingKey() == MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
+ AttributeMapping attributeMapping = getAttributeMapping(jpa);
+ return (attributeMapping.getKey() == MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
}
-
- private boolean hasEmbeddedPk(JavaPersistentType jpt){
- for(JavaSpecifiedPersistentAttribute at : jpt.getAttributes()){
+
+ private boolean hasEmbeddedPk(PersistentType jpt){
+ for(PersistentAttribute at : jpt.getAttributes()){
if(isEmbeddedId(at)){
return true;
}
}
return false;
}
-
- private JavaSpecifiedPersistentAttribute getEmbeddedIdAttribute(JavaPersistentType jpt){
- for(JavaSpecifiedPersistentAttribute jpa : jpt.getAttributes()){
+
+ private PersistentAttribute getEmbeddedIdAttribute(PersistentType jpt){
+ for(PersistentAttribute jpa : jpt.getAttributes()){
if(isEmbeddedId(jpa)){
return jpa;
}
}
return null;
}
-
+
public boolean isEmbeddedId(PersistentAttribute jpa) {
- return (jpa.getMappingKey() == MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ AttributeMapping attributeMapping = getAttributeMapping(jpa);
+ return (attributeMapping.getKey() == MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
}
-
- public boolean isEmbeddedAttribute(JavaSpecifiedPersistentAttribute jpa) {
- return (jpa.getMappingKey() == MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
+
+ public boolean isEmbeddedAttribute(PersistentAttribute jpa) {
+ AttributeMapping attributeMapping = getAttributeMapping(jpa);
+ return (attributeMapping.getKey() == MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY);
}
-
- public String getColumnName(JavaSpecifiedPersistentAttribute jpa) {
+
+ public String getColumnName(PersistentAttribute jpa) {
String columnName= null;
- ColumnAnnotation an = (ColumnAnnotation)jpa.
- getResourceAttribute().
- getAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- if (an != null)
- columnName = an.getName();
- if (columnName == null)
- columnName = jpa.getName();
+
+ AttributeMapping attributeMapping = getAttributeMapping(jpa);
+
+ if(attributeMapping instanceof ColumnMapping){
+ columnName = ((ColumnMapping)attributeMapping).getColumn().getName();
+ }
return columnName;
}
@@ -1926,18 +1989,18 @@ public class JpaArtifactFactory {
return renderingStyle;
}
- public JPAEditorConstants.DIAGRAM_OBJECT_TYPE determineDiagramObjectType(JavaPersistentType jpt) {
- if (this.hasEntityAnnotation(jpt)) {
+ public JPAEditorConstants.DIAGRAM_OBJECT_TYPE determineDiagramObjectType(PersistentType jpt) {
+ if (this.isEntity(jpt)) {
return JPAEditorConstants.DIAGRAM_OBJECT_TYPE.Entity;
- } else if (this.hasMappedSuperclassAnnotation(jpt)) {
+ } else if (this.isMappedSuperclass(jpt)) {
return JPAEditorConstants.DIAGRAM_OBJECT_TYPE.MappedSupeclass;
- } else if (this.hasEmbeddableAnnotation(jpt)){
+ } else if (this.isEmbeddable(jpt)){
return JPAEditorConstants.DIAGRAM_OBJECT_TYPE.Embeddable;
}
throw new IllegalArgumentException();
}
- public String generateIdName(JavaPersistentType jpt) {
+ public String generateIdName(PersistentType jpt) {
String name = "id"; //$NON-NLS-1$
String genName = name;
for (int i = 0; i < 10000000; i++) {
@@ -1949,7 +2012,7 @@ public class JpaArtifactFactory {
}
- private boolean hasAttributeNamed(JavaPersistentType jpt, String name) {
+ private boolean hasAttributeNamed(PersistentType jpt, String name) {
Iterable<String> hier = jpt.getAllAttributeNames();
Iterator<String> it = hier.iterator();
while (it.hasNext()) {
@@ -1960,7 +2023,7 @@ public class JpaArtifactFactory {
return false;
}
- public String getMappedSuperclassPackageDeclaration(JavaPersistentType jpt) throws JavaModelException {
+ public String getMappedSuperclassPackageDeclaration(PersistentType jpt) throws JavaModelException {
String packageName = null;
IPackageDeclaration[] packages = JPAEditorUtil.getCompilationUnit(jpt)
.getPackageDeclarations();
@@ -1971,7 +2034,7 @@ public class JpaArtifactFactory {
return packageName;
}
- public void buildHierarchy(JavaPersistentType superclass, JavaPersistentType subclass, boolean build) {
+ public void buildHierarchy(PersistentType superclass, PersistentType subclass, boolean build) {
Command createNewAttributeCommand = new CreateEntityTypeHierarchy(superclass, subclass, build);
try {
@@ -1987,13 +2050,14 @@ public class JpaArtifactFactory {
* @param inverseJPT - the parent entity (the relationship's inverse/target entity)
* @param ownerAttr - the relationship's owner attribute
*/
- public void calculateDerivedIdAnnotation(JavaPersistentType ownerJPT, JavaPersistentType inverseJPT, JavaSpecifiedPersistentAttribute ownerAttr) {
+ public void calculateDerivedIdAttribute(PersistentType ownerJPT, PersistentType inverseJPT, PersistentAttribute ownerAttr) {
String attributeType = null;
if(hasSimplePk(inverseJPT)){
- JavaSpecifiedPersistentAttribute jpa = getSimplePkAttribute(inverseJPT);
+
+ PersistentAttribute jpa = getSimplePkAttribute(inverseJPT);
attributeType = JPAEditorUtil.getAttributeTypeNameWithGenerics(jpa);
} else {
- if(hasIDClassAnnotation(inverseJPT)){
+ if(hasIDClass(inverseJPT)){
attributeType = getIdType(inverseJPT);
} else if (hasEmbeddedPk(inverseJPT)){
attributeType = JPAEditorUtil.getAttributeTypeNameWithGenerics(getEmbeddedIdAttribute(inverseJPT));
@@ -2010,22 +2074,36 @@ public class JpaArtifactFactory {
* @param ownerAttr - the relationship's owner attribute
* @param inverseIdClassFQN - he type of the primary key of the parent entity
*/
- private void addAppropriateDerivedIdAnnotation(JavaPersistentType ownerJPT,
- JavaPersistentType inverseJPT, JavaSpecifiedPersistentAttribute ownerAttr,
+ private void addAppropriateDerivedIdAnnotation(PersistentType ownerJPT,
+ PersistentType inverseJPT, PersistentAttribute ownerAttr,
String inverseIdClassFQN) {
- if(hasIDClassAnnotation(ownerJPT)){
+ String annotationName = null;
+ String mapsIdValue = null;
+ boolean isXmlDefined = getORMPersistentAttribute(ownerAttr) != null;
+ if(hasIDClass(ownerJPT)){
+ annotationName = IdAnnotation.ANNOTATION_NAME;
String ownerIdClassFQN = getIdType(ownerJPT);
addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, ownerIdClassFQN,
- inverseIdClassFQN, IdAnnotation.ANNOTATION_NAME);
+ inverseIdClassFQN, annotationName, isXmlDefined);
} else if(hasEmbeddedPk(ownerJPT)){
+ annotationName = MapsId2_0Annotation.ANNOTATION_NAME;
String ownerIdClassFQN = JPAEditorUtil.getAttributeTypeNameWithGenerics(getEmbeddedIdAttribute(ownerJPT));
- addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, ownerIdClassFQN,
- inverseIdClassFQN, MapsId2_0Annotation.ANNOTATION_NAME);
+ mapsIdValue = addDerivedIdAnnotation(ownerJPT, inverseJPT, ownerAttr, ownerIdClassFQN,
+ inverseIdClassFQN, annotationName, isXmlDefined);
} else if(hasSimplePk(ownerJPT)){
- ownerAttr.getResourceAttribute().addAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
+ annotationName = MapsId2_0Annotation.ANNOTATION_NAME;
+ if(!isXmlDefined) {
+ ownerAttr.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(annotationName);
+ }
+ mapsIdValue = getSimplePkAttribute(inverseJPT).getName();
} else {
- ownerAttr.getResourceAttribute().addAnnotation(IdAnnotation.ANNOTATION_NAME);
+ annotationName = IdAnnotation.ANNOTATION_NAME;
+ if(!isXmlDefined) {
+ ownerAttr.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(annotationName);
+ }
}
+ addDerivedIdMapping(ownerAttr, mapsIdValue, annotationName);
+
addJoinColumnIfNecessary(ownerAttr, inverseJPT);
}
@@ -2037,19 +2115,40 @@ public class JpaArtifactFactory {
* @param ownerIdClassFQN - the fully qualified name of the composite primary key's class
* @param inverseIdClassFQN - the type of the primary key of the parent entity
* @param annotationName - the derived identifier's annotation (either @Id or @MapsId)
+ * @param isXmlDefined - boolean value, indicating whether the attribute is registered in the
+ * orm.xml, or not.
*/
- private void addDerivedIdAnnotation(JavaPersistentType ownerJPT,
- JavaPersistentType inverseJPT, JavaSpecifiedPersistentAttribute ownerAttr,
- String ownerIdClassFQN, String inverseIdClassFQN, String annotationName) {
+ private String addDerivedIdAnnotation(PersistentType ownerJPT,
+ PersistentType inverseJPT, PersistentAttribute ownerAttr,
+ String ownerIdClassFQN, String inverseIdClassFQN, String annotationName, boolean isXmlDefined) {
if(!inverseIdClassFQN.equals(ownerIdClassFQN)){
String attributeType = JPAEditorUtil.returnSimpleName(inverseIdClassFQN);
addFieldInCompositeKeyClass(inverseJPT, ownerAttr, ownerIdClassFQN, attributeType);
- Annotation ann = ownerAttr.getResourceAttribute().addAnnotation(annotationName);
- if(ann instanceof MapsId2_0Annotation){
- ((MapsId2_0Annotation)ann).setValue(ownerAttr.getName());
+ if(!isXmlDefined) {
+ Annotation ann = ownerAttr.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(annotationName);
+ if(ann != null && ann instanceof MapsId2_0Annotation){
+ ((MapsId2_0Annotation)ann).setValue(ownerAttr.getName());
+ }
}
+ return ownerAttr.getName();
} else {
- ownerAttr.getResourceAttribute().addAnnotation(annotationName);
+ if(!isXmlDefined) {
+ ownerAttr.getJavaPersistentAttribute().getResourceAttribute().addAnnotation(annotationName);
+ }
+ }
+
+ return null;
+ }
+
+ private void addDerivedIdMapping(PersistentAttribute attr, String idAttributeName, String annotationName){
+ AttributeMapping attributeMapping = getAttributeMapping(attr);
+ if(attributeMapping instanceof SingleRelationshipMapping2_0) {
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ if(annotationName.equals(IdAnnotation.ANNOTATION_NAME)) {
+ identity.getIdDerivedIdentityStrategy().setValue(true);
+ } else {
+ identity.getMapsIdDerivedIdentityStrategy().setSpecifiedIdAttributeName(idAttributeName);
+ }
}
}
@@ -2063,13 +2162,13 @@ public class JpaArtifactFactory {
* @param fqnClass - the fully qualified name of the composite primary key's class
* @param attributeTypeName - the attribute's type
*/
- private void addFieldInCompositeKeyClass(JavaPersistentType inverseJPT,
- JavaSpecifiedPersistentAttribute ownerAttr, String fqnClass, String attributeTypeName) {
+ private void addFieldInCompositeKeyClass(PersistentType inverseJPT,
+ PersistentAttribute ownerAttr, String fqnClass, String attributeTypeName) {
IJavaProject javaProject = JavaCore.create(ownerAttr.getJpaProject().getProject());
IType type = getType(javaProject, fqnClass);
if(type != null && !type.getField(ownerAttr.getName()).exists()){
ICompilationUnit unit = type.getCompilationUnit();
- JavaPersistentType jpt = JPAEditorUtil.getJPType(unit);
+ PersistentType jpt = JPAEditorUtil.getJPType(unit);
Command createNewAttributeCommand = new AddAttributeCommand(null, jpt, attributeTypeName, null, ownerAttr.getName(),
ownerAttr.getName(), null, null, false, unit);
try {
@@ -2077,9 +2176,36 @@ public class JpaArtifactFactory {
} catch (InterruptedException e) {
JPADiagramEditorPlugin.logError("Cannot create a new attribute with name " + ownerAttr.getName(), e); //$NON-NLS-1$
}
+ if(jpt != null) {
+ PersistentAttribute attr = jpt.getAttributeNamed(ownerAttr.getName());
+ attr.getJavaPersistentAttribute().setMappingKey(MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY);
+ }
+ }
+ }
+
+ public void addPersistentTypeToORMXml(JpaProject jpaProject, String entityName, String mapping){
+ Command renameAttributeCommand = new AddPersistentTypeToOrmXmlCommand(jpaProject, mapping, entityName);
+ try {
+ getJpaProjectManager().execute(renameAttributeCommand, SynchronousUiCommandExecutor.instance());
+ } catch (InterruptedException e) {
+ e.printStackTrace();
}
}
+ public void deletePersistentTypeFromORMXml(JpaProject jpaProject, PersistentType jpt){
+ PersistenceUnit unit = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
+ if(unit.getMappingFileRefsSize() == 0)
+ return;
+ MappingFileRef fileRef = unit.getMappingFileRefs().iterator().next();
+ if(fileRef == null)
+ return;
+ MappingFile ref = fileRef.getMappingFile();
+ OrmXml ormXml = (OrmXml)ref;
+ OrmManagedType type = ormXml.getRoot().getManagedType(jpt.getName());
+ if(type != null){
+ ormXml.getRoot().removeManagedType(type);
+ }
+ }
public IType getType(IJavaProject javaProject, String fqnClass) {
try {
IType type = javaProject.findType(fqnClass);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java
index 4670028360..494e01c390 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPACreateFactory.java
@@ -48,10 +48,9 @@ import org.eclipse.jpt.common.utility.internal.iterable.EmptyIterable;
import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
+import org.eclipse.jpt.jpa.core.context.JpaContextModelRoot;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
@@ -227,7 +226,7 @@ public class JPACreateFactory {
String name = nameElements.get(Math.max(0, nameElements.size()-1));
// SynchronousJpaProjectUpdater updater = new SynchronousJpaProjectUpdater(jpaProject);
// updater.start();
- JpaRootContextNode jpaProjectContent = jpaProject.getRootContextNode();
+ JpaContextModelRoot jpaProjectContent = jpaProject.getContextModelRoot();
PersistenceXml persXML = jpaProjectContent.getPersistenceXml();
int cnt = 0;
while ((persXML == null) && (cnt < 100)) {
@@ -524,9 +523,9 @@ public class JPACreateFactory {
}
}
- public static ReadOnlyPersistentAttribute getPersistentAttribute(IFile entity, String attributeName){
- Set<ReadOnlyPersistentAttribute> result = getEntityFields(entity);
- for(ReadOnlyPersistentAttribute attribute : result){
+ public static PersistentAttribute getPersistentAttribute(IFile entity, String attributeName){
+ Set<PersistentAttribute> result = getEntityFields(entity);
+ for(PersistentAttribute attribute : result){
if(attributeName.equals(attribute.getName())){
return attribute;
}
@@ -550,17 +549,17 @@ public class JPACreateFactory {
return jpaFile.getRootStructureNodes();
}
- public static Set<ReadOnlyPersistentAttribute> getEntityFields(IFile file){
- Set<ReadOnlyPersistentAttribute> result = new HashSet<ReadOnlyPersistentAttribute>();
+ public static Set<PersistentAttribute> getEntityFields(IFile file){
+ Set<PersistentAttribute> result = new HashSet<PersistentAttribute>();
JpaFile jpaFile = getJpaFile(file);
if(jpaFile == null){
return result;
}
for (JpaStructureNode node : getRootNodes(jpaFile)) {
PersistentType entity = (PersistentType) node;
- Iterator<ReadOnlyPersistentAttribute> attributes = entity.getAllAttributes().iterator();
+ Iterator<PersistentAttribute> attributes = entity.getAllAttributes().iterator();
while (attributes.hasNext()){
- ReadOnlyPersistentAttribute attribute = attributes.next();
+ PersistentAttribute attribute = attributes.next();
result.add(attribute);
}
}
@@ -572,13 +571,13 @@ public class JPACreateFactory {
}
public void addAttributes(IFile entity, String attName, String attType, String annotation, String attActName, boolean isCollection){
- JavaPersistentType javaPersistentType = (JavaPersistentType)getPersistentType(entity);
+ PersistentType javaPersistentType = getPersistentType(entity);
int cnt = 0;
while ((javaPersistentType == null) && (cnt < 100)) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {}
- javaPersistentType = (JavaPersistentType)getPersistentType(entity);
+ javaPersistentType = getPersistentType(entity);
cnt++;
}
if (javaPersistentType == null)
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPAEditorTestsActivator.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPAEditorTestsActivator.java
index d922b41d38..64a25284e9 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPAEditorTestsActivator.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/JPAEditorTestsActivator.java
@@ -35,8 +35,6 @@ public class JPAEditorTestsActivator extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
- JpaProjectManager jpaProjectManager = this.getJpaProjectManager();
-// ReflectionTools.executeMethod(jpaProjectManager, "executeCommandsSynchronously"); //$NON-NLS-1$
}
protected JpaProjectManager getJpaProjectManager() {
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/Utils.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/Utils.java
index 0f3783e39a..e32a8a36cd 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/Utils.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/internal/Utils.java
@@ -10,7 +10,6 @@ import java.util.concurrent.Semaphore;
* @author i057508
*
*/
-@SuppressWarnings({"restriction", "PMD"})
public class Utils {
/**
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java
index 086de2ae7a..8ec3bae227 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EditorProxy.java
@@ -44,17 +44,19 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jpt.common.core.resource.java.Annotation;
+import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpa.core.context.PersistentType;
-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.TypeMapping;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapsId2_0Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.jpa.core.jpa2.context.DerivedIdentity2_0;
+import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -213,9 +215,9 @@ public class EditorProxy {
PictogramElement el = (PictogramElement) attribute.part().getModel();
Object bo = fp.getBusinessObjectForPictogramElement(el);
assertTrue("The selected element is not an attribute!",
- (bo instanceof JavaPersistentAttribute));
+ (bo instanceof PersistentAttribute));
String currentAttributeType = JPAEditorUtil
- .getAttributeTypeName((JavaPersistentAttribute) bo);
+ .getAttributeTypeName((PersistentAttribute) bo);
return currentAttributeType;
}
@@ -229,7 +231,7 @@ public class EditorProxy {
public SWTBotGefEditPart addAttributeToJPT(SWTBotGefEditPart jptType,
String attributeName) {
- JavaPersistentType jpt = getJPTObjectForGefElement(jptType);
+ PersistentType jpt = getJPTObjectForGefElement(jptType);
System.out.println(">>>>>> Attribute is trying to be added in "
+ jpt.getName());
@@ -255,7 +257,7 @@ public class EditorProxy {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
jptType));
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
assertNotNull(jpa);
assertEquals(
"The newly added attribute must be mapped as basic attribute.",
@@ -285,7 +287,7 @@ public class EditorProxy {
JPAEditorMessages.AddJPAEntityFeature_basicAttributesShapes,
jptType));
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
assertEquals(
"The newly added attribute must be mapped as element-collection.",
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
@@ -600,7 +602,7 @@ public class EditorProxy {
for (int i = 0; i < entitiesInDiagram.size(); i++) {
SWTBotGefEditPart editPart = entitiesInDiagram.get(i);
assertNotNull(editPart);
- JavaPersistentType type = getJPTObjectForGefElement(editPart);
+ PersistentType type = getJPTObjectForGefElement(editPart);
if (type != null) {
editPart.select();
jpaDiagramEditor.clickContextMenu("Delete");
@@ -819,7 +821,7 @@ public class EditorProxy {
Object ob = fp.getBusinessObjectForPictogramElement(conn);
if (ob == null) {
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
HasReferanceRelation rel = fp
.getEmbeddedRelationRelatedToAttribute(jpa);
assertNotNull(rel);
@@ -848,13 +850,13 @@ public class EditorProxy {
}
/**
- * Gets the business object (JavaPersistentType) for the given GEF element
+ * Gets the business object (PersistentType) for the given GEF element
*
* @param element
* @return the java persistent type for the given element, null if the
* selected element is not an entity
*/
- public JavaPersistentType getJPTObjectForGefElement(
+ public PersistentType getJPTObjectForGefElement(
SWTBotGefEditPart element) {
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
@@ -862,20 +864,20 @@ public class EditorProxy {
if (el == null)
return null;
Object bo = fp.getBusinessObjectForPictogramElement(el);
- if (bo instanceof JavaPersistentType) {
- return (JavaPersistentType) bo;
+ if (bo instanceof PersistentType) {
+ return (PersistentType) bo;
}
return null;
}
- public JavaPersistentAttribute getJPAObjectForGefElement(
+ public PersistentAttribute getJPAObjectForGefElement(
SWTBotGefEditPart element) {
final IFeatureProvider fp = ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
PictogramElement el = (PictogramElement) element.part().getModel();
Object bo = fp.getBusinessObjectForPictogramElement(el);
- if (bo instanceof JavaPersistentAttribute) {
- return (JavaPersistentAttribute) bo;
+ if (bo instanceof PersistentAttribute) {
+ return (PersistentAttribute) bo;
}
return null;
}
@@ -908,10 +910,10 @@ public class EditorProxy {
PictogramElement el = (PictogramElement) element.part().getModel();
Object bo = fp.getBusinessObjectForPictogramElement(el);
IResource res = null;
- if (bo instanceof JavaPersistentAttribute) {
- res = ((JavaPersistentAttribute) bo).getResource();
- } else if (bo instanceof JavaPersistentType) {
- res = ((JavaPersistentType) bo).getResource();
+ if (bo instanceof PersistentAttribute) {
+ res = ((PersistentAttribute) bo).getResource();
+ } else if (bo instanceof PersistentType) {
+ res = ((PersistentType) bo).getResource();
}
if (res != null) {
@@ -1316,7 +1318,7 @@ public class EditorProxy {
* @return the name of the owner relationship attribute
*/
public String testOwnerRelationAttributeProperties(IRelation rel) {
- JavaPersistentAttribute ownerAttr = rel.getOwnerAnnotatedAttribute();
+ PersistentAttribute ownerAttr = rel.getOwnerAnnotatedAttribute();
String attributeName = rel.getOwnerAttributeName();
assertNotNull(ownerAttr);
assertNotNull(jpaDiagramEditor.getEditPart(attributeName));
@@ -1332,7 +1334,7 @@ public class EditorProxy {
*/
public String testEmbeddedAttributeProperties(HasReferanceRelation rel,
String attributeMapping) {
- JavaPersistentAttribute embeddedAttr = rel
+ PersistentAttribute embeddedAttr = rel
.getEmbeddedAnnotatedAttribute();
String attributeName = embeddedAttr.getName();
assertNotNull(embeddedAttr);
@@ -1350,7 +1352,7 @@ public class EditorProxy {
* @return the name of the inverse relationship attribute
*/
public String testInverseRelationAttributeProperties(IRelation rel) {
- JavaPersistentAttribute inverseAttr = rel
+ PersistentAttribute inverseAttr = rel
.getInverseAnnotatedAttribute();
String inverseAttributeName = rel.getInverseAttributeName();
assertNotNull(inverseAttr);
@@ -1928,9 +1930,9 @@ public class EditorProxy {
attribute.select();
attribute.click();
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
+ HashSet<String> annotations = getAnnotationNames(jpa);
assertTrue(annotations.contains(relationAnnotation));
assertTrue(annotations.contains(derivedIdAnnotation));
@@ -1944,17 +1946,19 @@ public class EditorProxy {
SWTBotGefEditPart owner, SWTBotGefEditPart inverse, SWTBotGefEditPart embeddable,
RelType reltype, String relationAnnotation, String derivedIdAnnotation, String linkLabel,
boolean isBiDir, boolean isSamePK, String idClassFQN){
- int sourceConnSize = owner.sourceConnections().size();
+ int sourceConnSize = owner.sourceConnections().size();
+
if(isBiDir){
jpaDiagramEditor.activateTool(relationFeatureName, 1);
} else {
jpaDiagramEditor.activateTool(relationFeatureName, 0);
}
jpaDiagramEditor.click(owner);
+
jpaDiagramEditor.click(inverse);
- bot.waitUntil(new ConnectionIsShown(owner, sourceConnSize), 10000);
+ bot.waitUntil(new ConnectionIsShown(owner, sourceConnSize), 20000);
waitASecond();
jpaDiagramEditor.activateDefaultTool();
@@ -1985,11 +1989,11 @@ public class EditorProxy {
attribute.select();
attribute.click();
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
+ HashSet<String> annotations = getAnnotationNames(jpa);
assertTrue(annotations.contains(relationAnnotation));
- assertTrue(annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID));
+ assertTrue(annotations.contains("MapsId"));
String helperAttributeName = null;
if(!isSamePK) {
@@ -2051,11 +2055,11 @@ public class EditorProxy {
attribute.select();
attribute.click();
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
+ HashSet<String> annotations = getAnnotationNames(jpa);
assertTrue(annotations.contains(relationAnnotation));
- assertTrue(annotations.contains(JPAEditorConstants.ANNOTATION_ID));
+ assertTrue(annotations.contains("Id"));
String helperAttributeName = null;
if(!isSamePK) {
@@ -2078,18 +2082,32 @@ public class EditorProxy {
private String assertContainsHelperAttrInEmbeddable(
SWTBotGefEditPart inverse, SWTBotGefEditPart embeddable,
- JavaPersistentAttribute jpa, String IdClassFQN) {
+ PersistentAttribute jpa, String IdClassFQN) {
String helperAttributeName = JPAEditorUtil.decapitalizeFirstLetter(getJPTObjectForGefElement(inverse).getSimpleName());
- SWTBotGefEditPart helperAttr = getAttributeInPE(embeddable, helperAttributeName);
- assertNotNull(helperAttr);
+// SWTBotGefEditPart helperAttr = getAttributeInPE(embeddable, helperAttributeName);
+
+ PersistentType pt = getJPTObjectForGefElement(embeddable);
+ PersistentAttribute helperAttr = pt.getAttributeNamed(helperAttributeName);
+ assertNotNull(pt.getAttributeNamed(helperAttributeName));
- Annotation an = jpa.getResourceAttribute().getAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertTrue(an instanceof MapsId2_0Annotation);
- String mapsIdValue = ((MapsId2_0Annotation)an).getValue();
- assertEquals(mapsIdValue, helperAttributeName);
+// embeddable.part().refresh();
+//
+// helperAttr = getAttributeInPE(embeddable, helperAttributeName);
+// assertNotNull(helperAttr);
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ assertTrue(SingleRelationshipMapping2_0.class.isInstance(attributeMapping));
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ assertTrue(identity.usesMapsIdDerivedIdentityStrategy());
+ assertEquals(helperAttributeName, identity.getMapsIdDerivedIdentityStrategy().getSpecifiedIdAttributeName());
+
+// Annotation an = jpa.getResourceAttribute().getAnnotation(MapsId2_0Annotation.ANNOTATION_NAME);
+// assertNotNull(an);
+// assertTrue(an instanceof MapsId2_0Annotation);
+// String mapsIdValue = ((MapsId2_0Annotation)an).getValue();
+// assertEquals(mapsIdValue, helperAttributeName);
- String helperAttrType = JPAEditorUtil.getAttributeTypeNameWithGenerics(getJPAObjectForGefElement(helperAttr));
+ String helperAttrType = JPAEditorUtil.getAttributeTypeNameWithGenerics(helperAttr);
if(IdClassFQN != null){
assertEquals(helperAttrType, IdClassFQN);
@@ -2103,13 +2121,23 @@ public class EditorProxy {
private String assertContainsHelperAttrInIdClass(
SWTBotGefEditPart inverse, IFile idClass,
- JavaPersistentAttribute jpa, String IdClassFQN) throws JavaModelException {
+ PersistentAttribute jpa, String IdClassFQN) throws JavaModelException {
IType idClassType = JavaCore.createCompilationUnitFrom(idClass).findPrimaryType();
assertNotNull(idClassType);
- Annotation an = jpa.getResourceAttribute().getAnnotation(IdAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
+// Annotation an = jpa.getResourceAttribute().getAnnotation(IdAnnotation.ANNOTATION_NAME);
+// assertNotNull(an);
+
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ assertTrue(SingleRelationshipMapping2_0.class.isInstance(attributeMapping));
+ DerivedIdentity2_0 identity = ((SingleRelationshipMapping2_0)attributeMapping).getDerivedIdentity();
+ assertTrue(identity.usesIdDerivedIdentityStrategy());
+// assertEquals(helperAttributeName, identity.getIdDerivedIdentityStrategy()..getSpecifiedIdAttributeName());
+
+// AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+// assertTrue(IdMapping.class.isInstance(attributeMapping));
IField helperAttr = idClassType.getField(jpa.getName());
assertNotNull(helperAttr);
@@ -2172,9 +2200,9 @@ public class EditorProxy {
attribute.select();
attribute.click();
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
+ HashSet<String> annotations = getAnnotationNames(jpa);
assertTrue(annotations.contains(relationAnnotation));
assertTrue(annotations.contains(derivedIdAnnotation));
@@ -2219,11 +2247,11 @@ public class EditorProxy {
attribute.select();
attribute.click();
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(attribute);
+ PersistentAttribute jpa = getJPAObjectForGefElement(attribute);
- HashSet<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(jpa);
- assertTrue(annotations.contains(JPAEditorConstants.ANNOTATION_ONE_TO_ONE));
- assertTrue(annotations.contains(JPAEditorConstants.ANNOTATION_MAPS_ID));
+ HashSet<String> annotations = getAnnotationNames(jpa);
+ assertTrue(annotations.contains("OneToOne"));
+ assertTrue(annotations.contains("MapsId"));
}
public void testSelfUniDirRelation(String relationFeatureName,
@@ -2241,7 +2269,7 @@ public class EditorProxy {
waitASecond();
jpaDiagramEditor.activateDefaultTool();
- assertSelfConnectionIsCreated(entity);
+// assertSelfConnectionIsCreated(entity);
SWTBotGefConnectionEditPart connection = getConnection(entity, entity);
assertNotNull("Connection must be shown in the diagram.", connection);
@@ -2624,9 +2652,9 @@ public class EditorProxy {
assertTypeIsCorretlyMapped(superclass, superclassMappingLinkLabel);
assertTypeIsCorretlyMapped(inheritedEntity,
- JptUiDetailsMessages.EntityUiProvider_linkLabel);
+ JptJpaUiDetailsMessages.EntityUiProvider_linkLabel);
- JavaPersistentType superJPT = (JavaPersistentType) getJPTObjectForGefElement(
+ PersistentType superJPT = getJPTObjectForGefElement(
inheritedEntity).getSuperPersistentType();
assertNotNull("The entity must has a super persitent type.", superJPT);
assertEquals(
@@ -2811,7 +2839,7 @@ public class EditorProxy {
embeddable);
assertNotNull("Connection must be shown in the diagram.", connection);
- JavaPersistentType emb = getJPTObjectForGefElement(embeddable);
+ PersistentType emb = getJPTObjectForGefElement(embeddable);
String embAttr = JPAEditorUtil.decapitalizeFirstLetter(emb
.getSimpleName());
@@ -2833,8 +2861,7 @@ public class EditorProxy {
assertAttributeIsCorretlyMapped(attributeName, linkLabel);
- JavaPersistentType parententity = (JavaPersistentType) rel
- .getEmbeddedAnnotatedAttribute().getOwningPersistentType();
+ PersistentType parententity = rel.getEmbeddedAnnotatedAttribute().getDeclaringPersistentType();
assertEquals("The entity must contain an embedded attribute.",
parententity, getJPTObjectForGefElement(embeddingEntity));
assertEquals(rel.getEmbeddingEntity(),
@@ -2850,7 +2877,7 @@ public class EditorProxy {
public String getUniqueAttrName(SWTBotGefEditPart jptType) {
IJPAEditorFeatureProvider fp = (IJPAEditorFeatureProvider) ((DiagramEditPart) jpaDiagramEditor
.mainEditPart().part()).getFeatureProvider();
- JavaPersistentType jpt = getJPTObjectForGefElement(jptType);
+ PersistentType jpt = getJPTObjectForGefElement(jptType);
String attrName = JpaArtifactFactory.instance().genUniqueAttrName(jpt,
"java.lang.String", fp);
@@ -2898,7 +2925,7 @@ public class EditorProxy {
deleteDiagramElements();
Utils.printFormatted(">>>>>>>>>>>> elements are deleted from the diagram.");
- ListIterator<PersistenceUnit> lit = jpaProject.getRootContextNode()
+ ListIterator<PersistenceUnit> lit = jpaProject.getContextModelRoot()
.getPersistenceXml().getRoot().getPersistenceUnits().iterator();
PersistenceUnit pu = lit.next();
Iterator<PersistentType> persistentTypesIterator = (Iterator<PersistentType>) pu
@@ -2926,15 +2953,15 @@ public class EditorProxy {
String embeddedAttributeName = embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity,
embeddable, HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel,
3);
SWTBotGefEditPart embeddedAttribute = getAttributeInPE(embeddingEntity,
embeddedAttributeName);
assertNotNull(embeddedAttribute);
- JavaPersistentAttribute jpa = getJPAObjectForGefElement(embeddedAttribute);
- jpa.setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
+ PersistentAttribute jpa = getJPAObjectForGefElement(embeddedAttribute);
+ jpa.getJavaPersistentAttribute().setMappingKey(MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY);
}
/**
@@ -2971,9 +2998,30 @@ public class EditorProxy {
throws IOException, CoreException, JavaModelException {
IFile idClass = JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, idClassName);
- JavaPersistentType jptType= getJPTObjectForGefElement(entity);
- Annotation an = jptType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- ((IdClassAnnotation)an).setValue(idClassName);
+ PersistentType jptType= getJPTObjectForGefElement(entity);
+
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(jptType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(idClassName);
+
+// Annotation an = jptType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
+// ((IdClassAnnotation)an).setValue(idClassName);
return idClass;
}
+
+ /**
+ * Get all annotations as string for the given attribute.
+ * @param persistentAttribite
+ * @return a set of strings of all current annotation names of the given attribute.
+ */
+ public HashSet<String> getAnnotationNames(PersistentAttribute persistentAttribite) {
+ HashSet<String> res = new HashSet<String>();
+ if(persistentAttribite != null) {
+ JavaResourceAttribute jrpt = persistentAttribite.getJavaPersistentAttribute().getResourceAttribute();
+ for (Annotation annotation : jrpt.getAnnotations()) {
+ res.add(JPAEditorUtil.returnSimpleName(annotation.getAnnotationName()));
+ }
+ }
+ return res;
+ }
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
index 678e001198..f47e448831 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EmbeddableInDiagramSWTBotTest.java
@@ -7,13 +7,14 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0;
-import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
-import org.eclipse.jpt.jpa.ui.internal.jpa2.details.JptUiDetailsMessages2_0;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
+import org.eclipse.jpt.jpa.ui.jpa2.details.JptJpaUiDetailsMessages2_0;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.HasReferanceRelation.HasReferenceType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IRelation;
+import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -235,7 +236,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
embeddable2, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy.deleteDiagramElements();
@@ -731,7 +732,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, entity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -759,7 +760,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, entity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
2);
editorProxy.deleteDiagramElements();
@@ -788,7 +789,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddable1,
embeddable2, HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -817,7 +818,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
embeddable2, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
2);
editorProxy.deleteDiagramElements();
@@ -849,7 +850,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
embeddable2, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
2);
SWTBotGefEditPart entity = editorProxy.addEntityToDiagram(200, 50,
@@ -861,10 +862,13 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, entity,
embeddable2, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
4);
- editorProxy.deleteAttributeInJPT(embeddable1, "embeddable2");
+
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable2).getSimpleName();
+ String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
+ editorProxy.deleteAttributeInJPT(embeddable1, embeddingAttributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -895,7 +899,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable1,
embeddable2, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
2);
SWTBotGefEditPart embeddable3 = editorProxy.addEmbeddableToDiagram(200, 50,
@@ -907,10 +911,12 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy._testEmbeddedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddable3,
embeddable2, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
4);
- editorProxy.deleteAttributeInJPT(embeddable1, "embeddable2");
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable2).getSimpleName();
+ String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
+ editorProxy.deleteAttributeInJPT(embeddable1, embeddingAttributeName);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1131,7 +1137,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testBiDirRel(
@@ -1139,7 +1145,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelRemoveInverseAttribute(
@@ -1147,7 +1153,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelRemoveOwnerAttr(
@@ -1155,7 +1161,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1194,7 +1200,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testBiDirRelWithTwoMappingTypes(
@@ -1202,8 +1208,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelWithTwoMappingsWithoutInverseAttr(
@@ -1211,8 +1217,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelWithTwoMappingsWithoutOwnerAttr(
@@ -1220,8 +1226,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1261,7 +1267,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testBiDirRel(
@@ -1269,7 +1275,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy
.testBiDirRelRemoveInverseAttribute(
@@ -1277,7 +1283,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy
.testBiDirRelRemoveOwnerAttr(
@@ -1285,7 +1291,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1323,7 +1329,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testUniDirRelation(
@@ -1331,7 +1337,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1339,7 +1345,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1377,7 +1383,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testUniDirRelation(
@@ -1385,7 +1391,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1393,7 +1399,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1431,7 +1437,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testUniDirRelation(
@@ -1439,7 +1445,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1447,7 +1453,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1485,7 +1491,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy
@@ -1494,7 +1500,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelRemoveInverseAttribute(
@@ -1502,7 +1508,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelRemoveOwnerAttr(
@@ -1510,7 +1516,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1549,7 +1555,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy
@@ -1558,8 +1564,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelWithTwoMappingsWithoutInverseAttr(
@@ -1567,8 +1573,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy
.testBiDirRelWithTwoMappingsWithoutOwnerAttr(
@@ -1576,8 +1582,8 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1609,12 +1615,12 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testNoConnectionIsCreatedWithEmbeddable(
@@ -1627,7 +1633,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1635,7 +1641,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1667,12 +1673,12 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testNoConnectionIsCreatedWithEmbeddable(
@@ -1685,7 +1691,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1693,7 +1699,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1725,12 +1731,12 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity1, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy.embedConnection(JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, embeddingEntity2, embeddable,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 3);
editorProxy
.testNoConnectionIsCreatedWithEmbeddable(
@@ -1743,7 +1749,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1751,7 +1757,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1789,7 +1795,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy
@@ -1798,7 +1804,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1806,7 +1812,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1844,7 +1850,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy
@@ -1853,7 +1859,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy
.testUniDirRelRemoveOwnerAttribute(
@@ -1861,7 +1867,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
embeddable,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1901,7 +1907,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy
@@ -1946,7 +1952,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(JPAEditorMessages.EmbedCollectionOfObjectsFeature_ElementCollectionFeatureName, embeddingEntity,
embeddable, HasReferenceType.COLLECTION,
MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages2_0.ElementCollectionMapping2_0_linkLabel,
+ JptJpaUiDetailsMessages2_0.ELEMENT_COLLECTION_MAPPING_LINK_LABEL,
3);
editorProxy
@@ -2000,7 +2006,7 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.embedConnection(jpaDiagramEditor10, JPAEditorMessages.EmbedSingleObjectFeature_EmbeddedFeatureName, entity, embeddable1,
HasReferenceType.SINGLE,
MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY,
- JptUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
+ JptJpaUiDetailsMessages.EmbeddedMappingUiProvider_linkLabel, 2);
SWTBotGefEditPart entity1 = editorProxy.addEntityToDiagram(300, 300,
jpaProject);
@@ -2039,7 +2045,9 @@ public class EmbeddableInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
1, embeddable1, entity1);
- editorProxy.deleteAttributeInJPT(entity, "embeddable1");
+ String embeddableName = editorProxy.getJPTObjectForGefElement(embeddable1).getSimpleName();
+ String embeddingAttributeName = JPAEditorUtil.decapitalizeFirstLetter(embeddableName);
+ editorProxy.deleteAttributeInJPT(entity, embeddingAttributeName);
editorProxy.deleteDiagramElements();
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
index 04f65bc1ba..089c066ac4 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/EntitiesInDiagramSWTBotTest.java
@@ -7,11 +7,11 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.common.core.resource.java.Annotation;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.jpa.core.context.Entity;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.TypeMapping;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -1109,7 +1109,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
// create One-to-One unidirectional relation from entity1 to entity2
editorProxy
@@ -1118,7 +1118,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1149,7 +1149,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
entity1,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1185,7 +1185,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
// create One-to-One bidirectional relation from entity1 to entity2
editorProxy
@@ -1194,7 +1194,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
// create One-to-One bidirectional relation from entity1 to entity2
editorProxy
@@ -1203,7 +1203,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1233,7 +1233,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
entity1,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1268,7 +1268,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_MANY,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
// create One-to-One bidirectional relation from entity1 to entity2
editorProxy
@@ -1277,7 +1277,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.ONE_TO_MANY,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -1309,7 +1309,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateOneToManyUniDirRelationFeature_oneToManyUniDirFeatureName,
entity1,
IRelation.RelType.ONE_TO_MANY,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -1344,7 +1344,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
// create Many-to-One bidirectional relation from entity1 to entity2
editorProxy
@@ -1353,7 +1353,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1384,7 +1384,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
entity1,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1420,8 +1420,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
// create Many-to-One bidirectional relation from entity1 to entity2
editorProxy
@@ -1430,8 +1430,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
// create Many-to-One bidirectional relation from entity1 to entity2
editorProxy
@@ -1440,8 +1440,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -1472,8 +1472,8 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
entity1,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
jpaDiagramEditor.save();
@@ -1507,7 +1507,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
// create Many-to-Many bidirectional relation from entity1 to entity2
editorProxy
@@ -1516,7 +1516,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -1547,7 +1547,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateManyToManyUniDirRelationFeature_manyToManyUniDirFeatureName,
entity1,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -1583,7 +1583,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
// create Many-to-Many bidirectional relation from entity1 to entity2
editorProxy
@@ -1592,7 +1592,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
// create Many-to-Many bidirectional relation from entity1 to entity2
editorProxy
@@ -1601,7 +1601,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
entity1,
entity2,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -1632,7 +1632,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPAEditorMessages.CreateManyToManyBiDirRelationFeature_manyToManyBiDirFeatureName,
entity1,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -1656,7 +1656,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
jpaProject);
editorProxy.createInheritedEntity(entity1, jpaProject,
- JptUiDetailsMessages.EntityUiProvider_linkLabel, false, false);
+ JptJpaUiDetailsMessages.EntityUiProvider_linkLabel, false, false);
editorProxy.deleteDiagramElements();
@@ -1695,7 +1695,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
editorProxy.testCreateAndDeleteIsARelation(superclass, subclassName,
- JptUiDetailsMessages.EntityUiProvider_linkLabel, false,
+ JptJpaUiDetailsMessages.EntityUiProvider_linkLabel, false,
superclassName, subclass, true);
editorProxy.deleteDiagramElements();
@@ -1730,20 +1730,20 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.deleteEntityDefaultPK(dependentEntity);
editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "Id", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "Id", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "Id", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "Id", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
Utils.sayTestFinished("testSimpleDerivedIdWithoutDefaultPK");
}
@@ -1770,20 +1770,20 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
jpaProject);
editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel);
editorProxy.testUniDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
editorProxy.testBiDirDerivedIdWithIdAnnotation(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
+ dependentEntity, parentEntity, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel);
Utils.sayTestFinished("testSimpleDerivedIdWithDefaultPK");
}
@@ -1821,20 +1821,20 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, null);
Utils.sayTestFinished("testDerivedIdWithEmbeddedPK");
}
@@ -1864,20 +1864,20 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
IFile idClass = editorProxy.setIdClass(dependentEntity, "TestIdClass", jpaProject);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, null);
Utils.sayTestFinished("testDerivedIdWithIdClassPK");
}
@@ -1907,25 +1907,27 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
SWTBotGefEditPart dependentEntity = editorProxy.addEntityToDiagram(50, 300,
jpaProject);
- JavaPersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
- Annotation an = parentJPTType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- ((IdClassAnnotation)an).setValue(idClassFQN);
+ PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
+
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
Utils.sayTestFinished("testDerivedIdWithSameIdClassPK");
}
@@ -1962,20 +1964,20 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
Utils.sayTestFinished("testDerivedIdWithDifferentIdClassPK");
}
@@ -2013,19 +2015,19 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
Utils.sayTestFinished("testDerivedIdWithSameEmbeddedPK");
}
@@ -2040,6 +2042,7 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
* Test that the created relation is successfully deleted. Repeats all steps for the other three
* types of relation also.
*/
+ @Ignore
@Test
public void testDerivedIdWithDifferentEmbeddedPK(){
Utils.sayTestStarted("testDerivedIdWithDifferentEmbeddedPK");
@@ -2069,20 +2072,21 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
String idClassFQN = editorProxy.getJPTObjectForGefElement(parentEmbeddable).getName();
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
-
+ dependentEntity, parentEntity, dependentEmbeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+
Utils.sayTestFinished("testDerivedIdWithDifferentEmbeddedPK");
}
@@ -2114,9 +2118,10 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, "TestIdClass");
String idClassFQN = "org.persistence.TestIdClass";
- JavaPersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(parentEntity);
- Annotation an = parentJPTType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- ((IdClassAnnotation)an).setValue("TestIdClass");
+ PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(parentEntity);
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName("TestIdClass");
SWTBotGefEditPart embeddable = editorProxy.addEmbeddableToDiagram(300, 50, jpaProject);
@@ -2124,20 +2129,20 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
Utils.sayTestFinished("testDerivedIdWithIdClassAndEmbeddedPK");
}
@@ -2180,26 +2185,28 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
editorProxy.addAttributeToJPT(embeddable, attrname);
- JavaPersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(parentEntity);
- Annotation an = parentJPTType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- ((IdClassAnnotation)an).setValue(editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName());
-
+ PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(parentEntity);
+
+ String className = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(className);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithEmbeddedPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, embeddable, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
Utils.sayTestFinished("testDerivedIdWithIdClassAndSameEmbeddedPK");
}
@@ -2238,26 +2245,27 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
IFile idClass = JPACreateFactory.instance().createIdClassInProject(jpaProject.getProject(), new String[] {"org", "persistence"}, "TestIdClass");
String idClassFQN = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
- JavaPersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
- Annotation an = parentJPTType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- ((IdClassAnnotation)an).setValue("TestIdClass");
+ PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName("TestIdClass");
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, false, idClassFQN);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
+ dependentEntity, parentEntity, idClass, IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, false, idClassFQN);
Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndIdClass");
}
@@ -2299,26 +2307,27 @@ public class EntitiesInDiagramSWTBotTest extends SWTBotGefTestCase {
String attrnamString = editorProxy.getUniqueAttrName(parentEntity);
editorProxy.addAttributeToJPT(parentEntity, attrnamString);
- JavaPersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
- Annotation an = parentJPTType.getJavaResourceType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- ((IdClassAnnotation)an).setValue(editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName());
-
+ PersistentType parentJPTType= editorProxy.getJPTObjectForGefElement(dependentEntity);
+ String className = editorProxy.getJPTObjectForGefElement(embeddable).getSimpleName();
+ TypeMapping typeMapping = JpaArtifactFactory.instance().getTypeMapping(parentJPTType);
+ assertTrue(Entity.class.isInstance(typeMapping));
+ ((Entity)typeMapping).getIdClassReference().setSpecifiedIdClassName(className);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneUniDirRelationFeature_oneToOneUniDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateOneToOneBiDirRelationFeature_oneToOneBiDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.ONE_TO_ONE, JPAEditorConstants.ANNOTATION_ONE_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.ONE_TO_ONE, "OneToOne",
+ "MapsId", JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true, true, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneUniDirRelationFeature_manyToOneUniDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
+ dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, false, true, null);
editorProxy.testUniDirDerivedIdWithIdClassPk(JPAEditorMessages.CreateManyToOneBiDirRelationFeature_manyToOneBiDirFeatureName,
- dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.MANY_TO_ONE, JPAEditorConstants.ANNOTATION_MANY_TO_ONE,
- JPAEditorConstants.ANNOTATION_MAPS_ID, JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
+ dependentEntity, parentEntity, (IFile)parentJPTType.getResource(), IRelation.RelType.MANY_TO_ONE, "ManyToOne",
+ "MapsId", JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true, true, null);
Utils.sayTestFinished("testDerivedIdWithEmbeddedPkAndSameIdClass");
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java
index 1dcf927674..511b05f358 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.swtbot.tests/src/org/eclipse/jpt/jpadiagrameditor/swtbot/tests/ui/editor/MappedSuperclassesInDiagramSWTBotTest.java
@@ -4,7 +4,7 @@ import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.ui.internal.parts.DiagramEditPart;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.ui.internal.details.JptUiDetailsMessages;
+import org.eclipse.jpt.jpa.ui.details.JptJpaUiDetailsMessages;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.JPACreateFactory;
import org.eclipse.jpt.jpadiagrameditor.swtbot.tests.internal.Utils;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
@@ -679,7 +679,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
.addMappedSuperclassToDiagram(50, 50, jpaProject);
editorProxy.createInheritedEntity(mappedSuperclass, jpaProject,
- JptUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
true, false);
editorProxy.deleteDiagramElements();
@@ -720,7 +720,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
editorProxy.testCreateAndDeleteIsARelation(superclass, subclassName,
- JptUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
true, superclassName, subclass, false);
editorProxy.deleteDiagramElements();
@@ -765,7 +765,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
editorProxy.waitASecond();
editorProxy.testIsARelationProperties(superclass, subclassName,
- JptUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
+ JptJpaUiDetailsMessages.MappedSuperclassUiProvider_linkLabel,
true, superclassName, subclass, false);
SWTBotGefEditPart secondSuperclass = editorProxy.addEntityToDiagram(
@@ -816,7 +816,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
mappedSuperclass,
entity,
IRelation.RelType.ONE_TO_ONE,
- JptUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.OneToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -851,7 +851,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
mappedSuperclass,
entity,
IRelation.RelType.ONE_TO_MANY,
- JptUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.OneToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
@@ -886,7 +886,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
mappedSuperclass,
entity,
IRelation.RelType.MANY_TO_ONE,
- JptUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
+ JptJpaUiDetailsMessages.ManyToOneMappingUiProvider_linkLabel, true);
editorProxy.deleteDiagramElements();
@@ -922,7 +922,7 @@ public class MappedSuperclassesInDiagramSWTBotTest extends SWTBotGefTestCase {
mappedSuperclass,
entity,
IRelation.RelType.MANY_TO_MANY,
- JptUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
+ JptJpaUiDetailsMessages.ManyToManyMappingUiProvider_linkLabel, false);
editorProxy.deleteDiagramElements();
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java
index 52884b411c..f5e07f8ffd 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/JPACreateFactory.java
@@ -48,9 +48,8 @@ import org.eclipse.jpt.jpa.core.JpaFile;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.JpaStructureNode;
import org.eclipse.jpt.jpa.core.context.JpaContextModelRoot;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetDataModelProperties;
import org.eclipse.jpt.jpa.core.internal.facet.JpaFacetInstallDataModelProperties;
@@ -578,13 +577,13 @@ public class JPACreateFactory {
}
public void addAttributes(IFile entity, String attName, String attType, String annotation, String attActName, boolean isCollection){
- JavaPersistentType javaPersistentType = (JavaPersistentType)getPersistentType(entity);
+ PersistentType javaPersistentType = (PersistentType)getPersistentType(entity);
int cnt = 0;
while ((javaPersistentType == null) && (cnt < 100)) {
try {
Thread.sleep(250);
} catch (InterruptedException e) {}
- javaPersistentType = (JavaPersistentType)getPersistentType(entity);
+ javaPersistentType = getPersistentType(entity);
cnt++;
}
if (javaPersistentType == null)
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java
index 9cbd9e4ee1..475a212061 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/editor/EditorTest.java
@@ -20,6 +20,7 @@ import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertNotNull;
+
import org.easymock.EasyMock;
import org.eclipse.gef.EditPart;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
@@ -39,7 +40,7 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleListener;
-@SuppressWarnings({"restriction", "nls"})
+@SuppressWarnings({"nls"})
public class EditorTest {
@Test
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddAttributeFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddAttributeFeatureTest.java
index 932ec7d2a2..9d98e548db 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddAttributeFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/AddAttributeFeatureTest.java
@@ -36,7 +36,7 @@ import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
import org.eclipse.graphiti.mm.algorithms.Text;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.AddAttributeFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.junit.Before;
@@ -48,7 +48,7 @@ public class AddAttributeFeatureTest {
private AddContext context;
- private JavaSpecifiedPersistentAttribute jpa;
+ private PersistentAttribute jpa;
private ContainerShape entityShape;
@@ -62,7 +62,7 @@ public class AddAttributeFeatureTest {
@Before
public void setUp() throws Exception {
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
- jpa = EasyMock.createMock(JavaSpecifiedPersistentAttribute.class);
+ jpa = EasyMock.createMock(PersistentAttribute.class);
context = new AddContext();
context.setNewObject(jpa);
context.setTargetContainer(entityShape);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java
index ba66a6aa3c..d7e5d2e9ab 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/ClickAddFeatureTest.java
@@ -19,6 +19,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertNotNull;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
@@ -29,7 +30,7 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.ClickAddAttributeButtonFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
@@ -47,7 +48,7 @@ public class ClickAddFeatureTest {
final String TEST_PROJECT = "Test";
private JpaProject jpaProject = null;
private JPACreateFactory factory = null;
- JavaPersistentType jpt = null;
+ PersistentType jpt = null;
ICompilationUnit cu = null;
@Before
@@ -68,11 +69,11 @@ public class ClickAddFeatureTest {
IDirectEditingInfo dei = EasyMock.createMock(IDirectEditingInfo.class);
dei.setActive(true);
Thread.sleep(2000);
- jpt = (JavaPersistentType)JPACreateFactory.getPersistentType(entity);
+ jpt = (PersistentType)JPACreateFactory.getPersistentType(entity);
int cnt = 0;
while ((cnt < 50) && (jpt == null)) {
Thread.sleep(200);
- jpt = (JavaPersistentType)JPACreateFactory.getPersistentType(entity);
+ jpt = (PersistentType)JPACreateFactory.getPersistentType(entity);
cnt++;
}
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
@@ -85,7 +86,7 @@ public class ClickAddFeatureTest {
cu = JavaCore.createCompilationUnitFrom(entity);
cnt++;
}
- expect(featureProvider.getCompilationUnit((JavaPersistentType) EasyMock.anyObject())).andReturn(cu).anyTimes();
+ expect(featureProvider.getCompilationUnit((PersistentType) EasyMock.anyObject())).andReturn(cu).anyTimes();
expect(featureProvider.addIfPossible(isA(IAddContext.class))).andStubReturn(null);
expect(featureProvider.getDirectEditingInfo()).andStubReturn(dei);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java
index bed0addb0f..9a24037eb2 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateDeleteOnlyAttributeTest.java
@@ -22,8 +22,10 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -44,6 +46,7 @@ import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -59,7 +62,7 @@ public class CreateDeleteOnlyAttributeTest {
final String TEST_PROJECT = "Test";
private JpaProject jpaProject = null;
private JPACreateFactory factory = null;
- JavaPersistentType jpt = null;
+ PersistentType jpt = null;
@Before
public void setUp() throws Exception{
@@ -67,19 +70,19 @@ public class CreateDeleteOnlyAttributeTest {
jpaProject = factory.createJPAProject(TEST_PROJECT + "_" + System.currentTimeMillis());
assertNotNull(jpaProject);
IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1");
- jpt = (JavaPersistentType)JPACreateFactory.getPersistentType(entity);
+ jpt = (PersistentType)JPACreateFactory.getPersistentType(entity);
int c = 0;
while ((jpt == null) && (c < 100)) {
try {
Thread.sleep(250);
} catch (Exception e) {}
- jpt = (JavaPersistentType)JPACreateFactory.getPersistentType(entity);
+ jpt = (PersistentType)JPACreateFactory.getPersistentType(entity);
c++;
}
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(isA(ContainerShape.class))).andStubReturn(jpt);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
expect(featureProvider.addIfPossible(isA(IAddContext.class))).andStubReturn(null);
expect(featureProvider.getPictogramElementForBusinessObject(jpt)).andStubReturn(isA(ContainerShape.class));
ICompilationUnit cu = JavaCore.createCompilationUnitFrom(entity);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java
index c1bb10a536..38d40a9f00 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/CreateRelationFeaturesTest.java
@@ -15,11 +15,13 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-
-import java.util.HashSet;
-import java.util.Iterator;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
@@ -34,8 +36,10 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToManyBiDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToManyUniDirRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.CreateManyToOneBiDirRelationFeature;
@@ -54,7 +58,6 @@ import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.OneToManyUniDirRel
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.OneToOneBiDirRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.OneToOneUniDirRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
-import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory;
import org.junit.Before;
@@ -92,12 +95,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -143,7 +146,7 @@ public class CreateRelationFeaturesTest {
assertSame(rel.getInverse(), t2);
assertNotNull(t1.getAttributeNamed(rel.getOwnerAttributeName()));
assertTrue(JpaArtifactFactory.instance().isMethodAnnotated(t1));
- JavaSpecifiedPersistentAttribute jpa = t1.getAttributeNamed("id");
+ PersistentAttribute jpa = t1.getAttributeNamed("id");
assertFalse(isRelationAnnotated(jpa));
jpa = t1.getAttributeNamed(rel.getOwnerAttributeName());
assertTrue(isRelationAnnotated(jpa));
@@ -166,12 +169,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -233,12 +236,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -299,12 +302,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -365,12 +368,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -430,12 +433,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -495,12 +498,12 @@ public class CreateRelationFeaturesTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -549,14 +552,10 @@ public class CreateRelationFeaturesTest {
return JavaCore.createCompilationUnitFrom(file);
}
- private boolean isRelationAnnotated(JavaSpecifiedPersistentAttribute jpa) {
-
- HashSet<String> anNames = JpaArtifactFactory.instance().getAnnotationNames(jpa);
- Iterator<String> it = anNames.iterator();
- while (it.hasNext()) {
- String anName = it.next();
- if (JPAEditorConstants.RELATION_ANNOTATIONS.contains(anName))
- return true;
+ private boolean isRelationAnnotated(PersistentAttribute jpa) {
+ AttributeMapping mapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ if(mapping instanceof RelationshipMapping){
+ return true;
}
return false;
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java
index cdcb83c87e..5500a02f22 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DeleteRelationFeatureTest.java
@@ -25,7 +25,7 @@ import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.features.context.IRemoveContext;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.jdt.core.ICompilationUnit;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DeleteRelationFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.IBidirectionalRelation;
@@ -48,8 +48,8 @@ public class DeleteRelationFeatureTest {
IBidirectionalRelation rel = EasyMock.createMock(IBidirectionalRelation.class);
ICompilationUnit cu1 = EasyMock.createMock(ICompilationUnit.class);
ICompilationUnit cu2 = EasyMock.createMock(ICompilationUnit.class);
- JavaPersistentType jpt1 = EasyMock.createMock(JavaPersistentType.class);
- JavaPersistentType jpt2 = EasyMock.createMock(JavaPersistentType.class);
+ PersistentType jpt1 = EasyMock.createMock(PersistentType.class);
+ PersistentType jpt2 = EasyMock.createMock(PersistentType.class);
expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(rel);
expect(rel.getOwner()).andStubReturn(jpt1);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DirectEditAttributeFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DirectEditAttributeFeatureTest.java
index c62e9361df..8c9075885a 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DirectEditAttributeFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/DirectEditAttributeFeatureTest.java
@@ -27,8 +27,8 @@ import org.eclipse.graphiti.features.IDirectEditingFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.IDirectEditingContext;
import org.eclipse.jdt.core.JavaConventions;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DirectEditAttributeFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.i18n.JPAEditorMessages;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -47,8 +47,8 @@ public class DirectEditAttributeFeatureTest {
@Test
public void testCheckValueValidStringByJavaConventions() {
- JavaPersistentType jpt = EasyMock.createNiceMock(JavaPersistentType.class);
- JavaSpecifiedPersistentAttribute jpa = configureJpaForJpt(jpt);
+ PersistentType jpt = EasyMock.createNiceMock(PersistentType.class);
+ PersistentAttribute jpa = configureJpaForJpt(jpt);
expect(jpt.getAttributeNamed(isA(String.class))).andStubReturn(jpa);
replay(jpa, jpt);
@@ -65,11 +65,11 @@ public class DirectEditAttributeFeatureTest {
@Test
public void testCheckValueValidStringDuplicateAttribute() {
- JavaSpecifiedPersistentAttribute otherJpa = EasyMock.createMock(JavaSpecifiedPersistentAttribute.class);
- JavaPersistentType jpt = EasyMock.createMock(JavaPersistentType.class);
+ PersistentAttribute otherJpa = EasyMock.createMock(PersistentAttribute.class);
+ PersistentType jpt = EasyMock.createMock(PersistentType.class);
expect(jpt.getAttributeNamed("attrName")).andStubReturn(otherJpa);
- JavaSpecifiedPersistentAttribute jpa = configureJpaForJpt(jpt);
+ PersistentAttribute jpa = configureJpaForJpt(jpt);
replay(jpa, jpt, otherJpa);
IFeatureProvider provider = replayJpaForNullPe(jpa);
@@ -80,15 +80,15 @@ public class DirectEditAttributeFeatureTest {
assertEquals(MessageFormat.format(JPAEditorMessages.DirectEditAttributeFeature_attributeExists, "attrName"), feature.checkValueValid("attrName", context));
}
- private IFeatureProvider replayJpaForNullPe(JavaSpecifiedPersistentAttribute jpa) {
+ private IFeatureProvider replayJpaForNullPe(PersistentAttribute jpa) {
IFeatureProvider provider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(provider.getBusinessObjectForPictogramElement(null)).andStubReturn(jpa);
replay(provider);
return provider;
}
- private JavaSpecifiedPersistentAttribute configureJpaForJpt(JavaPersistentType jpt) {
- JavaSpecifiedPersistentAttribute jpa = EasyMock.createMock(JavaSpecifiedPersistentAttribute.class);
+ private PersistentAttribute configureJpaForJpt(PersistentType jpt) {
+ PersistentAttribute jpa = EasyMock.createMock(PersistentAttribute.class);
expect(jpa.getParent()).andStubReturn(jpt);
return jpa;
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/OpenMiniatureViewFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/OpenMiniatureViewFeatureTest.java
index 474e0cd048..88dd49e61a 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/OpenMiniatureViewFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/OpenMiniatureViewFeatureTest.java
@@ -25,7 +25,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.graphiti.features.context.IAddContext;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.OpenMiniatureViewFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory;
@@ -49,7 +49,7 @@ public class OpenMiniatureViewFeatureTest {
Thread.sleep(2000);
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
replay(featureProvider);
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RefactorAttributeTypeFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RefactorAttributeTypeFeatureTest.java
index 3ee7135713..e9c22dab3e 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RefactorAttributeTypeFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RefactorAttributeTypeFeatureTest.java
@@ -29,8 +29,8 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.graphiti.features.context.ICustomContext;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.RefactorAttributeTypeFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -83,14 +83,14 @@ public class RefactorAttributeTypeFeatureTest {
@Test
public void testAttributeUtils(){
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
- JavaPersistentType jpt = (JavaPersistentType)pu.getPersistentType("org.eclipse.Ent");
- JavaSpecifiedPersistentAttribute at = jpt.getAttributeNamed("id");
+ PersistentType jpt = pu.getPersistentType("org.eclipse.Ent");
+ PersistentAttribute at = jpt.getAttributeNamed("id");
List<String> lst = JpaArtifactFactory.instance().getAnnotationStrings(at);
assertEquals(1, lst.size());
assertTrue(lst.contains("@Id"));
String typeName1 = JPAEditorUtil.getAttributeTypeName(at);
assertEquals("int", typeName1);
- String typeName2 = JPAEditorUtil.getAttributeTypeName(at.getResourceAttribute());
+ String typeName2 = JPAEditorUtil.getAttributeTypeName(at.getJavaPersistentAttribute().getResourceAttribute());
assertEquals("int", typeName2);
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RemoveAttributeFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RemoveAttributeFeatureTest.java
index a1fcf4aea2..146de54ef9 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RemoveAttributeFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/RemoveAttributeFeatureTest.java
@@ -37,7 +37,7 @@ import org.eclipse.graphiti.mm.pictograms.Anchor;
import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.graphiti.mm.pictograms.Shape;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.RemoveAttributeFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.JPACreateFactory;
@@ -96,7 +96,7 @@ public class RemoveAttributeFeatureTest {
expect(featureProvider.decreaseAttribsNum(pictogramElement)).andReturn(0);
expect(featureProvider.getKeyForBusinessObject(isA(Object.class))).andReturn("");
expect(featureProvider.remove("")).andReturn(null);
- expect(featureProvider.getRelationRelatedToAttribute(isA(JavaSpecifiedPersistentAttribute.class))).andReturn(null);
+ expect(featureProvider.getRelationRelatedToAttribute(isA(PersistentAttribute.class), entity.getName())).andReturn(null);
replay(featureProvider);
context = EasyMock.createMock(IRemoveContext.class);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java
index 80a249f10f..ada8dadc54 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/feature/SaveEntityFeatureTest.java
@@ -15,8 +15,12 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.feature;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -27,7 +31,7 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.SaveEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -65,7 +69,7 @@ public class SaveEntityFeatureTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
int cnt = 0;
while ((cnt < 25) && (t1 == null)) {
Thread.sleep(200);
@@ -75,7 +79,7 @@ public class SaveEntityFeatureTest {
if (t1 == null)
return;
expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(t1);
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(createCompilationUnitFrom(customerFile)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(createCompilationUnitFrom(customerFile)).anyTimes();
SaveEntityFeature ft = new SaveEntityFeature(featureProvider);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java
index 19e416b6d1..4930ca9358 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/listener/JPAProjectListenerTest.java
@@ -19,6 +19,7 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertNotNull;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -33,7 +34,7 @@ import org.eclipse.graphiti.mm.pictograms.ContainerShape;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
@@ -61,7 +62,7 @@ public class JPAProjectListenerTest {
Thread.sleep(2000);
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
}
public ICompilationUnit createCompilationUnitFrom(IFile file) {
@@ -74,7 +75,7 @@ public class JPAProjectListenerTest {
slv.setFeatureProvider(featureProvider);
jpaProject.addCollectionChangeListener("mark", slv.new JPAProjectListener());
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
- JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT("org.eclipse.Entity1", pu);
+ PersistentType jpt = JpaArtifactFactory.instance().getJPT("org.eclipse.Entity1", pu);
ContainerShape cs = EasyMock.createMock(ContainerShape.class);
expect(featureProvider.getPictogramElementForBusinessObject(jpt)).andStubReturn(cs);
IRemoveFeature ft = EasyMock.createMock(IRemoveFeature.class);
@@ -91,7 +92,7 @@ public class JPAProjectListenerTest {
slv.setFeatureProvider(featureProvider);
jpaProject.addCollectionChangeListener("mark", slv.new JPAProjectListener());
PersistenceUnit pu = JpaArtifactFactory.instance().getPersistenceUnit(jpaProject);
- JavaPersistentType jpt = JpaArtifactFactory.instance().getJPT("org.eclipse.Entity1", pu);
+ PersistentType jpt = JpaArtifactFactory.instance().getJPT("org.eclipse.Entity1", pu);
expect(featureProvider.getPictogramElementForBusinessObject(jpt)).andStubReturn(null);
IRemoveFeature ft = EasyMock.createMock(IRemoveFeature.class);
expect(featureProvider.getRemoveFeature(isA(IRemoveContext.class))).andReturn(ft);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java
index a5a92e84c9..e18233bbdd 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/modelintegration/ui/ModelIntegrationTest.java
@@ -20,6 +20,7 @@ import static org.easymock.EasyMock.isA;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -35,7 +36,7 @@ import org.eclipse.graphiti.platform.IDiagramEditor;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.ui.JPAEditorMatchingStrategy;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.util.IModelIntegrationUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
@@ -71,7 +72,7 @@ public class ModelIntegrationTest {
Thread.sleep(2000);
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entityFile));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entityFile)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entityFile)).anyTimes();
}
@Test
@@ -83,7 +84,7 @@ public class ModelIntegrationTest {
ICompilationUnit cu = createCompilationUnitFrom(entityFile);
IJPAEditorUtil ut = EasyMock.createMock(IJPAEditorUtil.class);
- JavaPersistentType inputJptType = (JavaPersistentType) JPACreateFactory.getPersistentType(entityFile);
+ PersistentType inputJptType = JPACreateFactory.getPersistentType(entityFile);
expect(ut.getJPType(cu)).andStubReturn(inputJptType);
expect(featureProvider.getJPAEditorUtil()).andStubReturn(ut);
Diagram d = EasyMock.createMock(Diagram.class);
@@ -120,7 +121,7 @@ public class ModelIntegrationTest {
ICompilationUnit cu = createCompilationUnitFrom(entityFile);
IJPAEditorUtil ut = EasyMock.createMock(IJPAEditorUtil.class);
- JavaPersistentType inputJptType = (JavaPersistentType) JPACreateFactory.getPersistentType(entityFile);
+ PersistentType inputJptType = JPACreateFactory.getPersistentType(entityFile);
expect(ut.getJPType(cu)).andStubReturn(inputJptType);
expect(featureProvider.getJPAEditorUtil()).andStubReturn(ut);
Diagram d = EasyMock.createMock(Diagram.class);
@@ -178,7 +179,7 @@ public class ModelIntegrationTest {
// IFileEditorInput input = EasyMock.createMock(IFileEditorInput.class);
// IJPAEditorUtil ut = EasyMock.createMock(IJPAEditorUtil.class);
// expect(featureProvider.getJPAEditorUtil()).andStubReturn(ut);
-// JavaPersistentType jpt = EasyMock.createMock(JavaPersistentType.class);
+// PersistentType jpt = EasyMock.createMock(PersistentType.class);
// ICompilationUnit cu = JavaCore.createCompilationUnitFrom(entityFile);
// expect(ut.getJPType(cu)).andStubReturn(jpt);
// PersistenceUnit pu = EasyMock.createMock(PersistenceUnit.class);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorFeatureProviderTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorFeatureProviderTest.java
index 85ec90c9e3..1d93ea353f 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorFeatureProviderTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorFeatureProviderTest.java
@@ -30,8 +30,8 @@ import org.eclipse.graphiti.features.IDeleteFeature;
import org.eclipse.graphiti.features.context.IDeleteContext;
import org.eclipse.graphiti.mm.Property;
import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.ClickRemoveAttributeButtonFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DeleteJPAEntityFeature;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.feature.DeleteRelationFeature;
@@ -73,7 +73,7 @@ public class JPAEditorFeatureProviderTest {
@Test
public void testAttributeDeleteFeature(){
PictogramElement pe = replayPictogramElement();
- JavaSpecifiedPersistentAttribute jpa = replayAttribute();
+ PersistentAttribute jpa = replayAttribute();
expect(solver.getBusinessObjectForKey(businessObjectKey)).andStubReturn(jpa);
IJPAEditorFeatureProvider provider = createFeatureProvider();
@@ -87,7 +87,7 @@ public class JPAEditorFeatureProviderTest {
@Test
public void testEntityDeleteFeature(){
PictogramElement pe = replayPictogramElement();
- JavaPersistentType jpt = replayJPT("TestEntity");
+ PersistentType jpt = replayJPT("TestEntity");
expect(solver.getBusinessObjectForKey(businessObjectKey)).andStubReturn(jpt);
IJPAEditorFeatureProvider provider = createFeatureProvider();
@@ -102,8 +102,8 @@ public class JPAEditorFeatureProviderTest {
@Test
public void testRelationDeleteFeature(){
PictogramElement pe = replayPictogramElement();
- JavaPersistentType jpt1 = replayJPT("TestEntity1");
- JavaPersistentType jpt2 = replayJPT("TestEntity2");
+ PersistentType jpt1 = replayJPT("TestEntity1");
+ PersistentType jpt2 = replayJPT("TestEntity2");
IJPAEditorFeatureProvider provider = createFeatureProvider();
AbstractRelation relation = new ManyToManyUniDirRelation(provider, jpt1, jpt2, "attribute1", false);
@@ -116,15 +116,15 @@ public class JPAEditorFeatureProviderTest {
assertTrue(deleteFeature instanceof DeleteRelationFeature);
}
- private JavaPersistentType replayJPT(String name){
- JavaPersistentType jpt = EasyMock.createMock(JavaPersistentType.class);
+ private PersistentType replayJPT(String name){
+ PersistentType jpt = EasyMock.createMock(PersistentType.class);
expect(jpt.getName()).andReturn(name);
replay(jpt);
return jpt;
}
-
- private JavaSpecifiedPersistentAttribute replayAttribute(){
- JavaSpecifiedPersistentAttribute attribute = EasyMock.createMock(JavaSpecifiedPersistentAttribute.class);
+
+ private PersistentAttribute replayAttribute(){
+ PersistentAttribute attribute = EasyMock.createMock(PersistentAttribute.class);
expect(attribute.getName()).andReturn("attribute");
replay(attribute);
return attribute;
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorToolBehaviorProviderTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorToolBehaviorProviderTest.java
index 97049b8156..956fdf9a0f 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorToolBehaviorProviderTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/provider/JPAEditorToolBehaviorProviderTest.java
@@ -34,8 +34,9 @@ import org.eclipse.graphiti.mm.pictograms.PictogramElement;
import org.eclipse.graphiti.tb.IDecorator;
import org.eclipse.graphiti.tb.IToolBehaviorProvider;
import org.eclipse.graphiti.tb.ImageDecorator;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.modelintegration.ui.JPAEditorMatchingStrategy;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.JPAEditorToolBehaviorProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
@@ -58,7 +59,7 @@ public class JPAEditorToolBehaviorProviderTest {
public void testGetRenderingDecoratorsPictogramElementError() throws Exception {
PictogramElement pe = replayPictogramElement(100, 100);
IMarker marker = replayMarker(IMarker.SEVERITY_ERROR, "Error message");
- JavaPersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
+ PersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IToolBehaviorProvider provider = new JPAEditorToolBehaviorProvider(dtp);
@@ -72,7 +73,7 @@ public class JPAEditorToolBehaviorProviderTest {
PictogramElement pe = replayPictogramElement(100, 100);
IMarker marker = replayMarker(IMarker.SEVERITY_WARNING, "Warning message");
- JavaPersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
+ PersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IToolBehaviorProvider provider = new JPAEditorToolBehaviorProvider(dtp);
@@ -85,7 +86,7 @@ public class JPAEditorToolBehaviorProviderTest {
public void testGetRenderingDecoratorsPictogramElementInfo() throws Exception {
PictogramElement pe = replayPictogramElement(100, 100);
IMarker marker = replayMarker(IMarker.SEVERITY_INFO, "Info message");
- JavaPersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
+ PersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IToolBehaviorProvider provider = new JPAEditorToolBehaviorProvider(dtp);
@@ -97,7 +98,7 @@ public class JPAEditorToolBehaviorProviderTest {
@Test
public void testGetRenderingDecoratorsPictogramElementNoMarkers() throws Exception {
PictogramElement pe = replayPictogramElement(100, 100);
- JavaPersistentType jpt = replayJptWithMarker(new IMarker[0]);
+ PersistentType jpt = replayJptWithMarker(new IMarker[0]);
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IToolBehaviorProvider provider = new JPAEditorToolBehaviorProvider(dtp);
@@ -110,7 +111,7 @@ public class JPAEditorToolBehaviorProviderTest {
PictogramElement pe = replayPictogramElement(100, 100);
IMarker warningMarker = replayMarker(IMarker.SEVERITY_WARNING, "warning");
IMarker errorMarker = replayMarker(IMarker.SEVERITY_ERROR, "error");
- JavaPersistentType jpt = replayJptWithMarker(new IMarker[] { errorMarker, warningMarker });
+ PersistentType jpt = replayJptWithMarker(new IMarker[] { errorMarker, warningMarker });
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IToolBehaviorProvider provider = new JPAEditorToolBehaviorProvider(dtp);
IDecorator[] decorators = provider.getDecorators(pe);
@@ -122,7 +123,7 @@ public class JPAEditorToolBehaviorProviderTest {
public void testGetRenderingDecoratorsPictogramElementLocation() throws Exception {
PictogramElement pe = replayPictogramElement(100, 100);
IMarker marker = replayMarker(IMarker.SEVERITY_ERROR, "Error message");
- JavaPersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
+ PersistentType jpt = replayJptWithMarker(new IMarker[] { marker });
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IToolBehaviorProvider provider = new JPAEditorToolBehaviorProvider(dtp);
@@ -136,7 +137,7 @@ public class JPAEditorToolBehaviorProviderTest {
public void testGetDoubleClickOnJptFeature() throws PartInitException, CoreException {
PictogramElement pe = replayPictogramElement(100, 100);
IFile file = replayResource();
- JavaPersistentType jpt = replayJpt(pe, file);
+ PersistentType jpt = replayJpt(pe, file);
IDiagramTypeProvider dtp = replayDiagramProvider(pe, jpt);
IEclipseFacade facade = EasyMock.createMock(IEclipseFacade.class);
@@ -155,7 +156,7 @@ public class JPAEditorToolBehaviorProviderTest {
public void testGetDoubleClickOnJpaFeature() throws Exception {
PictogramElement pe = replayPictogramElement(100, 100);
IFile file = replayResource();
- JavaSpecifiedPersistentAttribute jpa = replayJpa(pe, file);
+ PersistentAttribute jpa = replayJpa(pe, file);
IDiagramTypeProvider dtp = replayDiagramProviderForJpa(pe, jpa);
IEclipseFacade eclipseFacade = EasyMock.createMock(IEclipseFacade.class);
@@ -170,7 +171,7 @@ public class JPAEditorToolBehaviorProviderTest {
verify(ide);
}
- private IDiagramTypeProvider replayDiagramProvider(PictogramElement pe, JavaPersistentType jpt) {
+ private IDiagramTypeProvider replayDiagramProvider(PictogramElement pe, PersistentType jpt) {
IFeatureProvider featureProvider = EasyMock.createMock(IFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(jpt);
IDiagramTypeProvider dtp = EasyMock.createMock(IDiagramTypeProvider.class);
@@ -187,8 +188,8 @@ public class JPAEditorToolBehaviorProviderTest {
return marker;
}
- private JavaPersistentType replayJptWithMarker(IMarker[] markers) throws CoreException {
- JavaPersistentType jpt = EasyMock.createMock(JavaPersistentType.class);
+ private PersistentType replayJptWithMarker(IMarker[] markers) throws CoreException {
+ PersistentType jpt = EasyMock.createMock(PersistentType.class);
IFile file = EasyMock.createMock(IFile.class);
expect(file.exists()).andReturn(true);
expect(file.findMarkers(null, true, IResource.DEPTH_INFINITE)).andStubReturn(markers);
@@ -213,25 +214,28 @@ public class JPAEditorToolBehaviorProviderTest {
return context;
}
- private JavaPersistentType replayJpt(PictogramElement pe, IFile file){
+ private PersistentType replayJpt(PictogramElement pe, IFile file){
IFeatureProvider featureProvider = EasyMock.createMock(IFeatureProvider.class);
- JavaPersistentType jpt = EasyMock.createMock(JavaPersistentType.class);
+ PersistentType jpt = EasyMock.createMock(PersistentType.class);
expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(jpt);
expect(jpt.getResource()).andReturn(file);
replay(jpt, featureProvider);
return jpt;
}
-
- private JavaSpecifiedPersistentAttribute replayJpa(PictogramElement pe, IFile file){
+
+ private PersistentAttribute replayJpa(PictogramElement pe, IFile file){
IFeatureProvider featureProvider = EasyMock.createMock(IFeatureProvider.class);
JavaSpecifiedPersistentAttribute jpa = EasyMock.createMock(JavaSpecifiedPersistentAttribute.class);
- expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(jpa);
+ PersistentAttribute pa = EasyMock.createMock(PersistentAttribute.class);
+
+ expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(pa);
+ expect(pa.getJavaPersistentAttribute()).andReturn(jpa);
expect(jpa.getResource()).andReturn(file);
- replay(jpa, featureProvider);
- return jpa;
+ replay(pa, jpa, featureProvider);
+ return pa;
}
-
- private IDiagramTypeProvider replayDiagramProviderForJpa(PictogramElement pe, JavaSpecifiedPersistentAttribute jpa) {
+
+ private IDiagramTypeProvider replayDiagramProviderForJpa(PictogramElement pe, PersistentAttribute jpa) {
IFeatureProvider featureProvider = EasyMock.createMock(IFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(pe)).andStubReturn(jpa);
IDiagramTypeProvider dtp = EasyMock.createMock(IDiagramTypeProvider.class);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java
index de62c5a971..e85403a00d 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationAttributesTest.java
@@ -15,8 +15,13 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.relation;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -27,14 +32,12 @@ import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.jpa.core.JpaProject;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.ManyToManyMapping;
+import org.eclipse.jpt.jpa.core.context.ManyToOneMapping;
+import org.eclipse.jpt.jpa.core.context.OneToManyMapping;
+import org.eclipse.jpt.jpa.core.context.OneToOneMapping;
import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
@@ -61,7 +64,7 @@ public class CreateRelationAttributesTest {
Thread.sleep(2000);
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
replay(featureProvider);
}
@@ -106,9 +109,8 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute attr = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)t1, (JavaPersistentType)t2, null, "add", "add", false,
+ PersistentAttribute attr = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, t1, t2, null, "add", "add", false,
createCompilationUnitFrom(customerFile));
jpaProject.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, new NullProgressMonitor());
PersistenceUnit pu = jpaProject.getContextModelRoot().getPersistenceXml().getRoot().getPersistenceUnits().iterator().next();
@@ -148,13 +150,13 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute attr = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)t1, (JavaPersistentType)t2, null, "address", "address", false,
+
+ PersistentAttribute attr = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, t1, t2, null, "address", "address", false,
createCompilationUnitFrom((IFile)t1.getResource()));
assertNotNull(attr);
- JpaArtifactFactory.instance().addOneToOneUnidirectionalRelation(featureProvider, (JavaPersistentType)t1, attr);
+ JpaArtifactFactory.instance().addOneToOneUnidirectionalRelation(featureProvider, t1, attr);
PersistentType pt = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (pt == null) {
@@ -198,18 +200,18 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, creditCardType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute attr = JpaArtifactFactory.instance().
- addAttribute( featureProvider, (JavaPersistentType)t1, (JavaPersistentType)t2, null, "creditCard", "creditCard", false,
+
+ PersistentAttribute attr = JpaArtifactFactory.instance().
+ addAttribute( featureProvider, t1, t2, null, "creditCard", "creditCard", false,
createCompilationUnitFrom((IFile)t1.getResource()));
assertNotNull(attr);
- JavaSpecifiedPersistentAttribute attr2 = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)t2, (JavaPersistentType)t1, null, "customer", "customer", false,
+ PersistentAttribute attr2 = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, t2, t1, null, "customer", "customer", false,
createCompilationUnitFrom((IFile)t2.getResource()));
assertNotNull(attr2);
- JpaArtifactFactory.instance().addOneToOneBidirectionalRelation(featureProvider, (JavaPersistentType)t1, attr, (JavaPersistentType)t2, attr2);
+ JpaArtifactFactory.instance().addOneToOneBidirectionalRelation(featureProvider, t1, attr, t2, attr2);
PersistentType ownerPersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (ownerPersistentType == null) {
@@ -219,12 +221,10 @@ public class CreateRelationAttributesTest {
PersistentAttribute ownerPersistentAttribute = ownerPersistentType.resolveAttribute("creditCard");
assertNotNull(ownerPersistentAttribute);
- assertTrue(ownerPersistentAttribute instanceof JavaSpecifiedPersistentAttribute);
-
AttributeMapping ownerSideMapping = ownerPersistentAttribute.getMapping();
- assertTrue(ownerSideMapping instanceof JavaOneToOneMapping);
+ assertTrue(ownerSideMapping instanceof OneToOneMapping);
- assertTrue(((JavaOneToOneMapping)ownerSideMapping).isRelationshipOwner());
+ assertTrue(((OneToOneMapping)ownerSideMapping).isRelationshipOwner());
PersistentType inversePersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, creditCardType.getTypeBinding().getQualifiedName());
while (inversePersistentType == null) {
@@ -234,12 +234,11 @@ public class CreateRelationAttributesTest {
PersistentAttribute inversePersistentAttribute = inversePersistentType.resolveAttribute("customer");
assertNotNull(inversePersistentAttribute);
- assertTrue(inversePersistentAttribute instanceof JavaSpecifiedPersistentAttribute);
-
+
AttributeMapping inverseSideMapping = inversePersistentAttribute.getMapping();
- assertTrue(inverseSideMapping instanceof JavaOneToOneMapping);
+ assertTrue(inverseSideMapping instanceof OneToOneMapping);
- assertFalse(((JavaOneToOneMapping)inverseSideMapping).isRelationshipOwner());
+ assertFalse(((OneToOneMapping)inverseSideMapping).isRelationshipOwner());
}
@@ -273,12 +272,12 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, phoneType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute attr = JpaArtifactFactory.instance().addAttribute(featureProvider, (JavaPersistentType)t1, (JavaPersistentType)t2, null, "phones", "phones", true,
+
+ PersistentAttribute attr = JpaArtifactFactory.instance().addAttribute(featureProvider, t1, t2, null, "phones", "phones", true,
createCompilationUnitFrom((IFile)t1.getResource()));
assertNotNull(attr);
- JpaArtifactFactory.instance().addOneToManyUnidirectionalRelation(featureProvider, (JavaPersistentType)t1, attr, false);
+ JpaArtifactFactory.instance().addOneToManyUnidirectionalRelation(featureProvider, t1, attr, false);
PersistentType pt = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (pt == null) {
@@ -291,9 +290,9 @@ public class CreateRelationAttributesTest {
AttributeMapping mapping = cPersistentAttribute.getMapping();
assertNotNull(mapping);
- assertTrue(mapping instanceof JavaOneToManyMapping);
+ assertTrue(mapping instanceof OneToManyMapping);
- assertTrue(((JavaOneToManyMapping)mapping).isRelationshipOwner());
+ assertTrue(((OneToManyMapping)mapping).isRelationshipOwner());
}
@@ -326,18 +325,18 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
manySidePersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, reservationType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute singleSideAttribute = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)singleSidePersistentType, (JavaPersistentType)manySidePersistentType, null, "reservations", "reservations", true,
+
+ PersistentAttribute singleSideAttribute = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, singleSidePersistentType, manySidePersistentType, null, "reservations", "reservations", true,
createCompilationUnitFrom((IFile)singleSidePersistentType.getResource()));
assertNotNull(singleSideAttribute);
- JavaSpecifiedPersistentAttribute manySideAttribute = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)manySidePersistentType, (JavaPersistentType)singleSidePersistentType, null, "cruise", "cruise", false,
+ PersistentAttribute manySideAttribute = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, manySidePersistentType, singleSidePersistentType, null, "cruise", "cruise", false,
createCompilationUnitFrom((IFile)manySidePersistentType.getResource()));
assertNotNull(manySideAttribute);
- JpaArtifactFactory.instance().addOneToManyBidirectionalRelation(featureProvider, (JavaPersistentType)singleSidePersistentType, singleSideAttribute, (JavaPersistentType)manySidePersistentType, manySideAttribute, false);
+ JpaArtifactFactory.instance().addOneToManyBidirectionalRelation(featureProvider, singleSidePersistentType, singleSideAttribute, manySidePersistentType, manySideAttribute, false);
// In one-to-many bidirectional relation many side is ALWAYS owner
PersistentType inversePersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, cruiseType.getTypeBinding().getQualifiedName());
@@ -348,12 +347,11 @@ public class CreateRelationAttributesTest {
PersistentAttribute inversePersistentAttribute = inversePersistentType.resolveAttribute("reservations");
assertNotNull(inversePersistentAttribute);
- assertTrue(inversePersistentAttribute instanceof JavaSpecifiedPersistentAttribute);
AttributeMapping inverseSideMapping = inversePersistentAttribute.getMapping();
- assertTrue(inverseSideMapping instanceof JavaOneToManyMapping);
+ assertTrue(inverseSideMapping instanceof OneToManyMapping);
- assertFalse(((JavaOneToManyMapping)inverseSideMapping).isRelationshipOwner());
+ assertFalse(((OneToManyMapping)inverseSideMapping).isRelationshipOwner());
// In one-to-many bidirectional relation many side is ALWAYS owner
PersistentType ownerPersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, reservationType.getTypeBinding().getQualifiedName());
@@ -374,7 +372,6 @@ public class CreateRelationAttributesTest {
}
assertNotNull(ownerPersistentAttribute);
- assertTrue(ownerPersistentAttribute instanceof JavaSpecifiedPersistentAttribute);
AttributeMapping ownerSideMapping = ownerPersistentAttribute.getMapping();
c = 0;
@@ -386,9 +383,9 @@ public class CreateRelationAttributesTest {
if (ownerSideMapping == null)
return;
assertNotNull("ownerSideMapping must not be null", ownerSideMapping);
- assertTrue("ownerSideMapping class is " + ownerSideMapping.getClass().getName(), JavaManyToOneMapping.class.isInstance(ownerSideMapping));
+ assertTrue("ownerSideMapping class is " + ownerSideMapping.getClass().getName(), ManyToOneMapping.class.isInstance(ownerSideMapping));
- assertTrue(((JavaManyToOneMapping)ownerSideMapping).isRelationshipOwner());
+ assertTrue(((ManyToOneMapping)ownerSideMapping).isRelationshipOwner());
}
@@ -419,13 +416,13 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
singleSidePersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, shipType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute mappedAttribute = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)manySidePersistentType, (JavaPersistentType)singleSidePersistentType, null, "ship", "ship", true,
+
+ PersistentAttribute mappedAttribute = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, manySidePersistentType, singleSidePersistentType, null, "ship", "ship", true,
createCompilationUnitFrom((IFile)manySidePersistentType.getResource()));
assertNotNull(mappedAttribute);
- JpaArtifactFactory.instance().addManyToOneUnidirectionalRelation(featureProvider, (JavaPersistentType)manySidePersistentType, mappedAttribute);
+ JpaArtifactFactory.instance().addManyToOneUnidirectionalRelation(featureProvider, manySidePersistentType, mappedAttribute);
PersistentType pt = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, cruiseType.getTypeBinding().getQualifiedName());
while (pt == null) {
@@ -450,9 +447,9 @@ public class CreateRelationAttributesTest {
cnt++;
}
assertNotNull(mapping);
- assertTrue(mapping instanceof JavaManyToOneMapping);
+ assertTrue(mapping instanceof ManyToOneMapping);
- assertTrue(((JavaManyToOneMapping)mapping).isRelationshipOwner());
+ assertTrue(((ManyToOneMapping)mapping).isRelationshipOwner());
}
@@ -484,17 +481,17 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
inverseSidePersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute ownerSideAttribute = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)ownerSidePersistentType, (JavaPersistentType)inverseSidePersistentType, null, "customers", "customers", true,
+
+ PersistentAttribute ownerSideAttribute = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, ownerSidePersistentType, inverseSidePersistentType, null, "customers", "customers", true,
createCompilationUnitFrom((IFile)ownerSidePersistentType.getResource()));
assertNotNull(ownerSideAttribute);
- JavaSpecifiedPersistentAttribute inverseSideAttributes = JpaArtifactFactory.instance().addAttribute(featureProvider, (JavaPersistentType)inverseSidePersistentType, (JavaPersistentType)ownerSidePersistentType, null, "reservations", "reservations", true,
+ PersistentAttribute inverseSideAttributes = JpaArtifactFactory.instance().addAttribute(featureProvider, inverseSidePersistentType, ownerSidePersistentType, null, "reservations", "reservations", true,
createCompilationUnitFrom((IFile)inverseSidePersistentType.getResource()));
assertNotNull(inverseSideAttributes);
- JpaArtifactFactory.instance().addManyToManyBidirectionalRelation(featureProvider, (JavaPersistentType)ownerSidePersistentType, ownerSideAttribute, (JavaPersistentType)inverseSidePersistentType, inverseSideAttributes, false);
+ JpaArtifactFactory.instance().addManyToManyBidirectionalRelation(featureProvider, ownerSidePersistentType, ownerSideAttribute, inverseSidePersistentType, inverseSideAttributes, false);
PersistentType ownerPersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, reservationType.getTypeBinding().getQualifiedName());
while (ownerPersistentType == null) {
@@ -504,12 +501,11 @@ public class CreateRelationAttributesTest {
PersistentAttribute ownerPersistentAttribute = ownerPersistentType.resolveAttribute("customers");
assertNotNull(ownerPersistentAttribute);
- assertTrue(ownerPersistentAttribute instanceof JavaSpecifiedPersistentAttribute);
-
+
AttributeMapping ownerSideMapping = ownerPersistentAttribute.getMapping();
- assertTrue(ownerSideMapping instanceof JavaManyToManyMapping);
+ assertTrue(ownerSideMapping instanceof ManyToManyMapping);
- assertTrue(((JavaManyToManyMapping)ownerSideMapping).isRelationshipOwner());
+ assertTrue(((ManyToManyMapping)ownerSideMapping).isRelationshipOwner());
PersistentType inversePersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (inversePersistentType == null) {
@@ -519,12 +515,11 @@ public class CreateRelationAttributesTest {
PersistentAttribute inversePersistentAttribute = inversePersistentType.resolveAttribute("reservations");
assertNotNull(inversePersistentAttribute);
- assertTrue(inversePersistentAttribute instanceof JavaSpecifiedPersistentAttribute);
-
+
AttributeMapping inverseSideMapping = inversePersistentAttribute.getMapping();
- assertTrue(inverseSideMapping instanceof JavaManyToManyMapping);
+ assertTrue(inverseSideMapping instanceof ManyToManyMapping);
- assertFalse(((JavaManyToManyMapping)inverseSideMapping).isRelationshipOwner());
+ assertFalse(((ManyToManyMapping)inverseSideMapping).isRelationshipOwner());
}
@Test
@@ -555,13 +550,13 @@ public class CreateRelationAttributesTest {
Thread.sleep(200);
referencedPersistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, cabinType.getTypeBinding().getQualifiedName());
}
-
- JavaSpecifiedPersistentAttribute annotatedSideAttribute = JpaArtifactFactory.instance().
- addAttribute(featureProvider, (JavaPersistentType)annotatedPersistentType, (JavaPersistentType)referencedPersistentType, null, "cabins", "cabins", true,
+
+ PersistentAttribute annotatedSideAttribute = JpaArtifactFactory.instance().
+ addAttribute(featureProvider, annotatedPersistentType, referencedPersistentType, null, "cabins", "cabins", true,
createCompilationUnitFrom((IFile)annotatedPersistentType.getResource()));
assertNotNull(annotatedSideAttribute);
- JpaArtifactFactory.instance().addManyToManyUnidirectionalRelation(featureProvider, (JavaPersistentType)annotatedPersistentType, annotatedSideAttribute, false);
+ JpaArtifactFactory.instance().addManyToManyUnidirectionalRelation(featureProvider, annotatedPersistentType, annotatedSideAttribute, false);
PersistentType persistentType = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, reservationType.getTypeBinding().getQualifiedName());
while (persistentType == null) {
@@ -571,15 +566,10 @@ public class CreateRelationAttributesTest {
PersistentAttribute persistentAttribute = persistentType.resolveAttribute("cabins");
assertNotNull(persistentAttribute);
- assertTrue(persistentAttribute instanceof JavaSpecifiedPersistentAttribute);
-
+
AttributeMapping mapping = persistentAttribute.getMapping();
- assertTrue(mapping instanceof JavaManyToManyMapping);
+ assertTrue(mapping instanceof ManyToManyMapping);
- assertTrue(((JavaManyToManyMapping)mapping).isRelationshipOwner());
+ assertTrue(((ManyToManyMapping)mapping).isRelationshipOwner());
}
-
-
-
-
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java
index 9d11ef5adf..14e4ceb945 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsInFieldAnnotatedEntitiesTest.java
@@ -15,9 +15,15 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.relation;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
-import java.util.Set;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -28,9 +34,13 @@ import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
+import org.eclipse.jpt.jpa.core.MappingKeys;
+import org.eclipse.jpt.jpa.core.context.AttributeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.ManyToManyBiDirRelation;
@@ -64,7 +74,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
Thread.sleep(2000);
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
replay(featureProvider);
}
@@ -87,7 +97,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -98,7 +108,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -109,11 +119,15 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
- assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("OneToOne"));
- assertNull(((OwnableRelationshipMappingAnnotation)ownerAt.getMapping()).getMappedBy());
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ assertNotNull(ownerAt);
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
assertTrue(cu1.isWorkingCopy());
IType javaType = cu1.findPrimaryType();
@@ -136,7 +150,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -147,7 +161,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -159,17 +173,25 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("OneToOne"));
- assertNull(((OwnableRelationshipMappingAnnotation)ownerAt.getMapping()).getMappedBy());
-
- JavaSpecifiedPersistentAttribute inverseAt = t2.getAttributeNamed("customer");
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
+
+ PersistentAttribute inverseAt = t2.getAttributeNamed("customer");
assertNotNull(inverseAt);
- annotations = JpaArtifactFactory.instance().getAnnotationNames(inverseAt);
- assertTrue(annotations.contains("OneToOne"));
- assertEquals("address", ((OwnableRelationshipMappingAnnotation)inverseAt.getMapping()).getMappedBy());
+
+ attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(inverseAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertEquals("address", ((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
assertTrue(cu1.isWorkingCopy());
assertTrue(cu2.isWorkingCopy());
@@ -197,7 +219,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -208,7 +230,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -219,11 +241,15 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("OneToMany"));
- assertNull(((OwnableRelationshipMappingAnnotation)ownerAt.getMapping()).getMappedBy());
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
assertTrue(cu1.isWorkingCopy());
@@ -247,7 +273,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -258,7 +284,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -269,10 +295,15 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("ManyToOne"));
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
assertTrue(cu1.isWorkingCopy());
@@ -297,7 +328,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -308,7 +339,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -320,16 +351,25 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("ManyToOne"));
-
- JavaSpecifiedPersistentAttribute inverseAt = t2.getAttributeNamed("customer");
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
+
+ PersistentAttribute inverseAt = t2.getAttributeNamed("customer");
assertNotNull(inverseAt);
- annotations = JpaArtifactFactory.instance().getAnnotationNames(inverseAt);
- assertTrue(annotations.contains("OneToMany"));
- assertEquals("address", ((OwnableRelationshipMappingAnnotation)inverseAt.getMapping()).getMappedBy());
+
+ attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(inverseAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertEquals("address", ((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
assertTrue(cu1.isWorkingCopy());
assertTrue(cu2.isWorkingCopy());
@@ -357,7 +397,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -368,7 +408,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -379,11 +419,15 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("ManyToMany"));
- assertNull(((OwnableRelationshipMappingAnnotation)ownerAt.getMapping()).getMappedBy());
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
assertTrue(cu1.isWorkingCopy());
@@ -407,7 +451,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
@@ -418,7 +462,7 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getTypeBinding().getQualifiedName());
@@ -430,18 +474,27 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Set<String> annotations = JpaArtifactFactory.instance().getAnnotationNames(ownerAt);
- assertTrue(annotations.contains("ManyToMany"));
- assertNull(((OwnableRelationshipMappingAnnotation)ownerAt.getMapping()).getMappedBy());
-
- JavaSpecifiedPersistentAttribute inverseAt = t2.getAttributeNamed("customer");
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
+
+ PersistentAttribute inverseAt = t2.getAttributeNamed("customer");
assertNotNull(inverseAt);
- annotations = JpaArtifactFactory.instance().getAnnotationNames(inverseAt);
- assertTrue(annotations.contains("ManyToMany"));
- assertEquals("address", ((OwnableRelationshipMappingAnnotation)inverseAt.getMapping()).getMappedBy());
+
+ attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(inverseAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertEquals("address", ((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
+
assertTrue(cu1.isWorkingCopy());
assertTrue(cu2.isWorkingCopy());
@@ -454,7 +507,13 @@ public class CreateRelationsInFieldAnnotatedEntitiesTest {
}
-
+ public boolean isMappedAs(PersistentAttribute jpa, String mappingKey){
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(jpa);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(mappingKey, attributeMapping.getKey());
+
+ return false;
+ }
}
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java
index efb1f7d87a..1f24145611 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/relation/CreateRelationsTest.java
@@ -15,10 +15,18 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.relation;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.isA;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import java.util.Iterator;
import java.util.Properties;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -30,16 +38,17 @@ import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.common.core.resource.java.NestableAnnotation;
import org.eclipse.jpt.common.utility.internal.iterable.SubIterableWrapper;
import org.eclipse.jpt.jpa.core.JpaProject;
+import org.eclipse.jpt.jpa.core.MappingKeys;
import org.eclipse.jpt.jpa.core.context.AttributeMapping;
import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
+import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
+import org.eclipse.jpt.jpa.core.context.SpecifiedMappedByRelationshipStrategy;
import org.eclipse.jpt.jpa.core.resource.java.JPA;
import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.propertypage.JPADiagramPropertyPage;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.relations.AbstractRelation;
@@ -66,9 +75,9 @@ public class CreateRelationsTest {
private JPACreateFactory factory = null;
IEclipseFacade eclipseFacade = null;
private static final int MAX_NUM_OF_ITERATIONS = 250;
- JavaPersistentType t1 = null;
+ PersistentType t1 = null;
ICompilationUnit cu1 = null;
- JavaPersistentType t2 = null;
+ PersistentType t2 = null;
ICompilationUnit cu2 = null;
private IJPAEditorFeatureProvider featureProvider20;
private JpaProject jpa20Project;
@@ -84,7 +93,7 @@ public class CreateRelationsTest {
IFile entity = factory.createEntity(jpaProject, "org.eclipse.Entity1");
featureProvider = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity));
- expect(featureProvider.getCompilationUnit(isA(JavaPersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
+ expect(featureProvider.getCompilationUnit(isA(PersistentType.class))).andReturn(JavaCore.createCompilationUnitFrom(entity)).anyTimes();
assertNotNull(jpaProject);
IFile customerFile = factory.createEntityInProject(jpaProject.getProject(), new String[]{"com","test"}, "Customer");
@@ -128,7 +137,7 @@ public class CreateRelationsTest {
Thread.sleep(2000);
featureProvider20 = EasyMock.createMock(IJPAEditorFeatureProvider.class);
expect(featureProvider20.getBusinessObjectForPictogramElement(null)).andReturn(JPACreateFactory.getPersistentType(entity20));
- expect(featureProvider20.getCompilationUnit(isA(JavaPersistentType.class)))
+ expect(featureProvider20.getCompilationUnit(isA(PersistentType.class)))
.andReturn(JavaCore.createCompilationUnitFrom(entity20)).anyTimes();
}
@@ -144,11 +153,15 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- OneToOneAnnotation an = (OneToOneAnnotation)ownerAt.getResourceAttribute().getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertNull(an.getMappedBy());
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@@ -160,18 +173,25 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- OneToOneAnnotation an = (OneToOneAnnotation)ownerAt.getResourceAttribute().getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertNull(an.getMappedBy());
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
- JavaSpecifiedPersistentAttribute inverseAt = t2.getAttributeNamed("customer");
+ PersistentAttribute inverseAt = t2.getAttributeNamed("customer");
assertNotNull(inverseAt);
- an = (OneToOneAnnotation)inverseAt.getResourceAttribute().getAnnotation(OneToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertEquals("address", an.getMappedBy());
+ attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(inverseAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertEquals("address", ((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@@ -182,11 +202,15 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- OneToManyAnnotation an = (OneToManyAnnotation)ownerAt.getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNull(an.getMappedBy());
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@@ -198,10 +222,15 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- ManyToOneAnnotation an = (ManyToOneAnnotation)ownerAt.getResourceAttribute().getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@Test
@@ -211,17 +240,26 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- ManyToOneAnnotation an = (ManyToOneAnnotation)ownerAt.getResourceAttribute().getAnnotation(ManyToOneAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
+
assertEquals("customer", rel.getInverseAttributeName());
- JavaSpecifiedPersistentAttribute inverseAt = t2.getAttributeNamed("customer");
+ PersistentAttribute inverseAt = t2.getAttributeNamed("customer");
assertNotNull(inverseAt);
- OneToManyAnnotation an1 = (OneToManyAnnotation)inverseAt.getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(an1);
- assertEquals("address", an1.getMappedBy());
+
+ attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(inverseAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertEquals("address", ((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@Test
@@ -231,11 +269,15 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- ManyToManyAnnotation an = (ManyToManyAnnotation)ownerAt.getResourceAttribute().getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertNull(an.getMappedBy());
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@Test
@@ -245,18 +287,25 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- ManyToManyAnnotation an = (ManyToManyAnnotation)ownerAt.getResourceAttribute().getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertNull(an.getMappedBy());
+
+ AttributeMapping attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(ownerAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ RelationshipStrategy strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertNull(((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
- JavaSpecifiedPersistentAttribute inverseAt = t2.getAttributeNamed("customer");
+ PersistentAttribute inverseAt = t2.getAttributeNamed("customer");
assertNotNull(inverseAt);
- an = (ManyToManyAnnotation)inverseAt.getResourceAttribute().getAnnotation(ManyToManyAnnotation.ANNOTATION_NAME);
- assertNotNull(an);
- assertEquals("address", an.getMappedBy());
+ attributeMapping = JpaArtifactFactory.instance().getAttributeMapping(inverseAt);
+ assertTrue(RelationshipMapping.class.isInstance(attributeMapping));
+ assertEquals(MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY, attributeMapping.getKey());
+ strategy = ((RelationshipMapping)attributeMapping).getRelationship().getStrategy();
+ assertTrue(SpecifiedMappedByRelationshipStrategy.class.isInstance(strategy));
+ assertEquals("address", ((SpecifiedMappedByRelationshipStrategy)strategy).getMappedByAttribute());
}
@Test
@@ -273,7 +322,7 @@ public class CreateRelationsTest {
JavaResourceAbstractType customerType = jpa20Project.getJavaResourceType("com.test.Customer");
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, customerType.getTypeBinding().getQualifiedName());
expect(featureProvider20.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class));
ICompilationUnit cu1 = JavaCore.createCompilationUnitFrom(customerFile);
@@ -284,7 +333,7 @@ public class CreateRelationsTest {
assertNotNull(customerType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, addressType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, addressType.getTypeBinding().getQualifiedName());
expect(featureProvider20.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class));
ICompilationUnit cu2 = JavaCore.createCompilationUnitFrom(addressFile);
@@ -300,13 +349,13 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("address", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("address");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("address");
assertNotNull(ownerAt);
- Object o1 = ownerAt.getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
+ Object o1 = ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
assertNotNull(o1);
- Object o2 = ownerAt.getResourceAttribute().getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
+ Object o2 = ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(JoinColumnAnnotation.ANNOTATION_NAME);
assertNotNull(o2);
JoinColumnAnnotation joinColumn = (JoinColumnAnnotation) o2;
@@ -336,7 +385,7 @@ public class CreateRelationsTest {
JavaResourceAbstractType employeeType = jpa20Project.getJavaResourceType("com.test.Employee");
assertNotNull(employeeType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getTypeBinding().getQualifiedName());
expect(featureProvider20.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class));
ICompilationUnit cu1 = JavaCore.createCompilationUnitFrom(employeeFile);
@@ -347,7 +396,7 @@ public class CreateRelationsTest {
assertNotNull(employeeType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getTypeBinding().getQualifiedName());
expect(featureProvider20.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class));
ICompilationUnit cu2 = JavaCore.createCompilationUnitFrom(projectFile);
@@ -362,16 +411,16 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("project", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("project");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("project");
assertNotNull(ownerAt);
- Object o1 = ownerAt.getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
+ Object o1 = ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
assertNotNull(o1);
- Object o2 = ownerAt.getResourceAttribute().getAnnotation(JPA.JOIN_COLUMNS);
+ Object o2 = ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(JPA.JOIN_COLUMNS);
assertNotNull(o2);
- assertEquals(2, ownerAt.getResourceAttribute().getAnnotationsSize(JPA.JOIN_COLUMN));
+ assertEquals(2, ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotationsSize(JPA.JOIN_COLUMN));
}
@@ -392,7 +441,7 @@ public class CreateRelationsTest {
assertNotNull(employeeType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, employeeType.getTypeBinding().getQualifiedName());
expect(featureProvider20.getPictogramElementForBusinessObject(t1)).andStubReturn(isA(Shape.class));
ICompilationUnit cu1 = JavaCore.createCompilationUnitFrom(employeeFile);
@@ -407,7 +456,7 @@ public class CreateRelationsTest {
assertNotNull(employeeType);
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getTypeBinding().getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpa20Project, projectType.getTypeBinding().getQualifiedName());
expect(featureProvider20.getPictogramElementForBusinessObject(t2)).andStubReturn(isA(Shape.class));
ICompilationUnit cu2 = JavaCore.createCompilationUnitFrom(projectFile);
@@ -422,17 +471,17 @@ public class CreateRelationsTest {
assertSame(t1, rel.getOwner());
assertSame(t2, rel.getInverse());
assertEquals("person", rel.getOwnerAttributeName());
- JavaSpecifiedPersistentAttribute ownerAt = t1.getAttributeNamed("person");
+ PersistentAttribute ownerAt = t1.getAttributeNamed("person");
assertNotNull(ownerAt);
- Object o1 = ownerAt.getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
+ Object o1 = ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(OneToManyAnnotation.ANNOTATION_NAME);
assertNotNull(o1);
- Object o2 = ownerAt.getResourceAttribute().getAnnotation(JPA.JOIN_COLUMNS);
+ Object o2 = ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotation(JPA.JOIN_COLUMNS);
assertNotNull(o2);
- assertEquals(1, ownerAt.getResourceAttribute().getAnnotationsSize(JPA.JOIN_COLUMN));
- Iterable<JoinColumnAnnotation> nestedAnnotations = new SubIterableWrapper<NestableAnnotation, JoinColumnAnnotation>(ownerAt.getResourceAttribute().getAnnotations(JPA.JOIN_COLUMN));
+ assertEquals(1, ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotationsSize(JPA.JOIN_COLUMN));
+ Iterable<JoinColumnAnnotation> nestedAnnotations = new SubIterableWrapper<NestableAnnotation, JoinColumnAnnotation>(ownerAt.getJavaPersistentAttribute().getResourceAttribute().getAnnotations(JPA.JOIN_COLUMN));
Iterator<JoinColumnAnnotation> nestedIterator = nestedAnnotations.iterator();
while(nestedIterator.hasNext()){
JoinColumnAnnotation joinColumn = nestedIterator.next();
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java
index eaf8bc4df9..dbc2471d7f 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPAEditorUtilTest.java
@@ -15,9 +15,15 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import java.util.List;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -37,8 +43,8 @@ import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAbstractType;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaSpecifiedPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IPeServiceUtil;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JPAEditorConstants.ShapeType;
@@ -175,7 +181,7 @@ public class JPAEditorUtilTest {
ICompilationUnit cu = createCompilationUnitFrom(customerFile);
Thread.sleep(2000);
- JavaPersistentType jpt = JPAEditorUtil.getJPType(cu);
+ PersistentType jpt = JPAEditorUtil.getJPType(cu);
assertEquals(customerType.getTypeBinding().getQualifiedName(), jpt.getName());
}
@@ -265,7 +271,7 @@ public class JPAEditorUtilTest {
JavaResourceAbstractType customerType = jpaProject.getJavaResourceType("com.test.Customer");
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
int cnt = 0;
while ((cnt < 25) && (t1 == null)) {
Thread.sleep(200);
@@ -276,7 +282,7 @@ public class JPAEditorUtilTest {
return;
assertNotNull(JPAEditorUtil.getText(t1));
assertNotNull(JPAEditorUtil.getTooltipText(t1));
- JavaSpecifiedPersistentAttribute jpa = t1.getAttributeNamed("id");
+ PersistentAttribute jpa = t1.getAttributeNamed("id");
assertNotNull(jpa);
assertNotNull(JPAEditorUtil.getText(jpa));
assertNotNull(JPAEditorUtil.getTooltipText(jpa));
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPASolverTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPASolverTest.java
index fc6663c4d5..ef970f92f0 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPASolverTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JPASolverTest.java
@@ -34,18 +34,11 @@ import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.BasicInternalEList;
import org.eclipse.graphiti.dt.IDiagramTypeProvider;
-import org.eclipse.graphiti.mm.Property;
-import org.eclipse.graphiti.mm.pictograms.PictogramElement;
-import org.eclipse.graphiti.mm.pictograms.PictogramsPackage;
import org.eclipse.graphiti.platform.IDiagramEditor;
-import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
+import org.eclipse.jpt.jpa.core.context.TypeMapping;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IJPAEditorUtil;
@@ -97,10 +90,10 @@ public class JPASolverTest {
return file;
}
- private JavaPersistentType createJptForResource(IFile file, String name) {
- JavaPersistentType jpt = EasyMock.createNiceMock(JavaPersistentType.class);
+ private PersistentType createJptForResource(IFile file, String name) {
+ PersistentType jpt = EasyMock.createNiceMock(PersistentType.class);
JpaProject jpaProject = EasyMock.createNiceMock(JpaProject.class);
- JavaTypeMapping m = EasyMock.createNiceMock(JavaTypeMapping.class);
+ TypeMapping m = EasyMock.createNiceMock(TypeMapping.class);
expect(jpt.getResource()).andStubReturn(file);
expect(jpt.getJpaProject()).andStubReturn(jpaProject);
expect(jpt.getMapping()).andStubReturn(m);
diff --git a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JpaArtifactFactoryTest.java b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JpaArtifactFactoryTest.java
index 67327d9e97..82173eca20 100644
--- a/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JpaArtifactFactoryTest.java
+++ b/jpa_diagram_editor/tests/org.eclipse.jpt.jpadiagrameditor.ui.tests/src/org/eclipse/jpt/jpadiagrameditor/ui/tests/internal/util/JpaArtifactFactoryTest.java
@@ -15,8 +15,11 @@
*******************************************************************************/
package org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.util;
-import static org.easymock.EasyMock.*;
-import static org.junit.Assert.*;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import org.easymock.EasyMock;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -32,7 +35,7 @@ import org.eclipse.jpt.common.utility.model.event.ListRemoveEvent;
import org.eclipse.jpt.common.utility.model.event.ListReplaceEvent;
import org.eclipse.jpt.common.utility.model.listener.ListChangeListener;
import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
+import org.eclipse.jpt.jpa.core.context.PersistentType;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.provider.IJPAEditorFeatureProvider;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.IEclipseFacade;
import org.eclipse.jpt.jpadiagrameditor.ui.internal.util.JpaArtifactFactory;
@@ -75,12 +78,12 @@ public class JpaArtifactFactoryTest {
JavaResourceAbstractType addressType = jpaProject.getJavaResourceType("com.test.Address");
assertNotNull(addressType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getQualifiedName());
}
- JavaPersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getQualifiedName());
+ PersistentType t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getQualifiedName());
while (t2 == null) {
Thread.sleep(200);
t2 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, addressType.getQualifiedName());
@@ -123,7 +126,7 @@ public class JpaArtifactFactoryTest {
assertNotNull(t1.getAttributeNamed(rel.getOwnerAttributeName()));
assertNotNull(t2.getAttributeNamed(rel.getInverseAttributeName()));
- JavaPersistentAttribute jpa = t1.getAttributeNamed(rel.getOwnerAttributeName());
+ ReadOnlyPersistentAttribute jpa = t1.getAttributeNamed(rel.getOwnerAttributeName());
assertTrue(JpaArtifactFactory.instance().hasEntityAnnotation(t1));
//JavaPersistentAttribute jpa1 = JpaArtifactFactory.instance().getRelatedAttribute(t1, t2);
@@ -152,7 +155,7 @@ public class JpaArtifactFactoryTest {
JavaResourceAbstractType customerType = jpaProject.getJavaResourceType("com.test.Customer");
assertNotNull(customerType);
- JavaPersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
+ PersistentType t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());
while (t1 == null) {
Thread.sleep(200);
t1 = JpaArtifactFactory.instance().getContextPersistentType(jpaProject, customerType.getTypeBinding().getQualifiedName());

Back to the top