Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context')
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractJpaContextNode.java108
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractXmlContextNode.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseColumnTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseJoinColumnTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/EntityTextRangeResolver.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JoinColumnTextRangeResolver.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JptValidator.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java288
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/NamedColumnTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/OverrideTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributePropertyTester.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributeTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PrimaryKeyTextRangeResolver.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TableTextRangeResolver.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TypeMappingTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java171
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java293
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java310
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java304
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java293
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java1776
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java209
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java458
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java195
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java325
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java177
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java158
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java130
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java814
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java226
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java219
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java255
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java179
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java699
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java679
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java198
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java348
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java100
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java148
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java524
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java274
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java203
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java203
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java250
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java114
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java166
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java230
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java360
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java82
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java36
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java127
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java58
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java890
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAssociationOverrideRelationshipReference.java160
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java405
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseColumn.java311
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java306
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBasicMapping.java335
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEmbeddable.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java2071
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmGenerator.java236
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java439
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.java136
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnJoiningStrategy.java300
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinTableJoiningStrategy.java171
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToManyMapping.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneMapping.java54
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneRelationshipReference.java160
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMappedSuperclass.java194
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java820
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java221
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyMapping.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java235
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneMapping.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneRelationshipReference.java263
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java313
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmQuery.java193
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java429
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipReference.java126
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSequenceGenerator.java90
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java120
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTable.java500
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java432
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java251
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java448
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlDefinition.java107
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdClassReference.java277
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.java217
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnJoiningStrategy.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTableJoiningStrategy.java100
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java187
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneRelationshipReference.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedByJoiningStrategy.java205
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneRelationshipReference.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnJoiningStrategy.java304
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmAssociationOverrideContainer.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmJoinTableJoiningStrategy.java97
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableDefinition.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityDefinition.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityTextRangeResolver.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassDefinition.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOverrideTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTableTextRangeResolver.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingDefinition.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualCascadeType.java69
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAssociationOverride.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverride.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverrideColumn.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlBasic.java167
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlColumn.java184
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbedded.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbeddedId.java85
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlGeneratedValue.java60
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlId.java194
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinColumn.java147
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinTable.java140
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java182
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToOne.java157
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlNullAttributeMapping.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java198
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToOne.java202
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOrderColumn.java103
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java74
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java111
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSequenceGenerator.java95
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTableGenerator.java178
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTransient.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlUniqueConstraint.java41
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlVersion.java132
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractJarFileRef.java329
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java346
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java2116
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnitProperties.java529
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java29
195 files changed, 0 insertions, 34536 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractJpaContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractJpaContextNode.java
deleted file mode 100644
index 5ee3fc9ab1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractJpaContextNode.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.JpaNode;
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.context.JpaContextNode;
-import org.eclipse.jpt.core.context.MappingFileRoot;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.internal.AbstractJpaNode;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-
-public abstract class AbstractJpaContextNode
- extends AbstractJpaNode
- implements JpaContextNode
-{
-
- // ********** constructor **********
-
- protected AbstractJpaContextNode(JpaNode parent) {
- super(parent);
- }
-
-
- // ********** JpaNode implentation **********
-
- /**
- * covariant override
- */
- @Override
- public JpaContextNode getParent() {
- return (JpaContextNode) super.getParent();
- }
-
-
- // ********** JpaContextNode implementation **********
-
- public JpaResourceType getResourceType() {
- return getParent().getResourceType();
- }
-
- /**
- * Overridden in {@link org.eclipse.jpt.core.internal.context.persistence.AbstractPersistenceUnit}
- * to return itself.
- * Overridden in {@link org.eclipse.jpt.core.internal.jpa1.context.GenericRootContextNode}
- * to return null.
- */
- public PersistenceUnit getPersistenceUnit() {
- return this.getParent().getPersistenceUnit();
- }
-
- /**
- * Overridden in {@link org.eclipse.jpt.core.internal.context.orm.AbstractEntityMappings}
- * to return itself.
- * Overridden in {@link org.eclipse.jpt.core.internal.jpa1.context.GenericRootContextNode}
- * to return null.
- */
- public MappingFileRoot getMappingFileRoot() {
- return this.getParent().getMappingFileRoot();
- }
-
- public Schema getContextDefaultDbSchema() {
- SchemaContainer dbSchemaContainer = this.getContextDefaultDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getContextDefaultSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getContextDefaultDbSchemaContainer() {
- String catalog = this.getContextDefaultCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- protected String getContextDefaultSchema() {
- MappingFileRoot mfr = this.getMappingFileRoot();
- return (mfr != null) ? mfr.getSchema() : this.getPersistenceUnit().getDefaultSchema();
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getContextDefaultDbCatalog() {
- String catalog = this.getContextDefaultCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- protected String getContextDefaultCatalog() {
- MappingFileRoot mfr = this.getMappingFileRoot();
- return (mfr != null) ? mfr.getCatalog() : this.getPersistenceUnit().getDefaultCatalog();
- }
-
- public void postUpdate() {
- // do nothing
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractXmlContextNode.java
deleted file mode 100644
index 66eec94d9e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/AbstractXmlContextNode.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import java.util.List;
-
-import org.eclipse.jpt.core.context.JpaContextNode;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractXmlContextNode
- extends AbstractJpaContextNode
- implements XmlContextNode
-{
-
- // ********** constructor **********
-
- protected AbstractXmlContextNode(JpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** validation **********
-
- /**
- * All subclass implementations {@link #validate(List<IMessage>)}
- * should be preceded by a "super" call to this method
- */
- public void validate(List<IMessage> messages, IReporter reporter) {
- if (reporter.isCancelled()) {
- throw new ValidationCancelledException();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseColumnTextRangeResolver.java
deleted file mode 100644
index e00ff01f66..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseColumnTextRangeResolver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on named columns
- */
-public interface BaseColumnTextRangeResolver extends NamedColumnTextRangeResolver
-{
- TextRange getTableTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseJoinColumnTextRangeResolver.java
deleted file mode 100644
index 1fad1cdf83..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/BaseJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on join columns
- */
-public interface BaseJoinColumnTextRangeResolver extends NamedColumnTextRangeResolver
-{
- TextRange getReferencedColumnNameTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/EntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/EntityTextRangeResolver.java
deleted file mode 100644
index 694feefb54..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/EntityTextRangeResolver.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-
-public interface EntityTextRangeResolver
- extends PrimaryKeyTextRangeResolver
-{
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JoinColumnTextRangeResolver.java
deleted file mode 100644
index e7bfae421c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on join columns
- */
-public interface JoinColumnTextRangeResolver
- extends
- BaseJoinColumnTextRangeResolver,
- BaseColumnTextRangeResolver
-{
- TextRange getReferencedColumnNameTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JptValidator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JptValidator.java
deleted file mode 100644
index 41b38db1ca..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/JptValidator.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import java.util.List;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public interface JptValidator
-{
- /**
- * Return a boolean used to determine whether to continue validating
- */
- boolean validate(List<IMessage> messages, IReporter reporter);
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java
deleted file mode 100644
index 106fc8d1e4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/MappingTools.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0, which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.ColumnMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.ReferenceTable;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.CollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.ElementCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * Gather some of the behavior common to the Java and XML models. :-(
- */
-public class MappingTools {
-
- /**
- * Default join table name from the JPA spec:<br>
- * "The concatenated names of the two associated primary
- * entity tables, separated by a underscore."
- * <pre>
- * [owning table name]_[target table name]
- * </pre>
- * <strong>NB:</strong> The <em>names</em> are concatenated,
- * <em>not</em> the <em>identifiers</em>.
- * E.g. the join table for <code>"Foo"</code> and <code>"baR"</code>
- * (where the "delimited" identifier is required) is:
- * <pre>
- * "Foo_baR"
- * </pre>
- * not
- * <pre>
- * "Foo"_"baR"
- * </pre>
- * As a result, we cannot honestly calculate the default name without a
- * database connection. We need the database to convert the resulting name
- * to an identifier appropriate to the current database.
- */
- public static String buildJoinTableDefaultName(RelationshipReference relationshipReference) {
- if (relationshipReference.getJpaProject().getDataSource().connectionProfileIsActive()) {
- return buildDbJoinTableDefaultName(relationshipReference);
- }
- // continue with a "best effort":
- String owningTableName = relationshipReference.getTypeMapping().getPrimaryTableName();
- if (owningTableName == null) {
- return null;
- }
- RelationshipMapping relationshipMapping = relationshipReference.getRelationshipMapping();
- if (relationshipMapping == null) {
- return null;
- }
- Entity targetEntity = relationshipMapping.getResolvedTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- String targetTableName = targetEntity.getPrimaryTableName();
- if (targetTableName == null) {
- return null;
- }
- return owningTableName + '_' + targetTableName;
- }
-
- /**
- * Use the database to build a more accurate default name.
- */
- protected static String buildDbJoinTableDefaultName(RelationshipReference relationshipReference) {
- Table owningTable = relationshipReference.getTypeMapping().getPrimaryDbTable();
- if (owningTable == null) {
- return null;
- }
- RelationshipMapping relationshipMapping = relationshipReference.getRelationshipMapping();
- if (relationshipMapping == null) {
- return null;
- }
- Entity targetEntity = relationshipMapping.getResolvedTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- Table targetTable = targetEntity.getPrimaryDbTable();
- if (targetTable == null) {
- return null;
- }
- String name = owningTable.getName() + '_' + targetTable.getName();
- return owningTable.getDatabase().convertNameToIdentifier(name);
- }
-
- /**
- * Default collection table name from the JPA spec:<br>
- * "The concatenation of the name of the containing entity and
- * the name of the collection attribute, separated by an underscore."
- * <pre>
- * [owning entity name]_[attribute name]
- * </pre>
- */
- public static String buildCollectionTableDefaultName(ElementCollectionMapping2_0 mapping) {
- Entity entity = mapping.getEntity();
- if (entity == null) {
- return null;
- }
- String owningEntityName = entity.getName();
- String attributeName = mapping.getName();
- return owningEntityName + '_' + attributeName;
- }
-
- /**
- * Return the join column's default name;
- * which is typically
- * [attribute name]_[referenced column name]
- * But, if we don't have an attribute name (e.g. in a unidirectional
- * OneToMany or ManyToMany) is
- * [target entity name]_[referenced column name]
- *
- * @see #buildJoinTableDefaultName(RelationshipMapping)
- */
- public static String buildJoinColumnDefaultName(JoinColumn joinColumn, JoinColumn.Owner owner) {
- if (owner.joinColumnsSize() != 1) {
- return null;
- }
- String prefix = owner.getAttributeName();
- if (prefix == null) {
- Entity targetEntity = owner.getRelationshipTarget();
- if (targetEntity == null) {
- return null;
- }
- prefix = targetEntity.getName();
- }
- // not sure which of these is correct...
- // (the spec implies that the referenced column is always the
- // primary key column of the target entity)
- // Column targetColumn = joinColumn.getTargetPrimaryKeyDbColumn();
- String targetColumnName = joinColumn.getReferencedColumnName();
- if (targetColumnName == null) {
- return null;
- }
- String name = prefix + '_' + targetColumnName;
- // not sure which of these is correct...
- // converting the name to an identifier will result in the identifier
- // being delimited nearly every time (at least on non-Sybase/MS
- // databases); but that probably is not the intent of the spec...
- // return targetColumn.getDatabase().convertNameToIdentifier(name);
- return name;
- }
-
- /**
- * If appropriate, return the name of the single primary key column of the
- * relationship target.
- * Spec states:<br>
- * "The same name as the primary key column of the referenced table."<br>
- * We are assuming that the primary key column is defined by the mappings instead of the database.
- */
- public static String buildJoinColumnDefaultReferencedColumnName(JoinColumn.Owner joinColumnOwner) {
- if (joinColumnOwner.joinColumnsSize() != 1) {
- return null;
- }
- Entity targetEntity = joinColumnOwner.getRelationshipTarget();
- if (targetEntity == null) {
- return null;
- }
- return targetEntity.getPrimaryKeyColumnName();
- }
-
- public static ColumnMapping getColumnMapping(String attributeName, PersistentType persistentType) {
- if (attributeName == null || persistentType == null) {
- return null;
- }
- for (Iterator<PersistentAttribute> stream = persistentType.allAttributes(); stream.hasNext(); ) {
- PersistentAttribute persAttribute = stream.next();
- if (attributeName.equals(persAttribute.getName())) {
- if (persAttribute.getMapping() instanceof ColumnMapping) {
- return (ColumnMapping) persAttribute.getMapping();
- }
- // keep looking or return null???
- }
- }
- return null;
- }
-
- public static RelationshipMapping getRelationshipMapping(String attributeName, TypeMapping typeMapping) {
- if (attributeName == null || typeMapping == null) {
- return null;
- }
- for (Iterator<AttributeMapping> stream = typeMapping.allAttributeMappings(); stream.hasNext(); ) {
- AttributeMapping attributeMapping = stream.next();
- if (attributeName.equals(attributeMapping.getName())) {
- if (attributeMapping instanceof RelationshipMapping) {
- return (RelationshipMapping) attributeMapping;
- }
- // keep looking or return null???
- }
- }
- return null;
- }
-
- public static void convertReferenceTableDefaultToSpecifiedJoinColumn(ReferenceTable referenceTable) {
- JoinColumn defaultJoinColumn = referenceTable.getDefaultJoinColumn();
- if (defaultJoinColumn != null) {
- String columnName = defaultJoinColumn.getDefaultName();
- String referencedColumnName = defaultJoinColumn.getDefaultReferencedColumnName();
- JoinColumn joinColumn = referenceTable.addSpecifiedJoinColumn(0);
- joinColumn.setSpecifiedName(columnName);
- joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
- }
- }
-
- public static void convertJoinTableDefaultToSpecifiedInverseJoinColumn(JoinTable joinTable) {
- JoinColumn defaultInverseJoinColumn = joinTable.getDefaultInverseJoinColumn();
- if (defaultInverseJoinColumn != null) {
- String columnName = defaultInverseJoinColumn.getDefaultName();
- String referencedColumnName = defaultInverseJoinColumn.getDefaultReferencedColumnName();
- JoinColumn joinColumn = joinTable.addSpecifiedInverseJoinColumn(0);
- joinColumn.setSpecifiedName(columnName);
- joinColumn.setSpecifiedReferencedColumnName(referencedColumnName);
- }
- }
-
- public static String getMetamodelFieldMapKeyTypeName(CollectionMapping2_0 mapping) {
- PersistentType targetType = mapping.getResolvedTargetType();
- String mapKey = mapping.getMapKey();
- if (mapKey == null || targetType == null) {
- String mapKeyClass = mapping.getMapKeyClass();
- return mapKeyClass != null ? mapKeyClass : MetamodelField.DEFAULT_TYPE_NAME;
- }
- PersistentAttribute mapKeyAttribute = targetType.resolveAttribute(mapKey);
- if (mapKeyAttribute == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- AttributeMapping2_0 mapKeyMapping = (AttributeMapping2_0) mapKeyAttribute.getMapping();
- if (mapKeyMapping == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- return mapKeyMapping.getMetamodelTypeName();
- }
-
- public static Column resolveOverridenColumn(TypeMapping overridableTypeMapping, String attributeOverrideName) {
- if (overridableTypeMapping != null) {
- for (TypeMapping typeMapping : CollectionTools.iterable(overridableTypeMapping.inheritanceHierarchy())) {
- Column column = typeMapping.resolveOverriddenColumn(attributeOverrideName);
- if (column != null) {
- return column;
- }
- }
- }
- return null;
- }
-
- public static RelationshipReference resolveRelationshipReference(TypeMapping overridableTypeMapping, String associationOverrideName) {
- if (overridableTypeMapping != null) {
- for (TypeMapping typeMapping : CollectionTools.iterable(overridableTypeMapping.inheritanceHierarchy())) {
- RelationshipReference relationshipReference = typeMapping.resolveRelationshipReference(associationOverrideName);
- if (relationshipReference != null) {
- return relationshipReference;
- }
- }
- }
- return null;
- }
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private MappingTools() {
- super();
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/NamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/NamedColumnTextRangeResolver.java
deleted file mode 100644
index 286c6d7e2a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/NamedColumnTextRangeResolver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on named columns
- */
-public interface NamedColumnTextRangeResolver
-{
- TextRange getNameTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/OverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/OverrideTextRangeResolver.java
deleted file mode 100644
index 281cfb8791..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/OverrideTextRangeResolver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on named columns
- */
-public interface OverrideTextRangeResolver
-{
- TextRange getNameTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributePropertyTester.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributePropertyTester.java
deleted file mode 100644
index 80ee5ff187..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributePropertyTester.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-
-public class PersistentAttributePropertyTester extends PropertyTester
-{
- public static final String IS_MAPPED = "isMapped";
-
- public static final String IS_VIRTUAL = "isVirtual";
-
-
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (IS_MAPPED.equals(property)) {
- Boolean expectedIsMapped;
-
- try {
- expectedIsMapped = (Boolean) expectedValue;
- }
- catch (ClassCastException cce) {
- return false;
- }
-
- Boolean actualIsMapped = ((PersistentAttribute) receiver).getMappingKey() != MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY;
-
- return actualIsMapped == expectedIsMapped;
- }
- else if (IS_VIRTUAL.equals(property)) {
- Boolean expectedIsVirtual;
-
- try {
- expectedIsVirtual = (Boolean) expectedValue;
- }
- catch (ClassCastException cce) {
- return false;
- }
-
- Boolean actualIsVirtual = false;
- if (receiver instanceof OrmPersistentAttribute) {
- actualIsVirtual = ((OrmPersistentAttribute) receiver).isVirtual();
- }
-
- return actualIsVirtual == expectedIsVirtual;
- }
-
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributeTextRangeResolver.java
deleted file mode 100644
index bd2a663dc0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PersistentAttributeTextRangeResolver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on persistent attributes
- */
-public interface PersistentAttributeTextRangeResolver
-{
- TextRange getAttributeTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PrimaryKeyTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PrimaryKeyTextRangeResolver.java
deleted file mode 100644
index 9af7a2ceaa..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/PrimaryKeyTextRangeResolver.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on persistent type mappings that can define primary keys
- */
-public interface PrimaryKeyTextRangeResolver extends TypeMappingTextRangeResolver
-{
-
- TextRange getIdClassTextRange();
-
- TextRange getAttributeMappingTextRange(String attributeName);
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TableTextRangeResolver.java
deleted file mode 100644
index 947a1b0271..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TableTextRangeResolver.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on named columns
- */
-public interface TableTextRangeResolver
-{
- TextRange getNameTextRange();
-
- TextRange getSchemaTextRange();
-
- TextRange getCatalogTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TypeMappingTextRangeResolver.java
deleted file mode 100644
index 850f0a6caa..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/TypeMappingTextRangeResolver.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context;
-
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on persistent type mappings
- */
-public interface TypeMappingTextRangeResolver
-{
- TextRange getTypeMappingTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java
deleted file mode 100644
index 50b0229ea6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAssociationOverrideRelationshipReference.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnInAssociationOverrideJoiningStrategy;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaAssociationOverrideRelationshipReference extends AbstractJavaJpaContextNode
- implements JavaAssociationOverrideRelationshipReference
-{
-
- // cache the strategy for property change notification
- protected JoiningStrategy cachedPredominantJoiningStrategy;
-
- protected final JavaJoinColumnInAssociationOverrideJoiningStrategy joinColumnJoiningStrategy;
-
- protected AbstractJavaAssociationOverrideRelationshipReference(JavaAssociationOverride parent) {
- super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- }
-
- protected JavaJoinColumnInAssociationOverrideJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericJavaJoinColumnInAssociationOverrideJoiningStrategy(this);
- }
-
- @Override
- public JavaAssociationOverride getParent() {
- return (JavaAssociationOverride) super.getParent();
- }
-
- public JavaAssociationOverride getAssociationOverride() {
- return getParent();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public TypeMapping getTypeMapping() {
- return getAssociationOverride().getOwner().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-
- // **************** RelationshipMapping implementation *******************************
-
- public boolean isParentVirtual() {
- return getAssociationOverride().isVirtual();
- }
-
- // **************** predominant joining strategy ***************************
-
- public JoiningStrategy getPredominantJoiningStrategy() {
- return this.cachedPredominantJoiningStrategy;
- }
-
- protected void setPredominantJoiningStrategy(JoiningStrategy newJoiningStrategy) {
- JoiningStrategy oldJoiningStrategy = this.cachedPredominantJoiningStrategy;
- this.cachedPredominantJoiningStrategy = newJoiningStrategy;
- firePropertyChanged(PREDOMINANT_JOINING_STRATEGY_PROPERTY, oldJoiningStrategy, newJoiningStrategy);
- }
-
- public void initialize(AssociationOverrideAnnotation associationOverride) {
- initializeJoiningStrategies(associationOverride);
- this.cachedPredominantJoiningStrategy = calculatePredominantJoiningStrategy();
- }
-
- protected void initializeJoiningStrategies(AssociationOverrideAnnotation associationOverride) {
- this.joinColumnJoiningStrategy.initialize(associationOverride);
- }
-
- public void update(AssociationOverrideAnnotation associationOverride) {
- updateJoiningStrategies(associationOverride);
- setPredominantJoiningStrategy(calculatePredominantJoiningStrategy());
- }
-
- protected void updateJoiningStrategies(AssociationOverrideAnnotation associationOverride) {
- this.joinColumnJoiningStrategy.update(associationOverride);
- }
-
- protected abstract JoiningStrategy calculatePredominantJoiningStrategy();
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getAssociationOverride().getValidationTextRange(astRoot);
- }
-
- // **************** join columns *******************************************
-
-
- public JavaJoinColumnInAssociationOverrideJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.addStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return getAssociationOverride().getOwner().getRelationshipMapping(getAssociationOverride().getName());
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return getRelationshipMapping().isOwnedBy(mapping);
- }
-
- public boolean isRelationshipOwner() {
- return getRelationshipMapping().isRelationshipOwner();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
deleted file mode 100644
index fe0ab53a8c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMapping.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.ColumnMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.SimpleMetamodelField;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java attribute mapping
- */
-public abstract class AbstractJavaAttributeMapping<T extends Annotation>
- extends AbstractJavaJpaContextNode
- implements JavaAttributeMapping, AttributeMapping2_0
-{
- protected T mappingAnnotation;
-
- protected Vector<String> supportingAnnotationNames;
-
-
- protected AbstractJavaAttributeMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- @SuppressWarnings("unchecked")
- public void initialize(Annotation annotation) {
- this.mappingAnnotation = (T) annotation;
- this.initialize();
- }
-
- protected void initialize() {
- // do nothing by default
- }
-
- @SuppressWarnings("unchecked")
- public void update(Annotation annotation) {
- this.mappingAnnotation = (T) annotation;
- this.update();
- }
-
- protected void update() {
- // do nothing by default
- }
-
- @Override
- public JavaPersistentAttribute getParent() {
- return (JavaPersistentAttribute) super.getParent();
- }
-
- public JavaPersistentAttribute getPersistentAttribute() {
- return this.getParent();
- }
-
- protected JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.getParent().getResourcePersistentAttribute();
- }
-
- public T getMappingAnnotation() {
- return this.mappingAnnotation;
- }
-
- /**
- * the persistent attribute can tell whether there is a "specified" mapping
- * or a "default" one
- */
- public boolean isDefault() {
- return this.getPersistentAttribute().mappingIsDefault(this);
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return this.getTypeMapping().shouldValidateAgainstDatabase();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getPersistentAttribute().getOwningTypeMapping();
- }
-
- public String getName() {
- return this.getPersistentAttribute().getName();
- }
-
- public Table getDbTable(String tableName) {
- return this.getTypeMapping().getDbTable(tableName);
- }
-
- public String getPrimaryKeyColumnName() {
- return null;
- }
-
- public boolean isOverridableAttributeMapping() {
- return false;
- }
-
- public boolean isOverridableAssociationMapping() {
- return false;
- }
-
- public boolean isRelationshipOwner() {
- return false;
- }
-
- public boolean isOwnedBy(AttributeMapping mapping) {
- return false;
- }
-
- public Iterator<String> allMappingNames() {
- return new SingleElementIterator<String>(getName());
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- if (getName().equals(name)) {
- return this;
- }
- return null;
- }
-
- public Iterator<String> allOverrideableAttributeMappingNames() {
- if (isOverridableAttributeMapping()) {
- return new SingleElementIterator<String>(getName());
- }
- return EmptyIterator.<String> instance();
- }
-
- public Iterator<String> allOverrideableAssociationMappingNames() {
- if (isOverridableAssociationMapping()) {
- return new SingleElementIterator<String>(getName());
- }
- return EmptyIterator.<String> instance();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- ColumnMapping columnMapping = this.resolveColumnMapping(attributeName);
- return columnMapping == null ? null : columnMapping.getColumn();
- }
-
- protected ColumnMapping resolveColumnMapping(String name) {
- AttributeMapping attributeMapping = resolveAttributeMapping(name);
- if (attributeMapping != null && attributeMapping.isOverridableAttributeMapping()) {
- return (ColumnMapping) attributeMapping;
- }
- return null;
- }
-
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- RelationshipMapping relationshipMapping = this.resolveRelationshipMapping(attributeName);
- return relationshipMapping == null ? null : relationshipMapping.getRelationshipReference();
- }
-
- protected RelationshipMapping resolveRelationshipMapping(String name) {
- AttributeMapping attributeMapping = resolveAttributeMapping(name);
- if (attributeMapping != null && attributeMapping.isOverridableAssociationMapping()) {
- return (RelationshipMapping) attributeMapping;
- }
- return null;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** supporting annotation names **********
-
- public Iterable<String> getSupportingAnnotationNames() {
- if (this.supportingAnnotationNames == null) {
- this.supportingAnnotationNames = this.buildSupportingAnnotationNames();
- }
- return this.supportingAnnotationNames;
- }
-
- protected Vector<String> buildSupportingAnnotationNames() {
- Vector<String> names = new Vector<String>();
- this.addSupportingAnnotationNamesTo(names);
- return names;
- }
-
- protected void addSupportingAnnotationNamesTo(@SuppressWarnings("unused") Vector<String> names) {
- // the default is none
- }
-
-
- // ********** metamodel **********
-
- public MetamodelField getMetamodelField() {
- return new SimpleMetamodelField(
- this.getMetamodelFieldModifiers(),
- this.getMetamodelFieldTypeName(),
- this.getMetamodelFieldTypeArgumentNames(),
- this.getMetamodelFieldName()
- );
- }
-
- protected Iterable<String> getMetamodelFieldModifiers() {
- return STANDARD_METAMODEL_FIELD_MODIFIERS;
- }
-
- /**
- * most mappings are "singular"
- */
- protected String getMetamodelFieldTypeName() {
- return JPA2_0.SINGULAR_ATTRIBUTE;
- }
-
- protected final Iterable<String> getMetamodelFieldTypeArgumentNames() {
- ArrayList<String> typeArgumentNames = new ArrayList<String>(3);
- typeArgumentNames.add(this.getTypeMapping().getPersistentType().getName());
- this.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames);
- return typeArgumentNames;
- }
-
- /**
- * by default, we add only the mapping's attribute type name;
- * but collection relationship mappings will also need to add the key type
- * name if the "collection" is of type java.util.Map
- */
- protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) {
- typeArgumentNames.add(this.getMetamodelTypeName());
- }
-
- public String getMetamodelTypeName() {
- return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelTypeName();
- }
-
- protected String getMetamodelFieldName() {
- return this.getName();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateMappingType(messages, astRoot);
- }
-
- protected void validateMappingType(List<IMessage> messages, CompilationUnit astRoot) {
- if ( ! this.getTypeMapping().attributeMappingKeyAllowed(this.getKey())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getMappingAnnotationTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- protected TextRange getMappingAnnotationTextRange(CompilationUnit astRoot) {
- return (this.mappingAnnotation == null) ? null : this.mappingAnnotation.getTextRange(astRoot);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java
deleted file mode 100644
index 46bbad8953..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaAttributeMappingDefinition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-
-public abstract class AbstractJavaAttributeMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- protected AbstractJavaAttributeMappingDefinition() {
- super();
- }
-
-
- /**
- * Default implementation. Override if the mapping definition applies in the annotationless case.
- */
- public boolean testDefault(JavaPersistentAttribute persistentAttribute) {
- return false;
- }
-
- /**
- * Default implementation. Override if the mapping definition needs to do more analysis.
- */
- public boolean testSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(getAnnotationName())
- != null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
deleted file mode 100644
index cae35d5535..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseColumn.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.BaseColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-
-public abstract class AbstractJavaBaseColumn<T extends BaseColumnAnnotation> extends AbstractJavaNamedColumn<T>
- implements JavaBaseColumn
-{
-
- protected String specifiedTable;
-
- protected String defaultTable;
-
- protected Boolean specifiedUnique;
-
- protected Boolean specifiedNullable;
-
- protected Boolean specifiedInsertable;
-
- protected Boolean specifiedUpdatable;
-
- protected AbstractJavaBaseColumn(JavaJpaContextNode parent, JavaBaseColumn.Owner owner) {
- super(parent, owner);
- }
-
- @Override
- protected void initialize(T column) {
- super.initialize(column);
- this.defaultTable = this.buildDefaultTableName();
- this.specifiedTable = this.getResourceTable();
- this.specifiedUnique = this.getResourceUnique();
- this.specifiedNullable = this.getResourceNullable();
- this.specifiedInsertable = this.getResourceInsertable();
- this.specifiedUpdatable = this.getResourceUpdatable();
- }
-
- @Override
- protected void update(T column) {
- super.update(column);
- this.setDefaultTable(this.buildDefaultTableName());
- this.setSpecifiedTable_(this.getResourceTable());
- this.setSpecifiedUnique_(this.getResourceUnique());
- this.setSpecifiedNullable_(this.getResourceNullable());
- this.setSpecifiedInsertable_(this.getResourceInsertable());
- this.setSpecifiedUpdatable_(this.getResourceUpdatable());
- }
-
- @Override
- public JavaBaseColumn.Owner getOwner() {
- return (JavaBaseColumn.Owner) super.getOwner();
- }
-
- //************** BaseColumn implementation *******************
-
- //************** table *******************
-
- @Override
- public String getTable() {
- return (this.getSpecifiedTable() == null) ? getDefaultTable() : this.getSpecifiedTable();
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- public void setSpecifiedTable(String newSpecifiedTable) {
- String oldSpecifiedTable = this.specifiedTable;
- this.specifiedTable = newSpecifiedTable;
- getResourceColumn().setTable(newSpecifiedTable);
- firePropertyChanged(BaseColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedTable_(String newSpecifiedTable) {
- String oldSpecifiedTable = this.specifiedTable;
- this.specifiedTable = newSpecifiedTable;
- firePropertyChanged(BaseColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String newDefaultTable) {
- String oldDefaultTable = this.defaultTable;
- this.defaultTable = newDefaultTable;
- firePropertyChanged(BaseColumn.DEFAULT_TABLE_PROPERTY, oldDefaultTable, newDefaultTable);
- }
-
- protected String getResourceTable() {
- return getResourceColumn().getTable();
- }
-
- public boolean tableNameIsInvalid() {
- return getOwner().tableNameIsInvalid(getTable());
- }
-
- //************** unique *******************
-
- public boolean isUnique() {
- return (this.getSpecifiedUnique() == null) ? this.isDefaultUnique() : this.getSpecifiedUnique().booleanValue();
- }
-
- public boolean isDefaultUnique() {
- return BaseColumn.DEFAULT_UNIQUE;
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- public void setSpecifiedUnique(Boolean newSpecifiedUnique) {
- Boolean oldSpecifiedUnique = this.specifiedUnique;
- this.specifiedUnique = newSpecifiedUnique;
- this.getResourceColumn().setUnique(newSpecifiedUnique);
- firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedUnique_(Boolean newSpecifiedUnique) {
- Boolean oldSpecifiedUnique = this.specifiedUnique;
- this.specifiedUnique = newSpecifiedUnique;
- firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
- }
-
- protected Boolean getResourceUnique() {
- return getResourceColumn().getUnique();
- }
-
- //************** nullable *******************
-
- public boolean isNullable() {
- return (this.getSpecifiedNullable() == null) ? this.isDefaultNullable() : this.getSpecifiedNullable().booleanValue();
- }
-
- public boolean isDefaultNullable() {
- return BaseColumn.DEFAULT_NULLABLE;
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- public void setSpecifiedNullable(Boolean newSpecifiedNullable) {
- Boolean oldSpecifiedNullable = this.specifiedNullable;
- this.specifiedNullable = newSpecifiedNullable;
- this.getResourceColumn().setNullable(newSpecifiedNullable);
- firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedNullable_(Boolean newSpecifiedNullable) {
- Boolean oldSpecifiedNullable = this.specifiedNullable;
- this.specifiedNullable = newSpecifiedNullable;
- firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
- }
-
- protected Boolean getResourceNullable() {
- return getResourceColumn().getNullable();
- }
-
- //************** insertable *******************
-
- public boolean isInsertable() {
- return (this.getSpecifiedInsertable() == null) ? this.isDefaultInsertable() : this.getSpecifiedInsertable().booleanValue();
- }
-
- public boolean isDefaultInsertable() {
- return BaseColumn.DEFAULT_INSERTABLE;
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) {
- Boolean oldSpecifiedInsertable = this.specifiedInsertable;
- this.specifiedInsertable = newSpecifiedInsertable;
- this.getResourceColumn().setInsertable(newSpecifiedInsertable);
- firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedInsertable_(Boolean newSpecifiedInsertable) {
- Boolean oldSpecifiedInsertable = this.specifiedInsertable;
- this.specifiedInsertable = newSpecifiedInsertable;
- firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
- }
-
- protected Boolean getResourceInsertable() {
- return getResourceColumn().getInsertable();
- }
-
- //************** updatable *******************
-
- public boolean isUpdatable() {
- return (this.getSpecifiedUpdatable() == null) ? this.isDefaultUpdatable() : this.getSpecifiedUpdatable().booleanValue();
- }
-
- public boolean isDefaultUpdatable() {
- return BaseColumn.DEFAULT_UPDATABLE;
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) {
- Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
- this.specifiedUpdatable = newSpecifiedUpdatable;
- this.getResourceColumn().setUpdatable(newSpecifiedUpdatable);
- firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedUpdatable_(Boolean newSpecifiedUpdatable) {
- Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
- this.specifiedUpdatable = newSpecifiedUpdatable;
- firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
- }
-
- protected Boolean getResourceUpdatable() {
- return getResourceColumn().getUpdatable();
- }
-
- public TextRange getTableTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceColumn().getTableTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- public boolean tableTouches(int pos, CompilationUnit astRoot) {
- return getResourceColumn().tableTouches(pos, astRoot);
- }
-
- public Iterator<String> candidateTableNames() {
- return getOwner().candidateTableNames();
- }
-
- private Iterator<String> candidateTableNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateTableNames(), filter);
- }
-
- private Iterator<String> javaCandidateTableNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateTableNames(filter));
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.tableTouches(pos, astRoot)) {
- return this.javaCandidateTableNames(filter);
- }
- return null;
- }
-
- protected String buildDefaultTableName() {
- return this.getOwner().getDefaultTableName();
- }
-
- @Override
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaBaseColumnTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java
deleted file mode 100644
index 28217ee14f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaBaseEmbeddedMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaBaseEmbeddedMapping<T extends Annotation>
- extends AbstractJavaAttributeMapping<T>
- implements JavaBaseEmbeddedMapping
-{
- protected final JavaAttributeOverrideContainer attributeOverrideContainer;
-
- private Embeddable targetEmbeddable;
-
-
- protected AbstractJavaBaseEmbeddedMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.attributeOverrideContainer =
- this.getJpaFactory().buildJavaAttributeOverrideContainer(
- this,
- buildAttributeOverrideContainerOwner());
- }
-
-
- protected JavaAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() {
- return new AttributeOverrideContainerOwner();
- }
-
- public JavaAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return this.targetEmbeddable;
- }
-
-
- //****************** JavaAttributeMapping implementation *******************
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.ATTRIBUTE_OVERRIDE);
- names.add(JPA.ATTRIBUTE_OVERRIDES);
- }
-
- public Embeddable getTargetEmbeddable() {
- return this.targetEmbeddable;
- }
-
- protected void setTargetEmbeddable_(Embeddable newTargetEmbeddable) {
- Embeddable oldTargetEmbeddable = this.targetEmbeddable;
- this.targetEmbeddable = newTargetEmbeddable;
- firePropertyChanged(TARGET_EMBEDDABLE_PROPERTY, oldTargetEmbeddable, newTargetEmbeddable);
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.attributeOverrideContainer.initialize(this.getResourcePersistentAttribute());
- this.targetEmbeddable = this.getPersistentAttribute().getEmbeddable();
- }
-
- @Override
- protected void update() {
- super.update();
- setTargetEmbeddable_(this.getPersistentAttribute().getEmbeddable());
- this.attributeOverrideContainer.update(this.getResourcePersistentAttribute());
- }
-
- protected Iterator<AttributeMapping> embeddableAttributeMappings() {
- Embeddable targetEmbeddable = getTargetEmbeddable();
- if (targetEmbeddable != null && targetEmbeddable != getPersistentAttribute().getOwningTypeMapping()) {
- return targetEmbeddable.attributeMappings();
- }
- return EmptyIterator.instance();
- }
-
- @Override
- public Iterator<String> allOverrideableAttributeMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverrideableAttributeMappingNames() :
- super.allOverrideableAttributeMappingNames();
- }
-
- protected Iterator<String> embeddableOverrideableAttributeMappingNames() {
- return this.embeddableOverrideableMappingNames(
- new Transformer<AttributeMapping, Iterator<String>>() {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAttributeMappingNames();
- }
- }
- );
- }
-
- @Override
- public Iterator<String> allOverrideableAssociationMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverrideableAssociationMappingNames() :
- super.allOverrideableAssociationMappingNames();
- }
-
- protected Iterator<String> embeddableOverrideableAssociationMappingNames() {
- return this.embeddableOverrideableMappingNames(
- new Transformer<AttributeMapping, Iterator<String>>() {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAssociationMappingNames();
- }
- }
- );
- }
-
- protected Iterator<String> embeddableOverrideableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<String, String>(
- new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer)))
- {
- @Override
- protected String transform(String next) {
- return getName() + '.' + next;
- }
- };
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- if (this.isJpa2_0Compatible()) {
- int dotIndex = attributeName.indexOf('.');
- if (dotIndex != -1) {
- if (getName().equals(attributeName.substring(0, dotIndex))) {
- attributeName = attributeName.substring(dotIndex + 1);
- AttributeOverride override = getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getColumn();
- }
- if (this.getTargetEmbeddable() == null) {
- return null;
- }
- return this.getTargetEmbeddable().resolveOverriddenColumn(attributeName);
- }
- }
- }
- return null;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- result = getAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
- //******** Validation ******************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- if (validateTargetEmbeddable(messages, reporter, astRoot)) {
- validateOverrides(messages, reporter, astRoot);
- }
- }
-
- protected boolean validateTargetEmbeddable(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (getTargetEmbeddable() == null) {
- String targetEmbeddableTypeName = getPersistentAttribute().getTypeName();
- // if the type isn't resolveable, there'll already be a java error
- if (targetEmbeddableTypeName != null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_NOT_AN_EMBEDDABLE,
- new String[] {targetEmbeddableTypeName},
- this,
- this.getValidationTextRange(astRoot)));
- }
- return false;
- }
- return true;
- }
-
- protected void validateOverrides(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- getAttributeOverrideContainer().validate(messages, reporter, astRoot);
- }
-
- //********** AttributeOverrideContainer.Owner implementation *********
-
- protected class AttributeOverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaBaseEmbeddedMapping.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaBaseEmbeddedMapping.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : allOverridableAttributeNames_(typeMapping);
- }
-
- /* assumes the type mapping is not null */
- protected Iterator<String> allOverridableAttributeNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAttributeNames();
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- public boolean isRelevant(String overrideName) {
- //no prefix, so always true
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaBaseEmbeddedMapping.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java
deleted file mode 100644
index 3e27e83e3a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaBasicMapping.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.Fetchable;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.Nullable;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaConverter;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.EnumeratedAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.LobAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaBasicMapping
- extends AbstractJavaAttributeMapping<BasicAnnotation>
- implements JavaBasicMapping
-{
- protected FetchType specifiedFetch;
-
- protected Boolean specifiedOptional;
-
- protected final JavaColumn column;
-
- protected JavaConverter converter;
-
- protected final JavaConverter nullConverter;
-
- protected AbstractJavaBasicMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = getJpaFactory().buildJavaColumn(this, this);
- this.nullConverter = getJpaFactory().buildJavaNullConverter(this);
- this.converter = this.nullConverter;
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.column.initialize(this.getResourceColumn());
- this.converter = this.buildConverter(this.getResourceConverterType());
- this.specifiedFetch = this.getResourceFetch();
- this.specifiedOptional = this.getResourceOptional();
- }
-
- public ColumnAnnotation getResourceColumn() {
- return (ColumnAnnotation) getResourcePersistentAttribute().getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- //************** AttributeMapping implementation ***************
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- //************** JavaAttributeMapping implementation ***************
- public String getAnnotationName() {
- return BasicAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.COLUMN);
- names.add(JPA.LOB);
- names.add(JPA.TEMPORAL);
- names.add(JPA.ENUMERATED);
- }
-
- public String getDefaultColumnName() {
- return getName();
- }
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- //************** BasicMapping implementation ***************
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- public FetchType getFetch() {
- return (this.getSpecifiedFetch() == null) ? this.getDefaultFetch() : this.getSpecifiedFetch();
- }
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType newSpecifiedFetch) {
- FetchType oldFetch = this.specifiedFetch;
- this.specifiedFetch = newSpecifiedFetch;
- this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(newSpecifiedFetch));
- firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedFetch_(FetchType newSpecifiedFetch) {
- FetchType oldFetch = this.specifiedFetch;
- this.specifiedFetch = newSpecifiedFetch;
- firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch);
- }
-
- public boolean isOptional() {
- return (this.getSpecifiedOptional() == null) ? this.isDefaultOptional() : this.getSpecifiedOptional().booleanValue();
- }
-
- public boolean isDefaultOptional() {
- return Nullable.DEFAULT_OPTIONAL;
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean newSpecifiedOptional) {
- Boolean oldOptional = this.specifiedOptional;
- this.specifiedOptional = newSpecifiedOptional;
- this.mappingAnnotation.setOptional(newSpecifiedOptional);
- firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional);
- }
-
- protected void setSpecifiedOptional_(Boolean newSpecifiedOptional) {
- Boolean oldOptional = this.specifiedOptional;
- this.specifiedOptional = newSpecifiedOptional;
- firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional);
- }
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- JavaConverter oldConverter = this.converter;
- JavaConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(JavaConverter newConverter) {
- JavaConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- @Override
- protected void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update(this.getResourcePersistentAttribute());
- }
- else {
- JavaConverter javaConverter = buildConverter(getResourceConverterType());
- setConverter(javaConverter);
- }
- this.setSpecifiedFetch_(this.getResourceFetch());
- this.setSpecifiedOptional_(this.getResourceOptional());
- }
-
- protected FetchType getResourceFetch() {
- return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch());
- }
-
- protected Boolean getResourceOptional() {
- return this.mappingAnnotation.getOptional();
- }
-
- protected JavaConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.ENUMERATED_CONVERTER)) {
- return getJpaFactory().buildJavaEnumeratedConverter(this, this.getResourcePersistentAttribute());
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute());
- }
- if (this.valuesAreEqual(converterType, Converter.LOB_CONVERTER)) {
- return getJpaFactory().buildJavaLobConverter(this, this.getResourcePersistentAttribute());
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.getResourcePersistentAttribute().getAnnotation(EnumeratedAnnotation.ANNOTATION_NAME) != null) {
- return Converter.ENUMERATED_CONVERTER;
- }
- if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- if (this.getResourcePersistentAttribute().getAnnotation(LobAnnotation.ANNOTATION_NAME) != null) {
- return Converter.LOB_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = getConverter().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.getColumn().validate(messages, reporter, astRoot);
- this.getConverter().validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java
deleted file mode 100644
index 0bcff08ea6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEmbeddable.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-
-
-public abstract class AbstractJavaEmbeddable
- extends AbstractJavaTypeMapping
- implements JavaEmbeddable
-{
- protected AbstractJavaEmbeddable(JavaPersistentType parent) {
- super(parent);
- }
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddableAnnotation.ANNOTATION_NAME;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return EmptyIterable.instance();
- }
-
- public boolean isMapped() {
- return true;
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
deleted file mode 100644
index e5cdff300d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaEntity.java
+++ /dev/null
@@ -1,1776 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.JpaPlatformVariation.Supported;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AssociationOverride;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.SecondaryTable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaBaseJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaDiscriminatorColumn;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaQueryContainer;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.java.JavaTable;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinTableValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.DiscriminatorColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericEntityPrimaryKeyValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.MappedSuperclassOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.SecondaryTableValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.TableValidator;
-import org.eclipse.jpt.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0;
-import org.eclipse.jpt.core.resource.java.DiscriminatorColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.DiscriminatorValueAnnotation;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.core.resource.java.InheritanceAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.core.resource.java.SecondaryTablesAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaEntity
- extends AbstractJavaTypeMapping
- implements JavaEntity, JavaCacheableHolder2_0
-{
- protected String specifiedName;
-
- protected String defaultName;
-
- protected final JavaIdClassReference idClassReference;
-
- protected final JavaTable table;
-
- protected boolean specifiedTableIsAllowed;
-
- protected boolean tableIsUndefined;
-
- protected final List<JavaSecondaryTable> specifiedSecondaryTables;
-
- protected final List<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns;
-
- protected JavaPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn;
-
- protected InheritanceType specifiedInheritanceStrategy;
-
- protected InheritanceType defaultInheritanceStrategy;
-
- protected String defaultDiscriminatorValue;
-
- protected String specifiedDiscriminatorValue;
-
- protected boolean specifiedDiscriminatorValueIsAllowed;
-
- protected boolean discriminatorValueIsUndefined;
-
- protected final JavaDiscriminatorColumn discriminatorColumn;
-
- protected boolean specifiedDiscriminatorColumnIsAllowed;
-
- protected boolean discriminatorColumnIsUndefined;
-
- protected final JavaAttributeOverrideContainer attributeOverrideContainer;
-
- protected final JavaAssociationOverrideContainer associationOverrideContainer;
-
- protected final JavaQueryContainer queryContainer;
-
- protected final JavaGeneratorContainer generatorContainer;
-
- protected Entity rootEntity;
-
-
- protected AbstractJavaEntity(JavaPersistentType parent) {
- super(parent);
- this.idClassReference = buildIdClassReference();
- this.table = this.getJpaFactory().buildJavaTable(this, new TableOwner());
- this.discriminatorColumn = buildJavaDiscriminatorColumn();
- this.specifiedSecondaryTables = new ArrayList<JavaSecondaryTable>();
- this.specifiedPrimaryKeyJoinColumns = new ArrayList<JavaPrimaryKeyJoinColumn>();
- this.attributeOverrideContainer =
- getJpaFactory().buildJavaAttributeOverrideContainer(this, new AttributeOverrideContainerOwner());
- this.associationOverrideContainer =
- getJpaFactory().buildJavaAssociationOverrideContainer(this, new AssociationOverrideContainerOwner());
- this.queryContainer = getJpaFactory().buildJavaQueryContainer(this);
- this.generatorContainer = getJpaFactory().buildJavaGeneratorContainer(this);
- }
-
- protected JavaIdClassReference buildIdClassReference() {
- return new GenericJavaIdClassReference(this);
- }
-
- protected JavaBaseJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected JavaDiscriminatorColumn buildJavaDiscriminatorColumn() {
- return this.getJpaFactory().buildJavaDiscriminatorColumn(this, buildDiscriminatorColumnOwner());
- }
-
- protected JavaDiscriminatorColumn.Owner buildDiscriminatorColumnOwner() {
- return new JavaDiscriminatorColumn.Owner(){
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this;
- }
-
- public String getDefaultColumnName() {
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getName()
- :
- discriminatorColumnIsUndefined()?
- null
- :
- DiscriminatorColumn.DEFAULT_NAME;
- }
-
- public int getDefaultLength() {
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getLength()
- :
- discriminatorColumnIsUndefined()?
- 0//TODO think i want to return null here
- :
- DiscriminatorColumn.DEFAULT_LENGTH;
- }
-
- public DiscriminatorType getDefaultDiscriminatorType() {
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getDiscriminatorType()
- :
- discriminatorColumnIsUndefined()?
- null
- :
- DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE;
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new DiscriminatorColumnValidator(column, textRangeResolver);
- }
- };
- }
-
- @Override
- public void initialize(JavaResourcePersistentType resourcePersistentType) {
- super.initialize(resourcePersistentType);
-
- this.specifiedName = this.getResourceName();
- this.defaultName = this.getResourceDefaultName();
- this.idClassReference.initialize();
- this.rootEntity = calculateRootEntity();
- this.defaultInheritanceStrategy = this.buildDefaultInheritanceStrategy();
- this.specifiedInheritanceStrategy = this.getResourceInheritanceStrategy(getResourceInheritance());
- this.specifiedDiscriminatorValueIsAllowed = this.buildSpecifiedDiscriminatorValueIsAllowed();
- this.discriminatorValueIsUndefined = this.buildDiscriminatorValueIsUndefined();
- this.specifiedDiscriminatorValue = this.getResourceDiscriminatorValue().getValue();
- this.defaultDiscriminatorValue = this.buildDefaultDiscriminatorValue();
- this.specifiedDiscriminatorColumnIsAllowed = this.buildSpecifiedDiscriminatorColumnIsAllowed();
- this.discriminatorColumnIsUndefined = this.buildDiscriminatorColumnIsUndefined();
- this.discriminatorColumn.initialize(this.getResourceDiscriminatorColumn());
- this.specifiedTableIsAllowed = this.buildSpecifiedTableIsAllowed();
- this.tableIsUndefined = this.buildTableIsUndefined();
- this.table.initialize(resourcePersistentType);
- this.initializeSecondaryTables();
- this.generatorContainer.initialize(resourcePersistentType);
- this.queryContainer.initialize(resourcePersistentType);
- this.initializePrimaryKeyJoinColumns();
- this.initializeDefaultPrimaryKeyJoinColumn();
- this.attributeOverrideContainer.initialize(resourcePersistentType);
- this.associationOverrideContainer.initialize(resourcePersistentType);
- }
-
- protected void initializeSecondaryTables() {
- for (Iterator<NestableAnnotation> stream =
- this.javaResourcePersistentType.annotations(
- SecondaryTableAnnotation.ANNOTATION_NAME,
- SecondaryTablesAnnotation.ANNOTATION_NAME);
- stream.hasNext(); ) {
- this.specifiedSecondaryTables.add(
- buildSecondaryTable((SecondaryTableAnnotation) stream.next()));
- }
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- for (Iterator<NestableAnnotation> stream =
- this.javaResourcePersistentType.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- stream.hasNext(); ) {
- this.specifiedPrimaryKeyJoinColumns.add(
- buildPrimaryKeyJoinColumn((PrimaryKeyJoinColumnAnnotation) stream.next()));
- }
- }
-
- protected boolean shouldBuildDefaultPrimaryKeyJoinColumn() {
- return !containsSpecifiedPrimaryKeyJoinColumns();
- }
-
- protected void initializeDefaultPrimaryKeyJoinColumn() {
- if (!shouldBuildDefaultPrimaryKeyJoinColumn()) {
- return;
- }
- this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType));
- }
-
- //query for the inheritance resource every time on setters.
- //call one setter and the inheritanceResource could change.
- //You could call more than one setter before this object has received any notification
- //from the java resource model
- protected InheritanceAnnotation getResourceInheritance() {
- return (InheritanceAnnotation) this.javaResourcePersistentType.
- getNonNullAnnotation(InheritanceAnnotation.ANNOTATION_NAME);
- }
-
- protected DiscriminatorValueAnnotation getResourceDiscriminatorValue() {
- return (DiscriminatorValueAnnotation) this.javaResourcePersistentType.
- getNonNullAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
- }
-
- protected DiscriminatorColumnAnnotation getResourceDiscriminatorColumn() {
- return (DiscriminatorColumnAnnotation) this.javaResourcePersistentType.
- getNonNullAnnotation(DiscriminatorColumnAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected EntityAnnotation getResourceMappingAnnotation() {
- return (EntityAnnotation) super.getResourceMappingAnnotation();
- }
-
- // **************** AttributeOverrideContainer.Owner impl *****************
-
- public TypeMapping getTypeMapping() {
- return this;
- }
-
- public TypeMapping getOverridableTypeMapping() {
- PersistentType superPersistentType = getPersistentType().getSuperPersistentType();
- return superPersistentType == null ? null : superPersistentType.getMapping();
- }
-
-
- // **************** TypeMapping implementation ****************************
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- @Override
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
- @Override
- public String getPrimaryTableName() {
- return this.getTable().getName();
- }
-
- @Override
- public org.eclipse.jpt.db.Table getPrimaryDbTable() {
- return getTable().getDbTable();
- }
-
- @Override
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- // matching database objects and identifiers is database platform-specific
- return this.getDataSource().selectDatabaseObjectForIdentifier(this.getAssociatedDbTablesIncludingInherited(), tableName);
- }
-
- protected Iterable<org.eclipse.jpt.db.Table> getAssociatedDbTablesIncludingInherited() {
- return new FilteringIterable<org.eclipse.jpt.db.Table>(this.getAssociatedDbTablesIncludingInherited_()) {
- @Override
- protected boolean accept(org.eclipse.jpt.db.Table t) {
- return t != null;
- }
- };
- }
-
- protected Iterable<org.eclipse.jpt.db.Table> getAssociatedDbTablesIncludingInherited_() {
- return new TransformationIterable<Table, org.eclipse.jpt.db.Table>(this.getAssociatedTablesIncludingInherited()) {
- @Override
- protected org.eclipse.jpt.db.Table transform(Table t) {
- return t.getDbTable();
- }
- };
- }
-
- @Override
- public Schema getDbSchema() {
- return getTable().getDbSchema();
- }
-
-
- //****************** JavaTypeMapping implementation *******************
-
- public String getAnnotationName() {
- return EntityAnnotation.ANNOTATION_NAME;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
- protected static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JPA.TABLE,
- JPA.SECONDARY_TABLE,
- JPA.SECONDARY_TABLES,
- JPA.PRIMARY_KEY_JOIN_COLUMN,
- JPA.PRIMARY_KEY_JOIN_COLUMNS,
- JPA.ID_CLASS,
- JPA.INHERITANCE,
- JPA.DISCRIMINATOR_VALUE,
- JPA.DISCRIMINATOR_COLUMN,
- JPA.SEQUENCE_GENERATOR,
- JPA.TABLE_GENERATOR,
- JPA.NAMED_QUERY,
- JPA.NAMED_QUERIES,
- JPA.NAMED_NATIVE_QUERY,
- JPA.NAMED_NATIVE_QUERIES,
- JPA.SQL_RESULT_SET_MAPPING,
- JPA.EXCLUDE_DEFAULT_LISTENERS,
- JPA.EXCLUDE_SUPERCLASS_LISTENERS,
- JPA.ENTITY_LISTENERS,
- JPA.PRE_PERSIST,
- JPA.POST_PERSIST,
- JPA.PRE_REMOVE,
- JPA.POST_REMOVE,
- JPA.PRE_UPDATE,
- JPA.POST_UPDATE,
- JPA.POST_LOAD,
- JPA.ATTRIBUTE_OVERRIDE,
- JPA.ATTRIBUTE_OVERRIDES,
- JPA.ASSOCIATION_OVERRIDE,
- JPA.ASSOCIATION_OVERRIDES
- };
- protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
-
- // **************** name **************************************************
-
- @Override
- public String getName() {
- return (this.getSpecifiedName() == null) ? this.getDefaultName() : this.getSpecifiedName();
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- this.getResourceMappingAnnotation().setName(newSpecifiedName);
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- protected void setSpecifiedName_(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected/*private-protected*/ void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
-
- // **************** id class **********************************************
-
- public JavaIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
-
- // **************** table *************************************************
-
- public JavaTable getTable() {
- return this.table;
- }
-
- public ListIterator<JavaSecondaryTable> specifiedSecondaryTables() {
- return new CloneListIterator<JavaSecondaryTable>(this.specifiedSecondaryTables);
- }
-
- public int specifiedSecondaryTablesSize() {
- return this.specifiedSecondaryTables.size();
- }
-
- public JavaSecondaryTable addSpecifiedSecondaryTable(int index) {
- JavaSecondaryTable secondaryTable = getJpaFactory().buildJavaSecondaryTable(this, new SecondaryTableOwner());
- this.specifiedSecondaryTables.add(index, secondaryTable);
- SecondaryTableAnnotation secondaryTableResource =
- (SecondaryTableAnnotation) this.javaResourcePersistentType.
- addAnnotation(
- index, SecondaryTableAnnotation.ANNOTATION_NAME,
- SecondaryTablesAnnotation.ANNOTATION_NAME);
- secondaryTable.initialize(secondaryTableResource);
- fireItemAdded(SPECIFIED_SECONDARY_TABLES_LIST, index, secondaryTable);
- return secondaryTable;
- }
-
- public JavaSecondaryTable addSpecifiedSecondaryTable() {
- return this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size());
- }
-
- protected void addSpecifiedSecondaryTable(int index, JavaSecondaryTable secondaryTable) {
- addItemToList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- protected void addSpecifiedSecondaryTable(JavaSecondaryTable secondaryTable) {
- this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size(), secondaryTable);
- }
-
- public void removeSpecifiedSecondaryTable(SecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- public void removeSpecifiedSecondaryTable(int index) {
- JavaSecondaryTable removedSecondaryTable = this.specifiedSecondaryTables.remove(index);
- this.javaResourcePersistentType.removeAnnotation(
- index, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- fireItemRemoved(SPECIFIED_SECONDARY_TABLES_LIST, index, removedSecondaryTable);
- }
-
- protected void removeSpecifiedSecondaryTable_(JavaSecondaryTable secondaryTable) {
- removeItemFromList(secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- public void moveSpecifiedSecondaryTable(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedSecondaryTables, targetIndex, sourceIndex);
- this.javaResourcePersistentType.moveAnnotation(
- targetIndex, sourceIndex, SecondaryTablesAnnotation.ANNOTATION_NAME);
- fireItemMoved(SPECIFIED_SECONDARY_TABLES_LIST, targetIndex, sourceIndex);
- }
-
- public ListIterator<JavaSecondaryTable> secondaryTables() {
- return specifiedSecondaryTables();
- }
-
- public int secondaryTablesSize() {
- return specifiedSecondaryTablesSize();
- }
-
- public InheritanceType getInheritanceStrategy() {
- return (this.getSpecifiedInheritanceStrategy() == null) ? this.getDefaultInheritanceStrategy() : this.getSpecifiedInheritanceStrategy();
- }
-
- public InheritanceType getDefaultInheritanceStrategy() {
- return this.defaultInheritanceStrategy;
- }
-
- protected void setDefaultInheritanceStrategy(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.defaultInheritanceStrategy;
- this.defaultInheritanceStrategy = newInheritanceType;
- firePropertyChanged(DEFAULT_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- public InheritanceType getSpecifiedInheritanceStrategy() {
- return this.specifiedInheritanceStrategy;
- }
-
- public void setSpecifiedInheritanceStrategy(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = newInheritanceType;
- getResourceInheritance().setStrategy(InheritanceType.toJavaResourceModel(newInheritanceType));
- firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedInheritanceStrategy_(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = newInheritanceType;
- firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- public JavaDiscriminatorColumn getDiscriminatorColumn() {
- return this.discriminatorColumn;
- }
-
- public String getDefaultDiscriminatorValue() {
- return this.defaultDiscriminatorValue;
- }
-
- protected void setDefaultDiscriminatorValue(String newDefaultDiscriminatorValue) {
- String oldDefaultDiscriminatorValue = this.defaultDiscriminatorValue;
- this.defaultDiscriminatorValue = newDefaultDiscriminatorValue;
- firePropertyChanged(DEFAULT_DISCRIMINATOR_VALUE_PROPERTY, oldDefaultDiscriminatorValue, newDefaultDiscriminatorValue);
- }
-
- public String getSpecifiedDiscriminatorValue() {
- return this.specifiedDiscriminatorValue;
- }
-
- public void setSpecifiedDiscriminatorValue(String newSpecifiedDiscriminatorValue) {
- String oldSpecifiedDiscriminatorValue = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = newSpecifiedDiscriminatorValue;
- getResourceDiscriminatorValue().setValue(newSpecifiedDiscriminatorValue);
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, oldSpecifiedDiscriminatorValue, newSpecifiedDiscriminatorValue);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedDiscriminatorValue_(String newSpecifiedDiscriminatorValue) {
- String oldSpecifiedDiscriminatorValue = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = newSpecifiedDiscriminatorValue;
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, oldSpecifiedDiscriminatorValue, newSpecifiedDiscriminatorValue);
- }
-
- public String getDiscriminatorValue() {
- return (this.getSpecifiedDiscriminatorValue() == null) ? getDefaultDiscriminatorValue() : this.getSpecifiedDiscriminatorValue();
- }
-
- public boolean specifiedDiscriminatorValueIsAllowed() {
- return this.specifiedDiscriminatorValueIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorValueIsAllowed(boolean specifiedDiscriminatorValueIsAllowed) {
- boolean old = this.specifiedDiscriminatorValueIsAllowed;
- this.specifiedDiscriminatorValueIsAllowed = specifiedDiscriminatorValueIsAllowed;
- firePropertyChanged(Entity.SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorValueIsAllowed);
- }
-
- public boolean discriminatorValueIsUndefined() {
- return this.discriminatorValueIsUndefined;
- }
-
- protected void setDiscriminatorValueIsUndefined(boolean discriminatorValueIsUndefined) {
- boolean old = this.discriminatorValueIsUndefined;
- this.discriminatorValueIsUndefined = discriminatorValueIsUndefined;
- firePropertyChanged(DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, discriminatorValueIsUndefined);
- }
-
- public boolean specifiedDiscriminatorColumnIsAllowed() {
- return this.specifiedDiscriminatorColumnIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorColumnIsAllowed(boolean specifiedDiscriminatorColumnIsAllowed) {
- boolean old = this.specifiedDiscriminatorColumnIsAllowed;
- this.specifiedDiscriminatorColumnIsAllowed = specifiedDiscriminatorColumnIsAllowed;
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorColumnIsAllowed);
- }
-
- public boolean discriminatorColumnIsUndefined() {
- return this.discriminatorColumnIsUndefined;
- }
-
- protected void setDiscriminatorColumnIsUndefined(boolean discriminatorColumnIsUndefined) {
- boolean old = this.discriminatorColumnIsUndefined;
- this.discriminatorColumnIsUndefined = discriminatorColumnIsUndefined;
- firePropertyChanged(DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, discriminatorColumnIsUndefined);
- }
-
- public boolean specifiedTableIsAllowed() {
- return this.specifiedTableIsAllowed;
- }
-
- protected void setSpecifiedTableIsAllowed(boolean specifiedTableIsAllowed) {
- boolean old = this.specifiedTableIsAllowed;
- this.specifiedTableIsAllowed = specifiedTableIsAllowed;
- firePropertyChanged(SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed);
- }
-
- public boolean tableIsUndefined() {
- return this.tableIsUndefined;
- }
-
- protected void setTableIsUndefined(boolean tableIsUndefined) {
- boolean old = this.tableIsUndefined;
- this.tableIsUndefined = tableIsUndefined;
- firePropertyChanged(TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined);
- }
-
- public JavaGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- public ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumns() : this.defaultPrimaryKeyJoinColumns();
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.containsSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumnsSize() : this.defaultPrimaryKeyJoinColumnsSize();
- }
-
- public ListIterator<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() {
- return new CloneListIterator<JavaPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- public int specifiedPrimaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.size();
- }
-
- public boolean containsSpecifiedPrimaryKeyJoinColumns() {
- return !this.specifiedPrimaryKeyJoinColumns.isEmpty();
- }
-
- public JavaPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() {
- return this.defaultPrimaryKeyJoinColumn;
- }
-
- protected void setDefaultPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn newPkJoinColumn) {
- JavaPrimaryKeyJoinColumn oldPkJoinColumn = this.defaultPrimaryKeyJoinColumn;
- this.defaultPrimaryKeyJoinColumn = newPkJoinColumn;
- firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldPkJoinColumn, newPkJoinColumn);
- }
-
- protected ListIterator<JavaPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns() {
- if (this.defaultPrimaryKeyJoinColumn != null) {
- return new SingleElementListIterator<JavaPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn);
- }
- return EmptyListIterator.instance();
- }
-
- protected int defaultPrimaryKeyJoinColumnsSize() {
- return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1;
- }
-
- public JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn oldDefaultPkJoinColumn = this.getDefaultPrimaryKeyJoinColumn();
- if (oldDefaultPkJoinColumn != null) {
- //null the default join column now if one already exists.
- //if one does not exist, there is already a specified join column.
- //Remove it now so that it doesn't get removed during an update and
- //cause change notifications to be sent to the UI in the wrong order
- this.defaultPrimaryKeyJoinColumn = null;
- }
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, buildPrimaryKeyJoinColumnOwner());
- this.specifiedPrimaryKeyJoinColumns.add(index, primaryKeyJoinColumn);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnResource =
- (PrimaryKeyJoinColumnAnnotation) this.javaResourcePersistentType.
- addAnnotation(
- index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- primaryKeyJoinColumn.initialize(pkJoinColumnResource);
- this.fireItemAdded(SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, primaryKeyJoinColumn);
- if (oldDefaultPkJoinColumn != null) {
- this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, oldDefaultPkJoinColumn, null);
- }
- return primaryKeyJoinColumn;
- }
-
- protected void addSpecifiedPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- addItemToList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void addSpecifiedPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.addSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.size(), primaryKeyJoinColumn);
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn primaryKeyJoinColumn) {
- removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.indexOf(primaryKeyJoinColumn));
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn removedPrimaryKeyJoinColumn = this.specifiedPrimaryKeyJoinColumns.remove(index);
- if (!containsSpecifiedPrimaryKeyJoinColumns()) {
- //create the defaultJoinColumn now or this will happen during project update
- //after removing the join column from the resource model. That causes problems
- //in the UI because the change notifications end up in the wrong order.
- this.defaultPrimaryKeyJoinColumn = buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType));
- }
- this.javaResourcePersistentType.removeAnnotation(
- index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- fireItemRemoved(SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn);
- if (this.defaultPrimaryKeyJoinColumn != null) {
- //fire change notification if a defaultJoinColumn was created above
- this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, null, this.defaultPrimaryKeyJoinColumn);
- }
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- removeItemFromList(primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- this.javaResourcePersistentType.moveAnnotation(
- targetIndex, sourceIndex, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- moveItemInList(targetIndex, sourceIndex, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public JavaAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- public JavaAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.associationOverrideContainer;
- }
-
- public JavaQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
- public Entity getParentEntity() {
- for (Iterator<PersistentType> stream = getPersistentType().ancestors(); stream.hasNext();) {
- TypeMapping typeMapping = stream.next().getMapping();
- if (typeMapping instanceof Entity) {
- return (Entity) typeMapping;
- }
- }
- return null;
- }
-
- public Entity getRootEntity() {
- return this.rootEntity;
- }
-
- public boolean isRoot() {
- return this == this.getRootEntity();
- }
-
- /**
- * Return whether the entity is a descendant in (as opposed to the root of)
- * an inheritance hierarchy.
- */
- protected boolean isDescendant() {
- return ! this.isRoot();
- }
-
- /**
- * Table name defaults to the entity name.
- * If the entity is part of a single table inheritance hierarchy, table
- * name defaults to the root entity's table name.
- * If the entity is abstract and part of a table per class
- * inheritance hierarchy, the table name defaults to null, no table applies
- */
- public String getDefaultTableName() {
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getName()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getName();
- }
-
- public String getDefaultSchema() {
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getSchema()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getContextDefaultSchema();
- }
-
- public String getDefaultCatalog() {
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getCatalog()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getContextDefaultCatalog();
- }
-
- /**
- * Return whether the entity is a descendant of the root entity
- * of a "single table" inheritance hierarchy.
- */
- protected boolean isSingleTableDescendant() {
- return (this.getInheritanceStrategy() == InheritanceType.SINGLE_TABLE)
- && this.isDescendant();
- }
-
- /**
- * Return whether the entity is the top of an inheritance hierarchy
- * and has no descendants and no specified inheritance strategy has been defined.
- */
- protected boolean isRootNoDescendantsNoStrategyDefined() {
- return isRoot() && !getPersistenceUnit().entityIsRootWithSubEntities(this.getName()) && getSpecifiedInheritanceStrategy() == null;
- }
-
- /**
- * Return whether the entity is abstract and is a part of a
- * "table per class" inheritance hierarchy.
- */
- protected boolean isAbstractTablePerClass() {
- return isAbstract() && isTablePerClass();
- }
-
- /**
- * Return whether the entity is a part of a "table per class"
- * inheritance hierarchy.
- */
- protected boolean isTablePerClass() {
- return (this.getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS);
- }
-
- /**
- * Return whether the entity is a part of a "table per class"
- * inheritance hierarchy.
- */
- protected boolean isTablePerClassDescendant() {
- return isTablePerClass() && isDescendant();
- }
-
- /**
- * Return whether the type is abstract.
- */
- protected boolean isAbstract() {
- return this.javaResourcePersistentType.isAbstract();
- }
-
- /**
- * Return whether the type is final.
- */
- protected boolean isFinal() {
- return this.javaResourcePersistentType.isFinal();
- }
-
- /**
- * Return whether the type is a top-level type.
- */
- protected boolean isMember() {
- return this.javaResourcePersistentType.isMemberType();
- }
-
- /**
- * Return whether the type is static.
- */
- protected boolean isStatic() {
- return this.javaResourcePersistentType.isStatic();
- }
-
- public String getPrimaryKeyColumnName() {
- return getPrimaryKeyColumnName(this);
- }
-
- /**
- * Convenience implementation that is shared with ORM.
- */
- public static String getPrimaryKeyColumnName(Entity entity) {
- String pkColumnName = null;
- for (Iterator<PersistentAttribute> stream = entity.getPersistentType().allAttributes(); stream.hasNext(); ) {
- PersistentAttribute attribute = stream.next();
- String current = attribute.getPrimaryKeyColumnName();
- if (current != null) {
- // 229423 - if the attribute is a primary key, but it has an attribute override,
- // use the override column instead
- AttributeOverride attributeOverride = entity.getAttributeOverrideContainer().getAttributeOverrideNamed(attribute.getName());
- if (attributeOverride != null) {
- current = attributeOverride.getColumn().getName();
- }
- }
- if (pkColumnName == null) {
- pkColumnName = current;
- }
- else if (current != null) {
- // if we encounter a composite primary key, return null
- return null;
- }
- }
- // if we encounter only a single primary key column name, return it
- return pkColumnName;
- }
-
- public PersistentAttribute getIdAttribute() {
- Iterable<AttributeMapping> idAttributeMappings = getAllAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- if (CollectionTools.size(idAttributeMappings) != 1) {
- return null;
- }
- return idAttributeMappings.iterator().next().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- if (tableIsUndefined()) {
- return false;
- }
- return ! CollectionTools.contains(this.associatedTableNamesIncludingInherited(), tableName);
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return super.shouldValidateAgainstDatabase() && ! isAbstractTablePerClass();
- }
-
- @Override
- public Iterator<Table> associatedTables() {
- return new CompositeIterator<Table>(this.getTable(), this.secondaryTables());
- }
-
- @Override
- public Iterator<Table> associatedTablesIncludingInherited() {
- return this.getAssociatedTablesIncludingInherited().iterator();
- }
-
- protected Iterable<Table> getAssociatedTablesIncludingInherited() {
- return new CompositeIterable<Table>(new TransformationIterable<TypeMapping, Iterable<Table>>(this.getInheritanceHierarchy()) {
- @Override
- protected Iterable<Table> transform(TypeMapping mapping) {
- return new FilteringIterable<Table>(CollectionTools.iterable(mapping.associatedTables())) {
- @Override
- protected boolean accept(Table o) {
- return true;
- //TODO
- //filtering these out so as to avoid the duplicate table, root and children share the same table
- //return !(o instanceof SingleTableInheritanceChildTableImpl);
- }
- };
- }
- });
- }
-
- @Override
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return this.nonNullTableNames(this.associatedTablesIncludingInherited());
- }
-
- protected Iterator<String> nonNullTableNames(Iterator<Table> tables) {
- return new FilteringIterator<String>(this.tableNames(tables)) {
- @Override
- protected boolean accept(String o) {
- return o != null;
- }
- };
- }
-
- protected Iterator<String> tableNames(Iterator<Table> tables) {
- return new TransformationIterator<Table, String>(tables) {
- @Override
- protected String transform(Table t) {
- return t.getName();
- }
- };
- }
-
- /**
- * Return an iterator of Entities, each which inherits from the one before,
- * and terminates at the root entity (or at the point of cyclicity).
- */
- protected Iterator<TypeMapping> ancestors() {
- return new TransformationIterator<PersistentType, TypeMapping>(getPersistentType().ancestors()) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
- @Override
- public Iterator<String> overridableAttributeNames() {
- if (!isTablePerClass()) {
- return EmptyIterator.instance();
- }
- return super.overridableAttributeNames();
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- AttributeOverride override = getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getColumn();
- }
- return super.resolveOverriddenColumn(attributeName);
- }
-
- @Override
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- AssociationOverride override = getAssociationOverrideContainer().getAssociationOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getRelationshipReference();
- }
- return super.resolveRelationshipReference(attributeName);
- }
-
- @Override
- public Iterator<String> overridableAssociationNames() {
- if (!isTablePerClass()) {
- return EmptyIterator.instance();
- }
- return super.overridableAssociationNames();
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.allAttributeMappings())) {
- AttributeMapping resolvedMapping = attributeMapping.resolveAttributeMapping(name);
- if (resolvedMapping != null) {
- return resolvedMapping;
- }
- }
- return null;
- }
-
- @Override
- public void update(JavaResourcePersistentType resourcePersistentType) {
- super.update(resourcePersistentType);
- setSpecifiedName_(getResourceName());
- setDefaultName(getResourceDefaultName());
- this.idClassReference.update();
- updateRootEntity();
- updateInheritance(getResourceInheritance());
- updateDiscriminatorColumn();
- updateDiscriminatorValue(getResourceDiscriminatorValue());
- setSpecifiedTableIsAllowed(buildSpecifiedTableIsAllowed());
- setTableIsUndefined(buildTableIsUndefined());
- updateTable();
- updateSecondaryTables();
- this.generatorContainer.update(resourcePersistentType);
- this.queryContainer.update(resourcePersistentType);
- updateSpecifiedPrimaryKeyJoinColumns();
- updateDefaultPrimaryKeyJoinColumn();
- this.attributeOverrideContainer.update(resourcePersistentType);
- this.associationOverrideContainer.update(resourcePersistentType);
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- postUpdateDiscriminatorColumn();
- postUpdateDiscriminatorValue();
- this.associationOverrideContainer.postUpdate();
- }
-
- protected String getResourceName() {
- return this.getResourceMappingAnnotation().getName();
- }
-
- protected String getResourceDefaultName() {
- return this.javaResourcePersistentType.getName();
- }
-
- protected void updateTable() {
- getTable().update(this.javaResourcePersistentType);
- }
-
- protected void updateInheritance(InheritanceAnnotation inheritanceResource) {
- this.setSpecifiedInheritanceStrategy_(this.getResourceInheritanceStrategy(inheritanceResource));
- this.setDefaultInheritanceStrategy(this.buildDefaultInheritanceStrategy());
- }
-
- protected InheritanceType getResourceInheritanceStrategy(InheritanceAnnotation inheritanceResource) {
- return InheritanceType.fromJavaResourceModel(inheritanceResource.getStrategy());
- }
-
- protected InheritanceType buildDefaultInheritanceStrategy() {
- return this.isRoot() ? InheritanceType.SINGLE_TABLE : this.getRootEntity().getInheritanceStrategy();
- }
-
- protected void updateRootEntity() {
- //I am making an assumption here that we don't need property change notification for rootEntity, this might be wrong
- this.rootEntity = calculateRootEntity();
- if (this.rootEntity != this) {
- this.rootEntity.addSubEntity(this);
- }
- }
-
- protected Entity calculateRootEntity() {
- Entity root = this;
- for (Iterator<TypeMapping> stream = inheritanceHierarchy(); stream.hasNext();) {
- TypeMapping typeMapping = stream.next();
- if (typeMapping instanceof Entity) {
- root = (Entity) typeMapping;
- }
- }
- return root;
- }
-
- public void addSubEntity(Entity subEntity) {
- getPersistenceUnit().addRootEntityWithSubEntities(getName());
- }
-
- protected void updateDiscriminatorColumn() {
- this.setSpecifiedDiscriminatorColumnIsAllowed(this.buildSpecifiedDiscriminatorColumnIsAllowed());
- getDiscriminatorColumn().update(this.getResourceDiscriminatorColumn());
- }
-
- protected void postUpdateDiscriminatorColumn() {
- this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
- this.getDiscriminatorColumn().postUpdate();
- }
-
- protected void updateDiscriminatorValue(DiscriminatorValueAnnotation discriminatorValueResource) {
- this.setSpecifiedDiscriminatorValueIsAllowed(this.buildSpecifiedDiscriminatorValueIsAllowed());
- this.setSpecifiedDiscriminatorValue_(discriminatorValueResource.getValue());
- }
-
- protected void postUpdateDiscriminatorValue() {
- this.setDiscriminatorValueIsUndefined(this.buildDiscriminatorValueIsUndefined());
- this.setDefaultDiscriminatorValue(this.buildDefaultDiscriminatorValue());
- }
-
- /**
- * From the Spec:
- * If the DiscriminatorValue annotation is not specified, a
- * provider-specific function to generate a value representing
- * the entity type is used for the value of the discriminator
- * column. If the DiscriminatorType is STRING, the discriminator
- * value default is the entity name.
- *
- * TODO extension point for provider-specific function?
- */
- protected String buildDefaultDiscriminatorValue() {
- if (discriminatorValueIsUndefined()) {
- return null;
- }
- if (this.getDiscriminatorType() != DiscriminatorType.STRING) {
- return null;
- }
- return this.getName();
- }
-
- protected DiscriminatorType getDiscriminatorType() {
- return this.getDiscriminatorColumn().getDiscriminatorType();
- }
-
- protected boolean buildSpecifiedDiscriminatorValueIsAllowed() {
- return !isTablePerClass() && !isAbstract();
- }
-
- protected boolean buildDiscriminatorValueIsUndefined() {
- return isTablePerClass() || isAbstract() || isRootNoDescendantsNoStrategyDefined();
- }
-
- protected boolean buildSpecifiedDiscriminatorColumnIsAllowed() {
- return !isTablePerClass() && isRoot();
- }
-
- protected boolean buildDiscriminatorColumnIsUndefined() {
- return isTablePerClass() || isRootNoDescendantsNoStrategyDefined();
- }
-
- protected boolean buildSpecifiedTableIsAllowed() {
- return !isAbstractTablePerClass() && !isSingleTableDescendant();
- }
-
- protected boolean buildTableIsUndefined() {
- return isAbstractTablePerClass();
- }
-
- protected void updateSecondaryTables() {
- ListIterator<JavaSecondaryTable> secondaryTables = specifiedSecondaryTables();
- Iterator<NestableAnnotation> resourceSecondaryTables =
- this.javaResourcePersistentType.annotations(
- SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
-
- while (secondaryTables.hasNext()) {
- JavaSecondaryTable secondaryTable = secondaryTables.next();
- if (resourceSecondaryTables.hasNext()) {
- secondaryTable.update((SecondaryTableAnnotation) resourceSecondaryTables.next());
- }
- else {
- removeSpecifiedSecondaryTable_(secondaryTable);
- }
- }
-
- while (resourceSecondaryTables.hasNext()) {
- addSpecifiedSecondaryTable(buildSecondaryTable((SecondaryTableAnnotation) resourceSecondaryTables.next()));
- }
- }
-
- protected JavaSecondaryTable buildSecondaryTable(SecondaryTableAnnotation secondaryTableResource) {
- JavaSecondaryTable secondaryTable = getJpaFactory().buildJavaSecondaryTable(this, new SecondaryTableOwner());
- secondaryTable.initialize(secondaryTableResource);
- return secondaryTable;
- }
-
- protected void updateSpecifiedPrimaryKeyJoinColumns() {
- ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns = specifiedPrimaryKeyJoinColumns();
- Iterator<NestableAnnotation> resourcePrimaryKeyJoinColumns =
- this.javaResourcePersistentType.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
-
- while (primaryKeyJoinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = primaryKeyJoinColumns.next();
- if (resourcePrimaryKeyJoinColumns.hasNext()) {
- primaryKeyJoinColumn.update((PrimaryKeyJoinColumnAnnotation) resourcePrimaryKeyJoinColumns.next());
- }
- else {
- removeSpecifiedPrimaryKeyJoinColumn_(primaryKeyJoinColumn);
- }
- }
-
- while (resourcePrimaryKeyJoinColumns.hasNext()) {
- addSpecifiedPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn((PrimaryKeyJoinColumnAnnotation) resourcePrimaryKeyJoinColumns.next()));
- }
- }
-
- protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(PrimaryKeyJoinColumnAnnotation primaryKeyJoinColumnResource) {
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, buildPrimaryKeyJoinColumnOwner());
- primaryKeyJoinColumn.initialize(primaryKeyJoinColumnResource);
- return primaryKeyJoinColumn;
- }
-
- protected void updateDefaultPrimaryKeyJoinColumn() {
- if (!shouldBuildDefaultPrimaryKeyJoinColumn()) {
- setDefaultPrimaryKeyJoinColumn(null);
- return;
- }
- if (getDefaultPrimaryKeyJoinColumn() == null) {
- this.setDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType)));
- }
- else {
- this.defaultPrimaryKeyJoinColumn.update(new NullPrimaryKeyJoinColumnAnnotation(this.javaResourcePersistentType));
- }
- }
-
-
- //******************** Code Completion *************************
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getTable().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaSecondaryTable sTable : CollectionTools.iterable(this.secondaryTables())) {
- result = sTable.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- for (JavaPrimaryKeyJoinColumn column : CollectionTools.iterable(this.primaryKeyJoinColumns())) {
- result = column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- result = this.getAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getAssociationOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getDiscriminatorColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getGeneratorContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- //********** Validation ********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- validatePrimaryKey(messages, reporter, astRoot);
- validateTable(messages, reporter, astRoot);
- for (Iterator<JavaSecondaryTable> stream = this.specifiedSecondaryTables(); stream.hasNext();) {
- stream.next().validate(messages, reporter, astRoot);
- }
- validateInheritance(messages, reporter, astRoot);
- for (Iterator<JavaPrimaryKeyJoinColumn> stream = this.primaryKeyJoinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter, astRoot);
- }
- getGeneratorContainer().validate(messages, reporter, astRoot);
- getQueryContainer().validate(messages, reporter, astRoot);
- getAttributeOverrideContainer().validate(messages, reporter, astRoot);
- getAssociationOverrideContainer().validate(messages, reporter, astRoot);
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- buildPrimaryKeyValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) {
- return new GenericEntityPrimaryKeyValidator(this, buildTextRangeResolver(astRoot));
- }
-
- @Override
- protected EntityTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaEntityTextRangeResolver(this, astRoot);
- }
-
- protected void validateTable(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (isAbstractTablePerClass()) {
- if (this.table.isResourceSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.getTable().getValidationTextRange(astRoot)
- )
- );
- }
- return;
- }
- if (isSingleTableDescendant()) {
- if (this.table.isResourceSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.getTable().getValidationTextRange(astRoot)
- )
- );
- }
- return;
- }
- this.table.validate(messages, reporter, astRoot);
- }
-
- protected void validateInheritance(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- validateInheritanceStrategy(messages, astRoot);
- validateDiscriminatorColumn(messages, reporter, astRoot);
- validateDiscriminatorValue(messages, astRoot);
- }
-
- protected void validateDiscriminatorColumn(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (specifiedDiscriminatorColumnIsAllowed() && !discriminatorColumnIsUndefined()) {
- getDiscriminatorColumn().validate(messages, reporter, astRoot);
- }
- else if (getDiscriminatorColumn().isResourceSpecified()) {
- if (!isRoot()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange(astRoot)
- )
- );
- }
- else if (isTablePerClass()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange(astRoot)
- )
- );
- }
- }
- }
-
- protected void validateDiscriminatorValue(List<IMessage> messages, CompilationUnit astRoot) {
- if (discriminatorValueIsUndefined() && getSpecifiedDiscriminatorValue() != null) {
- if (isAbstract()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange(astRoot)
- )
- );
- }
- else if (isTablePerClass()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange(astRoot)
- )
- );
- }
- }
- }
-
- protected void validateInheritanceStrategy(List<IMessage> messages, CompilationUnit astRoot) {
- Supported tablePerConcreteClassInheritanceIsSupported = getJpaPlatformVariation().getTablePerConcreteClassInheritanceIsSupported();
- if (tablePerConcreteClassInheritanceIsSupported == Supported.YES) {
- return;
- }
- if ((getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS) && isRoot()) {
- if (tablePerConcreteClassInheritanceIsSupported == Supported.NO) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM,
- new String[] {this.getName()},
- this,
- this.getInheritanceStrategyTextRange(astRoot)
- )
- );
- }
- else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM,
- new String[] {this.getName()},
- this,
- this.getInheritanceStrategyTextRange(astRoot)
- )
- );
- }
- }
- }
-
- protected TextRange getDiscriminatorValueTextRange(CompilationUnit astRoot) {
- return getResourceDiscriminatorValue().getTextRange(astRoot);
- }
-
- protected TextRange getDiscriminatorColumnTextRange(CompilationUnit astRoot) {
- return getDiscriminatorColumn().getValidationTextRange(astRoot);
- }
-
- protected TextRange getInheritanceStrategyTextRange(CompilationUnit astRoot) {
- return getResourceInheritance().getStrategyTextRange(astRoot);
- }
-
-
- protected class TableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new TableValidator(table, textRangeResolver);
- }
- }
-
- protected class SecondaryTableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new SecondaryTableValidator((SecondaryTable) table, textRangeResolver);
- }
- }
-
- // ********** association override container owner **********
-
- protected class AssociationOverrideContainerOwner
- implements JavaAssociationOverrideContainer.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : typeMapping.allOverridableAssociationNames();
- }
-
- public RelationshipReference resolveRelationshipReference(String associationOverrideName) {
- return MappingTools.resolveRelationshipReference(getOverridableTypeMapping(), associationOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaEntity.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractJavaEntity.this.associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- public boolean isRelevant(String overrideName) {
- //no prefix, so always true
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AssociationOverrideValidator((AssociationOverride) override, (AssociationOverride.Owner) owner, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinColumnValidator((AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) owner, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinColumnValidator(override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideInverseJoinColumnValidator(override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinTableValidator(override, (JoinTable) table, textRangeResolver);
- }
- }
-
- //********** AttributeOverrideContainer.Owner implementation *********
-
- protected class AttributeOverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : allOverridableAttributeNames_(typeMapping);
- }
-
- /* assumes the type mapping is not null */
- protected Iterator allOverridableAttributeNames_(TypeMapping typeMapping) {
- final Collection mappedByRelationshipAttributes = CollectionTools.collection(
- new TransformationIterator<SingleRelationshipMapping2_0, String>(getMapsIdRelationships()) {
- @Override
- protected String transform(SingleRelationshipMapping2_0 next) {
- return next.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue();
- }
- });
- return new FilteringIterator<String>(typeMapping.allOverridableAttributeNames()) {
- @Override
- protected boolean accept(String o) {
- if (mappedByRelationshipAttributes.isEmpty()) {
- return true;
- }
- // overrideable names are (usually?) qualified with a container mapping,
- // which may also be the one mapped by a relationship
- String qualifier =
- (o.indexOf('.') > 0) ?
- o.substring(0, o.indexOf('.'))
- : o;
- return ! mappedByRelationshipAttributes.contains(qualifier);
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(
- new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(
- new CompositeIterable<AttributeMapping>(
- getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)))) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 o) {
- return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaEntity.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractJavaEntity.this.associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- public boolean isRelevant(String overrideName) {
- //no prefix, so always true
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-
-
- // ********** pk join column owner **********
-
- protected class PrimaryKeyJoinColumnOwner implements JavaBaseJoinColumn.Owner
- {
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this;
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractJavaEntity.this.getDbTable(tableName);
- }
-
- public org.eclipse.jpt.db.Table getReferencedColumnDbTable() {
- Entity parentEntity = AbstractJavaEntity.this.getParentEntity();
- return (parentEntity == null) ? null : parentEntity.getPrimaryDbTable();
- }
-
- public int joinColumnsSize() {
- return AbstractJavaEntity.this.primaryKeyJoinColumnsSize();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return AbstractJavaEntity.this.defaultPrimaryKeyJoinColumn == joinColumn;
- }
-
- public String getDefaultColumnName() {
- if (joinColumnsSize() != 1) {
- return null;
- }
- Entity parentEntity = AbstractJavaEntity.this.getParentEntity();
- return (parentEntity == null) ? getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new EntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java
deleted file mode 100644
index 1b7acb4051..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaGenerator.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.java.JavaGenerator;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.resource.java.GeneratorAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- *
- */
-public abstract class AbstractJavaGenerator
- extends AbstractJavaJpaContextNode
- implements JavaGenerator
-{
- protected String name;
-
- protected Integer specifiedInitialValue;
-
- protected Integer specifiedAllocationSize;
-
- protected GeneratorAnnotation resourceGenerator;
-
-
- protected AbstractJavaGenerator(JavaJpaContextNode parent) {
- super(parent);
- }
-
- protected GeneratorAnnotation getResourceGenerator() {
- return this.resourceGenerator;
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.resourceGenerator.setName(name);
- this.firePropertyChanged(Generator.NAME_PROPERTY, old, name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(Generator.NAME_PROPERTY, old, name);
- }
-
-
- // ********** initial value **********
-
- public int getInitialValue() {
- return (this.specifiedInitialValue != null) ? this.specifiedInitialValue.intValue() : this.getDefaultInitialValue();
- }
-
- public Integer getSpecifiedInitialValue() {
- return this.specifiedInitialValue;
- }
-
- public void setSpecifiedInitialValue(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.resourceGenerator.setInitialValue(specifiedInitialValue);
- this.firePropertyChanged(Generator.SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
- protected void setSpecifiedInitialValue_(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.firePropertyChanged(Generator.SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
-
- // ********** allocation size **********
-
- public int getAllocationSize() {
- return (this.specifiedAllocationSize != null) ? this.specifiedAllocationSize.intValue() : this.getDefaultAllocationSize();
- }
-
- public Integer getSpecifiedAllocationSize() {
- return this.specifiedAllocationSize;
- }
-
- public void setSpecifiedAllocationSize(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.resourceGenerator.setAllocationSize(specifiedAllocationSize);
- this.firePropertyChanged(Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
- protected void setSpecifiedAllocationSize_(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.firePropertyChanged(Generator.SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
- public int getDefaultAllocationSize() {
- return Generator.DEFAULT_ALLOCATION_SIZE;
- }
-
-
- // ********** text ranges **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
- public TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourceGenerator.getTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.resourceGenerator.getNameTextRange(astRoot);
- }
-
-
- // ********** resource => context **********
-
- protected void initialize(GeneratorAnnotation generatorAnnotation) {
- this.resourceGenerator = generatorAnnotation;
- this.name = generatorAnnotation.getName();
- this.specifiedInitialValue = generatorAnnotation.getInitialValue();
- this.specifiedAllocationSize = generatorAnnotation.getAllocationSize();
- }
-
- protected void update(GeneratorAnnotation generatorAnnotation) {
- this.resourceGenerator = generatorAnnotation;
- this.setName_(generatorAnnotation.getName());
- this.setSpecifiedInitialValue_(generatorAnnotation.getInitialValue());
- this.setSpecifiedAllocationSize_(generatorAnnotation.getAllocationSize());
- getPersistenceUnit().addGenerator(this);
- }
-
-
- // ********** database stuff **********
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- protected abstract String getSchema();
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- protected abstract String getCatalog();
-
-
- // ********** misc **********
-
- public boolean isVirtual() {
- return false;
- }
-
- public boolean overrides(Generator generator) {
- // java is at the base of the tree
- return false;
- }
-
- public boolean duplicates(Generator other) {
- return (this != other)
- && ! StringTools.stringIsEmpty(this.name)
- && this.name.equals(other.getName())
- && ! this.overrides(other)
- && ! other.overrides(this);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
deleted file mode 100644
index a89c3dcd82..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMapping.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaConverter;
-import org.eclipse.jpt.core.context.java.JavaGeneratedValue;
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.IdMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaIdMapping
- extends AbstractJavaAttributeMapping<IdAnnotation>
- implements JavaIdMapping, IdMapping2_0
-{
- protected final JavaColumn column;
-
- /* 2.0 feature - a relationship may map this id */
- protected boolean mappedByRelationship;
-
- protected JavaGeneratedValue generatedValue;
-
- protected final JavaGeneratorContainer generatorContainer;
-
- protected JavaConverter converter;
-
- protected final JavaConverter nullConverter;
-
-
- protected AbstractJavaIdMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = this.getJpaFactory().buildJavaColumn(this, this);
- this.generatorContainer = this.buildGeneratorContainer();
- this.nullConverter = getJpaFactory().buildJavaNullConverter(this);
- this.converter = this.nullConverter;
- }
-
-
- @Override
- protected void initialize() {
- super.initialize();
- this.column.initialize(this.getResourceColumn());
- this.mappedByRelationship = calculateMappedByRelationship();
- this.generatorContainer.initialize(this.getResourcePersistentAttribute());
- this.initializeGeneratedValue();
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
- protected void initializeGeneratedValue() {
- GeneratedValueAnnotation resourceGeneratedValue = this.getResourceGeneratedValue();
- if (resourceGeneratedValue != null) {
- this.generatedValue = this.buildGeneratedValue(resourceGeneratedValue);
- }
- }
-
- public ColumnAnnotation getResourceColumn() {
- return (ColumnAnnotation) this.getResourcePersistentAttribute().
- getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- protected boolean isColumnSpecified() {
- return getResourcePersistentAttribute().getAnnotation(ColumnAnnotation.ANNOTATION_NAME) != null;
- }
-
- private JavaGeneratorContainer buildGeneratorContainer() {
- return this.getJpaFactory().buildJavaGeneratorContainer(this);
- }
-
-
- //************** JavaAttributeMapping implementation ***************
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return IdAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.COLUMN);
- names.add(JPA.GENERATED_VALUE);
- names.add(JPA.TEMPORAL);
- names.add(JPA.TABLE_GENERATOR);
- names.add(JPA.SEQUENCE_GENERATOR);
- }
-
-
- //************** NamedColumn.Owner implementation ***************
-
- public String getDefaultColumnName() {
- return (isMappedByRelationship() && ! isColumnSpecified()) ? null : getName();
- }
-
-
- //************** BaseColumn.Owner implementation ***************
-
- public String getDefaultTableName() {
- return (isMappedByRelationship() && ! isColumnSpecified()) ? null : getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
-
- //************** IdMapping implementation ***************
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- public JavaGeneratedValue addGeneratedValue() {
- if (getGeneratedValue() != null) {
- throw new IllegalStateException("gemeratedValue already exists"); //$NON-NLS-1$
- }
- this.generatedValue = getJpaFactory().buildJavaGeneratedValue(this);
- GeneratedValueAnnotation generatedValueResource =
- (GeneratedValueAnnotation) getResourcePersistentAttribute().
- addAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- this.generatedValue.initialize(generatedValueResource);
- firePropertyChanged(GENERATED_VALUE_PROPERTY, null, this.generatedValue);
- return this.generatedValue;
- }
-
- public void removeGeneratedValue() {
- if (getGeneratedValue() == null) {
- throw new IllegalStateException("gemeratedValue does not exist, cannot be removed"); //$NON-NLS-1$
- }
- JavaGeneratedValue oldGeneratedValue = this.generatedValue;
- this.generatedValue = null;
- getResourcePersistentAttribute().removeAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- firePropertyChanged(GENERATED_VALUE_PROPERTY, oldGeneratedValue, null);
- }
-
- public JavaGeneratedValue getGeneratedValue() {
- return this.generatedValue;
- }
-
- protected void setGeneratedValue(JavaGeneratedValue newGeneratedValue) {
- JavaGeneratedValue oldGeneratedValue = this.generatedValue;
- this.generatedValue = newGeneratedValue;
- firePropertyChanged(GENERATED_VALUE_PROPERTY, oldGeneratedValue, newGeneratedValue);
- }
-
- public JavaGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- JavaConverter oldConverter = this.converter;
- JavaConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(JavaConverter newConverter) {
- JavaConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- @Override
- protected void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- setMappedByRelationship(calculateMappedByRelationship());
- this.generatorContainer.update(this.getResourcePersistentAttribute());
- this.updateGeneratedValue();
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update(this.getResourcePersistentAttribute());
- }
- else {
- JavaConverter javaConverter = buildConverter(getResourceConverterType());
- setConverter(javaConverter);
- }
- }
-
- protected void updateGeneratedValue() {
- GeneratedValueAnnotation resourceGeneratedValue = getResourceGeneratedValue();
- if (resourceGeneratedValue == null) {
- if (getGeneratedValue() != null) {
- setGeneratedValue(null);
- }
- }
- else {
- if (getGeneratedValue() == null) {
- setGeneratedValue(buildGeneratedValue(resourceGeneratedValue));
- }
- else {
- getGeneratedValue().update(resourceGeneratedValue);
- }
- }
- }
-
- protected JavaGeneratedValue buildGeneratedValue(GeneratedValueAnnotation resourceGeneratedValue) {
- JavaGeneratedValue gv = getJpaFactory().buildJavaGeneratedValue(this);
- gv.initialize(resourceGeneratedValue);
- return gv;
- }
-
- protected TableGeneratorAnnotation getResourceTableGenerator() {
- return (TableGeneratorAnnotation) this.getResourcePersistentAttribute().
- getAnnotation(TableGeneratorAnnotation.ANNOTATION_NAME);
- }
-
- protected SequenceGeneratorAnnotation getResourceSequenceGenerator() {
- return (SequenceGeneratorAnnotation) this.getResourcePersistentAttribute().
- getAnnotation(SequenceGeneratorAnnotation.ANNOTATION_NAME);
- }
-
- protected GeneratedValueAnnotation getResourceGeneratedValue() {
- return (GeneratedValueAnnotation) this.getResourcePersistentAttribute().
- getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute());
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
-
- // **************** IdMapping2_0 impl *************************************
-
- public boolean isMappedByRelationship() {
- return this.mappedByRelationship;
- }
-
- protected void setMappedByRelationship(boolean newValue) {
- boolean oldValue = this.mappedByRelationship;
- this.mappedByRelationship = newValue;
- firePropertyChanged(MAPPED_BY_RELATIONSHIP_PROPERTY, oldValue, newValue);
- }
-
- protected boolean calculateMappedByRelationship() {
- for (SingleRelationshipMapping2_0 each : getMapsIdRelationships()) {
- if (getName().equals(each.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue())) {
- return true;
- }
- }
- return false;
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(
- new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(
- new CompositeIterable<AttributeMapping>(
- getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)))) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 o) {
- return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
-
- // ********** code assist **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.generatorTouches(pos, astRoot)) {
- result = this.persistenceGeneratorNames(filter);
- if (result != null) {
- return result;
- }
- }
- result = this.getGeneratorContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = getConverter().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
-
- // ********** code assist: generator
-
- protected boolean generatorTouches(int pos, CompilationUnit astRoot) {
- if (getResourceGeneratedValue() != null) {
- return this.getResourceGeneratedValue().generatorTouches(pos, astRoot);
- }
- return false;
- }
-
- protected Iterator<String> persistenceGeneratorNames() {
- if(this.getPersistenceUnit().generatorsSize() == 0) {
- return EmptyIterator.<String> instance();
- }
- return CollectionTools.iterator(this.getPersistenceUnit().uniqueGeneratorNames());
- }
-
- private Iterator<String> generatorNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.persistenceGeneratorNames(), filter);
- }
-
- protected Iterator<String> persistenceGeneratorNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.generatorNames(filter));
- }
-
-
- // *************************************************************************
-
- @Override
- public String getPrimaryKeyColumnName() {
- return this.getColumn().getName();
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
-
- //*********** Validation ************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- // [JPA 2.0] if the column is specified, or if the id is not mapped by a relationship,
- // then the column is validated.
- // (In JPA 1.0, the column will always be validated, since the id is never mapped by a
- // relationship)
- if (isColumnSpecified() || ! isMappedByRelationship()) {
- this.getColumn().validate(messages, reporter, astRoot);
- }
-
- // [JPA 2.0] if the column is specified and the id is mapped by a relationship,
- // then that is an error
- // (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship)
- if (isColumnSpecified() && isMappedByRelationship()) {
- messages.add(
- buildMessage(
- JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
- new String[] {},
- getColumn().getValidationTextRange(astRoot)));
- }
-
- if (this.getGeneratedValue() != null) {
- this.getGeneratedValue().validate(messages, reporter, astRoot);
- }
- this.getGeneratorContainer().validate(messages, reporter, astRoot);
- this.getConverter().validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- /* TODO - move to AbstractOrmAttributeMapping? */
- protected IMessage buildMessage(String msgID, String[] params, TextRange textRange) {
- PersistentAttribute attribute = getPersistentAttribute();
- String attributeDesc = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
-
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- ArrayTools.add(params, 0, attributeDesc),
- this,
- textRange);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java
deleted file mode 100644
index 06fce4be77..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaIdMappingDefinition.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.IdAnnotation;
-
-public abstract class AbstractJavaIdMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- protected AbstractJavaIdMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return IdAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaIdMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java
deleted file mode 100644
index 0e1e64b65f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.core.internal.resource.java.NullJoinColumnAnnotation;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-
-public abstract class AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy
- extends AbstractJavaJoinColumnJoiningStrategy
-{
-
- protected AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy(JavaJoinColumnEnabledRelationshipReference parent) {
- super(parent);
- }
-
- @Override
- protected JavaJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- @Override
- public JavaJoinColumnEnabledRelationshipReference getRelationshipReference() {
- return (JavaJoinColumnEnabledRelationshipReference) super.getRelationshipReference();
- }
-
- @Override
- public JavaRelationshipMapping getRelationshipMapping() {
- return getRelationshipReference().getRelationshipMapping();
- }
-
- protected abstract Entity getRelationshipTargetEntity();
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- public boolean isOverridableAssociation() {
- return true;
- }
-
- protected JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute().getResourcePersistentAttribute();
- }
-
- @Override
- protected Iterator<JoinColumnAnnotation> joinColumnAnnotations() {
- return new TransformationIterator<NestableAnnotation, JoinColumnAnnotation>(
- this.getResourcePersistentAttribute().annotations(
- JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME)) {
- @Override
- protected JoinColumnAnnotation transform(NestableAnnotation next) {
- return (JoinColumnAnnotation) next;
- }
- };
- }
-
- @Override
- protected JoinColumnAnnotation buildNullJoinColumnAnnotation() {
- return new NullJoinColumnAnnotation(this.getResourcePersistentAttribute());
- }
-
- @Override
- protected JoinColumnAnnotation addAnnotation(int index) {
- return (JoinColumnAnnotation) this.getResourcePersistentAttribute().
- addAnnotation(
- index,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void removeAnnotation(int index) {
- this.getResourcePersistentAttribute().
- removeAnnotation(
- index,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void moveAnnotation(int targetIndex, int sourceIndex) {
- this.getResourcePersistentAttribute().
- moveAnnotation(
- targetIndex,
- sourceIndex,
- JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return getRelationshipMapping().getName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public Iterator<String> candidateTableNames() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.candidateTableNames();
- }
-
- public Table getDbTable(String tableName) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator((JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java
deleted file mode 100644
index cdc459610b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJoinColumnJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaJoinColumnJoiningStrategy
-{
- protected JavaJoinColumn defaultJoinColumn;
-
- protected final Vector<JavaJoinColumn> specifiedJoinColumns = new Vector<JavaJoinColumn>();
- protected final JavaJoinColumn.Owner joinColumnOwner;
-
-
- protected AbstractJavaJoinColumnJoiningStrategy(JoinColumnEnabledRelationshipReference parent) {
- super(parent);
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
- protected abstract JavaJoinColumn.Owner buildJoinColumnOwner();
-
- public void initializeFrom(JoinColumnJoiningStrategy oldStrategy) {
- for (JoinColumn joinColumn : CollectionTools.iterable(oldStrategy.joinColumns())) {
- JoinColumn newJoinColumn = this.addSpecifiedJoinColumn(this.specifiedJoinColumnsSize());
- newJoinColumn.setSpecifiedName(joinColumn.getName());
- newJoinColumn.setSpecifiedReferencedColumnName(joinColumn.getReferencedColumnName());
- }
- }
-
- @Override
- public JoinColumnEnabledRelationshipReference getParent() {
- return (JoinColumnEnabledRelationshipReference) super.getParent();
- }
-
- public JoinColumnEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? null : typeMapping.getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? null : typeMapping.getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? false : typeMapping.tableNameIsInvalid(tableName);
- }
-
- protected Iterator<String> candidateTableNames() {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? EmptyIterator.<String> instance() : typeMapping.associatedTableNamesIncludingInherited();
- }
-
- public void addStrategy() {
- if (specifiedJoinColumnsSize() == 0) {
- addSpecifiedJoinColumn(0);
- }
- }
-
- public void removeStrategy() {
- for (JoinColumn each : CollectionTools.iterable(specifiedJoinColumns())) {
- removeSpecifiedJoinColumn(each);
- }
- }
-
- public Table getReferencedColumnDbTable() {
- TypeMapping relationshipTarget = getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
- // **************** join columns *******************************************
-
- public ListIterator<JavaJoinColumn> joinColumns() {
- return this.hasSpecifiedJoinColumns() ?
- this.specifiedJoinColumns() : this.defaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ?
- this.specifiedJoinColumnsSize() : this.defaultJoinColumnsSize();
- }
-
-
- // **************** default join column ************************************
-
- public JavaJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(JavaJoinColumn column) {
- JavaJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = column;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, column);
- }
-
- protected ListIterator<JavaJoinColumn> defaultJoinColumns() {
- if (this.defaultJoinColumn != null) {
- return new SingleElementListIterator<JavaJoinColumn>(this.defaultJoinColumn);
- }
- return EmptyListIterator.instance();
- }
-
- protected int defaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
-
- // **************** specified join columns *********************************
-
- public ListIterator<JavaJoinColumn> specifiedJoinColumns() {
- return new CloneListIterator<JavaJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return ! this.specifiedJoinColumns.isEmpty();
- }
-
- public JavaJoinColumn addSpecifiedJoinColumn(int index) {
- // Clear out the default now so it doesn't get removed during an update and
- // cause change notifications to be sent to the UI in the wrong order.
- JavaJoinColumn oldDefault = this.defaultJoinColumn;
- this.defaultJoinColumn = null;
-
- JavaJoinColumn joinColumn = this.getJpaFactory().buildJavaJoinColumn(this, this.joinColumnOwner);
- this.specifiedJoinColumns.add(index, joinColumn);
- JoinColumnAnnotation joinColumnAnnotation = this.addAnnotation(index);
- joinColumn.initialize(joinColumnAnnotation);
- this.fireItemAdded(SPECIFIED_JOIN_COLUMNS_LIST, index, joinColumn);
-
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, oldDefault, null);
- return joinColumn;
- }
-
- protected void addSpecifiedJoinColumn(int index, JavaJoinColumn joinColumn) {
- addItemToList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected void addSpecifiedJoinColumn(JavaJoinColumn joinColumn) {
- addSpecifiedJoinColumn(this.specifiedJoinColumns.size(), joinColumn);
- }
-
- public void removeSpecifiedJoinColumn(JoinColumn joinColumn) {
- removeSpecifiedJoinColumn(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- public void removeSpecifiedJoinColumn(int index) {
- JavaJoinColumn removedJoinColumn = this.specifiedJoinColumns.remove(index);
- if (this.specifiedJoinColumns.isEmpty()) {
- //create the defaultJoinColumn now or this will happen during project update
- //after removing the join column from the resource model. That causes problems
- //in the UI because the change notifications end up in the wrong order.
- this.defaultJoinColumn = buildJoinColumn(buildNullJoinColumnAnnotation());
- }
- removeAnnotation(index);
- fireItemRemoved(SPECIFIED_JOIN_COLUMNS_LIST, index, removedJoinColumn);
- if (this.defaultJoinColumn != null) {
- //fire change notification if a defaultJoinColumn was created above
- firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, null, this.defaultJoinColumn);
- }
- }
-
- protected void removeSpecifiedJoinColumn_(JavaJoinColumn joinColumn) {
- removeItemFromList(joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedJoinColumns, targetIndex, sourceIndex);
- moveAnnotation(targetIndex, sourceIndex);
- fireItemMoved(SPECIFIED_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
- protected abstract JoinColumnAnnotation addAnnotation(int index);
-
- protected abstract void removeAnnotation(int index);
-
- protected abstract void moveAnnotation(int targetIndex, int sourceIndex);
-
- protected abstract Iterator<JoinColumnAnnotation> joinColumnAnnotations();
-
- protected abstract JoinColumnAnnotation buildNullJoinColumnAnnotation();
-
-
- // **************** resource => context ************************************
-
- public void initialize() {
- initializeSpecifiedJoinColumns();
- initializeDefaultJoinColumn();
- }
-
- protected void initializeSpecifiedJoinColumns() {
- Iterator<JoinColumnAnnotation> annotations = joinColumnAnnotations();
- while (annotations.hasNext()) {
- this.specifiedJoinColumns.add(buildJoinColumn(annotations.next()));
- }
- }
-
- public void initializeDefaultJoinColumn() {
- if (mayHaveDefaultJoinColumn()) {
- this.defaultJoinColumn =
- buildJoinColumn(buildNullJoinColumnAnnotation());
- }
- }
-
- public void update() {
- updateSpecifiedJoinColumns();
- updateDefaultJoinColumn();
- }
-
- protected void updateSpecifiedJoinColumns() {
- ListIterator<JavaJoinColumn> joinColumns = specifiedJoinColumns();
- Iterator<JoinColumnAnnotation> resourceJoinColumns = joinColumnAnnotations();
-
- while (joinColumns.hasNext()) {
- JavaJoinColumn joinColumn = joinColumns.next();
- if (resourceJoinColumns.hasNext()) {
- joinColumn.update(resourceJoinColumns.next());
- }
- else {
- removeSpecifiedJoinColumn_(joinColumn);
- }
- }
-
- while (resourceJoinColumns.hasNext()) {
- addSpecifiedJoinColumn(buildJoinColumn(resourceJoinColumns.next()));
- }
- }
-
- protected void updateDefaultJoinColumn() {
- if (mayHaveDefaultJoinColumn()) {
- JoinColumnAnnotation nullAnnotation = buildNullJoinColumnAnnotation();
- if (this.defaultJoinColumn == null) {
- setDefaultJoinColumn(this.buildJoinColumn(nullAnnotation));
- }
- this.defaultJoinColumn.update(nullAnnotation);
- }
- else {
- if (this.defaultJoinColumn != null) {
- setDefaultJoinColumn(null);
- }
- }
- }
-
- protected boolean mayHaveDefaultJoinColumn() {
- return getRelationshipReference().mayHaveDefaultJoinColumn()
- && ! hasSpecifiedJoinColumns();
- }
-
- protected JavaJoinColumn buildJoinColumn(JoinColumnAnnotation joinColumnResource) {
- JavaJoinColumn joinColumn = getJpaFactory().buildJavaJoinColumn(this, this.joinColumnOwner);
- joinColumn.initialize(joinColumnResource);
- return joinColumn;
- }
-
-
- // **************** Java completion proposals ******************************
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaJoinColumn column : CollectionTools.iterable(this.joinColumns())) {
- result = column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- for (Iterator<JavaJoinColumn> stream = this.joinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter, astRoot);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java
deleted file mode 100644
index 578936693b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.JoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.JoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.java.JavaJoinTable;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJoinTableJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaJoinTableJoiningStrategy, Table.Owner
-{
- protected JavaJoinTable joinTable;
-
-
- protected AbstractJavaJoinTableJoiningStrategy(JoinTableEnabledRelationshipReference parent) {
- super(parent);
- }
-
-
- @Override
- public JoinTableEnabledRelationshipReference getParent() {
- return (JoinTableEnabledRelationshipReference) super.getParent();
- }
-
- public JoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- return getJoinTable().getName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return getJoinTable().getDbTable();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return !StringTools.stringsAreEqual(getTableName(), tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.DOES_NOT_MATCH_JOIN_TABLE;
- }
-
- public String getJoinTableDefaultName() {
- return MappingTools.buildJoinTableDefaultName(this.getRelationshipReference());
- }
-
- public void addStrategy() {
- if (this.joinTable == null) {
- this.joinTable = this.buildJavaJoinTable();
- addAnnotation();
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, null, this.joinTable);
- }
- }
-
- public void removeStrategy() {
- if (this.joinTable != null) {
- JavaJoinTable oldJoinTable = this.joinTable;
- this.joinTable = null;
- removeAnnotation();
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, oldJoinTable, null);
- }
- }
-
- public void initializeFrom(JoinTableJoiningStrategy oldStrategy) {
- JoinTable oldJoinTable = oldStrategy.getJoinTable();
- if (oldJoinTable != null) {
- this.addStrategy();
- this.getJoinTable().setSpecifiedCatalog(oldJoinTable.getSpecifiedCatalog());
- this.getJoinTable().setSpecifiedSchema(oldJoinTable.getSpecifiedSchema());
- this.getJoinTable().setSpecifiedName(oldJoinTable.getSpecifiedName());
- }
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTable getJoinTable() {
- return this.joinTable;
- }
-
- protected void setJoinTable_(JavaJoinTable newJoinTable) {
- JavaJoinTable oldJoinTable = this.joinTable;
- this.joinTable = newJoinTable;
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, oldJoinTable, newJoinTable);
- }
-
- protected abstract JoinTableAnnotation addAnnotation();
-
- protected abstract void removeAnnotation();
-
- protected boolean mayHaveJoinTable() {
- return getAnnotation().isSpecified()
- || getRelationshipReference().mayHaveDefaultJoinTable();
- }
-
-
- // **************** resource => context ************************************
-
- public void initialize() {
- JoinTableAnnotation annotation = getAnnotation();
- if (mayHaveJoinTable()) {
- this.joinTable = this.buildJavaJoinTable();
- this.joinTable.initialize(annotation);
- }
- }
-
- public void update() {
- JoinTableAnnotation annotation = getAnnotation();
- if (mayHaveJoinTable()) {
- if (this.joinTable == null) {
- setJoinTable_(this.buildJavaJoinTable());
- }
- this.joinTable.update(annotation);
- }
- else {
- if (this.joinTable != null) {
- // no annotation, so no clean up
- setJoinTable_(null);
- }
- }
- }
-
- protected JavaJoinTable buildJavaJoinTable() {
- return getJpaFactory().buildJavaJoinTable(this, this);
- }
-
-
- // **************** Java completion proposals ******************************
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null && this.joinTable != null) {
- result = this.joinTable.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- if (this.joinTable != null) {
- this.joinTable.validate(messages, reporter, astRoot);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java
deleted file mode 100644
index 8a55d4a316..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaJpaContextNode.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.JpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.internal.context.AbstractJpaContextNode;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJpaContextNode
- extends AbstractJpaContextNode
- implements JavaJpaContextNode
-{
- // ********** constructor **********
-
- protected AbstractJavaJpaContextNode(JpaContextNode parent) {
- super(parent);
- }
-
- @Override
- public JpaResourceType getResourceType() {
- return JptCorePlugin.JAVA_SOURCE_RESOURCE_TYPE;
- }
-
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- if (this.connectionProfileIsActive()) {
- Iterator<String> result = this.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- /**
- * This method is called if the database is connected, allowing us to
- * get candidates from the various database tables etc.
- * This method should NOT be cascaded to "child" objects; it should
- * only return candidates for the current object. The cascading is
- * handled by #javaCompletionProposals(int, Filter, CompilationUnit).
- */
- @SuppressWarnings("unused")
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- return null;
- }
-
- // ********** validation **********
-
- /**
- * All subclass implementations {@link #validate(List, CompilationUnit))}
- * should be preceded by a "super" call to this method
- */
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (reporter.isCancelled()) {
- throw new ValidationCancelledException();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java
deleted file mode 100644
index 87f4be9190..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToManyMapping.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaManyToManyRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToManyMapping2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.ManyToMany2_0Annotation;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-
-
-public abstract class AbstractJavaManyToManyMapping
- extends AbstractJavaMultiRelationshipMapping<ManyToMany2_0Annotation>
- implements JavaManyToManyMapping2_0
-{
- protected AbstractJavaManyToManyMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- @Override
- protected JavaRelationshipReference buildRelationshipReference() {
- return new GenericJavaManyToManyRelationshipReference(this);
- }
-
- public String getAnnotationName() {
- return ManyToManyAnnotation.ANNOTATION_NAME;
- }
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- public JavaManyToManyRelationshipReference getRelationshipReference() {
- return (JavaManyToManyRelationshipReference) super.getRelationshipReference();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java
deleted file mode 100644
index 38b7e7d227..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneMapping.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.ManyToOne2_0Annotation;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-
-
-public abstract class AbstractJavaManyToOneMapping
- extends AbstractJavaSingleRelationshipMapping<ManyToOne2_0Annotation>
- implements JavaManyToOneMapping2_0
-{
- protected AbstractJavaManyToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
- public String getAnnotationName() {
- return ManyToOneAnnotation.ANNOTATION_NAME;
- }
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- public JavaManyToOneRelationshipReference2_0 getRelationshipReference() {
- return (JavaManyToOneRelationshipReference2_0) super.getRelationshipReference();
- }
-
- @Override
- protected Boolean getResourceOptional() {
- return this.mappingAnnotation.getOptional();
- }
-
- @Override
- protected void setResourceOptional(Boolean newOptional) {
- this.mappingAnnotation.setOptional(newOptional);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java
deleted file mode 100644
index 314634870b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaManyToOneRelationshipReference.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.jpa2.context.java.JavaManyToOneRelationshipReference2_0;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaManyToOneRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaManyToOneRelationshipReference2_0
-{
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
- protected AbstractJavaManyToOneRelationshipReference(JavaManyToOneMapping parent) {
- super(parent);
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
-
- protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericJavaJoinColumnJoiningStrategy(this);
- }
-
- protected abstract JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy();
-
- @Override
- public JavaManyToOneMapping getRelationshipMapping() {
- return (JavaManyToOneMapping) getParent();
- }
-
- public boolean isRelationshipOwner() {
- return true;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return false;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** join columns *******************************************
-
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- // join columns are default (and only, so far) strategy, so no need
- // to add to resource model
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.getJoinTableJoiningStrategy().getJoinTable() == null;
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.addStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.joinTableJoiningStrategy.initialize();
- // initialize join column strategy last, as the existence of a default
- // join column is dependent on the other mechanisms (join table) not
- // being specified
- this.joinColumnJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.joinTableJoiningStrategy.update();
- // update join column strategy last, as the existence of a default join
- // column is dependent on the other mechanisms (join table) not being
- // specified
- this.joinColumnJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java
deleted file mode 100644
index 7cc51ed495..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMappedSuperclass.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericMappedSuperclassPrimaryKeyValidator;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaMappedSuperclass extends AbstractJavaTypeMapping
- implements JavaMappedSuperclass
-{
- protected final JavaIdClassReference idClassReference;
-
-
- protected AbstractJavaMappedSuperclass(JavaPersistentType parent) {
- super(parent);
- this.idClassReference = buildIdClassReference();
- }
-
-
- protected GenericJavaIdClassReference buildIdClassReference() {
- return new GenericJavaIdClassReference(this);
- }
-
- public JavaIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- @Override
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return MappedSuperclassAnnotation.ANNOTATION_NAME;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- protected static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JPA.ID_CLASS,
- JPA.EXCLUDE_DEFAULT_LISTENERS,
- JPA.EXCLUDE_SUPERCLASS_LISTENERS,
- JPA.ENTITY_LISTENERS,
- JPA.PRE_PERSIST,
- JPA.POST_PERSIST,
- JPA.PRE_REMOVE,
- JPA.POST_REMOVE,
- JPA.PRE_UPDATE,
- JPA.POST_UPDATE,
- JPA.POST_LOAD
- };
-
- protected static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- @Override
- public void initialize(JavaResourcePersistentType persistentTypeResource) {
- super.initialize(persistentTypeResource);
- this.idClassReference.initialize();
- }
-
- @Override
- public void update(JavaResourcePersistentType persistentTypeResource) {
- super.update(persistentTypeResource);
- this.idClassReference.update();
- }
-
-
- // **************** validation ********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- validatePrimaryKey(messages, reporter, astRoot);
- }
-
- protected void validatePrimaryKey(
- List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
-
- buildPrimaryKeyValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) {
- return new GenericMappedSuperclassPrimaryKeyValidator(this, buildTextRangeResolver(astRoot));
- // TODO - JPA 2.0 validation
- }
-
- @Override
- protected PrimaryKeyTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaMappedSuperclassTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
deleted file mode 100644
index f2d5428ab7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ /dev/null
@@ -1,814 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.Orderable;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaMultiRelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaOrderable;
-import org.eclipse.jpt.core.context.java.JavaOverrideContainer;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoiningStrategyTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyColumnValidator;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaMapKeyColumn2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.MapKeyClass2_0Annotation;
-import org.eclipse.jpt.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
-import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java multi-relationship (m:m, 1:m) mapping
- */
-public abstract class AbstractJavaMultiRelationshipMapping<T extends RelationshipMapping2_0Annotation>
- extends AbstractJavaRelationshipMapping<T>
- implements JavaMultiRelationshipMapping, JavaCollectionMapping2_0
-{
- protected final JavaOrderable orderable;
-
- protected Embeddable resolvedTargetEmbeddable;
-
- protected Type valueType;
- protected Type keyType;
-
- protected String specifiedMapKey;
- protected boolean noMapKey = false;
- protected boolean pkMapKey = false;
- protected boolean customMapKey = false;
-
- protected String specifiedMapKeyClass;
- protected String defaultMapKeyClass;
- protected String fullyQualifiedMapKeyClass;
- protected PersistentType resolvedMapKeyType;
- protected Embeddable resolvedMapKeyEmbeddable;
- protected Entity resolvedMapKeyEntity;
-
- protected final JavaColumn mapKeyColumn;
-
- protected final JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer;
-
- protected AbstractJavaMultiRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orderable = this.buildOrderable();
- this.mapKeyColumn = this.buildMapKeyColumn();
- this.mapKeyAttributeOverrideContainer = this.getJpaFactory().buildJavaAttributeOverrideContainer(this, new MapKeyAttributeOverrideContainerOwner());
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.orderable.initialize();
- this.resolvedTargetType = this.resolveTargetType();
- this.resolvedTargetEmbeddable = this.resolveTargetEmbeddable();
- this.initializeValueType();
- this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
- this.specifiedMapKeyClass = this.getResourceMapKeyClass();
- this.fullyQualifiedMapKeyClass = this.buildFullyQualifiedMapKeyClass();
- this.resolvedMapKeyType = this.resolveMapKeyType();//no need for change notification, use resolved target embeddable change notification instead?
- this.resolvedMapKeyEmbeddable = this.resolveMapKeyEmbeddable();
- this.resolvedMapKeyEntity = this.resolveMapKeyEntity();
- this.initializeKeyType();
- this.initializeMapKey();
- this.initializeMapKeyColumn();
- this.mapKeyAttributeOverrideContainer.initialize(getResourcePersistentAttribute());
- }
-
- @Override
- protected void update() {
- super.update();
- this.orderable.update();
- this.resolvedTargetType = this.resolveTargetType();//no need for change notification, use resolved target embeddable change notification instead?
- this.resolvedTargetEmbeddable = this.resolveTargetEmbeddable();
- this.updateValueType();
- this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
- this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
- this.setFullyQualifiedMapKeyClass(this.buildFullyQualifiedMapKeyClass());
- this.resolvedMapKeyType = this.resolveMapKeyType();//no need for change notification, use resolved target embeddable change notification instead?
- this.setResolvedMapKeyEmbeddable(this.resolveMapKeyEmbeddable());
- this.setResolvedMapKeyEntity(this.resolveMapKeyEntity());
- this.updateKeyType();
- this.updateMapKey();
- this.updateMapKeyColumn();
- this.mapKeyAttributeOverrideContainer.update(getResourcePersistentAttribute());
- }
-
- // ********** AbstractJavaAttributeMapping implementation **********
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.JOIN_TABLE);
- names.add(JPA.MAP_KEY);
- names.add(JPA.ORDER_BY);
- if (this.isJpa2_0Compatible()) {
- names.add(JPA.ATTRIBUTE_OVERRIDE);
- names.add(JPA.ATTRIBUTE_OVERRIDES);
- names.add(JPA2_0.MAP_KEY_CLASS);
- names.add(JPA2_0.MAP_KEY_COLUMN);
- names.add(JPA2_0.MAP_KEY_ENUMERATED);
- names.add(JPA2_0.MAP_KEY_JOIN_COLUMN);
- names.add(JPA2_0.MAP_KEY_JOIN_COLUMNS);
- names.add(JPA2_0.MAP_KEY_TEMPORAL);
- names.add(JPA2_0.ORDER_COLUMN);
- }
- }
-
- // ********** AbstractJavaRelationshipMapping implementation **********
-
- @Override
- protected String buildDefaultTargetEntity() {
- return this.getPersistentAttribute().getMultiReferenceTargetTypeName();
- }
-
-
- // ********** ordering **********
-
- protected JavaOrderable buildOrderable() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory().buildJavaOrderable(this, this.buildOrderableOwner()) :
- this.getJpaFactory().buildJavaOrderable(this, new Orderable.Owner() {/*nothing*/});
- }
-
- public JavaOrderable getOrderable() {
- return this.orderable;
- }
-
- protected Orderable2_0.Owner buildOrderableOwner() {
- return new Orderable2_0.Owner() {
- public String getTableName() {
- return getRelationshipReference().getPredominantJoiningStrategy().getTableName();
- }
- public Table getDbTable(String tableName) {
- return getRelationshipReference().getPredominantJoiningStrategy().getDbTable(tableName);
- }
- };
- }
-
- // ********** Fetchable implementation **********
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- // ********** CollectionMapping implementation **********
-
- protected Embeddable resolveTargetEmbeddable() {
- if (this.resolvedTargetType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedTargetType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- public Type getValueType() {
- return this.valueType;
- }
-
- protected void setValueType(Type newValueType) {
- Type old = this.valueType;
- this.valueType = newValueType;
- firePropertyChanged(VALUE_TYPE_PROPERTY, old, newValueType);
- }
-
- protected void initializeValueType() {
- this.valueType = this.buildValueType();
- }
-
- protected void updateValueType() {
- this.setValueType(this.buildValueType());
- }
-
- protected Type buildValueType() {
- if (this.getResolvedTargetEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- else if (this.resolvedTargetEmbeddable != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- else if (getTargetEntity() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- public Type getKeyType() {
- return this.keyType;
- }
-
- protected void setKeyType(Type newKeyType) {
- Type old = this.keyType;
- this.keyType = newKeyType;
- firePropertyChanged(KEY_TYPE_PROPERTY, old, newKeyType);
- }
-
- protected void initializeKeyType() {
- this.keyType = this.buildKeyType();
- }
-
- protected void updateKeyType() {
- this.setKeyType(this.buildKeyType());
- }
-
- protected Type buildKeyType() {
- if (getResolvedMapKeyEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (getResolvedMapKeyEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- else if (getMapKeyClass() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- public Embeddable getResolvedMapKeyEmbeddable() {
- return this.resolvedMapKeyEmbeddable;
- }
-
- protected void setResolvedMapKeyEmbeddable(Embeddable embeddable) {
- Embeddable old = this.resolvedMapKeyEmbeddable;
- this.resolvedMapKeyEmbeddable = embeddable;
- this.firePropertyChanged(RESOLVED_MAP_KEY_EMBEDDABLE_PROPERTY, old, embeddable);
- }
-
- public Entity getResolvedMapKeyEntity() {
- return this.resolvedMapKeyEntity;
- }
-
- protected void setResolvedMapKeyEntity(Entity entity) {
- Entity old = this.resolvedMapKeyEntity;
- this.resolvedMapKeyEntity = entity;
- this.firePropertyChanged(RESOLVED_MAP_KEY_ENTITY_PROPERTY, old, entity);
- }
-
- public PersistentType getResolvedMapKeyType() {
- return getResolvedMapKeyEmbeddable() == null ? null : getResolvedMapKeyEmbeddable().getPersistentType();
- }
-
- protected PersistentType resolveMapKeyType() {
- return (this.fullyQualifiedMapKeyClass == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedMapKeyClass);
- }
-
- protected Embeddable resolveMapKeyEmbeddable() {
- if (this.resolvedMapKeyType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedMapKeyType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- protected Entity resolveMapKeyEntity() {
- if (this.resolvedMapKeyType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedMapKeyType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- // ********** map key **********
-
- public String getMapKey() {
- if (this.noMapKey) {
- return null;
- }
- if (this.pkMapKey) {
- return this.getTargetEntityIdAttributeName();
- }
- if (this.customMapKey) {
- return this.specifiedMapKey;
- }
- throw new IllegalStateException("unknown map key"); //$NON-NLS-1$
- }
-
- public String getSpecifiedMapKey() {
- return this.specifiedMapKey;
- }
-
- public void setSpecifiedMapKey(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKey == null) {
- if (mapKeyAnnotation != null) {
- this.removeMapKeyAnnotation();
- }
- } else {
- if (mapKeyAnnotation == null) {
- mapKeyAnnotation = this.addMapKeyAnnotation();
- }
- mapKeyAnnotation.setName(mapKey);
- }
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected void setSpecifiedMapKey_(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected void initializeMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKeyAnnotation == null) {
- this.noMapKey = true;
- } else {
- this.specifiedMapKey = mapKeyAnnotation.getName();
- if (this.specifiedMapKey == null) {
- this.pkMapKey = true;
- } else {
- this.customMapKey = true;
- }
- }
- }
-
- protected void updateMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKeyAnnotation == null) {
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(true);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(false);
- } else {
- String mk = mapKeyAnnotation.getName();
- this.setSpecifiedMapKey_(mk);
- this.setNoMapKey_(false);
- this.setPkMapKey_(mk == null);
- this.setCustomMapKey_(mk != null);
- }
- }
-
- protected MapKeyAnnotation getMapKeyAnnotation() {
- return (MapKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected MapKeyAnnotation addMapKeyAnnotation() {
- return (MapKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeMapKeyAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected boolean mapKeyNameTouches(int pos, CompilationUnit astRoot) {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation != null) && mapKeyAnnotation.nameTouches(pos, astRoot);
- }
-
-
- // ********** no map key **********
-
- public boolean isNoMapKey() {
- return this.noMapKey;
- }
-
- public void setNoMapKey(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- if (noMapKey) {
- if (this.getMapKeyAnnotation() != null) {
- this.removeMapKeyAnnotation();
- }
- } else {
- // the 'noMapKey' flag is cleared as a
- // side-effect of setting the other flags,
- // via a call to #setNoMapKey_(boolean)
- }
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
- protected void setNoMapKey_(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
-
- // ********** pk map key **********
-
- public boolean isPkMapKey() {
- return this.pkMapKey;
- }
-
- public void setPkMapKey(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (pkMapKey) {
- if (mapKeyAnnotation == null) {
- this.addMapKeyAnnotation();
- } else {
- mapKeyAnnotation.setName(null);
- }
- } else {
- // the 'pkMapKey' flag is cleared as a
- // side-effect of setting the other flags,
- // via a call to #setPkMapKey_(boolean)
- }
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
- protected void setPkMapKey_(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
-
- // ********** custom map key **********
-
- public boolean isCustomMapKey() {
- return this.customMapKey;
- }
-
- public void setCustomMapKey(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- if (customMapKey) {
- this.setSpecifiedMapKey(""); //$NON-NLS-1$
- } else {
- // the 'customMapKey' flag is cleared as a
- // side-effect of setting the other flags,
- // via a call to #setCustomMapKey_(boolean)
- }
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
- protected void setCustomMapKey_(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
-
- // *************** map key class *************
-
- public String getMapKeyClass() {
- return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
- }
-
- public String getSpecifiedMapKeyClass() {
- return this.specifiedMapKeyClass;
- }
-
- public void setSpecifiedMapKeyClass(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- MapKeyClass2_0Annotation mapKeyClassAnnotation = this.getMapKeyClassAnnotation();
- if (mapKeyClass == null) {
- if (mapKeyClassAnnotation != null) {
- this.removeMapKeyClassAnnotation();
- }
- } else {
- if (mapKeyClassAnnotation == null) {
- mapKeyClassAnnotation = this.addMapKeyClassAnnotation();
- }
- mapKeyClassAnnotation.setValue(mapKeyClass);
- }
-
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String getResourceMapKeyClass() {
- MapKeyClass2_0Annotation annotation = getMapKeyClassAnnotation();
- return annotation == null ? null : annotation.getValue();
- }
-
- public String getDefaultMapKeyClass() {
- return this.defaultMapKeyClass;
- }
-
- protected void setDefaultMapKeyClass(String mapKeyClass) {
- String old = this.defaultMapKeyClass;
- this.defaultMapKeyClass = mapKeyClass;
- this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String buildDefaultMapKeyClass() {
- return this.getPersistentAttribute().getMultiReferenceMapKeyTypeName();
- }
-
- public String getFullyQualifiedMapKeyClass() {
- return this.fullyQualifiedMapKeyClass;
- }
-
- protected void setFullyQualifiedMapKeyClass(String mapKeyClass) {
- String old = this.fullyQualifiedMapKeyClass;
- this.fullyQualifiedMapKeyClass = mapKeyClass;
- this.firePropertyChanged(FULLY_QUALIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String buildFullyQualifiedMapKeyClass() {
- return (this.specifiedMapKeyClass == null) ?
- this.defaultMapKeyClass :
- this.getMapKeyClassAnnotation().getFullyQualifiedClassName();
- }
-
- public char getMapKeyClassEnclosingTypeSeparator() {
- return '.';
- }
-
- protected MapKeyClass2_0Annotation getMapKeyClassAnnotation() {
- return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- }
-
- protected MapKeyClass2_0Annotation addMapKeyClassAnnotation() {
- return (MapKeyClass2_0Annotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- }
-
- protected void removeMapKeyClassAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(MapKeyClass2_0Annotation.ANNOTATION_NAME);
- }
-
- // ********** map key column - JPA 2.0 **********
-
- protected JavaColumn buildMapKeyColumn() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaMapKeyColumn(this, this.buildMapKeyColumnOwner()) :
- new NullJavaMapKeyColumn2_0(this);
- }
-
- public JavaColumn getMapKeyColumn() {
- return this.mapKeyColumn;
- }
-
- protected void initializeMapKeyColumn() {
- this.mapKeyColumn.initialize(getMapKeyColumnAnnotation());
- }
-
- protected void updateMapKeyColumn() {
- getMapKeyColumn().update(getMapKeyColumnAnnotation());
- }
-
- public MapKeyColumn2_0Annotation getMapKeyColumnAnnotation() {
- if (!isJpa2_0Compatible()) {
- return null;
- }
- return (MapKeyColumn2_0Annotation) this.getResourcePersistentAttribute().getNonNullAnnotation(MapKeyColumn2_0Annotation.ANNOTATION_NAME);
- }
-
- protected JavaBaseColumn.Owner buildMapKeyColumnOwner() {
- return new MapKeyColumnOwner();
- }
-
- public JavaAttributeOverrideContainer getMapKeyAttributeOverrideContainer() {
- return this.mapKeyAttributeOverrideContainer;
- }
-
- // ********** Java completion proposals **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getOrderable().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.mapKeyNameTouches(pos, astRoot)) {
- return this.javaCandidateMapKeyNames(filter);
- }
- result = this.getMapKeyColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getMapKeyAttributeOverrideContainer().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
- protected Iterator<String> javaCandidateMapKeyNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateMapKeyNames(filter));
- }
-
- protected Iterator<String> candidateMapKeyNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateMapKeyNames(), filter);
- }
-
- public Iterator<String> candidateMapKeyNames() {
- return this.allTargetEntityAttributeNames();
- }
-
-
- // ********** metamodel **********
-
- @Override
- protected String getMetamodelFieldTypeName() {
- return ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldTypeName();
- }
-
- @Override
- protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) {
- this.addMetamodelFieldMapKeyTypeArgumentNameTo(typeArgumentNames);
- super.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames);
- }
-
- protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) {
- String keyTypeName = ((JavaPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
- if (keyTypeName != null) {
- typeArgumentNames.add(keyTypeName);
- }
- }
-
- public String getMetamodelFieldMapKeyTypeName() {
- return MappingTools.getMetamodelFieldMapKeyTypeName(this);
- }
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.orderable.validate(messages, reporter, astRoot);
- this.validateMapKey(messages, reporter, astRoot);
- }
-
- protected void validateMapKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (getMapKeyAnnotation() != null) {//If MapKey annotation specified, no other MapKey* annotations can be specified, don't validate them
- //TODO validate that the map key refers to an existing attribute
- return;
- }
- if (getKeyType() == Type.BASIC_TYPE) {
- this.getMapKeyColumn().validate(messages, reporter, astRoot);
- //validate map key converter
- }
- else if (getKeyType() == Type.ENTITY_TYPE) {
- //validate map key join columns
- }
- else if (getKeyType() == Type.EMBEDDABLE_TYPE) {
- getMapKeyAttributeOverrideContainer().validate(messages, reporter, astRoot);
- //validate map key association overrides - for eclipselink
- }
- }
-
-
- protected class MapKeyColumnOwner implements JavaBaseColumn.Owner {
- public TypeMapping getTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getTypeMapping();
- }
-
- protected JoiningStrategy getPredominantJoiningStrategy() {
- return getRelationshipReference().getPredominantJoiningStrategy();
- }
-
- public String getDefaultTableName() {
- return getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public String getDefaultColumnName() {
- return AbstractJavaMultiRelationshipMapping.this.getName() + "_KEY"; //$NON-NLS-1$
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getPredominantJoiningStrategy().tableNameIsInvalid(tableName);
- }
-
- public java.util.Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaMultiRelationshipMapping.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new MapKeyColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new JoiningStrategyTableDescriptionProvider(getPredominantJoiningStrategy()));
- }
- }
-
- protected abstract class OverrideContainerOwner implements JavaOverrideContainer.Owner {
- public TypeMapping getTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getTypeMapping();
- }
-
- protected JoiningStrategy getPredominantJoiningStrategy() {
- return getRelationshipReference().getPredominantJoiningStrategy();
- }
-
- public String getDefaultTableName() {
- return getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public java.util.Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- /**
- * If there is a specified table name it needs to be the same
- * the default table name. the table is always the collection table
- */
- public boolean tableNameIsInvalid(String tableName) {
- return !StringTools.stringsAreEqual(getDefaultTableName(), tableName);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaMultiRelationshipMapping.this.getValidationTextRange(astRoot);
- }
- }
-
- protected class MapKeyAttributeOverrideContainerOwner
- extends OverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getResolvedMapKeyEmbeddable();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : typeMapping.allOverridableAttributeNames();
- }
-
- public String getPossiblePrefix() {
- return "key."; //$NON-NLS-1$
- }
-
- public String getWritePrefix() {
- return this.getPossiblePrefix();
- }
-
- //since only the key can be an embeddable on a 1-m or m-m, all overrides are relevant
- public boolean isRelevant(String overrideName) {
- return true;
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new JoiningStrategyTableDescriptionProvider(getPredominantJoiningStrategy()));
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
deleted file mode 100644
index 82e5419297..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaNamedColumn.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.NamedColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaNamedColumn<T extends NamedColumnAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaNamedColumn
-{
-
- protected Owner owner;
-
- protected String specifiedName;
-
- protected String defaultName;
-
- protected String columnDefinition;
-
- protected T resourceColumn;
-
- protected AbstractJavaNamedColumn(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- // ******************* initialization from java resource model ********************
-
- protected void initialize(T column) {
- this.resourceColumn = column;
- this.specifiedName = column.getName();
- this.defaultName = this.buildDefaultName();
- this.columnDefinition = column.getColumnDefinition();
- }
-
- protected void update(T column) {
- this.resourceColumn = column;
- this.setSpecifiedName_(column.getName());
- this.setDefaultName(this.buildDefaultName());
- this.setColumnDefinition_(column.getColumnDefinition());
- }
-
- protected T getResourceColumn() {
- return this.resourceColumn;
- }
-
-
- //************** NamedColumn implementation *****************
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- getResourceColumn().setName(newSpecifiedName);
- firePropertyChanged(NamedColumn.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedName_(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- firePropertyChanged(NamedColumn.SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(NamedColumn.DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
- /**
- * Return the default column name.
- */
- protected String buildDefaultName() {
- return this.getOwner().getDefaultColumnName();
- }
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- public void setColumnDefinition(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- getResourceColumn().setColumnDefinition(newColumnDefinition);
- firePropertyChanged(NamedColumn.COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setColumnDefinition_(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- firePropertyChanged(NamedColumn.COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- public Owner getOwner() {
- return this.owner;
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceColumn().getNameTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getResourceColumn().nameTouches(pos, astRoot);
- }
-
- public Column getDbColumn() {
- Table table = this.getDbTable();
- return (table == null) ? null : table.getColumnForIdentifier(this.getName());
- }
-
- public Table getDbTable() {
- return getOwner().getDbTable(this.getTable());
- }
-
- /**
- * Return the name of the column's table. This is overridden
- * in AbstractJavaBaseColumn where a table can be defined.
- */
- public String getTable() {
- return this.getOwner().getTypeMapping().getPrimaryTableName();
- }
-
- public boolean isResolved() {
- return this.getDbColumn() != null;
- }
-
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.getJavaCandidateNames(filter).iterator();
- }
- return null;
- }
-
- private Iterable<String> getJavaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames(filter));
- }
-
- private Iterable<String> getCandidateNames(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateNames(), filter);
- }
-
- private Iterable<String> getCandidateNames() {
- Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ****************** validation ****************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = getResourceColumn().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getOwner().getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildColumnValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildColumnValidator(CompilationUnit astRoot) {
- return this.getOwner().buildColumnValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaNamedColumnTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java
deleted file mode 100644
index 44b80160c2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyMapping.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Vector;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaOrphanRemoval2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.OneToMany2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-
-
-public abstract class AbstractJavaOneToManyMapping<T extends OneToMany2_0Annotation>
- extends AbstractJavaMultiRelationshipMapping<T>
- implements JavaOneToManyMapping2_0, JavaOrphanRemovalHolder2_0
-{
- protected final JavaOrphanRemovable2_0 orphanRemoval;
-
- protected AbstractJavaOneToManyMapping(JavaPersistentAttribute parent) {
- super(parent);
-
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
- // ********** initialize/update **********
-
- @Override
- protected void initialize() {
- super.initialize();
- this.orphanRemoval.initialize(this.getResourcePersistentAttribute());
- }
-
- @Override
- protected void update() {
- super.update();
- this.orphanRemoval.update(this.getResourcePersistentAttribute());
- }
-
-
- public String getAnnotationName() {
- return OneToManyAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.JOIN_COLUMN);
- names.add(JPA.JOIN_COLUMNS);
- }
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- // ********** JavaOneToManyMapping implementation **********
-
- @Override
- public JavaOneToManyRelationshipReference2_0 getRelationshipReference() {
- return (JavaOneToManyRelationshipReference2_0) super.getRelationshipReference();
- }
-
- // ********** JavaOrphanRemovalHolder2_0 implementation **********
-
- protected JavaOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaOrphanRemoval(this) :
- new NullJavaOrphanRemoval2_0(this);
- }
-
- public JavaOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java
deleted file mode 100644
index a0f4029318..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToManyRelationshipReference.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToManyRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaOneToManyRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaOneToManyRelationshipReference2_0
-{
- protected final JavaMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
-
- protected AbstractJavaOneToManyRelationshipReference(JavaOneToManyMapping parent) {
- super(parent);
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- }
-
- protected JavaMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericJavaMappedByJoiningStrategy(this);
- }
-
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new GenericJavaJoinTableJoiningStrategy(this);
- }
-
- protected abstract JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy();
-
- @Override
- public JavaOneToManyMapping getRelationshipMapping() {
- return (JavaOneToManyMapping) getParent();
- }
-
- public OneToManyAnnotation getMappingAnnotation() {
- return getRelationshipMapping().getMappingAnnotation();
- }
-
- public boolean isRelationshipOwner() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public boolean isTargetForeignKeyRelationship() {
- return getJoinColumnJoiningStrategy().isTargetForeignKeyRelationship();
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.mappedByJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** mapped by **********************************************
-
- public JavaMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public final void setMappedByJoiningStrategy() {
- setMappedByJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void setMappedByJoiningStrategy_() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public final void unsetMappedByJoiningStrategy() {
- unsetMappedByJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetMappedByJoiningStrategy_() {
- this.mappedByJoiningStrategy.removeStrategy();
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return this.getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- setJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void setJoinTableJoiningStrategy_() {
- // join table is default, so no need to add annotation
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null
- && ! this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns();
- }
-
-
- // **************** join columns *******************************************
-
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy.initialize();
- this.joinColumnJoiningStrategy.initialize();
- this.joinTableJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.joinColumnJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java
deleted file mode 100644
index 71e4a42087..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneMapping.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Vector;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaOrphanRemoval2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.OneToOne2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-
-
-public abstract class AbstractJavaOneToOneMapping
- extends AbstractJavaSingleRelationshipMapping<OneToOne2_0Annotation>
- implements JavaOneToOneMapping2_0, JavaOrphanRemovalHolder2_0
-{
- protected final JavaOrphanRemovable2_0 orphanRemoval;
-
- // ********** constructor **********
- protected AbstractJavaOneToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
- // ********** initialize/update **********
-
- @Override
- protected void initialize() {
- super.initialize();
- this.orphanRemoval.initialize(this.getResourcePersistentAttribute());
- }
-
- @Override
- protected void update() {
- super.update();
- this.orphanRemoval.update(this.getResourcePersistentAttribute());
- }
-
- public String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.PRIMARY_KEY_JOIN_COLUMN);
- names.add(JPA.PRIMARY_KEY_JOIN_COLUMNS);
- }
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected Boolean getResourceOptional() {
- return this.mappingAnnotation.getOptional();
- }
-
- @Override
- protected void setResourceOptional(Boolean newOptional) {
- this.mappingAnnotation.setOptional(newOptional);
- }
-
- // ********** JavaOneToOneMapping implementation **********
-
- @Override
- public JavaOneToOneRelationshipReference2_0 getRelationshipReference() {
- return (JavaOneToOneRelationshipReference2_0) super.getRelationshipReference();
- }
-
- // ********** JavaOrphanRemovalHolder2_0 implementation **********
-
- protected JavaOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaOrphanRemoval(this) :
- new NullJavaOrphanRemoval2_0(this);
- }
-
- public JavaOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java
deleted file mode 100644
index 971f184022..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOneToOneRelationshipReference.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.jpa2.context.java.JavaOneToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaOneToOneRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaOneToOneRelationshipReference2_0
-{
- protected final JavaMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected final JavaJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected final JavaPrimaryKeyJoinColumnJoiningStrategy primaryKeyJoinColumnJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
- protected AbstractJavaOneToOneRelationshipReference(JavaOneToOneMapping parent) {
- super(parent);
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- this.primaryKeyJoinColumnJoiningStrategy = buildPrimaryKeyJoinColumnJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
-
- protected JavaMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericJavaMappedByJoiningStrategy(this);
- }
-
- protected JavaJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericJavaJoinColumnJoiningStrategy(this);
- }
-
- protected JavaPrimaryKeyJoinColumnJoiningStrategy buildPrimaryKeyJoinColumnJoiningStrategy() {
- return new GenericJavaPrimaryKeyJoinColumnJoiningStrategy(this);
- }
-
- protected abstract JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy();
-
- @Override
- public JavaOneToOneMapping getRelationshipMapping() {
- return (JavaOneToOneMapping) getParent();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return getRelationshipMapping().getMappingAnnotation();
- }
-
- public boolean isRelationshipOwner() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.mappedByJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.primaryKeyJoinColumnJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** mapped by **********************************************
-
- public JavaMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public void setMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join columns *******************************************
-
- public JavaJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- // join columns are default, so no need to add annotations
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null
- && this.getPrimaryKeyJoinColumnJoiningStrategy().primaryKeyJoinColumnsSize() == 0
- && this.getJoinTableJoiningStrategy().getJoinTable() == null;
- }
-
-
- // **************** primary key join columns *******************************
-
- public JavaPrimaryKeyJoinColumnJoiningStrategy getPrimaryKeyJoinColumnJoiningStrategy() {
- return this.primaryKeyJoinColumnJoiningStrategy;
- }
-
- public boolean usesPrimaryKeyJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.primaryKeyJoinColumnJoiningStrategy;
- }
-
- public void setPrimaryKeyJoinColumnJoiningStrategy() {
- this.primaryKeyJoinColumnJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetPrimaryKeyJoinColumnJoiningStrategy() {
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultPrimaryKeyJoinColumn() {
- return false;
- }
-
-
- // **************** join table *********************************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy.initialize();
- this.primaryKeyJoinColumnJoiningStrategy.initialize();
- this.joinTableJoiningStrategy.initialize();
-
- // initialize join columns last, as the existence of a default join
- // column is dependent on the other mechanisms (mappedBy, join table)
- // not being specified
- this.joinColumnJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.primaryKeyJoinColumnJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
-
- // update join columns last, as the existence of a default join
- // column is dependent on the other mechanisms (mappedBy, join table)
- // not being specified
- this.joinColumnJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByJoiningStrategy.validate(messages, reporter, astRoot);
- this.primaryKeyJoinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinColumnJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java
deleted file mode 100644
index bbbac99f19..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaOverride.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaOverride;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.OverrideAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaOverride
- extends AbstractJavaJpaContextNode
- implements JavaOverride
-{
-
- protected String name;
-
- protected final Owner owner;
-
- protected OverrideAnnotation overrideAnnotation;
-
- public AbstractJavaOverride(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- protected void initialize(OverrideAnnotation overrideAnnotation) {
- this.overrideAnnotation = overrideAnnotation;
- this.initializeName();
- }
-
- protected void update(OverrideAnnotation overrideResource) {
- this.overrideAnnotation = overrideResource;
- this.updateName();
- }
-
- public OverrideAnnotation getOverrideAnnotation() {
- return this.overrideAnnotation;
- }
-
- // ********************* name ****************
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String prefix = getOwner().getPossiblePrefix();
- String unprefixedName = newName;
- if (newName != null && prefix != null && newName.startsWith(prefix)) {
- unprefixedName = newName.substring(newName.indexOf('.') + 1);
- }
- String oldName = this.name;
- this.name = unprefixedName; //set the name without the prefix in the context model
- this.overrideAnnotation.setName(newName); // set the name with the prefix in the resource model
- firePropertyChanged(NAME_PROPERTY, oldName, unprefixedName);
- }
-
- protected void setName_(String newName) {
- String oldName = this.name;
- this.name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- protected void initializeName() {
- String name = this.getResourceName();
- String prefix = getOwner().getPossiblePrefix();
- if (name != null && prefix != null && name.startsWith(prefix)) {
- name = name.substring(name.indexOf('.') + 1);
- }
- this.name = name;
- }
-
- protected void updateName() {
- String name = this.getResourceName();
- String prefix = getOwner().getPossiblePrefix();
- if (name != null && prefix != null && name.startsWith(prefix)) {
- name = name.substring(name.indexOf('.') + 1);
- }
- this.setName_(name);
- }
-
- protected String getResourceName() {
- return this.overrideAnnotation.getName();
- }
-
- public boolean isVirtual() {
- return getOwner().isVirtual(this);
- }
-
- public BaseOverride setVirtual(boolean virtual) {
- return getOwner().setVirtual(virtual, this);
- }
-
- public Owner getOwner() {
- return this.owner;
- }
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- protected abstract Iterator<String> candidateNames();
-
- private Iterator<String> candidateNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateNames(), filter);
- }
-
- private Iterator<String> javaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateNames(filter));
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.javaCandidateNames(filter);
- }
- return null;
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.overrideAnnotation.nameTouches(pos, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.overrideAnnotation.getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.overrideAnnotation.getNameTextRange(astRoot);
- return (textRange != null) ? textRange : this.getValidationTextRange(astRoot);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(getName());
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildValidator(CompilationUnit astRoot) {
- return this.getOwner().buildValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected OverrideTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaOverrideTextRangeResolver(this, astRoot);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
deleted file mode 100644
index c222107a15..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentAttribute.java
+++ /dev/null
@@ -1,699 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.CollectionMapping;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaStructureNodes;
-import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.ClassName;
-import org.eclipse.jpt.utility.internal.ReflectionTools;
-import org.eclipse.jpt.utility.internal.Tools;
-import org.eclipse.jpt.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * common state/behavior between Generic and EclipseLink persistent attributes
- */
-public abstract class AbstractJavaPersistentAttribute
- extends AbstractJavaJpaContextNode
- implements JavaPersistentAttribute2_0
-{
- protected String name;
-
- protected JavaAttributeMapping defaultMapping;
-
- protected JavaAttributeMapping specifiedMapping;
-
- protected AccessType defaultAccess;
-
- protected JavaResourcePersistentAttribute resourcePersistentAttribute;
-
-
- protected AbstractJavaPersistentAttribute(PersistentType parent, JavaResourcePersistentAttribute resourcePersistentAttribute) {
- super(parent);
- this.resourcePersistentAttribute = resourcePersistentAttribute;
- this.name = buildName();
- this.defaultMapping = buildDefaultMapping();
- this.specifiedMapping = buildSpecifiedMapping();
- this.defaultAccess = buildDefaultAccess();
- }
-
- public void update() {
- this.setName(this.buildName());
- this.updateDefaultMapping();
- this.updateSpecifiedMapping();
- this.setDefaultAccess(this.buildDefaultAccess());
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- getMapping().postUpdate();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return JavaStructureNodes.PERSISTENT_ATTRIBUTE_ID;
- }
-
- public JpaStructureNode getStructureNode(int textOffset) {
- return this;
- }
-
- public TextRange getSelectionTextRange() {
- return this.getSelectionTextRange(this.buildASTRoot());
- }
-
- protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentAttribute.getNameTextRange(astRoot);
- }
-
- protected CompilationUnit buildASTRoot() {
- return this.resourcePersistentAttribute.getJavaResourceCompilationUnit().buildASTRoot();
- }
-
- public void dispose() {
- //nothing to dispose
- }
-
-
- // ********** AccessHolder implementation **********
-
- public AccessType getAccess() {
- AccessType access = this.getSpecifiedAccess();
- return (access != null) ? access : this.getDefaultAccess();
- }
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType defaultAccess) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = defaultAccess;
- this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, defaultAccess);
- }
-
- protected AccessType buildDefaultAccess() {
- return this.resourcePersistentAttribute.isField() ? AccessType.FIELD : AccessType.PROPERTY;
- }
-
-
- // ********** [Java]PersistentAttribute implementation **********
-
- public JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.resourcePersistentAttribute;
- }
-
- public PersistentType getOwningPersistentType() {
- return this.getParent();
- }
-
- public TypeMapping getOwningTypeMapping() {
- return this.getOwningPersistentType().getMapping();
- }
-
- public String getPrimaryKeyColumnName() {
- return this.getMapping().getPrimaryKeyColumnName();
- }
-
- public String getTypeName() {
- return this.resourcePersistentAttribute.getTypeName();
- }
-
- public boolean isVirtual() {
- return false;
- }
-
- public boolean contains(int offset, CompilationUnit astRoot) {
- TextRange fullTextRange = this.getFullTextRange(astRoot);
- // 'fullTextRange' will be null if the attribute no longer exists in the java;
- // the context model can be out of synch with the resource model
- // when a selection event occurs before the context model has a
- // chance to synch with the resource model via the update thread
- return (fullTextRange == null) ? false : fullTextRange.includes(offset);
- }
-
- protected TextRange getFullTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentAttribute.getTextRange(astRoot);
- }
-
- public Embeddable getEmbeddable() {
- return (getTypeName() == null) ?
- null : this.getPersistenceUnit().getEmbeddable(getTypeName());
- }
-
- public boolean isField() {
- return this.resourcePersistentAttribute.isField();
- }
-
- public boolean isProperty() {
- return this.resourcePersistentAttribute.isProperty();
- }
-
- public boolean isPublic() {
- return Modifier.isPublic(this.resourcePersistentAttribute.getModifiers());
- }
-
- public boolean isFinal() {
- return Modifier.isFinal(this.resourcePersistentAttribute.getModifiers());
- }
-
- // ***** Basic defaults
- /**
- * From the JPA spec, when the basic mapping applies:
- * If the type of the attribute (field or property) is one of the following
- * it must be mapped as @Basic:
- * byte[]
- * java.lang.Byte[]
- * char[]
- * java.lang.Character[]
- * primitive types (except 'void')
- * primitive wrappers (except 'java.lang.Void')
- * java.lang.String
- * java.math.BigInteger
- * java.math.BigDecimal
- * java.util.Date
- * java.util.Calendar
- * java.sql.Date
- * java.sql.Time
- * java.sql.Timestamp
- * enums
- * any other type that implements java.io.Serializable
- */
- public boolean typeIsBasic() {
- // 'typeName' may include array brackets but not generic type arguments
- String typeName = getTypeName();
- if (typeName == null) {
- return false;
- }
-
- int arrayDepth = ReflectionTools.getArrayDepthForTypeDeclaration(typeName);
- if (arrayDepth > 1) {
- return false; // multi-dimensional arrays are not supported
- }
-
- if (arrayDepth == 1) {
- String elementTypeName = ReflectionTools.getElementTypeNameForTypeDeclaration(typeName, 1);
- return this.elementTypeIsValidForBasicArray(elementTypeName);
- }
-
- // arrayDepth == 0
- if (ClassName.isVariablePrimitive(typeName)) {
- return true; // any primitive but 'void'
- }
- if (ClassName.isVariablePrimitiveWrapper(typeName)) {
- return true; // any primitive wrapper but 'java.lang.Void'
- }
- if (this.typeIsOtherValidBasicType(typeName)) {
- return true;
- }
- if (this.resourcePersistentAttribute.typeIsEnum()) {
- return true;
- }
- if (this.resourcePersistentAttribute.typeIsSubTypeOf(SERIALIZABLE_TYPE_NAME)) {
- return true;
- }
- return false;
- }
-
- /**
- * Return whether the specified type is a valid element type for
- * a one-dimensional array that can default to a Basic mapping:
- * byte
- * char
- * java.lang.Byte
- * java.lang.Character
- */
- protected boolean elementTypeIsValidForBasicArray(String elementTypeName) {
- return ArrayTools.contains(VALID_BASIC_ARRAY_ELEMENT_TYPE_NAMES, elementTypeName);
- }
-
- protected static final String[] VALID_BASIC_ARRAY_ELEMENT_TYPE_NAMES = {
- byte.class.getName(),
- char.class.getName(),
- java.lang.Byte.class.getName(),
- java.lang.Character.class.getName()
- };
-
- /**
- * Return whether the specified type is among the various "other" types
- * that can default to a Basic mapping.
- */
- protected boolean typeIsOtherValidBasicType(String typeName) {
- return ArrayTools.contains(OTHER_VALID_BASIC_TYPE_NAMES, typeName);
- }
-
- protected static final String[] OTHER_VALID_BASIC_TYPE_NAMES = {
- java.lang.String.class.getName(),
- java.math.BigInteger.class.getName(),
- java.math.BigDecimal.class.getName(),
- java.util.Date.class.getName(),
- java.util.Calendar.class.getName(),
- java.sql.Date.class.getName(),
- java.sql.Time.class.getName(),
- java.sql.Timestamp.class.getName(),
- };
-
- protected static final String SERIALIZABLE_TYPE_NAME = java.io.Serializable.class.getName();
-
- // ***** reference entities
- public String getSingleReferenceTargetTypeName() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- String typeName = getTypeName();
- if (typeName == null) {
- return null;
- }
- if (ReflectionTools.getArrayDepthForTypeDeclaration(typeName) != 0) {
- return null; // arrays cannot be entities
- }
- if (this.typeIsContainer(typeName)) {
- return null; // "containers" cannot be entities
- }
- return typeName;
- }
-
- public String getMultiReferenceTargetTypeName() {
- return this.getJpaContainer().getMultiReferenceTargetTypeName(this.resourcePersistentAttribute);
- }
-
- public String getMultiReferenceMapKeyTypeName() {
- return this.getJpaContainer().getMultiReferenceMapKeyTypeName(this.resourcePersistentAttribute);
- }
-
- /**
- * return whether the specified type is one of the container
- * types allowed by the JPA spec
- */
- protected boolean typeIsContainer(String typeName) {
- return this.getJpaContainer(typeName).isContainer();
- }
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- protected String buildName() {
- return this.resourcePersistentAttribute.getName();
- }
-
- // ***** mapping
- public JavaAttributeMapping getMapping() {
- return (this.specifiedMapping != null) ? this.specifiedMapping : this.defaultMapping;
- }
-
- public String getMappingKey() {
- return this.getMapping().getKey();
- }
-
-
- // ***** default mapping
- public JavaAttributeMapping getDefaultMapping() {
- return this.defaultMapping;
- }
-
- /**
- * clients do not set the "default" mapping
- */
- protected void setDefaultMapping(JavaAttributeMapping defaultMapping) {
- JavaAttributeMapping old = this.defaultMapping;
- this.defaultMapping = defaultMapping;
- this.firePropertyChanged(DEFAULT_MAPPING_PROPERTY, old, defaultMapping);
- }
-
- protected JavaAttributeMapping buildDefaultMapping() {
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getDefaultJavaAttributeMappingDefinition(this);
- return buildDefaultMapping(mappingDefinition);
- }
-
- protected JavaAttributeMapping buildDefaultMapping(JavaAttributeMappingDefinition mappingDefinition) {
- Annotation annotation = this.resourcePersistentAttribute.
- buildNullAnnotation(mappingDefinition.getAnnotationName());
- JavaAttributeMapping mapping = mappingDefinition.buildMapping(this, getJpaFactory());
- mapping.initialize(annotation);
- return mapping;
- }
-
- /**
- * return null if there is no "default" mapping for the attribute
- */
- public String getDefaultMappingKey() {
- return this.defaultMapping.getKey();
- }
-
- /**
- * the mapping might be "default", but it still might be a "null" mapping...
- */
- public boolean mappingIsDefault(JavaAttributeMapping mapping) {
- return this.defaultMapping == mapping;
- }
-
- protected void updateDefaultMapping() {
- // There will always be a mapping definition, even if it is a "null" mapping definition ...
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getDefaultJavaAttributeMappingDefinition(this);
- String mappingKey = mappingDefinition.getKey();
- if (this.valuesAreEqual(this.defaultMapping.getKey(), mappingKey)) {
- this.defaultMapping.update(this.resourcePersistentAttribute.
- buildNullAnnotation(mappingDefinition.getAnnotationName()));
- }
- else {
- setDefaultMapping(buildDefaultMapping(mappingDefinition));
- }
- }
-
- // ***** specified mapping
- public JavaAttributeMapping getSpecifiedMapping() {
- return this.specifiedMapping;
- }
-
- /**
- * clients do not set the "specified" mapping;
- * @see #setSpecifiedMappingKey(String)
- */
- protected void setSpecifiedMapping(JavaAttributeMapping specifiedMapping) {
- JavaAttributeMapping old = this.specifiedMapping;
- this.specifiedMapping = specifiedMapping;
- this.firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, old, specifiedMapping);
- }
-
- protected JavaAttributeMapping buildSpecifiedMapping() {
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getSpecifiedJavaAttributeMappingDefinition(this);
- return buildSpecifiedMapping(mappingDefinition);
- }
-
- protected JavaAttributeMapping buildSpecifiedMapping(JavaAttributeMappingDefinition mappingDefinition) {
- Annotation annotation = this.resourcePersistentAttribute.
- getAnnotation(mappingDefinition.getAnnotationName());
- JavaAttributeMapping mapping = mappingDefinition.buildMapping(this, getJpaFactory());
- // specified mappings may be null
- if (mapping != null) {
- mapping.initialize(annotation);
- }
- return mapping;
- }
-
- /**
- * return the key of the currently specified mapping or null
- * if there is no specified mapping for the attribute
- */
- protected String getSpecifiedMappingKey() {
- return (this.specifiedMapping == null) ? null : this.specifiedMapping.getKey();
- }
-
- // TODO support morphing mappings, i.e. copying common settings over
- // to the new mapping; this can't be done in the same was as XmlAttributeMapping
- // since we don't know all the possible mapping types
- public void setSpecifiedMappingKey(String key) {
- if (Tools.valuesAreEqual(key, this.getSpecifiedMappingKey())) {
- return;
- }
- JavaAttributeMapping old = this.specifiedMapping;
- JavaAttributeMapping newMapping = this.buildMappingFromMappingKey(key);
-
- this.specifiedMapping = newMapping;
-
- String newAnnotation = (newMapping == null) ? null : newMapping.getAnnotationName();
- JavaAttributeMapping mapping = (newMapping == null) ? this.defaultMapping : newMapping;
- this.resourcePersistentAttribute.setPrimaryAnnotation(newAnnotation, mapping.getSupportingAnnotationNames());
- this.firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, old, newMapping);
- }
- protected static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- /**
- * return the annotation name of the currently specified mapping or null
- * if there is no specified mapping for the attribute
- */
- protected String getSpecifiedMappingAnnotationName() {
- return (this.specifiedMapping == null) ? null : this.specifiedMapping.getAnnotationName();
- }
-
- protected JavaAttributeMapping buildMappingFromMappingKey(String key) {
- JavaAttributeMappingDefinition mappingDefinition = getJpaPlatform().getSpecifiedJavaAttributeMappingDefinition(key);
- JavaAttributeMapping mapping = mappingDefinition.buildMapping(this, getJpaFactory());
- //no mapping.initialize(JavaResourcePersistentAttribute) call here
- //we do not yet have a mapping annotation so we can't call initialize
- return mapping;
- }
-
- protected Iterable<String> getSupportingAnnotationNames() {
- JavaAttributeMapping mapping = this.getMapping();
- return (mapping != null) ? mapping.getSupportingAnnotationNames() : EmptyIterable.<String>instance();
- }
-
- protected void updateSpecifiedMapping() {
- // There will always be a mapping definition, even if it is a "null" mapping provider ...
- JavaAttributeMappingDefinition mappingDefinition =
- getJpaPlatform().getSpecifiedJavaAttributeMappingDefinition(this);
- String mappingKey = mappingDefinition.getKey();
- if (this.specifiedMapping != null
- && this.specifiedMapping.getKey().equals(mappingKey)) {
- this.specifiedMapping.update(this.resourcePersistentAttribute.
- getAnnotation(mappingDefinition.getAnnotationName()));
- }
- else {
- setSpecifiedMapping(buildSpecifiedMapping(mappingDefinition));
- }
- }
-
-
- // ********** misc overrides **********
-
- @Override
- public PersistentType getParent() {
- return (PersistentType) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- this.validateAttribute(messages, reporter, astRoot);
-
- if (this.specifiedMapping != null) {
- this.specifiedMapping.validate(messages, reporter, astRoot);
- }
- else if (this.defaultMapping != null) {
- this.defaultMapping.validate(messages, reporter, astRoot);
- }
- }
-
- protected void validateAttribute(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.buildAttibuteValidator(astRoot).validate(messages, reporter);
- }
-
- protected abstract JptValidator buildAttibuteValidator(CompilationUnit astRoot);
-
- protected PersistentAttributeTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaPersistentAttributeTextRangeResolver(this, astRoot);
- }
-
-
- // ********** Java completion proposals **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return this.getMapping().javaCompletionProposals(pos, filter, astRoot);
- }
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainer().getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainer().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.getMapping());
- }
-
- public String getMetamodelTypeName() {
- String typeName = getTypeName();
- if (typeName == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- if (ClassName.isPrimitive(typeName)) {
- return ClassName.getWrapperClassName(typeName); // ???
- }
- return typeName;
- }
-
-
- // ********** JPA containers **********
-
- public JpaContainer getJpaContainer() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- return getJpaContainer(this.resourcePersistentAttribute.getTypeName());
- }
- /**
- * Return the JPA container corresponding to the specified type;
- * return a "null" JPA container if the specified type is not one of the
- * container types allowed by the JPA spec.
- */
- protected JpaContainer getJpaContainer(String typeName) {
- for (JpaContainer jpaContainer : JPA_CONTAINERS) {
- if (jpaContainer.getTypeName().equals(typeName)) {
- return jpaContainer;
- }
- }
- return JpaContainer.Null.instance();
- }
-
- protected static final Iterable<JpaContainer> JPA_CONTAINERS =
- new ArrayIterable<JpaContainer>(new JpaContainer[] {
- new CollectionJpaContainer(java.util.Collection.class, JPA2_0.COLLECTION_ATTRIBUTE),
- new CollectionJpaContainer(java.util.Set.class, JPA2_0.SET_ATTRIBUTE),
- new CollectionJpaContainer(java.util.List.class, JPA2_0.LIST_ATTRIBUTE),
- new MapJpaContainer(java.util.Map.class, JPA2_0.MAP_ATTRIBUTE)
- });
-
-
- /**
- * Abstract JPA container
- */
- protected abstract static class AbstractJpaContainer implements JpaContainer {
- protected final String typeName;
- protected final String metamodelContainerFieldTypeName;
-
- protected AbstractJpaContainer(Class<?> containerClass, String metamodelContainerFieldTypeName) {
- this(containerClass.getName(), metamodelContainerFieldTypeName);
- }
-
- protected AbstractJpaContainer(String typeName, String metamodelContainerFieldTypeName) {
- super();
- if ((typeName == null) || (metamodelContainerFieldTypeName == null)) {
- throw new NullPointerException();
- }
- this.typeName = typeName;
- this.metamodelContainerFieldTypeName = metamodelContainerFieldTypeName;
- }
-
- public String getTypeName() {
- return this.typeName;
- }
-
- public boolean isContainer() {
- return true;
- }
-
- public String getMetamodelContainerFieldTypeName() {
- return this.metamodelContainerFieldTypeName;
- }
-
- }
-
- /**
- * Collection JPA container
- */
- protected static class CollectionJpaContainer extends AbstractJpaContainer {
- protected CollectionJpaContainer(Class<?> collectionClass, String staticMetamodelTypeDeclarationTypeName) {
- super(collectionClass, staticMetamodelTypeDeclarationTypeName);
- }
-
- public String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 1) ?
- resourcePersistentAttribute.getTypeTypeArgumentName(0) :
- null;
- }
-
- public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return null;
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
- return null;
- }
-
- public boolean isMap() {
- return false;
- }
- }
-
- /**
- * Map JPA container
- */
- protected static class MapJpaContainer extends AbstractJpaContainer {
- protected MapJpaContainer(Class<?> mapClass, String staticMetamodelTypeDeclarationTypeName) {
- super(mapClass, staticMetamodelTypeDeclarationTypeName);
- }
-
- public String getMultiReferenceTargetTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 2) ?
- resourcePersistentAttribute.getTypeTypeArgumentName(1) :
- null;
- }
-
- public String getMultiReferenceMapKeyTypeName(JavaResourcePersistentAttribute resourcePersistentAttribute) {
- return (resourcePersistentAttribute.typeTypeArgumentNamesSize() == 2) ?
- resourcePersistentAttribute.getTypeTypeArgumentName(0) :
- null;
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName(CollectionMapping mapping) {
- return mapping.getMetamodelFieldMapKeyTypeName();
- }
-
- public boolean isMap() {
- return true;
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java
deleted file mode 100644
index c08fa0d69b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaPersistentType.java
+++ /dev/null
@@ -1,679 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.JpaFile;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaStructureNodes;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.internal.resource.java.source.SourceNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.utility.internal.iterators.ChainIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jst.j2ee.model.internal.validation.ValidationCancelledException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java persistent type:<ul>
- * <li>name
- * <li>access
- * <li>mapping
- * <li>attributes
- * <li>super persistent type
- * </ul>
- */
-public abstract class AbstractJavaPersistentType
- extends AbstractJavaJpaContextNode
- implements JavaPersistentType
-{
- protected JavaResourcePersistentType resourcePersistentType;
-
- protected String name;
-
- protected AccessType defaultAccess;
-
- protected AccessType specifiedAccess;
-
- protected JavaTypeMapping mapping;
-
- protected final Vector<JavaPersistentAttribute> attributes = new Vector<JavaPersistentAttribute>();
-
- protected PersistentType superPersistentType;
-
-
- protected AbstractJavaPersistentType(PersistentType.Owner parent, JavaResourcePersistentType jrpt) {
- super(parent);
- this.initialize(jrpt);
- }
-
- protected void initialize(JavaResourcePersistentType jrpt) {
- this.resourcePersistentType = jrpt;
- this.superPersistentType = this.buildSuperPersistentType();
- this.name = this.buildName();
- this.defaultAccess = buildDefaultAccess();
- this.specifiedAccess = buildSpecifiedAccess();
- this.mapping = buildMapping();
- this.initializeAttributes();
- }
-
-
- // ********** update **********
-
- public void update(JavaResourcePersistentType jrpt) {
- this.resourcePersistentType = jrpt;
- this.update();
- }
-
- public void update() {
- JpaFile jpaFile = this.getJpaFile();
- if (jpaFile != null) {
- // the JPA file can be null if the resource type is "external"
- jpaFile.addRootStructureNode(this.resourcePersistentType.getQualifiedName(), this);
- }
- this.setSuperPersistentType(this.buildSuperPersistentType());
- this.setName(this.buildName());
- this.updateAccess();
- this.updateMapping();
- this.updateAttributes();
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- this.mapping.postUpdate();
- for (PersistentAttribute attribute : this.getAttributes()) {
- attribute.postUpdate();
- }
- }
-
-
- // ********** AbstractJpaNode overrides **********
-
- @Override
- public PersistentType.Owner getParent() {
- return (PersistentType.Owner) super.getParent();
- }
-
- @Override
- public IResource getResource() {
- return this.resourcePersistentType.getFile();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return JavaStructureNodes.PERSISTENT_TYPE_ID;
- }
-
- // it would be nice if the we passed in an astRoot here, but then we
- // would need to pass it to the XML structure nodes too...
- public JpaStructureNode getStructureNode(int offset) {
- CompilationUnit astRoot = this.buildASTRoot();
-
- if (this.contains(offset, astRoot)) {
- for (JavaPersistentAttribute persistentAttribute : this.getAttributes()) {
- if (persistentAttribute.contains(offset, astRoot)) {
- return persistentAttribute;
- }
- }
- return this;
- }
- return null;
- }
-
- protected boolean contains(int offset, CompilationUnit astRoot) {
- TextRange fullTextRange = this.getFullTextRange(astRoot);
- // 'fullTextRange' will be null if the type no longer exists in the java;
- // the context model can be out of synch with the resource model
- // when a selection event occurs before the context model has a
- // chance to synch with the resource model via the update thread
- return (fullTextRange == null) ? false : fullTextRange.includes(offset);
- }
-
- protected TextRange getFullTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentType.getTextRange(astRoot);
- }
-
- public TextRange getSelectionTextRange() {
- return this.getSelectionTextRange(this.buildASTRoot());
- }
-
- protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentType.getNameTextRange(astRoot);
- }
-
- public void dispose() {
- JpaFile jpaFile = this.getJpaFile();
- if (jpaFile != null) {
- // the JPA file can be null if the .java file was deleted
- // or the resource type is "external"
- jpaFile.removeRootStructureNode(this.resourcePersistentType.getQualifiedName());
- }
- }
-
-
- // ********** PersistentType implementation **********
-
- public JavaResourcePersistentType getResourcePersistentType() {
- return this.resourcePersistentType;
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public String getShortName(){
- return this.name.substring(this.name.lastIndexOf('.') + 1);
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- protected String buildName() {
- return this.resourcePersistentType.getQualifiedName();
- }
-
-
- // ********** access **********
-
- public AccessType getAccess() {
- return (this.specifiedAccess != null) ? this.specifiedAccess : this.defaultAccess;
- }
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType defaultAccess) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = defaultAccess;
- this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, defaultAccess);
- }
-
- public AccessType getSpecifiedAccess() {
- return this.specifiedAccess;
- }
-
- /**
- * Check the access "specified" by the Java resource model:<ul>
- * <li>Check Java annotations first
- * <li>If <code>null</code>, check XML mapping specified access
- * <li>If still <code>null</code>, check {@link #superPersistentType} access
- * <li>If still <code>null</code>, check <code>entity-mappings</code>
- * specified access setting if the corresponding <code>persistent-type</code>
- * is listed in a mapping (<code>orm.xml</code>) file
- * <li>If still <code>null</code>, check the <code>persistence-unit</code>
- * default Access
- * <li>Default to <code>FIELD</code> if all else fails.
- * </ul>
- */
- protected AccessType buildDefaultAccess() {
- AccessType accessType = AccessType.fromJavaResourceModel(this.resourcePersistentType.getAccess());
- if (accessType != null) {
- return accessType;
- }
- accessType = this.getOwnerOverrideAccess();
- if (accessType != null) {
- return accessType;
- }
-
- if (this.superPersistentType != null) {
- accessType = this.superPersistentType.getAccess();
- if (accessType != null) {
- return accessType;
- }
- }
-
- accessType = this.getOwnerDefaultAccess();
- if (accessType != null) {
- return accessType;
- }
-
- // last ditch attempt to allow the user to annotate *something*
- return AccessType.FIELD;
- }
-
- protected void updateAccess() {
- this.setDefaultAccess(this.buildDefaultAccess());
- }
-
- /**
- * Build an access type based on annotations from the resource model.
- * (This is JPA platform-dependent.)
- */
- protected abstract AccessType buildSpecifiedAccess();
-
-
- // ********** mapping **********
-
- public JavaTypeMapping getMapping() {
- return this.mapping;
- }
-
- public String getMappingKey() {
- return this.mapping.getKey();
- }
-
- public void setMappingKey(String key) {
- if (this.valuesAreEqual(key, this.mapping.getKey())) {
- return;
- }
- JavaTypeMapping oldMapping = this.mapping;
- JavaTypeMapping newMapping = this.buildMappingFromMappingKey(key);
-
- this.mapping = newMapping;
- this.resourcePersistentType.setPrimaryAnnotation(newMapping.getAnnotationName(), newMapping.getSupportingAnnotationNames());
- this.firePropertyChanged(MAPPING_PROPERTY, oldMapping, newMapping);
- }
-
- protected void setMapping(JavaTypeMapping mapping) {
- JavaTypeMapping old = this.mapping;
- this.mapping = mapping;
- this.firePropertyChanged(MAPPING_PROPERTY, old, mapping);
- }
-
- protected JavaTypeMapping buildMapping() {
- JavaTypeMappingDefinition mappingDefinition = this.getJpaPlatform().getJavaTypeMappingDefinition(this);
- return this.buildMapping(mappingDefinition);
- }
-
- protected JavaTypeMapping buildMapping(JavaTypeMappingDefinition mappingDefinition) {
- JavaTypeMapping jtMapping = mappingDefinition.buildMapping(this, this.getJpaFactory());
- // mapping may be null
- if (jtMapping != null) {
- jtMapping.initialize(this.resourcePersistentType);
- }
- return jtMapping;
- }
-
- protected JavaTypeMapping buildMappingFromMappingKey(String key) {
- JavaTypeMappingDefinition mappingDefinition = this.getJpaPlatform().getJavaTypeMappingDefinition(key);
- JavaTypeMapping jtMapping = mappingDefinition.buildMapping(this, this.getJpaFactory());
- //no mapping.initialize(JavaResourcePersistentType) call here
- //we do not yet have a mapping annotation so we can't call initialize
- return jtMapping;
- }
-
- protected void updateMapping() {
- // There will always be a mapping definition, even if it is a "null" mapping definition ...
- JavaTypeMappingDefinition mappingDefinition = this.getJpaPlatform().getJavaTypeMappingDefinition(this);
- if ((this.mapping != null) && this.valuesAreEqual(this.mapping.getKey(), mappingDefinition.getKey())) {
- this.mapping.update(this.resourcePersistentType);
- } else {
- this.setMapping(this.buildMapping(mappingDefinition));
- }
- }
-
-
- // ********** attributes **********
-
- public ListIterator<JavaPersistentAttribute> attributes() {
- return new CloneListIterator<JavaPersistentAttribute>(this.attributes);
- }
-
- protected Iterable<JavaPersistentAttribute> getAttributes() {
- return new LiveCloneIterable<JavaPersistentAttribute>(this.attributes);
- }
-
- public int attributesSize() {
- return this.attributes.size();
- }
-
- private void addAttribute(int index, JavaPersistentAttribute attribute) {
- this.addItemToList(index, attribute, this.attributes, ATTRIBUTES_LIST);
- }
-
- private void removeAttribute(JavaPersistentAttribute attribute) {
- this.removeItemFromList(attribute, this.attributes, ATTRIBUTES_LIST);
- }
-
- private void moveAttribute(int index, JavaPersistentAttribute attribute) {
- this.moveItemInList(index, this.attributes.indexOf(attribute), this.attributes, ATTRIBUTES_LIST);
- }
-
- public Iterator<String> attributeNames() {
- return this.attributeNames(this.attributes());
- }
-
- protected Iterator<String> attributeNames(Iterator<? extends PersistentAttribute> attrs) {
- return new TransformationIterator<PersistentAttribute, String>(attrs) {
- @Override
- protected String transform(PersistentAttribute attribute) {
- return attribute.getName();
- }
- };
- }
-
- public JavaPersistentAttribute getAttributeNamed(String attributeName) {
- Iterator<JavaPersistentAttribute> stream = this.attributesNamed(attributeName);
- return stream.hasNext() ? stream.next() : null;
- }
-
- public PersistentAttribute resolveAttribute(String attributeName) {
- Iterator<JavaPersistentAttribute> stream = this.attributesNamed(attributeName);
- if (stream.hasNext()) {
- JavaPersistentAttribute attribute = stream.next();
- return stream.hasNext() ? null /*more than one*/: attribute;
- }
- return (this.superPersistentType == null) ? null : this.superPersistentType.resolveAttribute(attributeName);
- }
-
- protected Iterator<JavaPersistentAttribute> attributesNamed(final String attributeName) {
- return new FilteringIterator<JavaPersistentAttribute>(this.attributes()) {
- @Override
- protected boolean accept(JavaPersistentAttribute o) {
- return attributeName.equals(o.getName());
- }
- };
- }
-
- public Iterator<PersistentAttribute> allAttributes() {
- return new CompositeIterator<PersistentAttribute>(
- new TransformationIterator<PersistentType, Iterator<PersistentAttribute>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<PersistentAttribute> transform(PersistentType pt) {
- return pt.attributes();
- }
- }
- );
- }
-
- public Iterator<String> allAttributeNames() {
- return this.attributeNames(this.allAttributes());
- }
-
- protected void initializeAttributes() {
- for (Iterator<JavaResourcePersistentAttribute> stream = this.resourceAttributes(); stream.hasNext(); ) {
- this.attributes.add(this.createAttribute(stream.next()));
- }
- }
-
- protected Iterator<JavaResourcePersistentAttribute> resourceAttributes() {
- return (this.getAccess() == AccessType.PROPERTY) ?
- this.resourcePersistentType.persistableProperties() :
- this.resourcePersistentType.persistableFields();
- }
-
- protected void updateAttributes() {
- HashBag<JavaPersistentAttribute> contextAttributesToRemove = CollectionTools.bag(this.attributes(), this.attributesSize());
- ArrayList<JavaPersistentAttribute> contextAttributesToUpdate = new ArrayList<JavaPersistentAttribute>(this.attributesSize());
- int resourceIndex = 0;
-
- for (Iterator<JavaResourcePersistentAttribute> resourceAttributes = this.resourceAttributes(); resourceAttributes.hasNext(); ) {
- JavaResourcePersistentAttribute resourceAttribute = resourceAttributes.next();
- boolean match = false;
- for (Iterator<JavaPersistentAttribute> contextAttributes = contextAttributesToRemove.iterator(); contextAttributes.hasNext(); ) {
- JavaPersistentAttribute contextAttribute = contextAttributes.next();
- if (contextAttribute.getResourcePersistentAttribute() == resourceAttribute) {
- this.moveAttribute(resourceIndex, contextAttribute);
- contextAttributes.remove();
- contextAttributesToUpdate.add(contextAttribute);
- match = true;
- break;
- }
- }
- if ( ! match) {
- this.addAttribute(resourceIndex, this.createAttribute(resourceAttribute));
- }
- resourceIndex++;
- }
- for (JavaPersistentAttribute contextAttribute : contextAttributesToRemove) {
- this.removeAttribute(contextAttribute);
- }
- // handle adding and removing attributes first, update the
- // remaining attributes last; this reduces the churn during "update"
- for (JavaPersistentAttribute contextAttribute : contextAttributesToUpdate) {
- contextAttribute.update();
- }
- }
-
- protected JavaPersistentAttribute createAttribute(JavaResourcePersistentAttribute jrpa) {
- return this.getJpaFactory().buildJavaPersistentAttribute(this, jrpa);
- }
-
- public boolean hasAnyAnnotatedAttributes() {
- return this.resourcePersistentType.hasAnyAnnotatedAttributes();
- }
-
-
- // ********** super persistent type **********
-
- public PersistentType getSuperPersistentType() {
- return this.superPersistentType;
- }
-
- protected void setSuperPersistentType(PersistentType superPersistentType) {
- PersistentType old = this.superPersistentType;
- this.superPersistentType = superPersistentType;
- this.firePropertyChanged(SUPER_PERSISTENT_TYPE_PROPERTY, old, superPersistentType);
- }
-
- protected PersistentType buildSuperPersistentType() {
- HashSet<JavaResourcePersistentType> visited = new HashSet<JavaResourcePersistentType>();
- visited.add(this.resourcePersistentType);
- PersistentType spt = this.getSuperPersistentType(this.resourcePersistentType.getSuperclassQualifiedName(), visited);
- if (spt == null) {
- return null;
- }
- if (CollectionTools.contains(spt.inheritanceHierarchy(), this)) {
- return null; // short-circuit in this case, we have circular inheritance
- }
- return spt.isMapped() ? spt : spt.getSuperPersistentType();
- }
-
- /**
- * The JPA spec allows non-persistent types in a persistent type's
- * inheritance hierarchy. We check for a persistent type with the
- * specified name in the persistence unit. If it is not found we use
- * resource persistent type and look for *its* super type.
- *
- * The 'visited' collection is used to detect a cycle in the *resource* type
- * inheritance hierarchy and prevent the resulting stack overflow.
- * Any cycles in the *context* type inheritance hierarchy are handled in
- * #buildSuperPersistentType().
- */
- protected PersistentType getSuperPersistentType(String typeName, Collection<JavaResourcePersistentType> visited) {
- if (typeName == null) {
- return null;
- }
- JavaResourcePersistentType resourceType = this.getJpaProject().getJavaResourcePersistentType(typeName);
- if ((resourceType == null) || visited.contains(resourceType)) {
- return null;
- }
- visited.add(resourceType);
- PersistentType spt = this.getPersistentType(typeName);
- return (spt != null) ? spt : this.getSuperPersistentType(resourceType.getSuperclassQualifiedName(), visited); // recurse
- }
-
- protected PersistentType getPersistentType(String typeName) {
- return this.getPersistenceUnit().getPersistentType(typeName);
- }
-
-
- // ********** inheritance **********
-
- public Iterator<PersistentType> inheritanceHierarchy() {
- return this.inheritanceHierarchyOf(this);
- }
-
- public Iterator<PersistentType> ancestors() {
- return this.inheritanceHierarchyOf(this.superPersistentType);
- }
-
- protected Iterator<PersistentType> inheritanceHierarchyOf(PersistentType start) {
- // using a chain iterator to traverse up the inheritance tree
- return new ChainIterator<PersistentType>(start) {
- @Override
- protected PersistentType nextLink(PersistentType persistentType) {
- return persistentType.getSuperPersistentType();
- }
- };
- }
-
-
- // ********** code completion **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- Iterator<String> values = this.mapping.javaCompletionProposals(pos, filter, astRoot);
- if (values != null) {
- return values;
- }
- for (JavaPersistentAttribute attribute : this.getAttributes()) {
- values = attribute.javaCompletionProposals(pos, filter, astRoot);
- if (values != null) {
- return values;
- }
- }
- return EmptyIterator.instance();
- }
-
-
- // ********** validation **********
-
- public void validate(List<IMessage> messages, IReporter reporter) {
- if (reporter.isCancelled()) {
- throw new ValidationCancelledException();
- }
- // TODO temporary hack since we don't know yet where to put
- // any messages for types in another project (e.g. referenced by
- // persistence.xml)
- IFile file = this.resourcePersistentType.getFile();
- // 'file' will be null if the type is "external" and binary;
- // the file will be in a different project if the type is "external" and source;
- // the type will be binary if it is in a JAR in the current project
- if ((file != null) && file.getProject().equals(this.getJpaProject().getProject()) &&
- (this.resourcePersistentType instanceof SourceNode)) {
- // build the AST root here to pass down
- this.validate(messages, reporter, this.buildASTRoot());
- }
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateMapping(messages, reporter, astRoot);
- this.validateAttributes(messages, reporter, astRoot);
- }
-
- protected void validateMapping(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- try {
- this.mapping.validate(messages, reporter, astRoot);
- } catch(Throwable t) {
- JptCorePlugin.log(t);
- }
- }
-
- protected void validateAttributes(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- for (JavaPersistentAttribute attribute : this.getAttributes()) {
- this.validateAttribute(attribute, reporter, messages, astRoot);
- }
- }
-
- protected void validateAttribute(JavaPersistentAttribute attribute, IReporter reporter, List<IMessage> messages, CompilationUnit astRoot) {
- try {
- attribute.validate(messages, reporter, astRoot);
- } catch(Throwable t) {
- JptCorePlugin.log(t);
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
-
- // ********** misc **********
-
- public boolean isFor(String typeName) {
- String className = this.getName();
- return className != null && className.equals(typeName);
- }
-
- public boolean isIn(IPackageFragment packageFragment) {
- String packageName = this.getPackageName();
- if (packageName != null && packageName.equals(packageFragment.getElementName())) {
- return true;
- }
- return false;
- }
-
- protected String getPackageName() {
- return getResourcePersistentType().getPackageName();
- }
-
- public boolean isMapped() {
- return this.mapping.isMapped();
- }
-
- public AccessType getOwnerOverrideAccess() {
- return this.getParent().getOverridePersistentTypeAccess();
- }
-
- public AccessType getOwnerDefaultAccess() {
- return this.getParent().getDefaultPersistentTypeAccess();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
- protected CompilationUnit buildASTRoot() {
- return this.resourcePersistentType.getJavaResourceCompilationUnit().buildASTRoot();
- }
-
- protected JpaFile getJpaFile() {
- return this.getJpaFile(this.resourcePersistentType.getFile());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java
deleted file mode 100644
index 0f3c687b3e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaQuery.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Query;
-import org.eclipse.jpt.core.context.QueryHint;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaQuery;
-import org.eclipse.jpt.core.context.java.JavaQueryHint;
-import org.eclipse.jpt.core.resource.java.BaseNamedQueryAnnotation;
-import org.eclipse.jpt.core.resource.java.QueryHintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-
-
-public abstract class AbstractJavaQuery extends AbstractJavaJpaContextNode
- implements JavaQuery
-{
- protected String name;
-
- protected String query;
-
- protected final Vector<JavaQueryHint> hints;
-
- protected BaseNamedQueryAnnotation queryAnnotation;
-
- protected AbstractJavaQuery(JavaJpaContextNode parent) {
- super(parent);
- this.hints = new Vector<JavaQueryHint>();
- }
-
- protected BaseNamedQueryAnnotation getResourceQuery() {
- return this.queryAnnotation;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String oldName = this.name;
- this.name = newName;
- this.queryAnnotation.setName(newName);
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- protected void setName_(String newName) {
- String oldName = this.name;
- this.name = newName;
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String newQuery) {
- String oldQuery = this.query;
- this.query = newQuery;
- this.queryAnnotation.setQuery(newQuery);
- firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery);
- }
-
- protected void setQuery_(String newQuery) {
- String oldQuery = this.query;
- this.query = newQuery;
- firePropertyChanged(QUERY_PROPERTY, oldQuery, newQuery);
- }
-
- public ListIterator<JavaQueryHint> hints() {
- return new CloneListIterator<JavaQueryHint>(this.hints);
- }
-
- public int hintsSize() {
- return this.hints.size();
- }
-
- public JavaQueryHint addHint(int index) {
- JavaQueryHint hint = getJpaFactory().buildJavaQueryHint(this);
- this.hints.add(index, hint);
- this.getResourceQuery().addHint(index);
- this.fireItemAdded(HINTS_LIST, index, hint);
- return hint;
- }
-
- protected void addHint(int index, JavaQueryHint hint) {
- addItemToList(index, hint, this.hints, HINTS_LIST);
- }
-
- protected void addHint(JavaQueryHint hint) {
- addHint(this.hints.size(), hint);
- }
-
- public void removeHint(QueryHint queryHint) {
- removeHint(this.hints.indexOf(queryHint));
- }
-
- public void removeHint(int index) {
- JavaQueryHint removedHint = this.hints.remove(index);
- this.getResourceQuery().removeHint(index);
- fireItemRemoved(HINTS_LIST, index, removedHint);
- }
-
- protected void removeHint_(JavaQueryHint hint) {
- removeItemFromList(hint, this.hints, HINTS_LIST);
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.hints, targetIndex, sourceIndex);
- this.getResourceQuery().moveHint(targetIndex, sourceIndex);
- fireItemMoved(HINTS_LIST, targetIndex, sourceIndex);
- }
-
- protected void initialize(BaseNamedQueryAnnotation annotation) {
- this.queryAnnotation = annotation;
- this.name = annotation.getName();
- this.query = annotation.getQuery();
- this.initializeQueryHints();
- }
-
- protected void update(BaseNamedQueryAnnotation annotation) {
- this.queryAnnotation = annotation;
- this.setName_(annotation.getName());
- this.setQuery_(annotation.getQuery());
- this.updateQueryHints();
- getPersistenceUnit().addQuery(this);
- }
-
- protected void initializeQueryHints() {
- for (ListIterator<QueryHintAnnotation> resourceHints = this.queryAnnotation.hints(); resourceHints.hasNext(); ) {
- this.hints.add(createQueryHint(resourceHints.next()));
- }
- }
-
- protected void updateQueryHints() {
- ListIterator<JavaQueryHint> contextHints = hints();
- ListIterator<QueryHintAnnotation> resourceHints = this.queryAnnotation.hints();
-
- while (contextHints.hasNext()) {
- JavaQueryHint hint = contextHints.next();
- if (resourceHints.hasNext()) {
- hint.update(resourceHints.next());
- }
- else {
- removeHint_(hint);
- }
- }
-
- while (resourceHints.hasNext()) {
- addHint(createQueryHint(resourceHints.next()));
- }
- }
-
- protected JavaQueryHint createQueryHint(QueryHintAnnotation resourceQueryHint) {
- JavaQueryHint queryHint = getJpaFactory().buildJavaQueryHint(this);
- queryHint.initialize(resourceQueryHint);
- return queryHint;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.queryAnnotation.getTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.queryAnnotation.getNameTextRange(astRoot);
- }
-
- public boolean overrides(Query other) {
- // java is at the base of the tree
- return false;
- }
-
- public boolean duplicates(Query other) {
- return (this != other)
- && ! StringTools.stringIsEmpty(this.name)
- && this.name.equals(other.getName())
- && ! this.overrides(other)
- && ! other.overrides(this);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java
deleted file mode 100644
index d0819044df..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipMapping.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJavaCascade;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCascade2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java relationship mapping
- */
-public abstract class AbstractJavaRelationshipMapping<T extends RelationshipMapping2_0Annotation>
- extends AbstractJavaAttributeMapping<T>
- implements JavaRelationshipMapping2_0
-{
- protected String specifiedTargetEntity;
- protected String defaultTargetEntity;
- protected String fullyQualifiedTargetEntity;
- protected PersistentType resolvedTargetType;
- protected Entity resolvedTargetEntity;
-
- protected final JavaRelationshipReference relationshipReference;
-
- protected final JavaCascade2_0 cascade;
-
- protected FetchType specifiedFetch;
-
-
- protected AbstractJavaRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.relationshipReference = buildRelationshipReference();
- this.cascade = buildCascade();
- }
-
-
- @Override
- protected void initialize() {
- super.initialize();
- this.relationshipReference.initialize();
- this.specifiedFetch = this.getResourceFetch();
- this.cascade.initialize();
- this.defaultTargetEntity = this.buildDefaultTargetEntity();
- this.specifiedTargetEntity = this.getResourceTargetEntity();
- this.fullyQualifiedTargetEntity = this.buildFullyQualifiedTargetEntity();
- this.resolvedTargetType = this.resolveTargetType();
- this.resolvedTargetEntity = this.resolveTargetEntity();
- }
-
- @Override
- protected void update() {
- super.update();
- this.relationshipReference.update();
- this.setSpecifiedFetch_(this.getResourceFetch());
- this.cascade.update();
- this.setDefaultTargetEntity(this.buildDefaultTargetEntity());
- this.setSpecifiedTargetEntity_(this.getResourceTargetEntity());
- this.setFullyQualifiedTargetEntity(this.buildFullyQualifiedTargetEntity());
- this.resolvedTargetType = this.resolveTargetType();
- this.setResolvedTargetEntity(this.resolveTargetEntity());
- }
-
-
- // ********** target entity **********
-
- public String getTargetEntity() {
- return (this.specifiedTargetEntity != null) ? this.specifiedTargetEntity : this.defaultTargetEntity;
- }
-
- public String getSpecifiedTargetEntity() {
- return this.specifiedTargetEntity;
- }
-
- public void setSpecifiedTargetEntity(String targetEntity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = targetEntity;
- this.mappingAnnotation.setTargetEntity(targetEntity);
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected void setSpecifiedTargetEntity_(String targetEntity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = targetEntity;
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected String getResourceTargetEntity() {
- return this.mappingAnnotation.getTargetEntity();
- }
-
- public String getDefaultTargetEntity() {
- return this.defaultTargetEntity;
- }
-
- protected void setDefaultTargetEntity(String targetEntity) {
- String old = this.defaultTargetEntity;
- this.defaultTargetEntity = targetEntity;
- this.firePropertyChanged(DEFAULT_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected abstract String buildDefaultTargetEntity();
-
- public String getFullyQualifiedTargetEntity() {
- return this.fullyQualifiedTargetEntity;
- }
-
- protected void setFullyQualifiedTargetEntity(String targetEntity) {
- String old = this.fullyQualifiedTargetEntity;
- this.fullyQualifiedTargetEntity = targetEntity;
- this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected String buildFullyQualifiedTargetEntity() {
- return (this.specifiedTargetEntity == null) ?
- this.defaultTargetEntity :
- this.mappingAnnotation.getFullyQualifiedTargetEntityClassName();
- }
-
- public PersistentType getResolvedTargetType() {
- return this.resolvedTargetType;
- }
-
- protected PersistentType resolveTargetType() {
- return (this.fullyQualifiedTargetEntity == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedTargetEntity);
- }
-
- public Entity getResolvedTargetEntity() {
- return this.resolvedTargetEntity;
- }
-
- protected void setResolvedTargetEntity(Entity entity) {
- Entity old = this.resolvedTargetEntity;
- this.resolvedTargetEntity = entity;
- this.firePropertyChanged(RESOLVED_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- protected Entity resolveTargetEntity() {
- if (this.resolvedTargetType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedTargetType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public Iterator<String> allTargetEntityAttributeNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEntityAttributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allMappingNames();
- }
- });
- }
-
- protected Iterator<AttributeMapping> allTargetEntityAttributeMappings() {
- return (this.resolvedTargetEntity != null) ?
- this.resolvedTargetEntity.allAttributeMappings() :
- EmptyIterator.<AttributeMapping> instance();
- }
-
- protected String getTargetEntityIdAttributeName() {
- PersistentAttribute attribute = this.getTargetEntityIdAttribute();
- return (attribute == null) ? null : attribute.getName();
- }
-
- protected PersistentAttribute getTargetEntityIdAttribute() {
- return (this.resolvedTargetEntity == null) ? null : this.resolvedTargetEntity.getIdAttribute();
- }
-
- public char getTargetEntityEnclosingTypeSeparator() {
- return '.';
- }
-
-
- // ********** relationship reference **********
-
- public JavaRelationshipReference getRelationshipReference() {
- return this.relationshipReference;
- }
-
- protected abstract JavaRelationshipReference buildRelationshipReference();
-
- @Override
- public boolean isRelationshipOwner() {
- return this.relationshipReference.isRelationshipOwner();
- }
-
- public RelationshipMapping getRelationshipOwner() {
- Entity targetEntity = this.getResolvedTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- for (PersistentAttribute each :
- CollectionTools.iterable(
- targetEntity.getPersistentType().allAttributes())) {
- if (this.isOwnedBy(each.getMapping())) {
- return (RelationshipMapping) each.getMapping();
- }
- }
- return null;
- }
-
- @Override
- public boolean isOwnedBy(AttributeMapping mapping) {
- if (mapping.isRelationshipOwner()) {
- return this.relationshipReference.isOwnedBy((RelationshipMapping) mapping);
- }
- return false;
- }
-
- @Override
- public boolean isOverridableAssociationMapping() {
- return this.relationshipReference.isOverridableAssociation();
- }
-
-
- // ********** cascade **********
-
- protected JavaCascade2_0 buildCascade() {
- return new GenericJavaCascade(this);
- }
-
- public JavaCascade2_0 getCascade() {
- return this.cascade;
- }
-
-
- // ********** fetch **********
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.getDefaultFetch();
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.mappingAnnotation.setFetch(FetchType.toJavaResourceModel(fetch));
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType getResourceFetch() {
- return FetchType.fromJavaResourceModel(this.mappingAnnotation.getFetch());
- }
-
-
- // ********** Java completion proposals **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return this.relationshipReference.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateTargetEntity(messages, astRoot);
- this.relationshipReference.validate(messages, reporter, astRoot);
- }
-
- protected void validateTargetEntity(List<IMessage> messages, CompilationUnit astRoot) {
- if (this.getTargetEntity() == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
- else if (this.resolvedTargetEntity == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY,
- new String[] {this.getTargetEntity(), this.getName()},
- this,
- this.getTargetEntityTextRange(astRoot)
- )
- );
- }
- }
-
- protected TextRange getTargetEntityTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.mappingAnnotation.getTargetEntityTextRange(astRoot), astRoot);
- }
-
- protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) {
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
-
- // ********** metamodel **********
-
- @Override
- public String getMetamodelTypeName() {
- return (this.fullyQualifiedTargetEntity != null) ? this.fullyQualifiedTargetEntity : MetamodelField.DEFAULT_TYPE_NAME;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java
deleted file mode 100644
index 1b5ccb157d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaRelationshipReference.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaRelationshipReference;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public abstract class AbstractJavaRelationshipReference
- extends AbstractJavaJpaContextNode
- implements JavaRelationshipReference
-{
- // cache the strategy for property change notification
- protected JoiningStrategy cachedPredominantJoiningStrategy;
-
-
- public AbstractJavaRelationshipReference(JavaRelationshipMapping parent) {
- super(parent);
- }
-
-
- public JavaRelationshipMapping getRelationshipMapping() {
- return (JavaRelationshipMapping) getParent();
- }
-
- public TypeMapping getTypeMapping() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isOverridableAssociation() {
- return getPredominantJoiningStrategy().isOverridableAssociation();
- }
-
- public boolean isParentVirtual() {
- return getRelationshipMapping().getPersistentAttribute().isVirtual();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-
- // **************** predominant joining strategy ***************************
-
- public JoiningStrategy getPredominantJoiningStrategy() {
- return this.cachedPredominantJoiningStrategy;
- }
-
- protected void setPredominantJoiningStrategy() {
- setPredominantJoiningStrategy(calculatePredominantJoiningStrategy());
- }
-
- protected void setPredominantJoiningStrategy(JoiningStrategy newJoiningStrategy) {
- JoiningStrategy oldJoiningStrategy = this.cachedPredominantJoiningStrategy;
- this.cachedPredominantJoiningStrategy = newJoiningStrategy;
- firePropertyChanged(PREDOMINANT_JOINING_STRATEGY_PROPERTY, oldJoiningStrategy, newJoiningStrategy);
- }
-
-
- // **************** resource -> context ************************************
-
- public void initialize() {
- initializeJoiningStrategies();
- this.cachedPredominantJoiningStrategy = calculatePredominantJoiningStrategy();
- }
-
- protected abstract void initializeJoiningStrategies();
-
- public void update() {
- updateJoiningStrategies();
- setPredominantJoiningStrategy();
- }
-
- protected abstract void updateJoiningStrategies();
-
- protected abstract JoiningStrategy calculatePredominantJoiningStrategy();
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return getRelationshipMapping().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java
deleted file mode 100644
index 02d7926656..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSequenceGenerator.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.SequenceGenerator;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaSequenceGenerator;
-import org.eclipse.jpt.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-
-/**
- *
- */
-public abstract class AbstractJavaSequenceGenerator extends AbstractJavaGenerator
- implements JavaSequenceGenerator
-{
- protected String specifiedSequenceName;
-
-
- protected AbstractJavaSequenceGenerator(JavaJpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** sequence name **********
-
- public String getSequenceName() {
- return (this.specifiedSequenceName != null) ? this.specifiedSequenceName : this.getDefaultSequenceName();
- }
-
- public String getSpecifiedSequenceName() {
- return this.specifiedSequenceName;
- }
-
- public void setSpecifiedSequenceName(String specifiedSequenceName) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = specifiedSequenceName;
- this.getResourceGenerator().setSequenceName(specifiedSequenceName);
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, specifiedSequenceName);
- }
-
- protected void setSpecifiedSequenceName_(String specifiedSequenceName) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = specifiedSequenceName;
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, specifiedSequenceName);
- }
-
- public String getDefaultSequenceName() {
- return null;
- }
-
-
- // ********** resource => context **********
-
- public void initialize(SequenceGeneratorAnnotation resourceSequenceGenerator) {
- super.initialize(resourceSequenceGenerator);
- this.specifiedSequenceName = resourceSequenceGenerator.getSequenceName();
- }
-
- public void update(SequenceGeneratorAnnotation resourceSequenceGenerator) {
- super.update(resourceSequenceGenerator);
- this.setSpecifiedSequenceName_(resourceSequenceGenerator.getSequenceName());
- }
-
-
- // ********** Java completion proposals **********
-
- /**
- * called if the database is connected:
- * sequenceName
- */
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.sequenceNameTouches(pos, astRoot)) {
- return this.getJavaCandidateSequences(filter).iterator();
- }
- return null;
- }
-
- protected boolean sequenceNameTouches(int pos, CompilationUnit astRoot) {
- return this.getResourceGenerator().sequenceNameTouches(pos, astRoot);
- }
-
- protected Iterable<String> getJavaCandidateSequences(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSequences(filter));
- }
-
- protected Iterable<String> getCandidateSequences(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateSequences(), filter);
- }
-
- protected Iterable<String> getCandidateSequences() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema != null) ? dbSchema.getSortedSequenceIdentifiers() : EmptyIterable.<String> instance();
- }
-
-
- // ********** misc **********
-
- public int getDefaultInitialValue() {
- return SequenceGenerator.DEFAULT_INITIAL_VALUE;
- }
-
- @Override
- protected SequenceGeneratorAnnotation getResourceGenerator() {
- return (SequenceGeneratorAnnotation) super.getResourceGenerator();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java
deleted file mode 100644
index 375f50d6e5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.Nullable;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa2.context.java.NullJavaDerivedIdentity2_0;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaDerivedIdentity2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaSingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.RelationshipMapping2_0Annotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java single relationship (1:1, m:1) mapping
- */
-public abstract class AbstractJavaSingleRelationshipMapping<T extends RelationshipMapping2_0Annotation>
- extends AbstractJavaRelationshipMapping<T>
- implements JavaSingleRelationshipMapping2_0
-{
- protected Boolean specifiedOptional;
-
- protected final JavaDerivedIdentity2_0 derivedIdentity;
-
-
- protected AbstractJavaSingleRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.derivedIdentity = buildDerivedIdentity();
- }
-
- @Override
- protected void initialize() {
- super.initialize();
- this.specifiedOptional = this.getResourceOptional();
- this.derivedIdentity.initialize();
- }
-
- @Override
- protected void update() {
- super.update();
- this.setSpecifiedOptional_(this.getResourceOptional());
- this.derivedIdentity.update();
- }
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.JOIN_COLUMN);
- names.add(JPA.JOIN_COLUMNS);
- names.add(JPA.JOIN_TABLE);
- if (this.isJpa2_0Compatible()) {
- names.add(JPA.ID);
- names.add(JPA2_0.MAPS_ID);
- }
- }
-
-
- // ********** optional **********
-
- public boolean isOptional() {
- return (this.specifiedOptional != null) ? this.specifiedOptional.booleanValue() : this.isDefaultOptional();
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.setResourceOptional(optional);
- this.firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- public boolean isDefaultOptional() {
- return Nullable.DEFAULT_OPTIONAL;
- }
-
- protected abstract Boolean getResourceOptional();
-
- protected abstract void setResourceOptional(Boolean newOptional);
-
-
- // ********** 2.0 derived identity **********
-
- protected JavaDerivedIdentity2_0 buildDerivedIdentity() {
- return this.isJpa2_0Compatible() ?
- ((JpaFactory2_0) this.getJpaFactory()).buildJavaDerivedIdentity(this) :
- new NullJavaDerivedIdentity2_0(this);
- }
-
- public JavaDerivedIdentity2_0 getDerivedIdentity() {
- return this.derivedIdentity;
- }
-
-
- // ********** AbstractJavaRelationshipMapping implementation **********
-
- @Override
- protected String buildDefaultTargetEntity() {
- return this.getPersistentAttribute().getSingleReferenceTargetTypeName();
- }
-
-
- // ********** Fetchable implementation **********
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.derivedIdentity.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.derivedIdentity.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
deleted file mode 100644
index b99e9f5fc1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTable.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.java.JavaBaseTable;
-import org.eclipse.jpt.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.resource.java.BaseTableAnnotation;
-import org.eclipse.jpt.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Database;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java table
- */
-public abstract class AbstractJavaTable
- extends AbstractJavaJpaContextNode
- implements JavaBaseTable, UniqueConstraint.Owner
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected final Vector<JavaUniqueConstraint> uniqueConstraints = new Vector<JavaUniqueConstraint>();
-
- protected final Owner owner;
-
- // ********** constructor **********
-
- protected AbstractJavaTable(JavaJpaContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- protected Owner getOwner() {
- return this.owner;
- }
-
- // ********** abstract methods **********
-
- /**
- * Return the Java table annotation. Do not return null if the Java
- * annotation does not exist; return a null table annotation instead.
- */
- protected abstract BaseTableAnnotation getAnnotation();
-
- /**
- * Return the name of the Java annotation.
- */
- protected abstract String getAnnotationName();
-
- protected abstract String buildDefaultName();
-
- protected abstract String buildDefaultSchema();
-
- protected abstract String buildDefaultCatalog();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.getAnnotation().setName(name);
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String name) {
- String old = this.defaultName;
- this.defaultName = name;
- this.firePropertyChanged(DEFAULT_NAME_PROPERTY, old, name);
- }
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.getAnnotation().setSchema(schema);
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedSchema_(String newSpecifiedSchema) {
- String oldSpecifiedSchema = this.specifiedSchema;
- this.specifiedSchema = newSpecifiedSchema;
- firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, oldSpecifiedSchema, newSpecifiedSchema);
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.getAnnotation().setCatalog(catalog);
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- /**
- * internal setter used only for updating from the resource model.
- * There were problems with InvalidThreadAccess exceptions in the UI
- * when you set a value from the UI and the annotation doesn't exist yet.
- * Adding the annotation causes an update to occur and then the exception.
- */
- protected void setSpecifiedCatalog_(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
-
- // ********** unique constraints **********
-
- public @SuppressWarnings("unchecked") ListIterator<JavaUniqueConstraint> uniqueConstraints() {
- return new CloneListIterator<JavaUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public JavaUniqueConstraint addUniqueConstraint(int index) {
- JavaUniqueConstraint uniqueConstraint = getJpaFactory().buildJavaUniqueConstraint(this, this);
- this.uniqueConstraints.add(index, uniqueConstraint);
- UniqueConstraintAnnotation uniqueConstraintAnnotation = this.getAnnotation().addUniqueConstraint(index);
- uniqueConstraint.initialize(uniqueConstraintAnnotation);
- fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, uniqueConstraint);
- return uniqueConstraint;
- }
-
- public void removeUniqueConstraint(UniqueConstraint uniqueConstraint) {
- this.removeUniqueConstraint(this.uniqueConstraints.indexOf(uniqueConstraint));
- }
-
- public void removeUniqueConstraint(int index) {
- JavaUniqueConstraint removedUniqueConstraint = this.uniqueConstraints.remove(index);
- this.getAnnotation().removeUniqueConstraint(index);
- fireItemRemoved(UNIQUE_CONSTRAINTS_LIST, index, removedUniqueConstraint);
- }
-
- public void moveUniqueConstraint(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex);
- this.getAnnotation().moveUniqueConstraint(targetIndex, sourceIndex);
- fireItemMoved(UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex);
- }
-
- protected void addUniqueConstraint(int index, JavaUniqueConstraint uniqueConstraint) {
- addItemToList(index, uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected void addUniqueConstraint(JavaUniqueConstraint uniqueConstraint) {
- this.addUniqueConstraint(this.uniqueConstraints.size(), uniqueConstraint);
- }
-
- protected void removeUniqueConstraint_(JavaUniqueConstraint uniqueConstraint) {
- removeItemFromList(uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected void initializeUniqueConstraints(BaseTableAnnotation baseTableAnnotation) {
- for (Iterator<UniqueConstraintAnnotation> stream = baseTableAnnotation.uniqueConstraints(); stream.hasNext(); ) {
- this.uniqueConstraints.add(buildUniqueConstraint(stream.next()));
- }
- }
-
- protected void updateUniqueConstraints(BaseTableAnnotation baseTableAnnotation) {
- ListIterator<UniqueConstraintAnnotation> constraintAnnotations = baseTableAnnotation.uniqueConstraints();
- ListIterator<JavaUniqueConstraint> constraints = this.uniqueConstraints();
- while (constraints.hasNext()) {
- JavaUniqueConstraint uniqueConstraint = constraints.next();
- if (constraintAnnotations.hasNext()) {
- uniqueConstraint.update(constraintAnnotations.next());
- } else {
- this.removeUniqueConstraint_(uniqueConstraint);
- }
- }
-
- while (constraintAnnotations.hasNext()) {
- this.addUniqueConstraint(this.buildUniqueConstraint(constraintAnnotations.next()));
- }
- }
-
- protected JavaUniqueConstraint buildUniqueConstraint(UniqueConstraintAnnotation uniqueConstraintAnnotation) {
- JavaUniqueConstraint uniqueConstraint = this.getJpaFactory().buildJavaUniqueConstraint(this, this);
- uniqueConstraint.initialize(uniqueConstraintAnnotation);
- return uniqueConstraint;
- }
-
-
- // ********** convenience methods **********
-
- protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) {
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getNameTextRange(astRoot), astRoot);
- }
-
- protected boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getAnnotation().nameTouches(pos, astRoot);
- }
-
- public TextRange getSchemaTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getSchemaTextRange(astRoot), astRoot);
- }
-
- protected boolean schemaTouches(int pos, CompilationUnit astRoot) {
- return this.getAnnotation().schemaTouches(pos, astRoot);
- }
-
- public TextRange getCatalogTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getCatalogTextRange(astRoot), astRoot);
- }
-
- protected boolean catalogTouches(int pos, CompilationUnit astRoot) {
- return this.getAnnotation().catalogTouches(pos, astRoot);
- }
-
-
- // ********** resource => context **********
-
- protected void initialize(BaseTableAnnotation baseTableAnnotation) {
- this.defaultName = this.buildDefaultName();
- this.specifiedName = baseTableAnnotation.getName();
-
- this.defaultSchema = this.buildDefaultSchema();
- this.specifiedSchema = baseTableAnnotation.getSchema();
-
- this.defaultCatalog = this.buildDefaultCatalog();
- this.specifiedCatalog = baseTableAnnotation.getCatalog();
-
- this.initializeUniqueConstraints(baseTableAnnotation);
- }
-
- protected void update(BaseTableAnnotation baseTableAnnotation) {
- this.setDefaultName(this.buildDefaultName());
- this.setSpecifiedName_(baseTableAnnotation.getName());
-
- this.setDefaultSchema(this.buildDefaultSchema());
- this.setSpecifiedSchema_(baseTableAnnotation.getSchema());
-
- this.setDefaultCatalog(this.buildDefaultCatalog());
- this.setSpecifiedCatalog_(baseTableAnnotation.getCatalog());
-
- this.updateUniqueConstraints(baseTableAnnotation);
- }
-
-
- // ********** database **********
-
- public org.eclipse.jpt.db.Table getDbTable() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema == null) ? null : dbSchema.getTableForIdentifier(this.getName());
- }
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- public boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- public boolean hasResolvedSchema() {
- return this.getDbSchema() != null;
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public boolean hasResolvedCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.getDbCatalog(catalog) != null);
- }
-
-
- // ********** UniqueConstraint.Owner implementation **********
-
- public Iterator<String> candidateUniqueConstraintColumnNames() {
- org.eclipse.jpt.db.Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers().iterator() : EmptyIterator.<String>instance();
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getTextRange(this.getAnnotation().getTextRange(astRoot), astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.buildTableValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildTableValidator(CompilationUnit astRoot) {
- return this.getOwner().buildTableValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected TableTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaTableTextRangeResolver(this, astRoot);
- }
-
- // ********** Java completion proposals **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaUniqueConstraint constraint : CollectionTools.iterable(this.uniqueConstraints())) {
- result = constraint.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
- /**
- * called if the database is connected:
- * name, schema, catalog
- */
- @Override
- public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.getJavaCandidateNames(filter).iterator();
- }
- if (this.schemaTouches(pos, astRoot)) {
- return this.getJavaCandidateSchemata(filter).iterator();
- }
- if (this.catalogTouches(pos, astRoot)) {
- return this.getJavaCandidateCatalogs(filter).iterator();
- }
- return null;
- }
-
- protected Iterable<String> getJavaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateNames(filter));
- }
-
- protected Iterable<String> getCandidateNames(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateNames(), filter);
- }
-
- protected Iterable<String> getCandidateNames() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema != null) ? dbSchema.getSortedTableIdentifiers() : EmptyIterable.<String> instance();
- }
-
- protected Iterable<String> getJavaCandidateSchemata(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateSchemata(filter));
- }
-
- protected Iterable<String> getCandidateSchemata(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateSchemata(), filter);
- }
-
- protected Iterable<String> getCandidateSchemata() {
- return this.getDbSchemaContainer().getSortedSchemaIdentifiers();
- }
-
- protected Iterable<String> getJavaCandidateCatalogs(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.getCandidateCatalogs(filter));
- }
-
- protected Iterable<String> getCandidateCatalogs(Filter<String> filter) {
- return new FilteringIterable<String>(this.getCandidateCatalogs(), filter);
- }
-
- protected Iterable<String> getCandidateCatalogs() {
- Database db = this.getDatabase();
- return (db != null) ? db.getSortedCatalogIdentifiers() : EmptyIterable.<String> instance();
- }
-
-
- // ********** misc **********
-
- /**
- * covariant override
- */
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.getQualifiedName());
- }
-
- protected String getQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java
deleted file mode 100644
index 17a6b06938..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMapping.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericTypeMappingValidator;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaTypeMapping extends AbstractJavaJpaContextNode
- implements JavaTypeMapping
-{
- protected JavaResourcePersistentType javaResourcePersistentType;
-
-
- protected AbstractJavaTypeMapping(JavaPersistentType parent) {
- super(parent);
- }
-
- @Override
- public JavaPersistentType getParent() {
- return (JavaPersistentType) super.getParent();
- }
-
- protected JavaResourcePersistentType getResourcePersistentType() {
- return this.javaResourcePersistentType;
- }
-
- protected Annotation getResourceMappingAnnotation() {
- return this.javaResourcePersistentType.getAnnotation(getAnnotationName());
- }
-
- //***************** TypeMapping impl ***************************************
-
- public String getName() {
- return getPersistentType().getName();
- }
-
- public JavaPersistentType getPersistentType() {
- return getParent();
- }
-
- /* default implementation */
- public JavaPersistentType getIdClass() {
- return null;
- }
-
- public String getPrimaryTableName() {
- return null;
- }
-
- public org.eclipse.jpt.db.Table getPrimaryDbTable() {
- return null;
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return null;
- }
-
- public Schema getDbSchema() {
- return null;
- }
-
- public boolean attributeMappingKeyAllowed(String attributeMappingKey) {
- return true;
- }
-
- public Iterator<Table> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public Iterator<Table> associatedTablesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public TypeMapping getSuperTypeMapping() {
- return (getPersistentType().getSuperPersistentType() == null) ?
- null
- : getPersistentType().getSuperPersistentType().getMapping();
- }
-
- /**
- * Return an iterator of TypeMappings, each which inherits from the one before,
- * and terminates at the root entity (or at the point of cyclicity).
- */
- public Iterator<TypeMapping> inheritanceHierarchy() {
- return this.getInheritanceHierarchy().iterator();
- }
-
- public Iterable<TypeMapping> getInheritanceHierarchy() {
- return new TransformationIterable<PersistentType, TypeMapping>(CollectionTools.iterable(getPersistentType().inheritanceHierarchy())) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
- public Iterator<JavaAttributeMapping> attributeMappings() {
- return new TransformationIterator<JavaPersistentAttribute, JavaAttributeMapping>(getPersistentType().attributes()) {
- @Override
- protected JavaAttributeMapping transform(JavaPersistentAttribute attribute) {
- return attribute.getMapping();
- }
- };
- }
-
- public Iterable<JavaAttributeMapping> getAttributeMappings(final String mappingKey) {
- return new FilteringIterable<JavaAttributeMapping>(CollectionTools.collection(attributeMappings())) {
- @Override
- protected boolean accept(JavaAttributeMapping o) {
- return StringTools.stringsAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterator<AttributeMapping> allAttributeMappings() {
- return new CompositeIterator<AttributeMapping>(
- new TransformationIterator<TypeMapping, Iterator<AttributeMapping>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<AttributeMapping> transform(TypeMapping typeMapping) {
- return typeMapping == null ? EmptyIterator.<AttributeMapping> instance() : typeMapping.attributeMappings();
- }
- });
- }
-
- public Iterable<AttributeMapping> getAllAttributeMappings(final String mappingKey) {
- return new FilteringIterable<AttributeMapping>(CollectionTools.collection(allAttributeMappings())) {
- @Override
- protected boolean accept(AttributeMapping o) {
- return StringTools.stringsAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterator<String> overridableAttributeNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAttributeMappingNames();
- }
- });
- }
-
- public Iterator<String> allOverridableAttributeNames() {
- return new CompositeIterator<String>(new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAttributeNames();
- }
- });
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(attributeMappings())) {
- Column resolvedColumn = attributeMapping.resolveOverriddenColumn(attributeName);
- if (resolvedColumn != null) {
- return resolvedColumn;
- }
- }
- return null;
- }
-
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(attributeMappings())) {
- RelationshipReference resolvedRelationshipReference = attributeMapping.resolveRelationshipReference(attributeName);
- if (resolvedRelationshipReference != null) {
- return resolvedRelationshipReference;
- }
- }
- return null;
- }
-
- public Iterator<String> overridableAssociationNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAssociationMappingNames();
- }
- });
- }
-
- public Iterator<String> allOverridableAssociationNames() {
- return new CompositeIterator<String>(new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAssociationNames();
- }
- });
- }
-
-
- //******************** updating *********************
- public void initialize(JavaResourcePersistentType jrpt) {
- this.javaResourcePersistentType = jrpt;
- }
-
- public void update(JavaResourcePersistentType jrpt) {
- this.javaResourcePersistentType = jrpt;
- }
-
- //******************** validation *********************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- validateType(messages, reporter, astRoot);
- }
-
- protected void validateType(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.buildTypeMappingValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildTypeMappingValidator(CompilationUnit astRoot) {
- return new GenericTypeMappingValidator(this, this.javaResourcePersistentType, buildTextRangeResolver(astRoot));
- }
-
- protected TypeMappingTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaTypeMappingTextRangeResolver(this, astRoot);
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return getPersistenceUnit().shouldValidateAgainstDatabase();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getResourceMappingAnnotation().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getPersistentType().getValidationTextRange(astRoot);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getPersistentType().getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java
deleted file mode 100644
index 65e6850206..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaTypeMappingDefinition.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-public abstract class AbstractJavaTypeMappingDefinition
- implements JavaTypeMappingDefinition
-{
- protected AbstractJavaTypeMappingDefinition() {
- super();
- }
-
-
- /**
- * Default implementation. Override if the mapping definition needs to do more analysis.
- */
- public boolean test(JavaPersistentType persistentType) {
- return persistentType.getResourcePersistentType().getAnnotation(getAnnotationName())
- != null;
- }
-
- @Override
- public String toString() {
- return StringTools.buildToStringFor(this, this.getAnnotationName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java
deleted file mode 100644
index 0f1f2760db..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/AbstractJavaVersionMapping.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaConverter;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJavaVersionMapping
- extends AbstractJavaAttributeMapping<VersionAnnotation>
- implements JavaVersionMapping
-{
- protected final JavaColumn column;
-
- protected JavaConverter converter;
-
- protected final JavaConverter nullConverter;
-
- protected AbstractJavaVersionMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = getJpaFactory().buildJavaColumn(this, this);
- this.nullConverter = getJpaFactory().buildJavaNullConverter(this);
- this.converter = this.nullConverter;
- }
-
- @Override
- protected void initialize( ) {
- super.initialize();
- this.column.initialize(this.getResourceColumn());
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
- public ColumnAnnotation getResourceColumn() {
- return (ColumnAnnotation) getResourcePersistentAttribute().
- getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- //************** JavaAttributeMapping implementation ***************
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return VersionAnnotation.ANNOTATION_NAME;
- }
-
-
- @Override
- protected void addSupportingAnnotationNamesTo(Vector<String> names) {
- super.addSupportingAnnotationNamesTo(names);
- names.add(JPA.COLUMN);
- names.add(JPA.TEMPORAL);
- }
-
- //************** NamedColumn.Owner implementation ***************
-
- public String getDefaultColumnName() {
- return getName();
- }
-
- //************** BaseColumn.Owner implementation ***************
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- //************** VersionMapping implementation ***************
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- JavaConverter oldConverter = this.converter;
- JavaConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(JavaConverter newConverter) {
- JavaConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
-
- @Override
- protected void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update(this.getResourcePersistentAttribute());
- }
- else {
- JavaConverter javaConverter = buildConverter(getResourceConverterType());
- setConverter(javaConverter);
- }
- }
-
- protected JavaConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getJpaFactory().buildJavaTemporalConverter(this, this.getResourcePersistentAttribute());
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.getResourcePersistentAttribute().getAnnotation(TemporalAnnotation.ANNOTATION_NAME) != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.getColumn().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = getConverter().javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- return null;
- }
-
- //*********** Validation ******************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.getColumn().validate(messages, reporter, astRoot);
- this.getConverter().validate(messages, reporter, astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java
deleted file mode 100644
index 7d52f032ce..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaIdClassReference.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class GenericJavaIdClassReference
- extends AbstractJavaJpaContextNode
- implements JavaIdClassReference
-{
- protected String idClassName;
-
- protected String fullyQualifiedIdClassName;
-
- protected JavaPersistentType idClass;
-
-
- public GenericJavaIdClassReference(JavaTypeMapping parent) {
- super(parent);
- }
-
-
- protected JavaTypeMapping getTypeMapping() {
- return (JavaTypeMapping) getParent();
- }
-
- protected JavaPersistentType getPersistentType() {
- return getTypeMapping().getPersistentType();
- }
-
-
- // **************** PersistentType.Owner impl *****************************
-
- public AccessType getOverridePersistentTypeAccess() {
- return getPersistentType().getAccess();
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- // this shouldn't be needed, since we've specified an override access, but just to be safe ...
- return getPersistentType().getAccess();
- }
-
-
- // **************** IdClassReference impl *********************************
-
- public String getSpecifiedIdClassName() {
- return this.idClassName;
- }
-
- public void setSpecifiedIdClassName(String newClassName) {
- String oldClassName = this.idClassName;
- this.idClassName = newClassName;
- if (this.valuesAreDifferent(newClassName, oldClassName)) {
- if (newClassName != null) {
- if (getIdClassAnnotation() == null) {
- addIdClassAnnotation();
- }
- getIdClassAnnotation().setValue(newClassName);
- }
- else {
- removeIdClassAnnotation();
- }
- }
- firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected void setIdClassName_(String newClassName) {
- String oldClassName = this.idClassName;
- this.idClassName = newClassName;
- firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected String buildIdClassName() {
- IdClassAnnotation annotation = getIdClassAnnotation();
- if (annotation != null) {
- return annotation.getValue();
- }
- return null;
- }
-
- public String getDefaultIdClassName() {
- return null;
- }
-
- public String getIdClassName() {
- return getSpecifiedIdClassName();
- }
-
- public boolean isSpecified() {
- return getSpecifiedIdClassName() != null;
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClass;
- }
-
- protected void setIdClass_(JavaPersistentType newIdClass) {
- JavaPersistentType oldIdClass = this.idClass;
- this.idClass = newIdClass;
- firePropertyChanged(ID_CLASS_PROPERTY, oldIdClass, newIdClass);
- }
-
- protected JavaPersistentType buildIdClass() {
- JavaResourcePersistentType resourceIdClass = getResourceIdClass();
- return (resourceIdClass == null) ?
- null : this.buildIdClass(resourceIdClass);
- }
-
- protected JavaPersistentType buildIdClass(JavaResourcePersistentType resourceClass) {
- return getJpaFactory().buildJavaPersistentType(this, resourceClass);
- }
-
- protected JavaResourcePersistentType getResourcePersistentType() {
- return getPersistentType().getResourcePersistentType();
- }
-
- protected IdClassAnnotation getIdClassAnnotation() {
- return (IdClassAnnotation) getResourcePersistentType().
- getAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- }
-
- protected void addIdClassAnnotation() {
- getResourcePersistentType().addAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeIdClassAnnotation() {
- getResourcePersistentType().removeAnnotation(IdClassAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaResourcePersistentType getResourceIdClass() {
- return (this.fullyQualifiedIdClassName == null) ?
- null : getJpaProject().getJavaResourcePersistentType(this.fullyQualifiedIdClassName);
- }
-
- public String getFullyQualifiedIdClassName() {
- return this.fullyQualifiedIdClassName;
- }
-
- protected void setFullyQualifiedIdClassName(String idClass) {
- String old = this.fullyQualifiedIdClassName;
- this.fullyQualifiedIdClassName = idClass;
- this.firePropertyChanged(FULLY_QUALIFIED_ID_CLASS_PROPERTY, old, idClass);
- }
-
- protected String buildFullyQualifiedIdClassName() {
- IdClassAnnotation annotation = getIdClassAnnotation();
- return (annotation == null) ?
- null : annotation.getFullyQualifiedClassName();
- }
-
- public char getIdClassEnclosingTypeSeparator() {
- return '.';
- }
-
- public void initialize() {
- this.idClassName = buildIdClassName();
- this.fullyQualifiedIdClassName = this.buildFullyQualifiedIdClassName();
- this.idClass = buildIdClass();
- }
-
- public void update() {
- setIdClassName_(buildIdClassName());
- this.setFullyQualifiedIdClassName(this.buildFullyQualifiedIdClassName());
- updateIdClass();
- }
-
- protected void updateIdClass() {
- JavaResourcePersistentType resourceIdClass = getResourceIdClass();
- if (resourceIdClass == null) {
- setIdClass_(null);
- }
- else {
- if (this.idClass == null || this.idClass.getResourcePersistentType() != resourceIdClass) {
- setIdClass_(buildIdClass(resourceIdClass));
- }
- this.idClass.update(resourceIdClass);
- }
- }
-
-
- // **************** validation ********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return (getIdClassAnnotation() == null) ?
- getTypeMapping().getValidationTextRange(astRoot)
- : getIdClassAnnotation().getTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java
deleted file mode 100644
index f671423307..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnInAssociationOverrideJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn.Owner;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.resource.java.NullJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-
-public class GenericJavaJoinColumnInAssociationOverrideJoiningStrategy
- extends AbstractJavaJoinColumnJoiningStrategy
- implements JavaJoinColumnInAssociationOverrideJoiningStrategy
-{
- protected transient AssociationOverrideAnnotation associationOverrideAnnotation;
-
- public GenericJavaJoinColumnInAssociationOverrideJoiningStrategy(JavaAssociationOverrideRelationshipReference parent) {
- super(parent);
- }
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- if (relationshipMapping != null) {
- return relationshipMapping.getRelationshipReference().isTargetForeignKeyRelationship();
- }
- return false;
- }
-
- public TypeMapping getRelationshipSource() {
- if (isTargetForeignKeyRelationship()) {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
- return getAssociationOverrideOwner().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- if (isTargetForeignKeyRelationship()) {
- return getAssociationOverrideOwner().getTypeMapping();
- }
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping relationshipTarget = getRelationshipTarget();
- return (relationshipTarget != null) && (relationshipTarget.getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) ? (Entity) relationshipTarget : null;
- }
-
- @Override
- public RelationshipMapping getRelationshipMapping() {
- return getAssociationOverrideOwner().getRelationshipMapping(getAttributeName());
- }
-
- protected String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- @Override
- public String getTableName() {
- if (isTargetForeignKeyRelationship()) {
- return super.getTableName();
- }
- return getAssociationOverrideOwner().getDefaultTableName();
- }
-
- @Override
- public boolean tableNameIsInvalid(String tableName) {
- if (isTargetForeignKeyRelationship()) {
- return super.tableNameIsInvalid(tableName);
- }
- return getAssociationOverrideOwner().tableNameIsInvalid(tableName);
- }
-
- @Override
- public Iterator<String> candidateTableNames() {
- if (isTargetForeignKeyRelationship()) {
- return super.candidateTableNames();
- }
- return getAssociationOverrideOwner().candidateTableNames();
- }
-
- @Override
- public Table getDbTable(String tableName) {
- if (isTargetForeignKeyRelationship()) {
- return super.getDbTable(tableName);
- }
- return getAssociationOverrideOwner().getDbTable(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return null;
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- protected JavaAssociationOverride getAssociationOverride() {
- return this.getRelationshipReference().getAssociationOverride();
- }
-
- protected JavaAssociationOverride.Owner getAssociationOverrideOwner() {
- return getAssociationOverride().getOwner();
- }
-
- @Override
- public JavaAssociationOverrideRelationshipReference getRelationshipReference() {
- return (JavaAssociationOverrideRelationshipReference) super.getRelationshipReference();
- }
-
- @Override
- protected ListIterator<JoinColumnAnnotation> joinColumnAnnotations() {
- return this.associationOverrideAnnotation.joinColumns();
- }
-
- @Override
- protected JoinColumnAnnotation buildNullJoinColumnAnnotation() {
- return new NullJoinColumnAnnotation(this.associationOverrideAnnotation);
- }
-
- @Override
- protected JoinColumnAnnotation addAnnotation(int index) {
- return this.associationOverrideAnnotation.addJoinColumn(index);
- }
-
- @Override
- protected void removeAnnotation(int index) {
- this.associationOverrideAnnotation.removeJoinColumn(index);
- }
-
- @Override
- protected void moveAnnotation(int targetIndex, int sourceIndex) {
- this.associationOverrideAnnotation.moveJoinColumn(targetIndex, sourceIndex);
- }
-
- public void initialize(AssociationOverrideAnnotation associationOverride) {
- this.associationOverrideAnnotation = associationOverride;
- super.initialize();
- }
-
- public void update(AssociationOverrideAnnotation associationOverride) {
- this.associationOverrideAnnotation = associationOverride;
- super.update();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
-// ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
-
- protected JoinColumnOwner() {
- super();
- }
-
- public String getDefaultTableName() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getAttributeName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.candidateTableNames();
- }
-
- public Table getDbTable(String tableName) {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return false;
- }
-
- public int joinColumnsSize() {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaJoinColumnInAssociationOverrideJoiningStrategy.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return getAssociationOverrideOwner().buildColumnValidator(getAssociationOverride(), (BaseColumn) column, this, (BaseColumnTextRangeResolver) textRangeResolver);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java
deleted file mode 100644
index 859d781ec6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumnEnabledRelationshipReference;
-
-public class GenericJavaJoinColumnJoiningStrategy
- extends AbstractJavaJoinColumnInRelationshipMappingJoiningStrategy
-{
-
- public GenericJavaJoinColumnJoiningStrategy(JavaJoinColumnEnabledRelationshipReference parent) {
- super(parent);
- }
-
- public TypeMapping getRelationshipSource() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- return getRelationshipTargetEntity();
- }
-
- @Override
- protected Entity getRelationshipTargetEntity() {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java
deleted file mode 100644
index f2e1aaecae..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.java.JavaJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.InverseJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableValidator;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class GenericJavaJoinTableJoiningStrategy
- extends AbstractJavaJoinTableJoiningStrategy
-{
- protected JavaResourcePersistentAttribute resourcePersistentAttribute;
-
-
- public GenericJavaJoinTableJoiningStrategy(JavaJoinTableEnabledRelationshipReference parent) {
- super(parent);
- }
-
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new JoinTableValidator((JoinTable) table, textRangeResolver);
- }
-
- public boolean isOverridableAssociation() {
- return getJpaPlatformVariation().isJoinTableOverridable();
- }
-
- @Override
- public JavaJoinTableEnabledRelationshipReference getParent() {
- return (JavaJoinTableEnabledRelationshipReference) super.getParent();
- }
-
- @Override
- public JavaJoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return getRelationshipMapping().shouldValidateAgainstDatabase();
- }
-
-
- // **************** join table *********************************************
-
- @Override
- protected JoinTableAnnotation addAnnotation() {
- return (JoinTableAnnotation) this.resourcePersistentAttribute.
- addAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void removeAnnotation() {
- this.resourcePersistentAttribute.
- removeAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- public void initialize() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- super.initialize();
- }
-
- @Override
- public void update() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- super.update();
- }
-
- public JoinTableAnnotation getAnnotation() {
- return (JoinTableAnnotation) this.resourcePersistentAttribute.
- getNonNullAnnotation(JoinTableAnnotation.ANNOTATION_NAME);
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator(column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new InverseJoinColumnValidator(column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java
deleted file mode 100644
index 0844f8f36f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToManyRelationshipReference.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.java.JavaManyToManyRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaManyToManyRelationshipReference
- extends AbstractJavaRelationshipReference
- implements JavaManyToManyRelationshipReference
-{
- protected final JavaMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected final JavaJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
- public GenericJavaManyToManyRelationshipReference(JavaManyToManyMapping parent) {
- super(parent);
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
-
- protected JavaMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericJavaMappedByJoiningStrategy(this);
- }
-
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new GenericJavaJoinTableJoiningStrategy(this);
- }
-
- @Override
- public JavaManyToManyMapping getRelationshipMapping() {
- return (JavaManyToManyMapping) getParent();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return getRelationshipMapping().getMappingAnnotation();
- }
-
- public boolean isRelationshipOwner() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- protected JoiningStrategy calculatePredominantJoiningStrategy() {
- if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
- return this.mappedByJoiningStrategy;
- }
- return this.joinTableJoiningStrategy;
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result == null) {
- result = this.mappedByJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- if (result == null) {
- result = this.joinTableJoiningStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
- return result;
- }
-
-
- // **************** mapped by **********************************************
-
- public JavaMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public void setMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join table joining strategy ***************************
-
- public JavaJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public void setJoinTableJoiningStrategy() {
- // join table is default option, so no need to add to resource
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy.initialize();
- this.joinTableJoiningStrategy.initialize();
- }
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByJoiningStrategy.validate(messages, reporter, astRoot);
- this.joinTableJoiningStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java
deleted file mode 100644
index 7373ddbba2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaManyToOneRelationshipReference.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.java.NullJavaJoinTableJoiningStrategy;
-
-public class GenericJavaManyToOneRelationshipReference
- extends AbstractJavaManyToOneRelationshipReference
-{
-
- public GenericJavaManyToOneRelationshipReference(JavaManyToOneMapping parent) {
- super(parent);
- }
-
- @Override
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new NullJavaJoinTableJoiningStrategy(this);
- }
-
- @Override
- protected JoiningStrategy calculatePredominantJoiningStrategy() {
- // the only joining strategy
- return this.joinColumnJoiningStrategy;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java
deleted file mode 100644
index 6fe3a331a0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaMappedByJoiningStrategy.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.java.JavaMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaMappedByJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaMappedByJoiningStrategy
-{
- protected OwnableRelationshipMappingAnnotation mappingAnnotation;
-
- protected String mappedByAttribute;
-
-
- public GenericJavaMappedByJoiningStrategy(JavaOwnableRelationshipReference parent) {
- super(parent);
- }
-
-
- @Override
- public JavaOwnableRelationshipReference getParent() {
- return (JavaOwnableRelationshipReference) super.getParent();
- }
-
- public JavaOwnableRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public JavaRelationshipMapping getRelationshipMapping() {
- return getParent().getRelationshipMapping();
- }
-
- public String getTableName() {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? null : owner.getRelationshipReference().getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? null : owner.getRelationshipReference().getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? false : owner.getRelationshipReference().getPredominantJoiningStrategy().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- //this will not be called if getRelationshipOwner() is null
- return getRelationshipOwner().getRelationshipReference().getPredominantJoiningStrategy().getColumnTableNotValidDescription();
- }
-
- protected RelationshipMapping getRelationshipOwner() {
- return getRelationshipMapping().getRelationshipOwner();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public boolean relationshipIsOwnedBy(RelationshipMapping otherMapping) {
- String thisEntity =
- (getRelationshipReference().getEntity()) == null ?
- null : getRelationshipReference().getEntity().getName();
- String otherTargetEntity =
- (otherMapping.getResolvedTargetEntity() == null) ?
- null : otherMapping.getResolvedTargetEntity().getName();
- return StringTools.stringsAreEqual(
- thisEntity,
- otherTargetEntity)
- && StringTools.stringsAreEqual(
- getMappedByAttribute(),
- otherMapping.getName());
- }
-
- public String getMappedByAttribute() {
- return this.mappedByAttribute;
- }
-
- public void setMappedByAttribute(String newMappedByAttribute) {
- String oldMappedByAttribute = this.mappedByAttribute;
- this.mappedByAttribute = newMappedByAttribute;
- this.mappingAnnotation.setMappedBy(newMappedByAttribute);
- firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, oldMappedByAttribute, newMappedByAttribute);
- }
-
- protected void setMappedByAttribute_(String newMappedByAttribute) {
- String oldMappedByAttribute = this.mappedByAttribute;
- this.mappedByAttribute = newMappedByAttribute;
- firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, oldMappedByAttribute, newMappedByAttribute);
- }
-
- public void addStrategy() {
- if (this.mappedByAttribute == null) {
- setMappedByAttribute(""); //$NON-NLS-1$
- }
- }
-
- public void removeStrategy() {
- if (this.mappedByAttribute != null) {
- setMappedByAttribute(null);
- }
- }
-
- public void initialize() {
- this.mappingAnnotation = this.getRelationshipReference().getMappingAnnotation();
- this.mappedByAttribute = this.mappingAnnotation.getMappedBy();
- }
-
- public void update() {
- this.mappingAnnotation = this.getRelationshipReference().getMappingAnnotation();
- setMappedByAttribute_(this.mappingAnnotation.getMappedBy());
- }
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (this.mappingAnnotation.mappedByTouches(pos, astRoot)) {
- result = javaCandidateMappedByAttributeNames(filter);
- }
- return result;
- }
-
- public Iterator<String> candidateMappedByAttributeNames() {
- return getRelationshipMapping().allTargetEntityAttributeNames();
- }
-
- public Iterator<String> candidateMappedByAttributeNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateMappedByAttributeNames(), filter);
- }
-
- protected Iterator<String> javaCandidateMappedByAttributeNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateMappedByAttributeNames(filter));
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.mappingAnnotation.getMappedByTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- if (getMappedByAttribute() == null) {
- return;
- }
-
- Entity targetEntity = this.getRelationshipMapping().getResolvedTargetEntity();
- if (targetEntity == null) {
- return; // null target entity is validated elsewhere
- }
-
- AttributeMapping mappedByMapping = targetEntity.resolveAttributeMapping(this.mappedByAttribute);
-
- if (mappedByMapping == null) {
- messages.add(
- buildMessage(
- JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
- new String[] {this.mappedByAttribute},
- astRoot));
- return;
- }
-
- if (! this.getRelationshipReference().mayBeMappedBy(mappedByMapping)) {
- messages.add(
- buildMessage(
- JpaValidationMessages.MAPPING_INVALID_MAPPED_BY,
- new String[] {this.mappedByAttribute},
- astRoot));
- return;
- }
-
- // if mappedByMapping is not a relationship owner, then it should have
- // been flagged in above rule (mappedByIsValid)
- if (! ((RelationshipMapping) mappedByMapping).isRelationshipOwner()) {
- messages.add(buildMessage(
- JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
- new String[] {this.mappedByAttribute},
- astRoot));
- }
- }
-
- protected IMessage buildMessage(String msgID, String[] params, CompilationUnit astRoot) {
- PersistentAttribute attribute = getRelationshipMapping().getPersistentAttribute();
- String attributeDesc = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
-
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- ArrayTools.add(params, 0, attributeDesc),
- this,
- this.getValidationTextRange(astRoot));
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java
deleted file mode 100644
index a1cd310525..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaOneToOneRelationshipReference.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.java.NullJavaJoinTableJoiningStrategy;
-
-public class GenericJavaOneToOneRelationshipReference
- extends AbstractJavaOneToOneRelationshipReference
-{
-
- public GenericJavaOneToOneRelationshipReference(JavaOneToOneMapping parent) {
- super(parent);
- }
-
- @Override
- protected JavaJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new NullJavaJoinTableJoiningStrategy(this);
- }
-
- @Override
- protected JoiningStrategy calculatePredominantJoiningStrategy() {
- if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
- return this.mappedByJoiningStrategy;
- }
- else if (this.primaryKeyJoinColumnJoiningStrategy.primaryKeyJoinColumnsSize() > 0) {
- return this.primaryKeyJoinColumnJoiningStrategy;
- }
- return this.joinColumnJoiningStrategy;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java
deleted file mode 100644
index b26539e2eb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.OneToOnePrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.Filter;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaPrimaryKeyJoinColumnJoiningStrategy
- extends AbstractJavaJpaContextNode
- implements JavaPrimaryKeyJoinColumnJoiningStrategy
-{
- protected JavaResourcePersistentAttribute resourcePersistentAttribute;
-
- protected final Vector<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns = new Vector<JavaPrimaryKeyJoinColumn>();
- protected final JavaJoinColumn.Owner joinColumnOwner;
-
-
- public GenericJavaPrimaryKeyJoinColumnJoiningStrategy(
- JavaPrimaryKeyJoinColumnEnabledRelationshipReference parent) {
- super(parent);
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
- protected JavaJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- @Override
- public JavaPrimaryKeyJoinColumnEnabledRelationshipReference getParent() {
- return (JavaPrimaryKeyJoinColumnEnabledRelationshipReference) super.getParent();
- }
-
- public JavaPrimaryKeyJoinColumnEnabledRelationshipReference getRelationshipReference() {
- return getParent();
- }
-
- public JavaRelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public String getTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- protected TypeMapping getTypeMapping() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- // **************** primary key join columns *******************************
-
- public ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return new CloneListIterator<JavaPrimaryKeyJoinColumn>(this.primaryKeyJoinColumns);
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.primaryKeyJoinColumns.size();
- }
-
- public boolean hasPrimaryKeyJoinColumns() {
- return ! this.primaryKeyJoinColumns.isEmpty();
- }
-
- public JavaPrimaryKeyJoinColumn addPrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn pkJoinColumn =
- getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.joinColumnOwner);
- this.primaryKeyJoinColumns.add(index, pkJoinColumn);
- PrimaryKeyJoinColumnAnnotation pkJoinColumnAnnotation = addAnnotation(index);
- pkJoinColumn.initialize(pkJoinColumnAnnotation);
- fireItemAdded(PRIMARY_KEY_JOIN_COLUMNS_LIST, index, pkJoinColumn);
- return pkJoinColumn;
- }
-
- protected void addPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn joinColumn) {
- addItemToList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void addPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn joinColumn) {
- addPrimaryKeyJoinColumn(this.primaryKeyJoinColumns.size(), joinColumn);
- }
-
- public void removePrimaryKeyJoinColumn(PrimaryKeyJoinColumn pkJoinColumn) {
- removePrimaryKeyJoinColumn(this.primaryKeyJoinColumns.indexOf(pkJoinColumn));
- }
-
- public void removePrimaryKeyJoinColumn(int index) {
- JavaPrimaryKeyJoinColumn pkJoinColumn = this.primaryKeyJoinColumns.remove(index);
- removeAnnotation(index);
- fireItemRemoved(PRIMARY_KEY_JOIN_COLUMNS_LIST, index, pkJoinColumn);
- }
-
- protected void removePrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn joinColumn) {
- removeItemFromList(joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void movePrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.primaryKeyJoinColumns, targetIndex, sourceIndex);
- moveAnnotation(targetIndex, sourceIndex);
- fireItemMoved(PRIMARY_KEY_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
- protected PrimaryKeyJoinColumnAnnotation addAnnotation(int index) {
- return (PrimaryKeyJoinColumnAnnotation) this.resourcePersistentAttribute.
- addAnnotation(
- index,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeAnnotation(int index) {
- this.resourcePersistentAttribute.
- removeAnnotation(
- index,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void moveAnnotation(int targetIndex, int sourceIndex) {
- this.resourcePersistentAttribute.
- moveAnnotation(
- targetIndex,
- sourceIndex,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- public void addStrategy() {
- if (primaryKeyJoinColumnsSize() == 0) {
- addPrimaryKeyJoinColumn(0);
- }
- }
-
- public void removeStrategy() {
- for (PrimaryKeyJoinColumn each : CollectionTools.iterable(primaryKeyJoinColumns())) {
- removePrimaryKeyJoinColumn(each);
- }
- }
-
-
- // **************** resource -> context ************************************
-
- public void initialize() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- initializePrimaryKeyJoinColumns();
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- Iterator<NestableAnnotation> annotations =
- this.resourcePersistentAttribute.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
-
- while (annotations.hasNext()) {
- this.primaryKeyJoinColumns.add(
- buildPrimaryKeyJoinColumn(
- (PrimaryKeyJoinColumnAnnotation) annotations.next()));
- }
- }
-
- public void update() {
- this.resourcePersistentAttribute =
- getRelationshipReference().getRelationshipMapping().
- getPersistentAttribute().getResourcePersistentAttribute();
- updatePrimaryKeyJoinColumns();
- }
-
- protected void updatePrimaryKeyJoinColumns() {
- ListIterator<JavaPrimaryKeyJoinColumn> joinColumns = primaryKeyJoinColumns();
- Iterator<NestableAnnotation> annotations =
- this.resourcePersistentAttribute.annotations(
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
-
- while (joinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn joinColumn = joinColumns.next();
- if (annotations.hasNext()) {
- joinColumn.update(
- (PrimaryKeyJoinColumnAnnotation) annotations.next());
- }
- else {
- removePrimaryKeyJoinColumn_(joinColumn);
- }
- }
-
- while (annotations.hasNext()) {
- addPrimaryKeyJoinColumn(
- buildPrimaryKeyJoinColumn(
- (PrimaryKeyJoinColumnAnnotation) annotations.next()));
- }
- }
-
- protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(
- PrimaryKeyJoinColumnAnnotation annotation) {
- JavaPrimaryKeyJoinColumn joinColumn =
- getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.joinColumnOwner);
- joinColumn.initialize(annotation);
- return joinColumn;
- }
-
-
- // **************** Java completion proposals ******************************
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaPrimaryKeyJoinColumn column : CollectionTools.iterable(this.primaryKeyJoinColumns())) {
- result = column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- return null;
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationshipReference().getValidationTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- for (Iterator<JavaPrimaryKeyJoinColumn> stream = this.primaryKeyJoinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter, astRoot);
- }
- }
-
-
- // ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.getTableName();
- }
-
- public Entity getRelationshipTarget() {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- return getRelationshipMapping().getName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.getTypeMapping();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- Entity targetEntity = getRelationshipTarget();
- return (targetEntity == null) ? null : targetEntity.getPrimaryDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return false;
- }
-
- public String getDefaultColumnName() {
- return null;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.getValidationTextRange(astRoot);
- }
-
- public int joinColumnsSize() {
- return GenericJavaPrimaryKeyJoinColumnJoiningStrategy.this.primaryKeyJoinColumnsSize();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new OneToOnePrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java
deleted file mode 100644
index 9b989cf72b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBaseColumnTextRangeResolver.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaBaseColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements BaseColumnTextRangeResolver
-{
-
- public JavaBaseColumnTextRangeResolver(JavaBaseColumn column, CompilationUnit astRoot) {
- super(column, astRoot);
- }
-
- @Override
- protected JavaBaseColumn getColumn() {
- return (JavaBaseColumn) super.getColumn();
- }
- public TextRange getTableTextRange() {
- return this.getColumn().getTableTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java
deleted file mode 100644
index 1f6ae3ca21..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaBasicMappingDefinition.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.BasicAnnotation;
-
-public class JavaBasicMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaBasicMappingDefinition INSTANCE =
- new JavaBasicMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaBasicMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return BasicAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaBasicMapping(parent);
- }
-
- @Override
- public boolean testDefault(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.typeIsBasic();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java
deleted file mode 100644
index 2a94eab3b8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddableDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.resource.java.EmbeddableAnnotation;
-
-public class JavaEmbeddableDefinition
- extends AbstractJavaTypeMappingDefinition
-{
- // singleton
- private static final JavaEmbeddableDefinition INSTANCE =
- new JavaEmbeddableDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaEmbeddableDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddableAnnotation.ANNOTATION_NAME;
- }
-
- public JavaEmbeddable buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return factory.buildJavaEmbeddable(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java
deleted file mode 100644
index fe78cadb6a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.EmbeddedIdAnnotation;
-
-public class JavaEmbeddedIdMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaEmbeddedIdMappingDefinition INSTANCE =
- new JavaEmbeddedIdMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singletong usage
- */
- private JavaEmbeddedIdMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddedIdAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaEmbeddedIdMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java
deleted file mode 100644
index 5910a5327e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEmbeddedMappingDefinition.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.EmbeddedAnnotation;
-
-public class JavaEmbeddedMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaEmbeddedMappingDefinition INSTANCE =
- new JavaEmbeddedMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaEmbeddedMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EmbeddedAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaEmbeddedMapping(parent);
- }
-
- @Override
- public boolean testDefault(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getEmbeddable() != null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java
deleted file mode 100644
index 58df102ce8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.resource.java.EntityAnnotation;
-
-public class JavaEntityDefinition
- extends AbstractJavaTypeMappingDefinition
-{
- // singleton
- private static final JavaEntityDefinition INSTANCE =
- new JavaEntityDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaEntityDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return EntityAnnotation.ANNOTATION_NAME;
- }
-
- public JavaEntity buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return factory.buildJavaEntity(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java
deleted file mode 100644
index 944789b3fa..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaEntityTextRangeResolver.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaEntityTextRangeResolver
- implements EntityTextRangeResolver
-{
- private JavaEntity entity;
-
- private CompilationUnit astRoot;
-
-
- public JavaEntityTextRangeResolver(JavaEntity entity, CompilationUnit astRoot) {
- this.entity = entity;
- this.astRoot = astRoot;
- }
-
-
- public TextRange getTypeMappingTextRange() {
- return this.entity.getValidationTextRange(this.astRoot);
- }
-
- public TextRange getIdClassTextRange() {
- return this.entity.getIdClassReference().getValidationTextRange(this.astRoot);
- }
-
- public TextRange getAttributeMappingTextRange(String attributeName) {
- return this.entity.getPersistentType().
- getAttributeNamed(attributeName).getMapping().getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java
deleted file mode 100644
index 3e6e059340..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaIdMappingDefinition.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-
-public class JavaIdMappingDefinition
- extends AbstractJavaIdMappingDefinition
-{
- // singleton
- private static final JavaIdMappingDefinition INSTANCE =
- new JavaIdMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaIdMappingDefinition() {
- super();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java
deleted file mode 100644
index 86843504fd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaJoinColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements
- BaseColumnTextRangeResolver,
- JoinColumnTextRangeResolver
-{
-
- public JavaJoinColumnTextRangeResolver(JavaJoinColumn column, CompilationUnit astRoot) {
- super(column, astRoot);
- }
-
- @Override
- protected JavaJoinColumn getColumn() {
- return (JavaJoinColumn) super.getColumn();
- }
-
- public TextRange getTableTextRange() {
- return this.getColumn().getTableTextRange(this.astRoot);
- }
-
- public TextRange getReferencedColumnNameTextRange() {
- return this.getColumn().getReferencedColumnNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java
deleted file mode 100644
index e8e8382779..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToManyMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.ManyToManyAnnotation;
-
-public class JavaManyToManyMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaManyToManyMappingDefinition INSTANCE =
- new JavaManyToManyMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaManyToManyMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return ManyToManyAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaManyToManyMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java
deleted file mode 100644
index 6eef2bbd55..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaManyToOneMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.ManyToOneAnnotation;
-
-public class JavaManyToOneMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaManyToOneMappingDefinition INSTANCE =
- new JavaManyToOneMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaManyToOneMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return ManyToOneAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaManyToOneMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java
deleted file mode 100644
index d14c61cb57..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.core.resource.java.MappedSuperclassAnnotation;
-
-public class JavaMappedSuperclassDefinition
- extends AbstractJavaTypeMappingDefinition
-{
- // singleton
- private static final JavaMappedSuperclassDefinition INSTANCE =
- new JavaMappedSuperclassDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaMappedSuperclassDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return MappedSuperclassAnnotation.ANNOTATION_NAME;
- }
-
- public JavaMappedSuperclass buildMapping(JavaPersistentType parent, JpaFactory factory) {
- return factory.buildJavaMappedSuperclass(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java
deleted file mode 100644
index 35f5d8ae22..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaMappedSuperclassTextRangeResolver
- implements PrimaryKeyTextRangeResolver
-{
- private JavaMappedSuperclass mappedSuperclass;
-
- private CompilationUnit astRoot;
-
-
- public JavaMappedSuperclassTextRangeResolver(
- JavaMappedSuperclass mappedSuperclass, CompilationUnit astRoot) {
-
- this.mappedSuperclass = mappedSuperclass;
- this.astRoot = astRoot;
- }
-
-
- public TextRange getTypeMappingTextRange() {
- return this.mappedSuperclass.getValidationTextRange(this.astRoot);
- }
-
- public TextRange getIdClassTextRange() {
- return this.mappedSuperclass.getIdClassReference().getValidationTextRange(this.astRoot);
- }
-
- public TextRange getAttributeMappingTextRange(String attributeName) {
- return this.mappedSuperclass.getPersistentType().
- getAttributeNamed(attributeName).getMapping().getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java
deleted file mode 100644
index 4c10481f0f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNamedColumnTextRangeResolver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaNamedColumnTextRangeResolver
- implements NamedColumnTextRangeResolver
-{
- protected final JavaNamedColumn javaNamedColumn;
-
- protected final CompilationUnit astRoot;
-
- public JavaNamedColumnTextRangeResolver(JavaNamedColumn javaNamedColumn, CompilationUnit astRoot) {
- this.javaNamedColumn = javaNamedColumn;
- this.astRoot = astRoot;
- }
-
- protected JavaNamedColumn getColumn() {
- return this.javaNamedColumn;
- }
-
- public TextRange getNameTextRange() {
- return this.javaNamedColumn.getNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
deleted file mode 100644
index cbb5e22867..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaNullTypeMapping.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public class JavaNullTypeMapping extends AbstractJavaTypeMapping
-{
- public JavaNullTypeMapping(JavaPersistentType parent) {
- super(parent);
- }
-
- public String getAnnotationName() {
- return null;
- }
-
- public String getKey() {
- return MappingKeys.NULL_TYPE_MAPPING_KEY;
- }
-
- public boolean isMapped() {
- return false;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return EmptyIterable.instance();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- /**
- * We added this message here because the most likely solution is to add
- * an annotation to the .java file.
- * This message used to be found on the <class> tag in persistence.xml.
- * The other possible way to fix the error is to remove it from persistence.xml.
- * This can be accomplished with the Synchronize Classes action.
- * We could also add a quick fix for this error.
- */
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_INVALID_CLASS,
- new String[] {this.getPersistentType().getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
-
- @Override
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getPersistentType().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java
deleted file mode 100644
index 019d6f8c3d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToManyMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.OneToManyAnnotation;
-
-public class JavaOneToManyMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaOneToManyMappingDefinition INSTANCE =
- new JavaOneToManyMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaOneToManyMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return OneToManyAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaOneToManyMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java
deleted file mode 100644
index c785d6cf0d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOneToOneMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.OneToOneAnnotation;
-
-public class JavaOneToOneMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaOneToOneMappingDefinition INSTANCE =
- new JavaOneToOneMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaOneToOneMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaOneToOneMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java
deleted file mode 100644
index 598b53d31d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaOverrideTextRangeResolver.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaOverride;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaOverrideTextRangeResolver
- implements OverrideTextRangeResolver
-{
- protected final JavaOverride javaOverride;
-
- protected final CompilationUnit astRoot;
-
- public JavaOverrideTextRangeResolver(JavaOverride javaOverride, CompilationUnit astRoot) {
- this.javaOverride = javaOverride;
- this.astRoot = astRoot;
- }
-
- protected JavaOverride getOverride() {
- return this.javaOverride;
- }
-
- public TextRange getNameTextRange() {
- return this.javaOverride.getNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java
deleted file mode 100644
index 4b9da4bce3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaPersistentAttributeTextRangeResolver
- implements PersistentAttributeTextRangeResolver
-{
- private JavaPersistentAttribute javaPersistentAttribute;
-
- private CompilationUnit astRoot;
-
- public JavaPersistentAttributeTextRangeResolver(JavaPersistentAttribute javaPersistentAttribute, CompilationUnit astRoot) {
- this.javaPersistentAttribute = javaPersistentAttribute;
- this.astRoot = astRoot;
- }
-
- public TextRange getAttributeTextRange() {
- return this.javaPersistentAttribute.getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java
deleted file mode 100644
index 1c7d6eafe6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaPrimaryKeyJoinColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements
- BaseJoinColumnTextRangeResolver
-{
-
- public JavaPrimaryKeyJoinColumnTextRangeResolver(JavaPrimaryKeyJoinColumn column, CompilationUnit astRoot) {
- super(column, astRoot);
- }
-
- @Override
- protected JavaPrimaryKeyJoinColumn getColumn() {
- return (JavaPrimaryKeyJoinColumn) super.getColumn();
- }
-
- public TextRange getReferencedColumnNameTextRange() {
- return this.getColumn().getReferencedColumnNameTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java
deleted file mode 100644
index 3c8479c886..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTableTextRangeResolver.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaBaseTable;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaTableTextRangeResolver
- implements TableTextRangeResolver
-{
- protected final JavaBaseTable javaTable;
-
- protected final CompilationUnit astRoot;
-
- public JavaTableTextRangeResolver(JavaBaseTable javaTable, CompilationUnit astRoot) {
- this.javaTable = javaTable;
- this.astRoot = astRoot;
- }
-
- protected JavaBaseTable getTable() {
- return this.javaTable;
- }
-
- public TextRange getNameTextRange() {
- return this.javaTable.getNameTextRange(this.astRoot);
- }
-
- public TextRange getCatalogTextRange() {
- return this.javaTable.getCatalogTextRange(this.astRoot);
- }
-
- public TextRange getSchemaTextRange() {
- return this.javaTable.getSchemaTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java
deleted file mode 100644
index 197f4e9512..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTransientMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.TransientAnnotation;
-
-public class JavaTransientMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaTransientMappingDefinition INSTANCE =
- new JavaTransientMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaTransientMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return TransientAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaTransientMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java
deleted file mode 100644
index 5cf551e98b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaTypeMappingTextRangeResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class JavaTypeMappingTextRangeResolver
- implements TypeMappingTextRangeResolver
-{
- private JavaTypeMapping typeMapping;
-
- private CompilationUnit astRoot;
-
- public JavaTypeMappingTextRangeResolver(JavaTypeMapping typeMapping, CompilationUnit astRoot) {
- this.typeMapping = typeMapping;
- this.astRoot = astRoot;
- }
-
- public TextRange getTypeMappingTextRange() {
- return this.typeMapping.getValidationTextRange(this.astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java
deleted file mode 100644
index dc674b492a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/JavaVersionMappingDefinition.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.JpaFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.resource.java.VersionAnnotation;
-
-public class JavaVersionMappingDefinition
- extends AbstractJavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaVersionMappingDefinition INSTANCE =
- new JavaVersionMappingDefinition();
-
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaVersionMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return VersionAnnotation.ANNOTATION_NAME;
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute parent, JpaFactory factory) {
- return factory.buildJavaVersionMapping(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java
deleted file mode 100644
index debfe67de5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideAnnotation.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * javax.persistence.AssociationOverride
- */
-public abstract class VirtualAssociationOverrideAnnotation
- extends VirtualOverrideAnnotation
- implements AssociationOverrideAnnotation
-{
- protected JoiningStrategy joiningStrategy;
-
- private final Vector<JoinColumnAnnotation> joinColumns;
-
- protected VirtualAssociationOverrideAnnotation(JavaResourcePersistentMember parent, String name, JoiningStrategy joiningStrategy) {
- super(parent, name);
- this.joiningStrategy = joiningStrategy;
- this.joinColumns = this.buildJoinColumns();
- }
-
- protected Vector<JoinColumnAnnotation> buildJoinColumns() {
- if (this.joiningStrategy instanceof JoinColumnJoiningStrategy) {
- Vector<JoinColumnAnnotation> result = new Vector<JoinColumnAnnotation>(((JoinColumnJoiningStrategy) this.joiningStrategy).joinColumnsSize());
- for (JoinColumn joinColumn : CollectionTools.iterable(((JoinColumnJoiningStrategy) this.joiningStrategy).joinColumns())) {
- result.add(new VirtualAssociationOverrideJoinColumnAnnotation(this, joinColumn));
- }
- return result;
- }
- return new Vector<JoinColumnAnnotation>();
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- @Override
- protected AssociationOverrideAnnotation addAnnotation() {
- return (AssociationOverrideAnnotation) super.addAnnotation();
- }
-
- // ***** join columns
- public ListIterator<JoinColumnAnnotation> joinColumns() {
- return this.joinColumns.listIterator();
- }
-
- public JoinColumnAnnotation joinColumnAt(int index) {
- return this.joinColumns.elementAt(index);
- }
-
- public int indexOfJoinColumn(JoinColumnAnnotation joinColumn) {
- return this.joinColumns.indexOf(joinColumn);
- }
-
- public int joinColumnsSize() {
- return this.joinColumns.size();
- }
-
- public JoinColumnAnnotation addJoinColumn(int index) {
- throw new UnsupportedOperationException();
- }
-
- public void removeJoinColumn(int index) {
- throw new UnsupportedOperationException();
- }
-
- public void moveJoinColumn(int targetIndex, int sourceIndex) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void synchronizeWith(CompilationUnit astRoot) {
- super.synchronizeWith(astRoot);
- //Rebuilt every time so no need to implement update()
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java
deleted file mode 100644
index b782216bfb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAssociationOverrideJoinColumnAnnotation.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.internal.resource.java.NullBaseColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.Annotation;
-import org.eclipse.jpt.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * javax.persistence.Column
- */
-public final class VirtualAssociationOverrideJoinColumnAnnotation extends NullBaseColumnAnnotation
- implements JoinColumnAnnotation
-{
- private JoinColumn joinColumn;
-
- public VirtualAssociationOverrideJoinColumnAnnotation(Annotation parent, JoinColumn joinColumn) {
- super(parent);
- this.joinColumn = joinColumn;
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- @Override
- protected JoinColumnAnnotation addAnnotation() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getName() {
- return this.joinColumn.getSpecifiedName();
- }
-
- @Override
- public void setName(String name) {
- throw new UnsupportedOperationException();
- }
-
- public String getReferencedColumnName() {
- return this.joinColumn.getSpecifiedReferencedColumnName();
- }
-
- public void setReferencedColumnName(String referencedColumnName) {
- throw new UnsupportedOperationException();
- }
-
- public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) {
- return null;
- }
-
- public boolean referencedColumnNameTouches(int pos, CompilationUnit astRoot) {
- return false;
- }
-
- @Override
- public String getColumnDefinition() {
- return this.joinColumn.getColumnDefinition();
- }
-
- @Override
- public void setColumnDefinition(String columnDefinition) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getTable() {
- return this.joinColumn.getSpecifiedTable();
- }
-
- @Override
- public void setTable(String table) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getInsertable() {
- return this.joinColumn.getSpecifiedInsertable();
- }
-
- @Override
- public void setInsertable(Boolean insertable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getUpdatable() {
- return this.joinColumn.getSpecifiedUpdatable();
- }
-
- @Override
- public void setUpdatable(Boolean updatable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getNullable() {
- return this.joinColumn.getSpecifiedNullable();
- }
-
- @Override
- public void setNullable(Boolean nullable) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Boolean getUnique() {
- return this.joinColumn.getSpecifiedUnique();
- }
-
- @Override
- public void setUnique(Boolean unique) {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java
deleted file mode 100644
index 25e71fa18e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideAnnotation.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-
-/**
- * javax.persistence.AssociationOverride
- */
-public class VirtualAttributeOverrideAnnotation
- extends VirtualOverrideAnnotation
- implements AttributeOverrideAnnotation
-{
- private final VirtualAttributeOverrideColumnAnnotation column;
-
-
- public VirtualAttributeOverrideAnnotation(JavaResourcePersistentMember parent, String name, Column column) {
- super(parent, name);
- this.column = new VirtualAttributeOverrideColumnAnnotation(this, column);
- }
-
- public String getAnnotationName() {
- return ANNOTATION_NAME;
- }
-
- @Override
- protected AttributeOverrideAnnotation addAnnotation() {
- return (AttributeOverrideAnnotation) super.addAnnotation();
- }
-
- // ****** column
- public ColumnAnnotation getColumn() {
- return this.column;
- }
-
- public ColumnAnnotation getNonNullColumn() {
- return this.getColumn();
- }
-
- public ColumnAnnotation addColumn() {
- throw new UnsupportedOperationException();
- }
-
- public void removeColumn() {
- throw new UnsupportedOperationException();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java
deleted file mode 100644
index 89ebcab07c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualAttributeOverrideColumnAnnotation.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.internal.resource.java.NullAttributeOverrideColumnAnnotation;
-import org.eclipse.jpt.core.resource.java.AttributeOverrideAnnotation;
-
-/**
- * javax.persistence.Column
- */
-public class VirtualAttributeOverrideColumnAnnotation
- extends NullAttributeOverrideColumnAnnotation
-{
- private Column column;
-
- public VirtualAttributeOverrideColumnAnnotation(AttributeOverrideAnnotation parent, Column column) {
- super(parent);
- this.column = column;
- }
-
- @Override
- public String getName() {
- return this.column.getSpecifiedName();
- }
-
- @Override
- public String getColumnDefinition() {
- return this.column.getColumnDefinition();
- }
-
- @Override
- public String getTable() {
- return this.column.getSpecifiedTable();
- }
-
- @Override
- public Boolean getInsertable() {
- return this.column.getSpecifiedInsertable();
- }
-
- @Override
- public Boolean getUpdatable() {
- return this.column.getSpecifiedUpdatable();
- }
-
- @Override
- public Boolean getNullable() {
- return this.column.getSpecifiedNullable();
- }
-
- @Override
- public Boolean getUnique() {
- return this.column.getSpecifiedUnique();
- }
-
- @Override
- public Integer getLength() {
- return this.column.getSpecifiedLength();
- }
-
- @Override
- public Integer getScale() {
- return this.column.getSpecifiedScale();
- }
-
- @Override
- public Integer getPrecision() {
- return this.column.getSpecifiedPrecision();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java
deleted file mode 100644
index 01f16152ed..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/java/VirtualOverrideAnnotation.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.core.internal.resource.java.NullAnnotation;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.core.resource.java.OverrideAnnotation;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * Common behavior for virtual versions of
- * javax.persistence.AttributeOverride
- * and
- * javax.persistence.AssociationOverride
- */
-public abstract class VirtualOverrideAnnotation
- extends NullAnnotation
- implements OverrideAnnotation
-{
- private final String name;
-
- public VirtualOverrideAnnotation(JavaResourcePersistentMember parent, String name) {
- super(parent);
- this.name = name;
- }
-
- @Override
- protected OverrideAnnotation addAnnotation() {
- return (OverrideAnnotation) super.addAnnotation();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
- // ***** name
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- if (name != null) {
- this.addAnnotation().setName(name);
- }
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return null;
- }
-
- public boolean nameTouches(int pos, CompilationUnit astRoot) {
- return false;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java
deleted file mode 100644
index 7039399d28..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractEntityMappings.java
+++ /dev/null
@@ -1,890 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.MappingFileRoot;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.orm.EntityMappings;
-import org.eclipse.jpt.core.context.orm.OrmGenerator;
-import org.eclipse.jpt.core.context.orm.OrmPersistenceUnitDefaults;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.core.context.orm.OrmStructureNodes;
-import org.eclipse.jpt.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmXml;
-import org.eclipse.jpt.core.context.orm.PersistenceUnitMetadata;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> file
- * <br>
- * <code>entity-mappings</code> element
- */
-public abstract class AbstractEntityMappings
- extends AbstractOrmXmlContextNode
- implements EntityMappings
-{
- protected final XmlEntityMappings xmlEntityMappings;
-
- protected String description;
-
- protected String package_;
-
- protected AccessType specifiedAccess;
- protected AccessType defaultAccess;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected final PersistenceUnitMetadata persistenceUnitMetadata;
-
- protected final List<OrmPersistentType> persistentTypes;
-
- protected final List<OrmSequenceGenerator> sequenceGenerators;
-
- protected final List<OrmTableGenerator> tableGenerators;
-
- protected final OrmQueryContainer queryContainer;
-
-
- protected AbstractEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) {
- super(parent);
- this.xmlEntityMappings = xmlEntityMappings;
- this.persistentTypes = new ArrayList<OrmPersistentType>();
- this.sequenceGenerators = new ArrayList<OrmSequenceGenerator>();
- this.tableGenerators = new ArrayList<OrmTableGenerator>();
- this.queryContainer = this.getXmlContextNodeFactory().buildOrmQueryContainer(this, xmlEntityMappings);
-
- this.persistenceUnitMetadata = this.buildPersistenceUnitMetadata();
- this.description = this.xmlEntityMappings.getDescription();
- this.package_ = this.xmlEntityMappings.getPackage();
-
- this.defaultAccess = this.getPersistenceUnit().getDefaultAccess();
- this.specifiedAccess = this.getResourceAccess();
-
- this.defaultCatalog = this.getPersistenceUnit().getDefaultCatalog();
- this.specifiedCatalog = this.xmlEntityMappings.getCatalog();
-
- this.defaultSchema = this.getPersistenceUnit().getDefaultSchema();
- this.specifiedSchema = this.xmlEntityMappings.getSchema();
-
- this.initializePersistentTypes();
- this.initializeTableGenerators();
- this.initializeSequenceGenerators();
- }
-
- protected PersistenceUnitMetadata buildPersistenceUnitMetadata() {
- return this.getXmlContextNodeFactory().buildPersistenceUnitMetadata(this);
- }
-
- protected OrmPersistentType buildPersistentType(XmlTypeMapping resourceMapping) {
- return this.getXmlContextNodeFactory().buildOrmPersistentType(this, resourceMapping);
- }
-
- // **************** JpaNode impl *******************************************
-
- @Override
- public OrmXml getParent() {
- return (OrmXml) super.getParent();
- }
-
- protected OrmXml getOrmXml() {
- return this.getParent();
- }
-
-
- // **************** JpaContextNode impl ************************************
-
- @Override
- public MappingFileRoot getMappingFileRoot() {
- return this;
- }
-
-
- // **************** JpaStructureNode impl **********************************
-
- public String getId() {
- return OrmStructureNodes.ENTITY_MAPPINGS_ID;
- }
-
-
- // ********** PersistentType.Owner implementation **********
-
- public AccessType getOverridePersistentTypeAccess() {
- return this.isXmlMappingMetadataComplete() ? this.getSpecifiedAccess() : null;
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- return getAccess();
- }
-
- public String getDefaultPersistentTypePackage() {
- return getPackage();
- }
-
- protected boolean isXmlMappingMetadataComplete() {
- return this.persistenceUnitMetadata.isXmlMappingMetadataComplete();
- }
-
- public boolean isDefaultPersistentTypeMetadataComplete() {
- return this.isXmlMappingMetadataComplete();
- }
-
-
- // **************** EntityMappings impl ************************************
-
- public XmlEntityMappings getXmlEntityMappings() {
- return this.xmlEntityMappings;
- }
-
- public void changeMapping(OrmPersistentType ormPersistentType, OrmTypeMapping oldMapping, OrmTypeMapping newMapping) {
- AccessType savedAccess = ormPersistentType.getSpecifiedAccess();
- ormPersistentType.dispose();
- int sourceIndex = this.persistentTypes.indexOf(ormPersistentType);
- this.persistentTypes.remove(sourceIndex);
- oldMapping.removeFromResourceModel(this.xmlEntityMappings);
- int targetIndex = insertionIndex(ormPersistentType);
- this.persistentTypes.add(targetIndex, ormPersistentType);
- newMapping.addToResourceModel(this.xmlEntityMappings);
-
- newMapping.initializeFrom(oldMapping);
- //not sure where else to put this, need to set the access on the resource model
- ormPersistentType.setSpecifiedAccess(savedAccess);
- fireItemMoved(PERSISTENT_TYPES_LIST, targetIndex, sourceIndex);
- }
-
- public OrmPersistentType getPersistentType(String fullyQualifiedTypeName) {
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- if (ormPersistentType.isFor(fullyQualifiedTypeName)) {
- return ormPersistentType;
- }
- }
- return null;
- }
-
- public boolean containsPersistentType(String fullyQualifiedTypeName) {
- return getPersistentType(fullyQualifiedTypeName) != null;
- }
-
- public PersistentType resolvePersistentType(String className) {
- if (className == null) {
- return null;
- }
-
- //static inner class listed in orm.xml will use '$', replace with '.'
- className = className.replace('$', '.');
-
- // first try to resolve using only the locally specified name...
- PersistentType persistentType = getPersistenceUnit().getPersistentType(className);
- if (persistentType != null) {
- return persistentType;
- }
-
- // ...then try to resolve by prepending the global package name
- if (getPackage() == null) {
- return null;
- }
- return getPersistenceUnit().getPersistentType(getPackage() + '.' + className);
- }
-
- public JavaResourcePersistentType resolveJavaResourcePersistentType(String className) {
- if (className == null) {
- return null;
- }
-
- //static inner class listed in orm.xml will use '$', replace with '.'
- className = className.replace('$', '.');
-
- // first try to resolve using only the locally specified name...
- JavaResourcePersistentType jrpt = getJpaProject().getJavaResourcePersistentType(className);
- if (jrpt != null) {
- return jrpt;
- }
-
- // ...then try to resolve by prepending the global package name
- if (getPackage() == null) {
- return null;
- }
- return getJpaProject().getJavaResourcePersistentType(getPackage() + '.' + className);
- }
-
- public PersistenceUnitMetadata getPersistenceUnitMetadata() {
- return this.persistenceUnitMetadata;
- }
-
- public String getPackage() {
- return this.package_;
- }
-
- public void setPackage(String newPackage) {
- String oldPackage = this.package_;
- this.package_ = newPackage;
- this.xmlEntityMappings.setPackage(newPackage);
- firePropertyChanged(PACKAGE_PROPERTY, oldPackage, newPackage);
- }
-
- public String getVersion() {
- return this.xmlEntityMappings.getVersion();
- }
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String newDescription) {
- String oldDescription = this.description;
- this.description = newDescription;
- this.xmlEntityMappings.setDescription(newDescription);
- firePropertyChanged(DESCRIPTION_PROPERTY, oldDescription, newDescription);
- }
-
-
- // ********** access **********
-
- public AccessType getAccess() {
- return (this.specifiedAccess != null) ? this.specifiedAccess : this.defaultAccess;
- }
-
- public AccessType getSpecifiedAccess() {
- return this.specifiedAccess;
- }
-
- public void setSpecifiedAccess(AccessType access) {
- AccessType old = this.specifiedAccess;
- this.specifiedAccess = access;
- this.xmlEntityMappings.setAccess(AccessType.toOrmResourceModel(access));
- this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, access);
- }
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType access) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = access;
- this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, access);
- }
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.xmlEntityMappings.setSchema(schema);
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.xmlEntityMappings.setCatalog(catalog);
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
-
- // ********** schema container **********
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
-
- // ********** ORM persistent types **********
-
- public ListIterator<OrmPersistentType> persistentTypes() {
- return new CloneListIterator<OrmPersistentType>(this.persistentTypes);
- }
-
- public ListIterable<OrmPersistentType> getPersistentTypes() {
- return new LiveCloneListIterable<OrmPersistentType>(this.persistentTypes);
- }
-
- public int getPersistentTypesSize() {
- return this.persistentTypes.size();
- }
-
- public OrmPersistentType addPersistentType(String mappingKey, String className) {
- OrmTypeMappingDefinition mappingDefinition =
- getMappingFileDefinition().getOrmTypeMappingDefinition(mappingKey);
- XmlTypeMapping typeMapping =
- mappingDefinition.buildResourceMapping(getResourceNodeFactory());
- OrmPersistentType persistentType = buildPersistentType(typeMapping);
- int index = insertionIndex(persistentType);
- this.persistentTypes.add(index, persistentType);
- if (className.startsWith(getPackage() + '.')) {
- // adds short name if package name is specified
- className = className.substring(getPackage().length() + 1);
- }
- persistentType.getMapping().addToResourceModel(this.xmlEntityMappings);
- typeMapping.setClassName(className);
- fireItemAdded(PERSISTENT_TYPES_LIST, index, persistentType);
- return persistentType;
- }
-
- protected int insertionIndex(OrmPersistentType ormPersistentType) {
- return CollectionTools.insertionIndexOf(this.persistentTypes, ormPersistentType, MAPPING_COMPARATOR);
- }
-
- protected static final Comparator<OrmPersistentType> MAPPING_COMPARATOR =
- new Comparator<OrmPersistentType>() {
- public int compare(OrmPersistentType o1, OrmPersistentType o2) {
- int o1Sequence = o1.getMapping().getXmlSequence();
- int o2Sequence = o2.getMapping().getXmlSequence();
- if (o1Sequence < o2Sequence) {
- return -1;
- }
- if (o1Sequence == o2Sequence) {
- return 0;
- }
- return 1;
- }
- };
-
- public void removePersistentType(int index) {
- OrmPersistentType persistentType = this.persistentTypes.get(index);
- persistentType.dispose();
- this.persistentTypes.remove(index);
- persistentType.getMapping().removeFromResourceModel(this.xmlEntityMappings);
- fireItemRemoved(PERSISTENT_TYPES_LIST, index, persistentType);
- }
-
- public void removePersistentType(OrmPersistentType persistentType) {
- removePersistentType(this.persistentTypes.indexOf(persistentType));
- }
-
- protected void removePersistentType_(OrmPersistentType persistentType) {
- persistentType.dispose();
- removeItemFromList(persistentType, this.persistentTypes, PERSISTENT_TYPES_LIST);
- }
-
- protected void movePersistentType_(int index, OrmPersistentType persistentType) {
- moveItemInList(index, this.persistentTypes.indexOf(persistentType), this.persistentTypes, PERSISTENT_TYPES_LIST);
- }
-
-
- // ********** sequence generators **********
-
- public ListIterable<OrmSequenceGenerator> getSequenceGenerators() {
- return new LiveCloneListIterable<OrmSequenceGenerator>(this.sequenceGenerators);
- }
-
- public int getSequenceGeneratorsSize() {
- return this.sequenceGenerators.size();
- }
-
- public OrmSequenceGenerator addSequenceGenerator(int index) {
- XmlSequenceGenerator resourceSequenceGenerator = this.buildResourceSequenceGenerator();
- OrmSequenceGenerator contextSequenceGenerator = this.buildSequenceGenerator(resourceSequenceGenerator);
- this.sequenceGenerators.add(index, contextSequenceGenerator);
- this.xmlEntityMappings.getSequenceGenerators().add(index, resourceSequenceGenerator);
- fireItemAdded(SEQUENCE_GENERATORS_LIST, index, contextSequenceGenerator);
- return contextSequenceGenerator;
- }
-
- protected void addSequenceGenerator(int index, OrmSequenceGenerator sequenceGenerator) {
- addItemToList(index, sequenceGenerator, this.sequenceGenerators, EntityMappings.SEQUENCE_GENERATORS_LIST);
- }
-
- protected void addSequenceGenerator(OrmSequenceGenerator sequenceGenerator) {
- this.addSequenceGenerator(this.sequenceGenerators.size(), sequenceGenerator);
- }
-
- public void removeSequenceGenerator(OrmSequenceGenerator sequenceGenerator) {
- removeSequenceGenerator(this.sequenceGenerators.indexOf(sequenceGenerator));
- }
-
- public void removeSequenceGenerator(int index) {
- OrmSequenceGenerator removedSequenceGenerator = this.sequenceGenerators.remove(index);
- fireItemRemoved(SEQUENCE_GENERATORS_LIST, index, removedSequenceGenerator);
- this.xmlEntityMappings.getSequenceGenerators().remove(index);
- }
-
- protected void removeSequenceGenerator_(OrmSequenceGenerator sequenceGenerator) {
- removeItemFromList(sequenceGenerator, this.sequenceGenerators, EntityMappings.SEQUENCE_GENERATORS_LIST);
- }
-
- public void moveSequenceGenerator(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.sequenceGenerators, targetIndex, sourceIndex);
- this.xmlEntityMappings.getSequenceGenerators().move(targetIndex, sourceIndex);
- fireItemMoved(EntityMappings.SEQUENCE_GENERATORS_LIST, targetIndex, sourceIndex);
- }
-
- protected XmlSequenceGenerator buildResourceSequenceGenerator() {
- return OrmFactory.eINSTANCE.createXmlSequenceGenerator();
- }
-
- // ********** table generators **********
-
- public ListIterable<OrmTableGenerator> getTableGenerators() {
- return new LiveCloneListIterable<OrmTableGenerator>(this.tableGenerators);
- }
-
- public int getTableGeneratorsSize() {
- return this.tableGenerators.size();
- }
-
- public OrmTableGenerator addTableGenerator(int index) {
- XmlTableGenerator resourceTableGenerator = buildResourceTableGenerator();
- OrmTableGenerator contextTableGenerator = buildTableGenerator(resourceTableGenerator);
- this.tableGenerators.add(index, contextTableGenerator);
- this.xmlEntityMappings.getTableGenerators().add(index, resourceTableGenerator);
- fireItemAdded(TABLE_GENERATORS_LIST, index, contextTableGenerator);
- return contextTableGenerator;
- }
-
- protected void addTableGenerator(int index, OrmTableGenerator tableGenerator) {
- addItemToList(index, tableGenerator, this.tableGenerators, EntityMappings.TABLE_GENERATORS_LIST);
- }
-
- protected void addTableGenerator(OrmTableGenerator tableGenerator) {
- this.addTableGenerator(this.tableGenerators.size(), tableGenerator);
- }
-
- public void removeTableGenerator(OrmTableGenerator tableGenerator) {
- removeTableGenerator(this.tableGenerators.indexOf(tableGenerator));
- }
-
- public void removeTableGenerator(int index) {
- OrmTableGenerator removedTableGenerator = this.tableGenerators.remove(index);
- this.xmlEntityMappings.getTableGenerators().remove(index);
- fireItemRemoved(TABLE_GENERATORS_LIST, index, removedTableGenerator);
- }
-
- protected void removeTableGenerator_(OrmTableGenerator tableGenerator) {
- removeItemFromList(tableGenerator, this.tableGenerators, EntityMappings.TABLE_GENERATORS_LIST);
- }
-
- public void moveTableGenerator(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.tableGenerators, targetIndex, sourceIndex);
- this.xmlEntityMappings.getTableGenerators().move(targetIndex, sourceIndex);
- fireItemMoved(EntityMappings.TABLE_GENERATORS_LIST, targetIndex, sourceIndex);
- }
-
- protected XmlTableGenerator buildResourceTableGenerator() {
- return OrmFactory.eINSTANCE.createXmlTableGenerator();
- }
-
-
- // ********** named queries **********
- public OrmQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
-
- // ********** misc **********
-
- public OrmPersistenceUnitDefaults getPersistenceUnitDefaults() {
- return this.persistenceUnitMetadata.getPersistenceUnitDefaults();
- }
-
-
- // ********** initialization **********
-
- protected void initializePersistentTypes() {
- for (XmlTypeMapping typeMapping : this.xmlEntityMappings.getTypeMappings()) {
- addPersistentType(typeMapping);
- }
- }
-
- protected void initializeTableGenerators() {
- for (XmlTableGenerator tableGenerator : this.xmlEntityMappings.getTableGenerators()) {
- this.tableGenerators.add(buildTableGenerator(tableGenerator));
- }
- }
-
- protected void initializeSequenceGenerators() {
- for (XmlSequenceGenerator sequenceGenerator : this.xmlEntityMappings.getSequenceGenerators()) {
- this.sequenceGenerators.add(buildSequenceGenerator(sequenceGenerator));
- }
- }
-
-
- // ********** update **********
-
- public void update() {
- this.setDescription(this.xmlEntityMappings.getDescription());
- this.setPackage(this.xmlEntityMappings.getPackage());
-
- this.setDefaultAccess(this.getPersistenceUnit().getDefaultAccess());
- this.setSpecifiedAccess(this.getResourceAccess());
-
- this.setDefaultCatalog(this.getPersistenceUnit().getDefaultCatalog());
- this.setSpecifiedCatalog(this.xmlEntityMappings.getCatalog());
-
- this.setDefaultSchema(this.getPersistenceUnit().getDefaultSchema());
- this.setSpecifiedSchema(this.xmlEntityMappings.getSchema());
-
- this.persistenceUnitMetadata.update();
- this.updatePersistentTypes();
- this.updateTableGenerators();
- this.updateSequenceGenerators();
- getQueryContainer().update();
- }
-
- protected AccessType getResourceAccess() {
- return AccessType.fromOrmResourceModel(this.xmlEntityMappings.getAccess());
- }
-
- protected void updatePersistentTypes() {
- Collection<OrmPersistentType> contextTypesToRemove = CollectionTools.collection(persistentTypes());
- Collection<OrmPersistentType> contextTypesToUpdate = new ArrayList<OrmPersistentType>();
- int resourceIndex = 0;
-
- List<XmlTypeMapping> xmlTypeMappings = this.xmlEntityMappings.getTypeMappings();
- for (XmlTypeMapping xmlTypeMapping : xmlTypeMappings.toArray(new XmlTypeMapping[xmlTypeMappings.size()])) {
- boolean contextAttributeFound = false;
- for (OrmPersistentType contextType : contextTypesToRemove) {
- if (contextType.getMapping().getResourceTypeMapping() == xmlTypeMapping) {
- movePersistentType_(resourceIndex, contextType);
- contextTypesToRemove.remove(contextType);
- contextTypesToUpdate.add(contextType);
- contextAttributeFound = true;
- break;
- }
- }
- if (!contextAttributeFound) {
- OrmPersistentType ormPersistentType = addPersistentType(xmlTypeMapping);
- fireItemAdded(PERSISTENT_TYPES_LIST, getPersistentTypesSize(), ormPersistentType);
- }
- resourceIndex++;
- }
- for (OrmPersistentType contextType : contextTypesToRemove) {
- removePersistentType_(contextType);
- }
- //first handle adding/removing of the persistent types, then update the others last,
- //this causes less churn in the update process
- for (OrmPersistentType contextType : contextTypesToUpdate) {
- contextType.update();
- }
- }
-
- //not firing change notification so this can be reused in initialize and update
- protected OrmPersistentType addPersistentType(XmlTypeMapping resourceMapping) {
- OrmPersistentType ormPersistentType = buildPersistentType(resourceMapping);
- this.persistentTypes.add(ormPersistentType);
- return ormPersistentType;
- }
-
- protected void updateTableGenerators() {
- // make a copy of the XML generators (to prevent ConcurrentModificationException)
- Iterator<XmlTableGenerator> xmlGenerators = new CloneIterator<XmlTableGenerator>(this.xmlEntityMappings.getTableGenerators());
-
- for (OrmTableGenerator contextGenerator : this.getTableGenerators()) {
- if (xmlGenerators.hasNext()) {
- contextGenerator.update(xmlGenerators.next());
- } else {
- this.removeTableGenerator_(contextGenerator);
- }
- }
-
- while (xmlGenerators.hasNext()) {
- addTableGenerator(buildTableGenerator(xmlGenerators.next()));
- }
- }
-
- protected OrmTableGenerator buildTableGenerator(XmlTableGenerator resourceTableGenerator) {
- return getXmlContextNodeFactory().buildOrmTableGenerator(this, resourceTableGenerator);
- }
-
- protected void updateSequenceGenerators() {
- // make a copy of the XML sequence generators (to prevent ConcurrentModificationException)
- Iterator<XmlSequenceGenerator> xmlSequenceGenerators = new CloneIterator<XmlSequenceGenerator>(this.xmlEntityMappings.getSequenceGenerators());//prevent ConcurrentModificiationException
-
- for (OrmSequenceGenerator contextSequenceGenerator : this.getSequenceGenerators()) {
- if (xmlSequenceGenerators.hasNext()) {
- contextSequenceGenerator.update(xmlSequenceGenerators.next());
- }
- else {
- removeSequenceGenerator_(contextSequenceGenerator);
- }
- }
-
- while (xmlSequenceGenerators.hasNext()) {
- addSequenceGenerator(buildSequenceGenerator(xmlSequenceGenerators.next()));
- }
- }
-
- protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator resourceSequenceGenerator) {
- return getXmlContextNodeFactory().buildOrmSequenceGenerator(this, resourceSequenceGenerator);
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- for (PersistentType persistentType : this.getPersistentTypes()) {
- persistentType.postUpdate();
- }
- }
-
- // ********** text **********
-
- public JpaStructureNode getStructureNode(int textOffset) {
- for (OrmPersistentType persistentType: this.getPersistentTypes()) {
- if (persistentType.contains(textOffset)) {
- return persistentType.getStructureNode(textOffset);
- }
- }
- return this;
- }
-
- public boolean containsOffset(int textOffset) {
- return (this.xmlEntityMappings != null) && this.xmlEntityMappings.containsOffset(textOffset);
- }
-
- public TextRange getSelectionTextRange() {
- return this.xmlEntityMappings.getSelectionTextRange();
- }
-
- public TextRange getValidationTextRange() {
- return null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateVersion(messages);
- this.validateGenerators(messages);
- this.queryContainer.validate(messages, reporter);
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- this.validatePersistentType(ormPersistentType, messages, reporter);
- }
- }
-
- protected void validateVersion(List<IMessage> messages) {
- if (! latestDocumentVersion().equals(this.xmlEntityMappings.getVersion())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.LOW_SEVERITY,
- JpaValidationMessages.XML_VERSION_NOT_LATEST,
- this,
- this.xmlEntityMappings.getVersionTextRange()));
- }
- }
-
- /**
- * Return the latest version of the document supported by the platform
- */
- protected abstract String latestDocumentVersion();
-
- protected void validateGenerators(List<IMessage> messages) {
- for (OrmGenerator localGenerator : this.getGenerators()) {
- for (Iterator<Generator> globalGenerators = this.getPersistenceUnit().generators(); globalGenerators.hasNext(); ) {
- if (localGenerator.duplicates(globalGenerators.next())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- new String[] {localGenerator.getName()},
- localGenerator,
- localGenerator.getNameTextRange()
- )
- );
- }
- }
- }
- }
-
- /**
- * Return all the generators, table and sequence.
- */
- @SuppressWarnings("unchecked")
- protected Iterable<OrmGenerator> getGenerators() {
- return new CompositeIterable<OrmGenerator>(
- this.getTableGenerators(),
- this.getSequenceGenerators()
- );
- }
-
-
- protected void validatePersistentType(OrmPersistentType persistentType, List<IMessage> messages, IReporter reporter) {
- try {
- persistentType.validate(messages, reporter);
- } catch (Throwable exception) {
- JptCorePlugin.log(exception);
- }
- }
-
-
- // ********** refactoring **********
-
- public Iterable<DeleteEdit> createDeleteTypeEdits(final IType type) {
- return new CompositeIterable<DeleteEdit>(
- new TransformationIterable<OrmPersistentType, Iterable<DeleteEdit>>(getPersistentTypes()) {
- @Override
- protected Iterable<DeleteEdit> transform(OrmPersistentType persistentType) {
- return persistentType.createDeleteTypeEdits(type);
- }
- }
- );
- }
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(final IType originalType, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<OrmPersistentType, Iterable<ReplaceEdit>>(getPersistentTypes()) {
- @Override
- protected Iterable<ReplaceEdit> transform(OrmPersistentType persistentType) {
- return persistentType.createRenameTypeEdits(originalType, newName);
- }
- }
- );
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(final IType originalType, final IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<OrmPersistentType, Iterable<ReplaceEdit>>(getPersistentTypes()) {
- @Override
- protected Iterable<ReplaceEdit> transform(OrmPersistentType persistentType) {
- return persistentType.createMoveTypeEdits(originalType, newPackage);
- }
- }
- );
- }
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createRenamePackageEdits(final IPackageFragment originalPackage, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- this.createPersistentTypeRenamePackageEdits(originalPackage, newName),
- this.createRenamePackageEdit(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createPersistentTypeRenamePackageEdits(final IPackageFragment originalPackage, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<OrmPersistentType, Iterable<ReplaceEdit>>(getPersistentTypes()) {
- @Override
- protected Iterable<ReplaceEdit> transform(OrmPersistentType persistentType) {
- return persistentType.createRenamePackageEdits(originalPackage, newName);
- }
- }
- );
- }
-
- protected Iterable<ReplaceEdit> createRenamePackageEdit(final IPackageFragment originalPackage, final String newName) {
- if (this.package_ != null && originalPackage.getElementName().equals(this.package_)) {
- return new SingleElementIterable<ReplaceEdit>(this.xmlEntityMappings.createRenamePackageEdit(newName));
- }
- return EmptyIterable.instance();
- }
-
-
- // ********** dispose **********
-
- public void dispose() {
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- ormPersistentType.dispose();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAssociationOverrideRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAssociationOverrideRelationshipReference.java
deleted file mode 100644
index de18403841..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAssociationOverrideRelationshipReference.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.context.AssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnInAssociationOverrideJoiningStrategy;
-import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmAssociationOverrideRelationshipReference extends AbstractOrmXmlContextNode
- implements OrmAssociationOverrideRelationshipReference
-{
-
- // cache the strategy for property change notification
- protected JoiningStrategy cachedPredominantJoiningStrategy;
-
- protected OrmJoinColumnInAssociationOverrideJoiningStrategy joinColumnJoiningStrategy;
-
- protected AbstractOrmAssociationOverrideRelationshipReference(OrmAssociationOverride parent, XmlAssociationOverride xao) {
- super(parent);
- this.initializeJoiningStrategies(xao);
- }
-
- protected OrmJoinColumnInAssociationOverrideJoiningStrategy buildJoinColumnJoiningStrategy(XmlAssociationOverride xao) {
- return new GenericOrmJoinColumnInAssociationOverrideJoiningStrategy(this, xao);
- }
-
- public void initializeFrom(AssociationOverrideRelationshipReference oldAssociationOverride) {
- if (oldAssociationOverride.getJoinColumnJoiningStrategy().hasSpecifiedJoinColumns()) {
- getJoinColumnJoiningStrategy().initializeFrom(oldAssociationOverride.getJoinColumnJoiningStrategy());
- }
- }
-
- @Override
- public OrmAssociationOverride getParent() {
- return (OrmAssociationOverride) super.getParent();
- }
-
- public OrmAssociationOverride getAssociationOverride() {
- return getParent();
- }
-
- public TypeMapping getTypeMapping() {
- return getAssociationOverride().getOwner().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public boolean isParentVirtual() {
- return getAssociationOverride().isVirtual();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-
- // **************** predominant joining strategy ***************************
-
- public JoiningStrategy getPredominantJoiningStrategy() {
- return this.cachedPredominantJoiningStrategy;
- }
-
- protected void setPredominantJoiningStrategy(JoiningStrategy newJoiningStrategy) {
- JoiningStrategy oldJoiningStrategy = this.cachedPredominantJoiningStrategy;
- this.cachedPredominantJoiningStrategy = newJoiningStrategy;
- firePropertyChanged(PREDOMINANT_JOINING_STRATEGY_PROPERTY, oldJoiningStrategy, newJoiningStrategy);
- }
-
- protected void initialize(XmlAssociationOverride associationOverride) {
- initializeJoiningStrategies(associationOverride);
- this.cachedPredominantJoiningStrategy = calculatePredominantJoiningStrategy();
- }
-
- protected void initializeJoiningStrategies(XmlAssociationOverride xao) {
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy(xao);
- }
-
- public void update(XmlAssociationOverride associationOverride) {
- updateJoiningStrategies(associationOverride);
- setPredominantJoiningStrategy(calculatePredominantJoiningStrategy());
- }
-
- protected void updateJoiningStrategies(XmlAssociationOverride associationOverride) {
- this.joinColumnJoiningStrategy.update(associationOverride);
- }
-
- protected abstract JoiningStrategy calculatePredominantJoiningStrategy();
-
- // **************** join columns *******************************************
-
-
- public OrmJoinColumnInAssociationOverrideJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.addStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return getAssociationOverride().getOwner().getRelationshipMapping(getAssociationOverride().getName());
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return getRelationshipMapping().isOwnedBy(mapping);
- }
-
- public boolean isRelationshipOwner() {
- return getRelationshipMapping().isRelationshipOwner();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.joinColumnJoiningStrategy.validate(messages, reporter);
- }
-
- public TextRange getValidationTextRange() {
- return getAssociationOverride().getValidationTextRange();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java
deleted file mode 100644
index d3ba184bdd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmAttributeMapping.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.ColumnMapping;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.EntityMappings;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmBaseEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddedIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmMultiRelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmSingleRelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmTransientMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.core.internal.jpa2.context.SimpleMetamodelField;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmAttributeMapping<T extends XmlAttributeMapping>
- extends AbstractOrmXmlContextNode
- implements OrmAttributeMapping, AttributeMapping2_0
-{
- protected String name;
-
- protected final T resourceAttributeMapping;
-
- protected AbstractOrmAttributeMapping(OrmPersistentAttribute parent, T resourceAttributeMapping) {
- super(parent);
- this.resourceAttributeMapping = resourceAttributeMapping;
- this.name = this.getResourceMappingName();
- }
-
- protected JavaPersistentAttribute getJavaPersistentAttribute() {
- return this.getPersistentAttribute().getJavaPersistentAttribute();
- }
-
- protected JavaResourcePersistentAttribute getJavaResourcePersistentAttribute() {
- return this.getJavaPersistentAttribute().getResourcePersistentAttribute();
- }
-
- public boolean isVirtual() {
- return getPersistentAttribute().isVirtual();
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.resourceAttributeMapping.setName(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- this.getPersistentAttribute().nameChanged(old, name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- this.getPersistentAttribute().nameChanged(old, name);
- }
-
- public OrmPersistentAttribute getPersistentAttribute() {
- return (OrmPersistentAttribute) getParent();
- }
-
- protected EntityMappings getEntityMappings() {
- return this.getPersistentAttribute().getOwningPersistentType().getParent();
- }
-
- protected PersistentType resolvePersistentType(String className) {
- return this.getEntityMappings().resolvePersistentType(className);
- }
-
- public boolean isDefault() {
- return false;
- }
-
- public void initializeFromOrmAttributeMapping(OrmAttributeMapping oldMapping) {
- setName(oldMapping.getName());
- }
-
- public void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- initializeFromOrmAttributeMapping((OrmAttributeMapping) oldMapping);
- }
-
- public void initializeFromOrmBasicMapping(OrmBasicMapping oldMapping) {
- initializeFromOrmColumnMapping(oldMapping);
- }
-
- public void initializeFromOrmIdMapping(OrmIdMapping oldMapping) {
- initializeFromOrmColumnMapping(oldMapping);
- }
-
- public void initializeFromOrmTransientMapping(OrmTransientMapping oldMapping) {
- initializeFromOrmAttributeMapping(oldMapping);
- }
-
- public void initializeFromOrmBaseEmbeddedMapping(OrmBaseEmbeddedMapping oldMapping) {
- initializeFromOrmAttributeMapping(oldMapping);
- }
-
- public void initializeFromOrmEmbeddedMapping(OrmEmbeddedMapping oldMapping) {
- initializeFromOrmBaseEmbeddedMapping(oldMapping);
- }
-
- public void initializeFromOrmEmbeddedIdMapping(OrmEmbeddedIdMapping oldMapping) {
- initializeFromOrmBaseEmbeddedMapping(oldMapping);
- }
-
- public void initializeFromOrmVersionMapping(OrmVersionMapping oldMapping) {
- initializeFromOrmColumnMapping(oldMapping);
- }
-
- public void initializeFromOrmRelationshipMapping(OrmRelationshipMapping oldMapping) {
- initializeFromOrmAttributeMapping(oldMapping);
- }
-
- public void initializeFromOrmMultiRelationshipMapping(OrmMultiRelationshipMapping oldMapping) {
- initializeFromOrmRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmSingleRelationshipMapping(OrmSingleRelationshipMapping oldMapping) {
- initializeFromOrmRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmOneToManyMapping(OrmOneToManyMapping oldMapping) {
- initializeFromOrmMultiRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmManyToOneMapping(OrmManyToOneMapping oldMapping) {
- initializeFromOrmSingleRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmOneToOneMapping(OrmOneToOneMapping oldMapping) {
- initializeFromOrmSingleRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmManyToManyMapping(OrmManyToManyMapping oldMapping) {
- initializeFromOrmMultiRelationshipMapping(oldMapping);
- }
-
- public String getPrimaryKeyColumnName() {
- return null;
- }
-
- public OrmTypeMapping getTypeMapping() {
- return this.getPersistentAttribute().getOwningTypeMapping();
- }
-
-
- public boolean isOverridableAttributeMapping() {
- return false;
- }
-
- public boolean isOverridableAssociationMapping() {
- return false;
- }
-
- public boolean isRelationshipOwner() {
- return false;
- }
-
- public boolean isOwnedBy(AttributeMapping mapping) {
- // Default implementation - override where needed
- return false;
- }
-
- public Iterator<String> allMappingNames() {
- return getName() == null ? EmptyIterator.<String> instance() : new SingleElementIterator<String>(getName());
- }
-
- public AttributeMapping resolveAttributeMapping(String attributeName) {
- if (getName() != null && getName().equals(attributeName)) {
- return this;
- }
- return null;
- }
-
- public Iterator<String> allOverrideableAttributeMappingNames() {
- if (isOverridableAttributeMapping() && getName() != null) {
- return new SingleElementIterator<String>(getName());
- }
- return EmptyIterator.<String> instance();
- }
-
- public Iterator<String> allOverrideableAssociationMappingNames() {
- if (isOverridableAssociationMapping() && getName() != null) {
- return new SingleElementIterator<String>(getName());
- }
- return EmptyIterator.<String> instance();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- ColumnMapping columnMapping = this.resolveColumnMapping(attributeName);
- return columnMapping == null ? null : columnMapping.getColumn();
- }
-
- protected ColumnMapping resolveColumnMapping(String attributeName) {
- AttributeMapping attributeMapping = resolveAttributeMapping(attributeName);
- if (attributeMapping != null && attributeMapping.isOverridableAttributeMapping()) {
- return (ColumnMapping) attributeMapping;
- }
- return null;
- }
-
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- RelationshipMapping relationshipMapping = this.resolveRelationshipMapping(attributeName);
- return relationshipMapping == null ? null : relationshipMapping.getRelationshipReference();
- }
-
- protected RelationshipMapping resolveRelationshipMapping(String attributeName) {
- AttributeMapping attributeMapping = resolveAttributeMapping(attributeName);
- if (attributeMapping != null && attributeMapping.isOverridableAssociationMapping()) {
- return (RelationshipMapping) attributeMapping;
- }
- return null;
- }
-
- public T getResourceAttributeMapping() {
- return this.resourceAttributeMapping;
- }
-
- public void update() {
- this.setName_(this.getResourceMappingName());
- }
-
- protected String getResourceMappingName() {
- return this.resourceAttributeMapping.getName();
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return this.getTypeMapping().shouldValidateAgainstDatabase();
- }
-
- public boolean contains(int textOffset) {
- return this.resourceAttributeMapping.containsOffset(textOffset);
- }
-
- public TextRange getSelectionTextRange() {
- return this.resourceAttributeMapping.getSelectionTextRange();
- }
-
- public TextRange getValidationTextRange() {
- return (this.getPersistentAttribute().isVirtual()) ? this.getTypeMapping().getAttributesTextRange() : this.resourceAttributeMapping.getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.resourceAttributeMapping.getNameTextRange();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** metamodel **********
-
- public MetamodelField getMetamodelField() {
- // if we don't have a name we can't build a metamodel field...
- String metamodelFieldName = this.getMetamodelFieldName();
- return (metamodelFieldName == null) ? null :
- new SimpleMetamodelField(
- this.getMetamodelFieldModifiers(),
- this.getMetamodelFieldTypeName(),
- this.getMetamodelFieldTypeArgumentNames(),
- metamodelFieldName
- );
- }
-
- protected Iterable<String> getMetamodelFieldModifiers() {
- return STANDARD_METAMODEL_FIELD_MODIFIERS;
- }
-
- /**
- * most mappings are "singular"
- */
- protected String getMetamodelFieldTypeName() {
- return JPA2_0.SINGULAR_ATTRIBUTE;
- }
-
- protected final Iterable<String> getMetamodelFieldTypeArgumentNames() {
- ArrayList<String> typeArgumentNames = new ArrayList<String>(3);
- typeArgumentNames.add(this.getTypeMapping().getPersistentType().getName());
- this.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames);
- return typeArgumentNames;
- }
-
- /**
- * by default, we add only the mapping's attribute type name;
- * but collection relationship mappings will also need to add the key type
- * name if the "collection" is of type java.util.Map
- */
- protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) {
- typeArgumentNames.add(this.getMetamodelTypeName());
- }
-
- public String getMetamodelTypeName() {
- return ((OrmPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelTypeName();
- }
-
- protected String getMetamodelFieldName() {
- return this.getName();
- }
-
-
- // ********** refactoring **********
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return EmptyIterable.instance();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateAttribute(messages);
- this.validateMapping(messages);
- }
-
- protected void validateAttribute(List<IMessage> messages) {
- if (StringTools.stringIsEmpty(this.name)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNSPECIFIED_NAME,
- this,
- this.getValidationTextRange()
- )
- );
- return;
- }
- }
-
- //TODO validation message - i think more info is needed in this message. include type mapping type?
- protected void validateMapping(List<IMessage> messages) {
- if ( ! this.getTypeMapping().attributeMappingKeyAllowed(this.getKey())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_MAPPING,
- new String[] {this.name},
- this,
- this.getValidationTextRange()
- )
- );
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseColumn.java
deleted file mode 100644
index f059e95f93..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseColumn.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmBaseColumn;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-
-
-public abstract class AbstractOrmBaseColumn<T extends AbstractXmlColumn> extends AbstractOrmNamedColumn<T>
- implements OrmBaseColumn
-{
- protected String specifiedTable;
-
- protected String defaultTable;
-
- protected Boolean specifiedUnique;
-
- protected Boolean specifiedNullable;
-
- protected Boolean specifiedInsertable;
-
- protected Boolean specifiedUpdatable;
-
- protected AbstractOrmBaseColumn(XmlContextNode parent, OrmBaseColumn.Owner owner) {
- super(parent, owner);
- }
-
- public void initializeFrom(BaseColumn oldColumn) {
- super.initializeFrom(oldColumn);
- setSpecifiedTable(oldColumn.getSpecifiedTable());
- setSpecifiedUnique(oldColumn.getSpecifiedUnique());
- setSpecifiedNullable(oldColumn.getSpecifiedNullable());
- setSpecifiedInsertable(oldColumn.getSpecifiedInsertable());
- setSpecifiedUpdatable(oldColumn.getSpecifiedUpdatable());
- }
-
- @Override
- public OrmBaseColumn.Owner getOwner() {
- return (OrmBaseColumn.Owner) super.getOwner();
- }
-
-// @Override
-// protected void addInsignificantXmlFeatureIdsTo(Set<Integer> insignificantXmlFeatureIds) {
-// super.addInsignificantXmlFeatureIdsTo(insignificantXmlFeatureIds);
-// insignificantXmlFeatureIds.add(JpaCoreMappingsPackage.IABSTRACT_COLUMN__DEFAULT_TABLE);
-// insignificantXmlFeatureIds.add(JpaCoreMappingsPackage.IABSTRACT_COLUMN__TABLE);
-// }
-
- @Override
- public String getTable() {
- return (this.getSpecifiedTable() == null) ? getDefaultTable() : this.getSpecifiedTable();
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- public void setSpecifiedTable(String newSpecifiedTable) {
- String oldSpecifiedTable = this.specifiedTable;
- this.specifiedTable = newSpecifiedTable;
- if (this.valuesAreDifferent(oldSpecifiedTable, newSpecifiedTable)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setTable(newSpecifiedTable);
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newSpecifiedTable != null) {
- addResourceColumn();
- getResourceColumn().setTable(newSpecifiedTable);
- }
- }
- firePropertyChanged(BaseColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
- }
-
- protected void setSpecifiedTable_(String newSpecifiedTable) {
- String oldSpecifiedTable = this.specifiedTable;
- this.specifiedTable = newSpecifiedTable;
- firePropertyChanged(BaseColumn.SPECIFIED_TABLE_PROPERTY, oldSpecifiedTable, newSpecifiedTable);
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String newDefaultTable) {
- String oldDefaultTable = this.defaultTable;
- this.defaultTable = newDefaultTable;
- firePropertyChanged(BaseColumn.DEFAULT_TABLE_PROPERTY, oldDefaultTable, newDefaultTable);
- }
-
- public boolean tableNameIsInvalid() {
- return getOwner().tableNameIsInvalid(getTable());
- }
-
- public Iterator<String> candidateTableNames() {
- return getOwner().candidateTableNames();
- }
-
- public boolean isUnique() {
- return (this.getSpecifiedUnique() == null) ? this.isDefaultUnique() : this.getSpecifiedUnique().booleanValue();
- }
-
- public boolean isDefaultUnique() {
- return BaseColumn.DEFAULT_UNIQUE;
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- public void setSpecifiedUnique(Boolean newSpecifiedUnique) {
- Boolean oldSpecifiedUnique = this.specifiedUnique;
- this.specifiedUnique = newSpecifiedUnique;
- if (this.valuesAreDifferent(oldSpecifiedUnique, newSpecifiedUnique)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setUnique(newSpecifiedUnique);
- if (this.getResourceColumn().isUnset()) {
- removeResourceColumn();
- }
- }
- else if (newSpecifiedUnique != null) {
- addResourceColumn();
- getResourceColumn().setUnique(newSpecifiedUnique);
- }
- }
- firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
- }
-
- protected void setSpecifiedUnique_(Boolean newSpecifiedUnique) {
- Boolean oldSpecifiedUnique = this.specifiedUnique;
- this.specifiedUnique = newSpecifiedUnique;
- firePropertyChanged(BaseColumn.SPECIFIED_UNIQUE_PROPERTY, oldSpecifiedUnique, newSpecifiedUnique);
- }
-
- public boolean isNullable() {
- return (this.getSpecifiedNullable() == null) ? this.isDefaultNullable() : this.getSpecifiedNullable().booleanValue();
- }
-
- public boolean isDefaultNullable() {
- return BaseColumn.DEFAULT_NULLABLE;
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- public void setSpecifiedNullable(Boolean newSpecifiedNullable) {
- Boolean oldSpecifiedNullable = this.specifiedNullable;
- this.specifiedNullable = newSpecifiedNullable;
- if (this.valuesAreDifferent(oldSpecifiedNullable, newSpecifiedNullable)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setNullable(newSpecifiedNullable);
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newSpecifiedNullable != null) {
- addResourceColumn();
- getResourceColumn().setNullable(newSpecifiedNullable);
- }
- }
- firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
- }
-
- protected void setSpecifiedNullable_(Boolean newSpecifiedNullable) {
- Boolean oldSpecifiedNullable = this.specifiedNullable;
- this.specifiedNullable = newSpecifiedNullable;
- firePropertyChanged(BaseColumn.SPECIFIED_NULLABLE_PROPERTY, oldSpecifiedNullable, newSpecifiedNullable);
- }
-
- public boolean isInsertable() {
- return (this.getSpecifiedInsertable() == null) ? this.isDefaultInsertable() : this.getSpecifiedInsertable().booleanValue();
- }
-
- public boolean isDefaultInsertable() {
- return BaseColumn.DEFAULT_INSERTABLE;
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- public void setSpecifiedInsertable(Boolean newSpecifiedInsertable) {
- Boolean oldSpecifiedInsertable = this.specifiedInsertable;
- this.specifiedInsertable = newSpecifiedInsertable;
- if (this.valuesAreDifferent(oldSpecifiedInsertable, newSpecifiedInsertable)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setInsertable(newSpecifiedInsertable);
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newSpecifiedInsertable != null) {
- addResourceColumn();
- getResourceColumn().setInsertable(newSpecifiedInsertable);
- }
- }
- firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
- }
-
- protected void setSpecifiedInsertable_(Boolean newSpecifiedInsertable) {
- Boolean oldSpecifiedInsertable = this.specifiedInsertable;
- this.specifiedInsertable = newSpecifiedInsertable;
- firePropertyChanged(BaseColumn.SPECIFIED_INSERTABLE_PROPERTY, oldSpecifiedInsertable, newSpecifiedInsertable);
- }
-
- public boolean isUpdatable() {
- return (this.getSpecifiedUpdatable() == null) ? this.isDefaultUpdatable() : this.getSpecifiedUpdatable().booleanValue();
- }
-
- public boolean isDefaultUpdatable() {
- return BaseColumn.DEFAULT_UPDATABLE;
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- public void setSpecifiedUpdatable(Boolean newSpecifiedUpdatable) {
- Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
- this.specifiedUpdatable = newSpecifiedUpdatable;
- if (this.valuesAreDifferent(oldSpecifiedUpdatable, newSpecifiedUpdatable)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setUpdatable(newSpecifiedUpdatable);
- if (this.getResourceColumn().isUnset()) {
- removeResourceColumn();
- }
- }
- else if (newSpecifiedUpdatable != null) {
- addResourceColumn();
- getResourceColumn().setUpdatable(newSpecifiedUpdatable);
- }
- }
- firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
- }
-
- protected void setSpecifiedUpdatable_(Boolean newSpecifiedUpdatable) {
- Boolean oldSpecifiedUpdatable = this.specifiedUpdatable;
- this.specifiedUpdatable = newSpecifiedUpdatable;
- firePropertyChanged(BaseColumn.SPECIFIED_UPDATABLE_PROPERTY, oldSpecifiedUpdatable, newSpecifiedUpdatable);
- }
-
- public TextRange getTableTextRange() {
- if (getResourceColumn() != null) {
- TextRange textRange = getResourceColumn().getTableTextRange();
- if (textRange != null) {
- return textRange;
- }
- }
- return this.getParent().getValidationTextRange();
- }
-
- @Override
- protected void initialize(T column) {
- super.initialize(column);
- this.specifiedTable = this.getResourceTable(column);
- this.defaultTable = this.buildDefaultTableName();
- //TODO default from java for all of these settings
- this.specifiedNullable = this.getResourceNullable(column);
- this.specifiedUpdatable = this.getResourceUpdatable(column);
- this.specifiedUnique = this.getResourceUnique(column);
- this.specifiedInsertable = this.getResourceInsertable(column);
- }
-
- @Override
- protected void update(T column) {
- super.update(column);
- setSpecifiedTable_(this.getResourceTable(column));
- setDefaultTable(this.buildDefaultTableName());
- setSpecifiedNullable_(this.getResourceNullable(column));
- setSpecifiedUpdatable_(this.getResourceUpdatable(column));
- setSpecifiedUnique_(this.getResourceUnique(column));
- setSpecifiedInsertable_(this.getResourceInsertable(column));
- }
-
- protected String getResourceTable(T column) {
- return column == null ? null : column.getTable();
- }
-
- protected Boolean getResourceNullable(T column) {
- return column == null ? null : column.getNullable();
- }
-
- protected Boolean getResourceUpdatable(T column) {
- return column == null ? null : column.getUpdatable();
- }
-
- protected Boolean getResourceUnique(T column) {
- return column == null ? null : column.getUnique();
- }
-
- protected Boolean getResourceInsertable(T column) {
- return column == null ? null : column.getInsertable();
- }
-
- protected String buildDefaultTableName() {
- return getOwner().getDefaultTableName();
- }
-
- @Override
- protected NamedColumnTextRangeResolver buildTextRangeResolver() {
- return new OrmBaseColumnTextRangeResolver(this);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
deleted file mode 100644
index fba6e55f02..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.java.JavaBaseEmbeddedMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.orm.OrmBaseEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlEmbedded;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.Transformer;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmBaseEmbeddedMapping<T extends AbstractXmlEmbedded>
- extends AbstractOrmAttributeMapping<T>
- implements OrmBaseEmbeddedMapping
-{
- protected OrmAttributeOverrideContainer attributeOverrideContainer;
-
- protected Embeddable targetEmbeddable;
-
-
- protected AbstractOrmBaseEmbeddedMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.targetEmbeddable = embeddableFor(this.getJavaPersistentAttribute());
- this.attributeOverrideContainer
- = getXmlContextNodeFactory().buildOrmAttributeOverrideContainer(
- this,
- buildAttributeOverrideContainerOwner());
- }
-
-
- protected OrmAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() {
- return new AttributeOverrideContainerOwner();
- }
-
- @Override
- public void initializeFromOrmBaseEmbeddedMapping(OrmBaseEmbeddedMapping oldMapping) {
- super.initializeFromOrmBaseEmbeddedMapping(oldMapping);
- this.attributeOverrideContainer.initializeFromAttributeOverrideContainer(oldMapping.getAttributeOverrideContainer());
- }
-
- public OrmAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- protected JavaAttributeOverride getJavaAttributeOverrideNamed(String attributeName) {
- if (getJavaEmbeddedMapping() != null) {
- return getJavaEmbeddedMapping().getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- }
- return null;
- }
-
- public Embeddable getTargetEmbeddable() {
- return this.targetEmbeddable;
- }
-
- protected void setTargetEmbeddable_(Embeddable newTargetEmbeddable) {
- Embeddable oldTargetEmbeddable = this.targetEmbeddable;
- this.targetEmbeddable = newTargetEmbeddable;
- firePropertyChanged(TARGET_EMBEDDABLE_PROPERTY, oldTargetEmbeddable, newTargetEmbeddable);
- }
-
- protected Iterator<AttributeMapping> embeddableAttributeMappings() {
- Embeddable targetEmbeddable = getTargetEmbeddable();
- if (targetEmbeddable != null && targetEmbeddable != getPersistentAttribute().getOwningTypeMapping()) {
- return targetEmbeddable.attributeMappings();
- }
- return EmptyIterator.instance();
- }
-
- @Override
- public Iterator<String> allOverrideableAttributeMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverrideableAttributeMappingNames() :
- super.allOverrideableAttributeMappingNames();
- }
-
- protected Iterator<String> embeddableOverrideableAttributeMappingNames() {
- return this.embeddableOverrideableMappingNames(
- new Transformer<AttributeMapping, Iterator<String>>() {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAttributeMappingNames();
- }
- }
- );
- }
-
- @Override
- public Iterator<String> allOverrideableAssociationMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverrideableAssociationMappingNames() :
- super.allOverrideableAssociationMappingNames();
- }
-
- protected Iterator<String> embeddableOverrideableAssociationMappingNames() {
- return this.embeddableOverrideableMappingNames(
- new Transformer<AttributeMapping, Iterator<String>>() {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAssociationMappingNames();
- }
- }
- );
- }
-
- protected Iterator<String> embeddableOverrideableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<String, String>(
- new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer)))
- {
- @Override
- protected String transform(String next) {
- return getName() + '.' + next;
- }
- };
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- if (getName() == null) {
- return null;
- }
- if (this.isJpa2_0Compatible()) {
- int dotIndex = attributeName.indexOf('.');
- if (dotIndex != -1) {
- if (getName().equals(attributeName.substring(0, dotIndex))) {
- attributeName = attributeName.substring(dotIndex + 1);
- AttributeOverride override = getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- if (override != null && !override.isVirtual()) {
- return override.getColumn();
- }
- if (this.getTargetEmbeddable() == null) {
- return null;
- }
- return this.getTargetEmbeddable().resolveOverriddenColumn(attributeName);
- }
- }
- }
- return null;
- }
-
- public JavaBaseEmbeddedMapping getJavaEmbeddedMapping() {
- JavaPersistentAttribute jpa = this.getJavaPersistentAttribute();
- if ((jpa != null) && this.valuesAreEqual(jpa.getMappingKey(), this.getKey())) {
- return (JavaBaseEmbeddedMapping) jpa.getMapping();
- }
- return null;
- }
-
-
- @Override
- public void update() {
- super.update();
- setTargetEmbeddable_(embeddableFor(this.getJavaPersistentAttribute()));
- getAttributeOverrideContainer().update();
- }
-
-
- //******** Validation ******************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- if (validateTargetEmbeddable(messages, reporter)) {
- validateOverrides(messages, reporter);
- }
- }
-
- protected boolean validateTargetEmbeddable(List<IMessage> messages, IReporter reporter) {
- if (getTargetEmbeddable() == null) {
- String targetEmbeddableTypeName = getPersistentAttribute().getTypeName();
- // if the type isn't resolveable, there'll already be a java error
- if (targetEmbeddableTypeName != null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_NOT_AN_EMBEDDABLE,
- new String[] {targetEmbeddableTypeName},
- this,
- this.getValidationTextRange()));
- }
- return false;
- }
- return true;
- }
-
- protected void validateOverrides(List<IMessage> messages, IReporter reporter) {
- getAttributeOverrideContainer().validate(messages, reporter);
- }
-
- //************ static methods ************
-
- public static Embeddable embeddableFor(JavaPersistentAttribute javaPersistentAttribute) {
- return (javaPersistentAttribute == null) ? null : javaPersistentAttribute.getEmbeddable();
- }
-
-
- //********** AttributeOverrideContainer.Owner implementation *********
-
- protected class AttributeOverrideContainerOwner
- implements OrmAttributeOverrideContainer.Owner
- {
- public OrmTypeMapping getTypeMapping() {
- return AbstractOrmBaseEmbeddedMapping.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractOrmBaseEmbeddedMapping.this.getTargetEmbeddable();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : allOverridableAttributeNames_(typeMapping);
- }
-
- /* assumes the type mapping is not null */
- protected Iterator<String> allOverridableAttributeNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAttributeNames();
- }
-
- public EList<XmlAttributeOverride> getResourceAttributeOverrides() {
- return AbstractOrmBaseEmbeddedMapping.this.resourceAttributeMapping.getAttributeOverrides();
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- if (getPersistentAttribute().isVirtual() && !getTypeMapping().isMetadataComplete()) {
- JavaAttributeOverride javaAttributeOverride = getJavaAttributeOverrideNamed(attributeOverrideName);
- if (javaAttributeOverride != null && !javaAttributeOverride.isVirtual()) {
- return javaAttributeOverride.getColumn();
- }
- }
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public XmlColumn buildVirtualXmlColumn(Column overridableColumn, String attributeName, boolean isMetadataComplete) {
- return new VirtualXmlAttributeOverrideColumn(overridableColumn);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator(getPersistentAttribute(), (AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator(getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmBaseEmbeddedMapping.this.getValidationTextRange();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBasicMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBasicMapping.java
deleted file mode 100644
index 9b8c362169..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmBasicMapping.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BasicMapping;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.Fetchable;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.Nullable;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.core.context.orm.OrmConverter;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmBasicMapping<T extends XmlBasic>
- extends AbstractOrmAttributeMapping<T>
- implements OrmBasicMapping
-{
- protected final OrmColumn column;
-
- protected FetchType specifiedFetch;
-
- protected Boolean specifiedOptional;
-
- protected OrmConverter converter;
-
- protected final OrmConverter nullConverter;
-
- protected AbstractOrmBasicMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.column = getXmlContextNodeFactory().buildOrmColumn(this, this);
- this.column.initialize(this.getResourceColumn());//TODO pass in to factory
- this.specifiedFetch = this.getResourceFetch();
- this.specifiedOptional = this.getResourceOptional();
- this.nullConverter = this.getXmlContextNodeFactory().buildOrmNullConverter(this);
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
- public FetchType getFetch() {
- return (this.getSpecifiedFetch() == null) ? this.getDefaultFetch() : this.getSpecifiedFetch();
- }
-
- public FetchType getDefaultFetch() {
- return BasicMapping.DEFAULT_FETCH_TYPE;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType newSpecifiedFetch) {
- FetchType oldFetch = this.specifiedFetch;
- this.specifiedFetch = newSpecifiedFetch;
- this.resourceAttributeMapping.setFetch(FetchType.toOrmResourceModel(newSpecifiedFetch));
- firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch);
- }
-
- protected void setSpecifiedFetch_(FetchType newSpecifiedFetch) {
- FetchType oldFetch = this.specifiedFetch;
- this.specifiedFetch = newSpecifiedFetch;
- firePropertyChanged(Fetchable.SPECIFIED_FETCH_PROPERTY, oldFetch, newSpecifiedFetch);
- }
-
- public boolean isOptional() {
- return (this.getSpecifiedOptional() == null) ? this.isDefaultOptional() : this.getSpecifiedOptional().booleanValue();
- }
-
- public boolean isDefaultOptional() {
- return Nullable.DEFAULT_OPTIONAL;
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean newSpecifiedOptional) {
- Boolean oldOptional = this.specifiedOptional;
- this.specifiedOptional = newSpecifiedOptional;
- this.resourceAttributeMapping.setOptional(newSpecifiedOptional);
- firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional);
- }
-
- protected void setSpecifiedOptional_(Boolean newSpecifiedOptional) {
- Boolean oldOptional = this.specifiedOptional;
- this.specifiedOptional = newSpecifiedOptional;
- firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, oldOptional, newSpecifiedOptional);
- }
-
- public OrmConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- OrmConverter oldConverter = this.converter;
- OrmConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(OrmConverter newConverter) {
- OrmConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmBasicMapping(this);
- }
-
-
- @Override
- public void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- super.initializeFromOrmColumnMapping(oldMapping);
- getColumn().initializeFrom(oldMapping.getColumn());
- }
-
- public int getXmlSequence() {
- return 20;
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
- public OrmColumn getColumn() {
- return this.column;
- }
-
- public String getDefaultColumnName() {
- return getName();
- }
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- @Override
- public void update() {
- super.update();
- this.setSpecifiedFetch_(this.getResourceFetch());
- this.setSpecifiedOptional_(this.getResourceOptional());
- this.column.update(this.getResourceColumn());
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update();
- }
- else {
- setConverter(buildConverter(getResourceConverterType()));
- }
- }
-
- protected Boolean getResourceOptional() {
- return this.resourceAttributeMapping.getOptional();
- }
-
- protected FetchType getResourceFetch() {
- return FetchType.fromOrmResourceModel(this.resourceAttributeMapping.getFetch());
- }
-
- protected OrmConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.ENUMERATED_CONVERTER)) {
- return getXmlContextNodeFactory().buildOrmEnumeratedConverter(this, this.resourceAttributeMapping);
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getXmlContextNodeFactory().buildOrmTemporalConverter(this, this.resourceAttributeMapping);
- }
- if (this.valuesAreEqual(converterType, Converter.LOB_CONVERTER)) {
- return getXmlContextNodeFactory().buildOrmLobConverter(this, this.resourceAttributeMapping);
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.resourceAttributeMapping.getEnumerated() != null) {
- return Converter.ENUMERATED_CONVERTER;
- }
- else if (this.resourceAttributeMapping.getTemporal() != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- else if (this.resourceAttributeMapping.isLob()) {
- return Converter.LOB_CONVERTER;
- }
-
- return Converter.NO_CONVERTER;
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getBasics().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getBasics().remove(this.resourceAttributeMapping);
- }
-
- //***************** XmlColumn.Owner implementation ****************
-
- public XmlColumn getResourceColumn() {
- return this.resourceAttributeMapping.getColumn();
- }
-
- public void addResourceColumn() {
- this.resourceAttributeMapping.setColumn(OrmFactory.eINSTANCE.createXmlColumn());
- }
-
- public void removeResourceColumn() {
- this.resourceAttributeMapping.setColumn(null);
- }
-
-
- //************ refactoring ************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createConverterRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createConverterRenameTypeEdits(IType originalType, String newName) {
- if (getConverter() != null) {
- return getConverter().createRenameTypeEdits(originalType, newName);
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createConverterMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createConverterMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (getConverter() != null) {
- return getConverter().createMoveTypeEdits(originalType, newPackage);
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createConverterRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (getConverter() != null) {
- return getConverter().createRenamePackageEdits(originalPackage, newName);
- }
- return EmptyIterable.instance();
- }
-
-
- // ****************** validation ****************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- getColumn().validate(messages, reporter);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEmbeddable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEmbeddable.java
deleted file mode 100644
index 67f61d556c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEmbeddable.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Oracle. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-
-
-public abstract class AbstractOrmEmbeddable
- extends AbstractOrmTypeMapping<XmlEmbeddable>
- implements OrmEmbeddable
-{
- protected AbstractOrmEmbeddable(OrmPersistentType parent, XmlEmbeddable resourceMapping) {
- super(parent, resourceMapping);
- }
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 2;
- }
-
- public JavaEmbeddable getJavaEmbeddable() {
- JavaPersistentType javaPersistentType = this.getJavaPersistentType();
- if (javaPersistentType != null && javaPersistentType.getMappingKey() == MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY) {
- return (JavaEmbeddable) javaPersistentType.getMapping();
- }
- return null;
- }
-
- /**
- * This checks metaDataComplete before returning the JavaEmbeddable.
- * As far as defaults are concerned, if metadataComplete is true, the JavaEmbeddable is ignored.
- */
- protected JavaEmbeddable getJavaEmbeddableForDefaults() {
- if (isMetadataComplete()) {
- return null;
- }
- return getJavaEmbeddable();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public Iterator<Table> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<Table> associatedTablesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public void addToResourceModel(XmlEntityMappings entityMappings) {
- entityMappings.getEmbeddables().add(this.resourceTypeMapping);
- }
-
- public void removeFromResourceModel(XmlEntityMappings entityMappings) {
- entityMappings.getEmbeddables().remove(this.resourceTypeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java
deleted file mode 100644
index 98a8d85d2a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmEntity.java
+++ /dev/null
@@ -1,2071 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaPlatformVariation.Supported;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AssociationOverride;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.core.context.DiscriminatorType;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.InheritanceType;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.SecondaryTable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.java.JavaColumn;
-import org.eclipse.jpt.core.context.java.JavaEntity;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.java.JavaTable;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.orm.OrmBaseJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmDiscriminatorColumn;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmGeneratorContainer;
-import org.eclipse.jpt.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.core.context.orm.OrmSecondaryTable;
-import org.eclipse.jpt.core.context.orm.OrmTable;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideJoinTableValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AssociationOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.DiscriminatorColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericEntityPrimaryKeyValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.MappedSuperclassOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.SecondaryTableValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.TableValidator;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheableHolder2_0;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.orm.Inheritance;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.utility.internal.ClassName;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmEntity
- extends AbstractOrmTypeMapping<XmlEntity>
- implements OrmEntity, OrmCacheableHolder2_0
-{
- protected String specifiedName;
-
- protected String defaultName;
-
- protected final OrmIdClassReference idClassReference;
-
- protected final OrmTable table;
-
- protected boolean specifiedTableIsAllowed;
-
- protected boolean tableIsUndefined;
-
- protected final List<OrmSecondaryTable> specifiedSecondaryTables;
-
- protected final List<OrmSecondaryTable> virtualSecondaryTables;
-
- protected final List<OrmPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns;
-
- protected final List<OrmPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns;
-
- protected InheritanceType specifiedInheritanceStrategy;
-
- protected InheritanceType defaultInheritanceStrategy;
-
- protected String defaultDiscriminatorValue;
-
- protected String specifiedDiscriminatorValue;
-
- protected boolean specifiedDiscriminatorValueIsAllowed;
-
- protected boolean discriminatorValueIsUndefined;
-
- protected final OrmDiscriminatorColumn discriminatorColumn;
-
- protected boolean specifiedDiscriminatorColumnIsAllowed;
-
- protected boolean discriminatorColumnIsUndefined;
-
- protected final OrmGeneratorContainer generatorContainer;
-
- protected final OrmAttributeOverrideContainer attributeOverrideContainer;
-
- protected final OrmAssociationOverrideContainer associationOverrideContainer;
-
- protected final OrmQueryContainer queryContainer;
-
- protected Entity rootEntity;
-
- protected AbstractOrmEntity(OrmPersistentType parent, XmlEntity resourceMapping) {
- super(parent, resourceMapping);
- this.idClassReference = buildIdClassReference();
- this.table = getXmlContextNodeFactory().buildOrmTable(this, new TableOwner());
- this.specifiedSecondaryTables = new ArrayList<OrmSecondaryTable>();
- this.virtualSecondaryTables = new ArrayList<OrmSecondaryTable>();
- this.discriminatorColumn = buildDiscriminatorColumn();
- this.specifiedPrimaryKeyJoinColumns = new ArrayList<OrmPrimaryKeyJoinColumn>();
- this.defaultPrimaryKeyJoinColumns = new ArrayList<OrmPrimaryKeyJoinColumn>();
- this.associationOverrideContainer = buildAssociationOverrideContainer();
- this.attributeOverrideContainer = buildAttributeOverrideContainer();
- this.queryContainer = this.buildQueryContainer();
- this.generatorContainer = this.buildGeneratorContainer();
- this.specifiedName = this.resourceTypeMapping.getName();
- this.defaultName = this.buildDefaultName();
- this.rootEntity = this.calculateRootEntity();
- this.initializeInheritance(this.getResourceInheritance());
- this.specifiedDiscriminatorColumnIsAllowed = this.buildSpecifiedDiscriminatorColumnIsAllowed();
- this.discriminatorColumnIsUndefined = this.buildDiscriminatorColumnIsUndefined();
- this.discriminatorColumn.initialize(this.resourceTypeMapping); //TODO pass in to constructor
- this.specifiedDiscriminatorValueIsAllowed = this.buildSpecifiedDiscriminatorValueIsAllowed();
- this.discriminatorValueIsUndefined = this.buildDiscriminatorValueIsUndefined();
- this.specifiedDiscriminatorValue = this.resourceTypeMapping.getDiscriminatorValue();
- this.defaultDiscriminatorValue = this.buildDefaultDiscriminatorValue();
- this.specifiedTableIsAllowed = this.buildSpecifiedTableIsAllowed();
- this.tableIsUndefined = this.buildTableIsUndefined();
- this.table.initialize(this.resourceTypeMapping);//TODO pass in to constructor
- this.initializeSpecifiedSecondaryTables();
- this.initializeVirtualSecondaryTables();
- this.initializeSpecifiedPrimaryKeyJoinColumns();
- this.initializeDefaultPrimaryKeyJoinColumns();
- }
-
- protected OrmIdClassReference buildIdClassReference() {
- return new GenericOrmIdClassReference(this, getJavaIdClassReferenceForDefaults());
- }
-
- protected OrmDiscriminatorColumn buildDiscriminatorColumn() {
- return getXmlContextNodeFactory().buildOrmDiscriminatorColumn(this, buildDiscriminatorColumnOwner());
- }
-
- protected OrmDiscriminatorColumn.Owner buildDiscriminatorColumnOwner() {
- return new OrmDiscriminatorColumn.Owner(){
- public String getDefaultTableName() {
- return AbstractOrmEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractOrmEntity.this.getDbTable(tableName);
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractOrmEntity.this;
- }
-
- public String getDefaultColumnName() {
- if (getResourceTypeMapping().getDiscriminatorColumn() == null) {
- if (!isMetadataComplete()) {
- if (getJavaEntity() != null && getJavaEntity().getDiscriminatorColumn().getSpecifiedName() != null) {
- return getJavaEntity().getDiscriminatorColumn().getSpecifiedName();
- }
- }
- }
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getName()
- :
- isTablePerClass() ?
- null
- :
- DiscriminatorColumn.DEFAULT_NAME;
- }
-
- public int getDefaultLength() {
- if (getResourceTypeMapping().getDiscriminatorColumn() == null) {
- if (!isMetadataComplete()) {
- if (getJavaEntity() != null && getJavaEntity().getDiscriminatorColumn().getSpecifiedLength() != null) {
- return getJavaEntity().getDiscriminatorColumn().getSpecifiedLength().intValue();
- }
- }
- }
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getLength()
- :
- isTablePerClass() ?
- 0//TODO think i want to return null here
- :
- DiscriminatorColumn.DEFAULT_LENGTH;
- }
-
- public DiscriminatorType getDefaultDiscriminatorType() {
- if (getResourceTypeMapping().getDiscriminatorColumn() == null) {
- if (!isMetadataComplete()) {
- if (getJavaEntity() != null && getJavaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType() != null) {
- return getJavaEntity().getDiscriminatorColumn().getSpecifiedDiscriminatorType();
- }
- }
- }
- return isDescendant() ?
- getRootEntity().getDiscriminatorColumn().getDiscriminatorType()
- :
- isTablePerClass() ?
- null
- :
- DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE;
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new DiscriminatorColumnValidator(column, textRangeResolver);
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmEntity.this.getValidationTextRange();
- }
- };
- }
-
- protected OrmAssociationOverrideContainer buildAssociationOverrideContainer() {
- return getXmlContextNodeFactory().buildOrmAssociationOverrideContainer(
- this,
- new AssociationOverrideContainerOwner());
- }
-
- protected OrmAttributeOverrideContainer buildAttributeOverrideContainer() {
- return getXmlContextNodeFactory().buildOrmAttributeOverrideContainer(
- this,
- new AttributeOverrideContainerOwner());
- }
-
- protected OrmGeneratorContainer buildGeneratorContainer() {
- return getXmlContextNodeFactory().buildOrmGeneratorContainer(this, this.resourceTypeMapping);
- }
-
- protected OrmQueryContainer buildQueryContainer() {
- return getXmlContextNodeFactory().buildOrmQueryContainer(this, this.resourceTypeMapping);
- }
-
-
- // ******************* TypeMapping implementation ********************
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- @Override
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
- @Override
- public String getPrimaryTableName() {
- return this.table.getName();
- }
-
- @Override
- public org.eclipse.jpt.db.Table getPrimaryDbTable() {
- return this.table.getDbTable();
- }
-
- @Override
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- // matching database objects and identifiers is database platform-specific
- return this.getDataSource().selectDatabaseObjectForIdentifier(this.getAssociatedDbTablesIncludingInherited(), tableName);
- }
-
- private Iterable<org.eclipse.jpt.db.Table> getAssociatedDbTablesIncludingInherited() {
- return new FilteringIterable<org.eclipse.jpt.db.Table>(this.getAssociatedDbTablesIncludingInherited_()) {
- @Override
- protected boolean accept(org.eclipse.jpt.db.Table t) {
- return t != null;
- }
- };
- }
-
- private Iterable<org.eclipse.jpt.db.Table> getAssociatedDbTablesIncludingInherited_() {
- return new TransformationIterable<Table, org.eclipse.jpt.db.Table>(this.getAssociatedTablesIncludingInherited()) {
- @Override
- protected org.eclipse.jpt.db.Table transform(Table t) {
- return t.getDbTable();
- }
- };
- }
-
- @Override
- public Schema getDbSchema() {
- return this.table.getDbSchema();
- }
-
- public JavaEntity getJavaEntity() {
- JavaPersistentType javaPersistentType = this.getJavaPersistentType();
- if (javaPersistentType != null && javaPersistentType.getMappingKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) {
- return (JavaEntity) javaPersistentType.getMapping();
- }
- return null;
- }
-
- /**
- * This checks metaDataComplete before returning the JavaEntity.
- * As far as defaults are concerned, if metadataComplete is true, the JavaEntity is ignored.
- */
- protected JavaEntity getJavaEntityForDefaults() {
- if (isMetadataComplete()) {
- return null;
- }
- return getJavaEntity();
- }
-
- protected JavaIdClassReference getJavaIdClassReferenceForDefaults() {
- JavaEntity entity = getJavaEntityForDefaults();
- return (entity == null) ? null : entity.getIdClassReference();
- }
-
-
- //****************** OrmAttributeOverrideContainer.Owner implementation *******************
-
- public TypeMapping getOverridableTypeMapping() {
- PersistentType superPersistentType = getPersistentType().getSuperPersistentType();
- return superPersistentType == null ? null : superPersistentType.getMapping();
- }
-
- public OrmTypeMapping getTypeMapping() {
- return this;
- }
-
- protected JavaAttributeOverride getJavaAttributeOverrideNamed(String attributeName) {
- if (getJavaEntity() != null) {
- return getJavaEntity().getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- }
- return null;
- }
-
- @Override
- public RelationshipReference resolveRelationshipReference(String name) {
- if (this.isJpa2_0Compatible()) {
- int dotIndex = name.indexOf('.');
- if (dotIndex != -1) {
- AssociationOverride override = getAssociationOverrideContainer().getAssociationOverrideNamed(name.substring(dotIndex + 1));
- if (override != null && !override.isVirtual()) {
- return override.getRelationshipReference();
- }
- }
- }
- return super.resolveRelationshipReference(name);
- }
-
- protected JavaAssociationOverride getJavaAssociationOverrideNamed(String attributeName) {
- if (getJavaEntity() != null) {
- return getJavaEntity().getAssociationOverrideContainer().getAssociationOverrideNamed(attributeName);
- }
- return null;
- }
-
- // **************** name **************************************************
-
- @Override
- public String getName() {
- return (this.getSpecifiedName() == null) ? getDefaultName() : this.getSpecifiedName();
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- this.resourceTypeMapping.setName(newSpecifiedName);
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
-
- // **************** id class **********************************************
-
- public OrmIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
-
- // **************** table *************************************************
-
- public OrmTable getTable() {
- return this.table;
- }
-
- public ListIterator<OrmSecondaryTable> secondaryTables() {
- if (specifiedSecondaryTablesSize() > 0) {
- return specifiedSecondaryTables();
- }
- return virtualSecondaryTables();
- }
-
- public int secondaryTablesSize() {
- if (specifiedSecondaryTablesSize() > 0) {
- return specifiedSecondaryTablesSize();
- }
- return virtualSecondaryTablesSize();
- }
-
- public ListIterator<OrmSecondaryTable> virtualSecondaryTables() {
- return new CloneListIterator<OrmSecondaryTable>(this.virtualSecondaryTables);
- }
-
- public int virtualSecondaryTablesSize() {
- return this.virtualSecondaryTables.size();
- }
-
- protected void addVirtualSecondaryTable(OrmSecondaryTable secondaryTable) {
- addItemToList(secondaryTable, this.virtualSecondaryTables, OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST);
- }
-
- protected void removeVirtualSecondaryTable(OrmSecondaryTable secondaryTable) {
- removeItemFromList(secondaryTable, this.virtualSecondaryTables, OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST);
- }
-
- public ListIterator<OrmSecondaryTable> specifiedSecondaryTables() {
- return new CloneListIterator<OrmSecondaryTable>(this.specifiedSecondaryTables);
- }
-
- public int specifiedSecondaryTablesSize() {
- return this.specifiedSecondaryTables.size();
- }
-
- public OrmSecondaryTable addSpecifiedSecondaryTable(int index) {
- if (!secondaryTablesDefinedInXml()) {
- throw new IllegalStateException("Virtual secondary tables exist, must first call setSecondaryTablesDefinedInXml(true)"); //$NON-NLS-1$
- }
- XmlSecondaryTable secondaryTableResource = OrmFactory.eINSTANCE.createXmlSecondaryTable();
- OrmSecondaryTable secondaryTable = buildSecondaryTable(secondaryTableResource);
- this.specifiedSecondaryTables.add(index, secondaryTable);
- this.resourceTypeMapping.getSecondaryTables().add(index, secondaryTableResource);
- fireItemAdded(Entity.SPECIFIED_SECONDARY_TABLES_LIST, index, secondaryTable);
- return secondaryTable;
- }
-
- public OrmSecondaryTable addSpecifiedSecondaryTable() {
- return this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size());
- }
-
- protected void addSpecifiedSecondaryTable(int index, OrmSecondaryTable secondaryTable) {
- addItemToList(index, secondaryTable, this.specifiedSecondaryTables, Entity.SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- protected void addSpecifiedSecondaryTable(OrmSecondaryTable secondaryTable) {
- this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size(), secondaryTable);
- }
-
- public void removeSpecifiedSecondaryTable(SecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- public void removeSpecifiedSecondaryTable(int index) {
- OrmSecondaryTable removedSecondaryTable = this.specifiedSecondaryTables.remove(index);
- this.resourceTypeMapping.getSecondaryTables().remove(index);
- fireItemRemoved(Entity.SPECIFIED_SECONDARY_TABLES_LIST, index, removedSecondaryTable);
- }
-
- protected void removeSpecifiedSecondaryTable_(OrmSecondaryTable secondaryTable) {
- removeItemFromList(secondaryTable, this.specifiedSecondaryTables, Entity.SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- public void moveSpecifiedSecondaryTable(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedSecondaryTables, targetIndex, sourceIndex);
- this.resourceTypeMapping.getSecondaryTables().move(targetIndex, sourceIndex);
- fireItemMoved(Entity.SPECIFIED_SECONDARY_TABLES_LIST, targetIndex, sourceIndex);
- }
-
- public boolean containsSecondaryTable(String name) {
- return containsSecondaryTable(name, secondaryTables());
- }
-
- public boolean containsSpecifiedSecondaryTable(String name) {
- return containsSecondaryTable(name, specifiedSecondaryTables());
- }
-
- public boolean containsVirtualSecondaryTable(String name) {
- return containsSecondaryTable(name, virtualSecondaryTables());
- }
-
- public boolean containsVirtualSecondaryTable(OrmSecondaryTable secondaryTable) {
- return this.virtualSecondaryTables.contains(secondaryTable);
- }
-
- protected boolean containsSecondaryTable(String name, ListIterator<OrmSecondaryTable> secondaryTables) {
- for (OrmSecondaryTable secondaryTable : CollectionTools.iterable(secondaryTables)) {
- String secondaryTableName = secondaryTable.getName();
- if (secondaryTableName != null && secondaryTableName.equals(name)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean secondaryTablesDefinedInXml() {
- return virtualSecondaryTablesSize() == 0;
- }
-
- public void setSecondaryTablesDefinedInXml(boolean defineInXml) {
- if (defineInXml == secondaryTablesDefinedInXml()) {
- return;
- }
- if (defineInXml) {
- specifySecondaryTablesInXml();
- }
- else {
- removeSecondaryTablesFromXml();
- }
- }
-
- /**
- * This is used to take all the java secondary tables and specify them in the xml. You must
- * use setSecondaryTablesDefinedInXml(boolean) before calling addSpecifiedSecondaryTable().
- *
- * Yes this code looks odd, but be careful making changes to it
- */
- protected void specifySecondaryTablesInXml() {
- if (virtualSecondaryTablesSize() != 0) {
- List<OrmSecondaryTable> virtualSecondaryTables1 = CollectionTools.list(this.virtualSecondaryTables());
- List<OrmSecondaryTable> virtualSecondaryTables2 = CollectionTools.list(this.virtualSecondaryTables());
- //remove all the virtual secondary tables without firing change notification.
- for (OrmSecondaryTable virtualSecondaryTable : CollectionTools.iterable(virtualSecondaryTables())) {
- this.virtualSecondaryTables.remove(virtualSecondaryTable);
- }
- //add specified secondary tables for each virtual secondary table. If the virtual secondary tables
- //are not removed first, they will be removed as a side effect of adding the first specified secondary table.
- //This screws up the change notification to the UI, since that change notification is in a different thread
- for (OrmSecondaryTable virtualSecondaryTable : virtualSecondaryTables2) {
- XmlSecondaryTable secondaryTableResource = OrmFactory.eINSTANCE.createXmlSecondaryTable();
- OrmSecondaryTable specifiedSecondaryTable = buildSecondaryTable(secondaryTableResource);
- this.specifiedSecondaryTables.add(specifiedSecondaryTable);
- this.resourceTypeMapping.getSecondaryTables().add(secondaryTableResource);
- specifiedSecondaryTable.initializeFrom(virtualSecondaryTable);
- }
- //fire change notification at the end
- fireItemsRemoved(OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST, 0, virtualSecondaryTables1);
- fireItemsAdded(Entity.SPECIFIED_SECONDARY_TABLES_LIST, 0, this.specifiedSecondaryTables);
- }
- }
-
- protected void removeSecondaryTablesFromXml() {
- if (specifiedSecondaryTablesSize() != 0) {
- List<OrmSecondaryTable> specifiedSecondaryTablesCopy = CollectionTools.list(this.specifiedSecondaryTables());
- for (OrmSecondaryTable specifiedSecondaryTable : CollectionTools.iterable(specifiedSecondaryTables())) {
- int index = this.specifiedSecondaryTables.indexOf(specifiedSecondaryTable);
- this.specifiedSecondaryTables.remove(specifiedSecondaryTable);
- if (this.specifiedSecondaryTables.size() == 0) {
- initializeVirtualSecondaryTables();
- }
- this.resourceTypeMapping.getSecondaryTables().remove(index);
- }
- fireItemsRemoved(Entity.SPECIFIED_SECONDARY_TABLES_LIST, 0, specifiedSecondaryTablesCopy);
- if (this.virtualSecondaryTables.size() != 0) {
- fireItemsAdded(OrmEntity.VIRTUAL_SECONDARY_TABLES_LIST, 0, this.virtualSecondaryTables);
- }
- }
- }
-
- protected Iterator<String> tableNames(Iterator<Table> tables) {
- return new TransformationIterator<Table, String>(tables) {
- @Override
- protected String transform(Table t) {
- return t.getName();
- }
- };
- }
-
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return this.nonNullTableNames(this.associatedTablesIncludingInherited());
- }
-
- protected Iterator<String> nonNullTableNames(Iterator<Table> tables) {
- return new FilteringIterator<String>(this.tableNames(tables)) {
- @Override
- protected boolean accept(String o) {
- return o != null;
- }
- };
- }
-
- public Iterator<Table> associatedTables() {
- return new CompositeIterator<Table>(this.table, this.secondaryTables());
- }
-
- public Iterator<Table> associatedTablesIncludingInherited() {
- return this.getAssociatedTablesIncludingInherited().iterator();
- }
-
- public Iterable<Table> getAssociatedTablesIncludingInherited() {
- return new CompositeIterable<Table>(new TransformationIterable<TypeMapping, Iterable<Table>>(CollectionTools.iterable(this.inheritanceHierarchy())) {
- @Override
- protected Iterable<Table> transform(TypeMapping mapping) {
- return new FilteringIterable<Table>(CollectionTools.iterable(mapping.associatedTables())) {
- @Override
- protected boolean accept(Table o) {
- return true;
- //TODO
- //filtering these out so as to avoid the duplicate table, root and children share the same table
- //return !(o instanceof SingleTableInheritanceChildTableImpl);
- }
- };
- }
- });
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- if (tableIsUndefined()) {
- return false;
- }
- return ! CollectionTools.contains(this.associatedTableNamesIncludingInherited(), tableName);
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return super.shouldValidateAgainstDatabase() && ! isAbstractTablePerClass();
- }
-
- public InheritanceType getInheritanceStrategy() {
- return (this.getSpecifiedInheritanceStrategy() == null) ? this.getDefaultInheritanceStrategy() : this.getSpecifiedInheritanceStrategy();
- }
-
- public InheritanceType getDefaultInheritanceStrategy() {
- return this.defaultInheritanceStrategy;
- }
-
- protected void setDefaultInheritanceStrategy(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.defaultInheritanceStrategy;
- this.defaultInheritanceStrategy = newInheritanceType;
- firePropertyChanged(DEFAULT_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- public InheritanceType getSpecifiedInheritanceStrategy() {
- return this.specifiedInheritanceStrategy;
- }
-
- public void setSpecifiedInheritanceStrategy(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = newInheritanceType;
- if (oldInheritanceType != newInheritanceType) {
- if (this.getResourceInheritance() != null) {
- this.getResourceInheritance().setStrategy(InheritanceType.toOrmResourceModel(newInheritanceType));
- if (this.getResourceInheritance().isUnset()) {
- removeResourceInheritance();
- }
- }
- else if (newInheritanceType != null) {
- addResourceInheritance();
- getResourceInheritance().setStrategy(InheritanceType.toOrmResourceModel(newInheritanceType));
- }
- }
- firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- protected void setSpecifiedInheritanceStrategy_(InheritanceType newInheritanceType) {
- InheritanceType oldInheritanceType = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = newInheritanceType;
- firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, oldInheritanceType, newInheritanceType);
- }
-
- protected Inheritance getResourceInheritance() {
- return this.resourceTypeMapping.getInheritance();
- }
-
- protected void addResourceInheritance() {
- this.resourceTypeMapping.setInheritance(OrmFactory.eINSTANCE.createInheritance());
- }
-
- protected void removeResourceInheritance() {
- this.resourceTypeMapping.setInheritance(null);
- }
-
- public OrmDiscriminatorColumn getDiscriminatorColumn() {
- return this.discriminatorColumn;
- }
-
- public OrmGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- public String getDefaultDiscriminatorValue() {
- return this.defaultDiscriminatorValue;
- }
-
- protected void setDefaultDiscriminatorValue(String newDefaultDiscriminatorValue) {
- String oldDefaultDiscriminatorValue = this.defaultDiscriminatorValue;
- this.defaultDiscriminatorValue = newDefaultDiscriminatorValue;
- firePropertyChanged(DEFAULT_DISCRIMINATOR_VALUE_PROPERTY, oldDefaultDiscriminatorValue, newDefaultDiscriminatorValue);
- }
-
- public String getSpecifiedDiscriminatorValue() {
- return this.specifiedDiscriminatorValue;
- }
-
- public void setSpecifiedDiscriminatorValue(String newSpecifiedDiscriminatorValue) {
- String oldSpecifiedDiscriminatorValue = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = newSpecifiedDiscriminatorValue;
- this.resourceTypeMapping.setDiscriminatorValue(newSpecifiedDiscriminatorValue);
- firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, oldSpecifiedDiscriminatorValue, newSpecifiedDiscriminatorValue);
- }
-
- public String getDiscriminatorValue() {
- return (this.getSpecifiedDiscriminatorValue() == null) ? getDefaultDiscriminatorValue() : this.getSpecifiedDiscriminatorValue();
- }
-
- public boolean specifiedDiscriminatorValueIsAllowed() {
- return this.specifiedDiscriminatorValueIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorValueIsAllowed(boolean specifiedDiscriminatorValueIsAllowed) {
- boolean old = this.specifiedDiscriminatorValueIsAllowed;
- this.specifiedDiscriminatorValueIsAllowed = specifiedDiscriminatorValueIsAllowed;
- firePropertyChanged(Entity.SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorValueIsAllowed);
- }
-
- public boolean discriminatorValueIsUndefined() {
- return this.discriminatorValueIsUndefined;
- }
-
- protected void setDiscriminatorValueIsUndefined(boolean discriminatorValueIsUndefined) {
- boolean old = this.discriminatorValueIsUndefined;
- this.discriminatorValueIsUndefined = discriminatorValueIsUndefined;
- firePropertyChanged(Entity.DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, discriminatorValueIsUndefined);
- }
-
- public boolean specifiedDiscriminatorColumnIsAllowed() {
- return this.specifiedDiscriminatorColumnIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorColumnIsAllowed(boolean specifiedDiscriminatorColumnIsAllowed) {
- boolean old = this.specifiedDiscriminatorColumnIsAllowed;
- this.specifiedDiscriminatorColumnIsAllowed = specifiedDiscriminatorColumnIsAllowed;
- firePropertyChanged(Entity.SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, specifiedDiscriminatorColumnIsAllowed);
- }
-
- public boolean discriminatorColumnIsUndefined() {
- return this.discriminatorColumnIsUndefined;
- }
-
- protected void setDiscriminatorColumnIsUndefined(boolean discriminatorColumnIsUndefined) {
- boolean old = this.discriminatorColumnIsUndefined;
- this.discriminatorColumnIsUndefined = discriminatorColumnIsUndefined;
- firePropertyChanged(Entity.DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, discriminatorColumnIsUndefined);
- }
-
-
- public boolean specifiedTableIsAllowed() {
- return this.specifiedTableIsAllowed;
- }
-
- protected void setSpecifiedTableIsAllowed(boolean specifiedTableIsAllowed) {
- boolean old = this.specifiedTableIsAllowed;
- this.specifiedTableIsAllowed = specifiedTableIsAllowed;
- firePropertyChanged(Entity.SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed);
- }
-
- public boolean tableIsUndefined() {
- return this.tableIsUndefined;
- }
-
- protected void setTableIsUndefined(boolean tableIsUndefined) {
- boolean old = this.tableIsUndefined;
- this.tableIsUndefined = tableIsUndefined;
- firePropertyChanged(Entity.TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined);
- }
-
- public ListIterator<OrmPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns() {
- return new CloneListIterator<OrmPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumns);
- }
-
- public int defaultPrimaryKeyJoinColumnsSize() {
- return this.defaultPrimaryKeyJoinColumns.size();
- }
-
- public OrmPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() {
- throw new UnsupportedOperationException("use defaultPrimaryKeyJoinColumns() instead"); //$NON-NLS-1$
- }
-
- protected void addDefaultPrimaryKeyJoinColumn(OrmPrimaryKeyJoinColumn defaultPkJoinColumn) {
- addItemToList(defaultPkJoinColumn, this.defaultPrimaryKeyJoinColumns, OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void removeDefaultPrimaryKeyJoinColumn(PrimaryKeyJoinColumn defaultPkJoinColumn) {
- removeItemFromList(defaultPkJoinColumn, this.defaultPrimaryKeyJoinColumns, OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.specifiedPrimaryKeyJoinColumns.isEmpty() ? this.defaultPrimaryKeyJoinColumns() : this.specifiedPrimaryKeyJoinColumns();
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.isEmpty() ? this.defaultPrimaryKeyJoinColumnsSize() : this.specifiedPrimaryKeyJoinColumnsSize();
- }
-
- public ListIterator<OrmPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() {
- return new CloneListIterator<OrmPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- public int specifiedPrimaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.size();
- }
-
- public boolean containsSpecifiedPrimaryKeyJoinColumns() {
- return !this.specifiedPrimaryKeyJoinColumns.isEmpty();
- }
-
- public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) {
- if (!this.defaultPrimaryKeyJoinColumns.isEmpty()) {
- this.defaultPrimaryKeyJoinColumns.clear();
- }
- XmlPrimaryKeyJoinColumn resourcePkJoinColumn = OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn();
- OrmPrimaryKeyJoinColumn contextPkJoinColumn = buildPrimaryKeyJoinColumn(resourcePkJoinColumn);
- this.specifiedPrimaryKeyJoinColumns.add(index, contextPkJoinColumn);
- this.resourceTypeMapping.getPrimaryKeyJoinColumns().add(index, resourcePkJoinColumn);
-
- this.fireItemAdded(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, contextPkJoinColumn);
- this.fireListCleared(OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- return contextPkJoinColumn;
- }
-
- protected OrmBaseJoinColumn.Owner createPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected void addSpecifiedPrimaryKeyJoinColumn(int index, OrmPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- addItemToList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void addSpecifiedPrimaryKeyJoinColumn(OrmPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.addSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.size(), primaryKeyJoinColumn);
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.indexOf(primaryKeyJoinColumn));
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(int index) {
- OrmPrimaryKeyJoinColumn removedPrimaryKeyJoinColumn = this.specifiedPrimaryKeyJoinColumns.remove(index);
- if (!containsSpecifiedPrimaryKeyJoinColumns()) {
- //create the defaultJoinColumn now or this will happen during project update
- //after removing the join column from the resource model. That causes problems
- //in the UI because the change notifications end up in the wrong order.
- initializeDefaultPrimaryKeyJoinColumns();
- }
- this.resourceTypeMapping.getPrimaryKeyJoinColumns().remove(index);
- fireItemRemoved(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPrimaryKeyJoinColumn);
- if (!this.defaultPrimaryKeyJoinColumns.isEmpty()) {
- fireListChanged(OrmEntity.DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST, this.defaultPrimaryKeyJoinColumns);
- }
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(OrmPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- removeItemFromList(primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedPrimaryKeyJoinColumns, targetIndex, sourceIndex);
- this.resourceTypeMapping.getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex);
- fireItemMoved(Entity.SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
- public OrmAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- public OrmAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.associationOverrideContainer;
- }
-
- public OrmQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
- public String getDefaultTableName() {
- JavaEntity javaEntity = this.getJavaEntity();
- if (javaEntity != null) {
- JavaTable javaTable = javaEntity.getTable();
- if ( ! this.isMetadataComplete()
- && ! this.table.isResourceSpecified()
- && javaTable.getSpecifiedName() != null) {
- return javaTable.getSpecifiedName();
- }
- }
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getName()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getName();
- }
-
- public String getDefaultSchema() {
- JavaEntity javaEntity = this.getJavaEntity();
- if (javaEntity != null) {
- JavaTable javaTable = javaEntity.getTable();
- if ( ! this.isMetadataComplete()
- && ! this.table.isResourceSpecified()
- && javaTable.getSpecifiedSchema() != null) {
- return javaTable.getSpecifiedSchema();
- }
- }
-
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getSchema()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getContextDefaultSchema();
- }
-
- public String getDefaultCatalog() {
- JavaEntity javaEntity = this.getJavaEntity();
- if (javaEntity != null) {
- JavaTable javaTable = javaEntity.getTable();
- if ( ! this.isMetadataComplete()
- && ! this.table.isResourceSpecified()
- && javaTable.getSpecifiedCatalog() != null) {
- return javaTable.getSpecifiedCatalog();
- }
- }
-
- return this.isSingleTableDescendant() ?
- this.getRootEntity().getTable().getCatalog()
- :
- this.isAbstractTablePerClass() ?
- null
- :
- this.getContextDefaultCatalog();
- }
-
- /**
- * Return whether the entity is a descendant of the root entity
- * of a "single table" inheritance hierarchy.
- */
- protected boolean isSingleTableDescendant() {
- return this.isDescendant() && (this.getInheritanceStrategy() == InheritanceType.SINGLE_TABLE);
- }
-
- public Entity getParentEntity() {
- for (Iterator<PersistentType> stream = getPersistentType().ancestors(); stream.hasNext();) {
- TypeMapping tm = stream.next().getMapping();
- if (tm instanceof Entity) {
- return (Entity) tm;
- }
- }
- return null;
- }
-
- public Entity getRootEntity() {
- return this.rootEntity;
- }
-
- public boolean isRoot() {
- return this == this.getRootEntity();
- }
-
- /**
- * Return whether the entity is a descendant in (as opposed to the root of)
- * an inheritance hierarchy.
- */
- protected boolean isDescendant() {
- return ! this.isRoot();
- }
-
- /**
- * Return whether the entity is the top of an inheritance hierarchy
- * and has no descendants and no specified inheritance strategy has been defined.
- */
- protected boolean isRootNoDescendantsNoStrategyDefined() {
- return isRoot() && !getPersistenceUnit().entityIsRootWithSubEntities(this.getName()) && getSpecifiedInheritanceStrategy() == null;
- }
-
- /**
- * Return whether the entity is abstract and is a part of a
- * "table per class" inheritance hierarchy.
- */
- protected boolean isAbstractTablePerClass() {
- return isAbstract() && isTablePerClass();
- }
-
- protected boolean isResourceTableSpecified() {
- return this.table.isResourceSpecified() || (getJavaEntity() != null && getJavaEntity().getTable().isResourceSpecified());
- }
-
- /**
- * Return whether the entity is a part of a "table per class"
- * inheritance hierarchy.
- */
- protected boolean isTablePerClass() {
- return (this.getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS);
- }
-
- /**
- * Return whether the type is abstract, false if no java type exists.
- */
- protected boolean isAbstract() {
- JavaResourcePersistentType javaResourcePersistentType = getJavaResourcePersistentType();
- return javaResourcePersistentType == null ? false : javaResourcePersistentType.isAbstract();
- }
-
- /**
- * Return whether the type is abstract, false if no java type exists.
- */
- protected boolean isFinal() {
- JavaResourcePersistentType javaResourcePersistentType = getJavaResourcePersistentType();
- return javaResourcePersistentType == null ? false : javaResourcePersistentType.isFinal();
- }
-
- /**
- * Return whether the type is a top-level type.
- */
- protected boolean isMember() {
- JavaResourcePersistentType javaResourcePersistentType = getJavaResourcePersistentType();
- return javaResourcePersistentType == null ? false : javaResourcePersistentType.isMemberType();
- }
-
- /**
- * Return whether the type is static.
- */
- protected boolean isStatic() {
- JavaResourcePersistentType javaResourcePersistentType = getJavaResourcePersistentType();
- return javaResourcePersistentType == null ? false : javaResourcePersistentType.isStatic();
- }
-
-// public String primaryKeyColumnName() {
-// String pkColumnName = null;
-// for (Iterator<IPersistentAttribute> stream = getPersistentType().allAttributes(); stream.hasNext();) {
-// IPersistentAttribute attribute = stream.next();
-// String name = attribute.primaryKeyColumnName();
-// if (pkColumnName == null) {
-// pkColumnName = name;
-// }
-// else if (name != null) {
-// // if we encounter a composite primary key, return null
-// return null;
-// }
-// }
-// // if we encounter only a single primary key column name, return it
-// return pkColumnName;
-// }
-//
-// public String primaryKeyAttributeName() {
-// String pkColumnName = null;
-// String pkAttributeName = null;
-// for (Iterator<IPersistentAttribute> stream = getPersistentType().allAttributes(); stream.hasNext();) {
-// IPersistentAttribute attribute = stream.next();
-// String name = attribute.primaryKeyColumnName();
-// if (pkColumnName == null) {
-// pkColumnName = name;
-// pkAttributeName = attribute.getName();
-// }
-// else if (name != null) {
-// // if we encounter a composite primary key, return null
-// return null;
-// }
-// }
-// // if we encounter only a single primary key column name, return it
-// return pkAttributeName;
-// }
-//
-
-
- public int getXmlSequence() {
- return 1;
- }
-
- /**
- * Return an iterator of Entities, each which inherits from the one before,
- * and terminates at the root entity (or at the point of cyclicity).
- */
- protected Iterator<TypeMapping> ancestors() {
- return new TransformationIterator<PersistentType, TypeMapping>(getPersistentType().ancestors()) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
- @Override
- public Iterator<String> overridableAttributeNames() {
- if (!isTablePerClass()) {
- return EmptyIterator.instance();
- }
- return super.overridableAttributeNames();
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- if (this.isJpa2_0Compatible()) {
- int dotIndex = attributeName.indexOf('.');
- if (dotIndex != -1) {
- AttributeOverride override = getAttributeOverrideContainer().getAttributeOverrideNamed(attributeName.substring(dotIndex + 1));
- if (override != null && !override.isVirtual()) {
- return override.getColumn();
- }
- }
- }
- return super.resolveOverriddenColumn(attributeName);
- }
-
- @Override
- public Iterator<String> overridableAssociationNames() {
- if (!isTablePerClass()) {
- return EmptyIterator.instance();
- }
- return super.overridableAssociationNames();
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.allAttributeMappings())) {
- AttributeMapping resolvedMapping = attributeMapping.resolveAttributeMapping(name);
- if (resolvedMapping != null) {
- return resolvedMapping;
- }
- }
- return null;
- }
-
-//
-// public IAttributeOverride createAttributeOverride(int index) {
-// return OrmFactory.eINSTANCE.createXmlAttributeOverride(new IEntity.AttributeOverrideOwner(this));
-// }
-//
-// public IAssociationOverride createAssociationOverride(int index) {
-// return OrmFactory.eINSTANCE.createXmlAssociationOverride(new IEntity.AssociationOverrideOwner(this));
-// }
-//
-// public IAttributeOverride attributeOverrideNamed(String name) {
-// return (IAttributeOverride) overrideNamed(name, getAttributeOverrides());
-// }
-//
-// public boolean containsAttributeOverride(String name) {
-// return containsOverride(name, getAttributeOverrides());
-// }
-//
-// public boolean containsSpecifiedAttributeOverride(String name) {
-// return containsOverride(name, getSpecifiedAttributeOverrides());
-// }
-//
-// public boolean containsAssociationOverride(String name) {
-// return containsOverride(name, getAssociationOverrides());
-// }
-//
-// public boolean containsSpecifiedAssociationOverride(String name) {
-// return containsOverride(name, getSpecifiedAssociationOverrides());
-// }
-//
-// private IOverride overrideNamed(String name, List<? extends IOverride> overrides) {
-// for (IOverride override : overrides) {
-// String overrideName = override.getName();
-// if (overrideName == null && name == null) {
-// return override;
-// }
-// if (overrideName != null && overrideName.equals(name)) {
-// return override;
-// }
-// }
-// return null;
-// }
-//
-// private boolean containsOverride(String name, List<? extends IOverride> overrides) {
-// return overrideNamed(name, overrides) != null;
-// }
-//
-// public boolean containsSpecifiedPrimaryKeyJoinColumns() {
-// return !this.getSpecifiedPrimaryKeyJoinColumns().isEmpty();
-// }
-
- protected void initializeInheritance(Inheritance inheritanceResource) {
- this.specifiedInheritanceStrategy = this.getResourceInheritanceStrategy(inheritanceResource);
- //no need to initialize defaultInheritanceStrategy, need to get all the persistentTypes in the model first
- }
-
- protected void initializeSpecifiedSecondaryTables() {
- for (XmlSecondaryTable secondaryTable : this.resourceTypeMapping.getSecondaryTables()) {
- this.specifiedSecondaryTables.add(buildSecondaryTable(secondaryTable));
- }
- }
-
- protected void initializeVirtualSecondaryTables() {
- if (isMetadataComplete()) {
- return;
- }
- if (getJavaEntity() == null) {
- return;
- }
- if (specifiedSecondaryTablesSize() > 0) {
- return;
- }
- ListIterator<JavaSecondaryTable> javaSecondaryTables = getJavaEntity().secondaryTables();
- while(javaSecondaryTables.hasNext()) {
- JavaSecondaryTable javaSecondaryTable = javaSecondaryTables.next();
- if (javaSecondaryTable.getName() != null) {
- this.virtualSecondaryTables.add(buildVirtualSecondaryTable(javaSecondaryTable));
- }
- }
- }
-
- protected void initializeDefaultPrimaryKeyJoinColumns() {
- if (isMetadataComplete()) {
- return;
- }
- if (getJavaEntity() == null) {
- this.defaultPrimaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(null));
- return;
- }
- if (specifiedPrimaryKeyJoinColumnsSize() > 0) {
- return;
- }
- ListIterator<JavaPrimaryKeyJoinColumn> javaPkJoinColumns = getJavaEntity().primaryKeyJoinColumns();
- while(javaPkJoinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn javaPkJoinColumn = javaPkJoinColumns.next();
- if (javaPkJoinColumn.getName() != null) {
- this.defaultPrimaryKeyJoinColumns.add(buildVirtualPrimaryKeyJoinColumn(javaPkJoinColumn));
- }
- }
- }
-
- protected void initializeSpecifiedPrimaryKeyJoinColumns() {
- for (XmlPrimaryKeyJoinColumn resourcePkJoinColumn : this.resourceTypeMapping.getPrimaryKeyJoinColumns()) {
- this.specifiedPrimaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(resourcePkJoinColumn));
- }
- }
-
- @Override
- public void update() {
- super.update();
- this.setSpecifiedName(this.resourceTypeMapping.getName());
- this.setDefaultName(this.buildDefaultName());
- this.idClassReference.update(getJavaIdClassReferenceForDefaults());
- this.updateInheritance(this.getResourceInheritance());
- this.updateRootEntity();
- this.updateDiscriminatorColumn();
- this.updateDiscriminatorValue();
- this.setSpecifiedTableIsAllowed(this.buildSpecifiedTableIsAllowed());
- this.setTableIsUndefined(this.buildTableIsUndefined());
- this.table.update(this.resourceTypeMapping);
- this.updateSpecifiedSecondaryTables();
- this.updateVirtualSecondaryTables();
- this.generatorContainer.update();
- this.updateSpecifiedPrimaryKeyJoinColumns();
- this.updateDefaultPrimaryKeyJoinColumns();
- getAttributeOverrideContainer().update();
- getAssociationOverrideContainer().update();
- getQueryContainer().update();
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- this.postUpdateDiscriminatorColumn();
- this.postUpdateDiscriminatorValue();
- }
-
- protected String buildDefaultName() {
- if (!isMetadataComplete()) {
- JavaEntity javaEntity = getJavaEntity();
- if (javaEntity != null) {
- return javaEntity.getName();
- }
- }
- String className = getClass_();
- return StringTools.stringIsEmpty(className) ? null : ClassName.getSimpleName(className);
- }
-
- protected void updateDiscriminatorColumn() {
- this.setSpecifiedDiscriminatorColumnIsAllowed(this.buildSpecifiedDiscriminatorColumnIsAllowed());
- getDiscriminatorColumn().update(this.resourceTypeMapping);
- }
-
- protected void postUpdateDiscriminatorColumn() {
- this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
- this.getDiscriminatorColumn().postUpdate();
- }
-
- protected void updateDiscriminatorValue() {
- this.setSpecifiedDiscriminatorValueIsAllowed(this.buildSpecifiedDiscriminatorValueIsAllowed());
- this.setSpecifiedDiscriminatorValue(this.resourceTypeMapping.getDiscriminatorValue());
- }
-
- protected void postUpdateDiscriminatorValue() {
- this.setDiscriminatorValueIsUndefined(this.buildDiscriminatorValueIsUndefined());
- this.setDefaultDiscriminatorValue(this.buildDefaultDiscriminatorValue());
- }
-
- /**
- * From the Spec:
- * If the DiscriminatorValue annotation is not specified, a
- * provider-specific function to generate a value representing
- * the entity type is used for the value of the discriminator
- * column. If the DiscriminatorType is STRING, the discriminator
- * value default is the entity name.
- *
- * TODO extension point for provider-specific function?
- */
- protected String buildDefaultDiscriminatorValue() {
- if (!isMetadataComplete() && getJavaEntity() != null) {
- return getJavaEntity().getDiscriminatorValue();
- }
- if (discriminatorValueIsUndefined()) {
- return null;
- }
- if (this.getDiscriminatorType() != DiscriminatorType.STRING) {
- return null;
- }
- return this.getName();
- }
-
- protected DiscriminatorType getDiscriminatorType() {
- return this.getDiscriminatorColumn().getDiscriminatorType();
- }
-
- protected boolean buildSpecifiedDiscriminatorValueIsAllowed() {
- return !isTablePerClass() && !isAbstract();
- }
-
- protected boolean buildDiscriminatorValueIsUndefined() {
- return isTablePerClass() || isAbstract() || isRootNoDescendantsNoStrategyDefined();
- }
-
- protected boolean buildSpecifiedDiscriminatorColumnIsAllowed() {
- return !isTablePerClass() && isRoot();
- }
-
- protected boolean buildDiscriminatorColumnIsUndefined() {
- return isTablePerClass() || isRootNoDescendantsNoStrategyDefined();
- }
-
- protected boolean buildSpecifiedTableIsAllowed() {
- return !isAbstractTablePerClass() && !isSingleTableDescendant();
- }
-
- protected boolean buildTableIsUndefined() {
- return isAbstractTablePerClass();
- }
-
-
- protected void updateInheritance(Inheritance inheritanceResource) {
- this.setSpecifiedInheritanceStrategy_(this.getResourceInheritanceStrategy(inheritanceResource));
- this.setDefaultInheritanceStrategy(this.buildDefaultInheritanceStrategy());
- }
-
- protected void updateRootEntity() {
- //I am making an assumption here that we don't need property change notification for rootEntity, this might be wrong
- this.rootEntity = calculateRootEntity();
- if (this.rootEntity != this) {
- this.rootEntity.addSubEntity(this);
- }
- }
-
- protected Entity calculateRootEntity() {
- Entity root = this;
- for (Iterator<TypeMapping> stream = inheritanceHierarchy(); stream.hasNext();) {
- TypeMapping typeMapping = stream.next();
- if (typeMapping instanceof Entity) {
- root = (Entity) typeMapping;
- }
- }
- return root;
- }
-
- public void addSubEntity(Entity subEntity) {
- getPersistenceUnit().addRootEntityWithSubEntities(getName());
- }
-
- protected void updateSpecifiedSecondaryTables() {
- // make a copy of the XML tables (to prevent ConcurrentModificationException)
- Iterator<XmlSecondaryTable> xmlTables = new CloneIterator<XmlSecondaryTable>(this.resourceTypeMapping.getSecondaryTables());
-
- for (Iterator<OrmSecondaryTable> contextTables = this.specifiedSecondaryTables(); contextTables.hasNext(); ) {
- OrmSecondaryTable contextTable = contextTables.next();
- if (xmlTables.hasNext()) {
- contextTable.update(xmlTables.next());
- }
- else {
- removeSpecifiedSecondaryTable_(contextTable);
- }
- }
-
- while (xmlTables.hasNext()) {
- addSpecifiedSecondaryTable(buildSecondaryTable(xmlTables.next()));
- }
- }
-
- //if any secondary-tables are specified in the xml file, then all of the java secondaryTables are overriden
- protected void updateVirtualSecondaryTables() {
- ListIterator<OrmSecondaryTable> secondaryTables = virtualSecondaryTables();
- ListIterator<JavaSecondaryTable> javaSecondaryTables = EmptyListIterator.instance();
-
- if (getJavaEntity() != null && !isMetadataComplete() && specifiedSecondaryTablesSize() == 0) {
- javaSecondaryTables = getJavaEntity().secondaryTables();
- }
- while (secondaryTables.hasNext()) {
- OrmSecondaryTable virtualSecondaryTable = secondaryTables.next();
- if (javaSecondaryTables.hasNext()) {
- JavaSecondaryTable javaSecondaryTable = javaSecondaryTables.next();
- virtualSecondaryTable.update(new VirtualXmlSecondaryTable(javaSecondaryTable));
- }
- else {
- removeVirtualSecondaryTable(virtualSecondaryTable);
- }
- }
-
- while (javaSecondaryTables.hasNext()) {
- JavaSecondaryTable javaSecondaryTable = javaSecondaryTables.next();
- addVirtualSecondaryTable(buildVirtualSecondaryTable(javaSecondaryTable));
- }
- }
-
- protected OrmSecondaryTable buildSecondaryTable(XmlSecondaryTable xmlSecondaryTable) {
- return getXmlContextNodeFactory().buildOrmSecondaryTable(this, new SecondaryTableOwner(), xmlSecondaryTable);
- }
-
- protected OrmSecondaryTable buildVirtualSecondaryTable(JavaSecondaryTable javaSecondaryTable) {
- return buildSecondaryTable(new VirtualXmlSecondaryTable(javaSecondaryTable));
- }
-
- protected InheritanceType getResourceInheritanceStrategy(Inheritance inheritanceResource) {
- if (inheritanceResource == null) {
- return null;
- }
- return InheritanceType.fromOrmResourceModel(inheritanceResource.getStrategy());
- }
-
- protected InheritanceType buildDefaultInheritanceStrategy() {
- if ((this.getResourceInheritance() == null)
- && ! this.isMetadataComplete()
- && (this.getJavaEntity() != null)) {
- return this.getJavaEntity().getInheritanceStrategy();
- }
- return this.isRoot() ? InheritanceType.SINGLE_TABLE : this.getRootEntity().getInheritanceStrategy();
- }
-
- protected void updateSpecifiedPrimaryKeyJoinColumns() {
- // make a copy of the XML join columns (to prevent ConcurrentModificationException)
- Iterator<XmlPrimaryKeyJoinColumn> xmlPkJoinColumns = new CloneIterator<XmlPrimaryKeyJoinColumn>(this.resourceTypeMapping.getPrimaryKeyJoinColumns());
-
- for (Iterator<OrmPrimaryKeyJoinColumn> contextPkJoinColumns = this.specifiedPrimaryKeyJoinColumns(); contextPkJoinColumns.hasNext(); ) {
- OrmPrimaryKeyJoinColumn contextPkJoinColumn = contextPkJoinColumns.next();
- if (xmlPkJoinColumns.hasNext()) {
- contextPkJoinColumn.update(xmlPkJoinColumns.next());
- }
- else {
- removeSpecifiedPrimaryKeyJoinColumn_(contextPkJoinColumn);
- }
- }
-
- while (xmlPkJoinColumns.hasNext()) {
- addSpecifiedPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(xmlPkJoinColumns.next()));
- }
- }
-
- //if there are any specified pkJoinColumns, then no default pkJoinColumns
- //if the java has specified pkJoinColumns, then those are the default pkJoinColumns
- //otherwise, just 1 pkJoinColumn, defaults being null if multiple primaryKey columns
- protected void updateDefaultPrimaryKeyJoinColumns() {
- ListIterator<OrmPrimaryKeyJoinColumn> defaultPkJoinColumns = defaultPrimaryKeyJoinColumns();
- ListIterator<JavaPrimaryKeyJoinColumn> javaPkJoinColumns = EmptyListIterator.instance();
-
- if (getJavaEntity() != null && !isMetadataComplete() && specifiedPrimaryKeyJoinColumnsSize() == 0) {
- javaPkJoinColumns = getJavaEntity().primaryKeyJoinColumns();
- }
- while (defaultPkJoinColumns.hasNext()) {
- OrmPrimaryKeyJoinColumn defaultPkJoinColumn = defaultPkJoinColumns.next();
- if (javaPkJoinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn javaPkJoinColumn = javaPkJoinColumns.next();
- defaultPkJoinColumn.update(new VirtualXmlPrimaryKeyJoinColumn(javaPkJoinColumn));
- }
- else {
- if (defaultPrimaryKeyJoinColumnsSize() == 1) {
- defaultPkJoinColumn.update(null);
- }
- else {
- removeDefaultPrimaryKeyJoinColumn(defaultPkJoinColumn);
- }
- }
- }
-
- while (javaPkJoinColumns.hasNext()) {
- JavaPrimaryKeyJoinColumn javaPkJoinColumn = javaPkJoinColumns.next();
- addDefaultPrimaryKeyJoinColumn(buildVirtualPrimaryKeyJoinColumn(javaPkJoinColumn));
- }
-
- if (defaultPrimaryKeyJoinColumnsSize() == 0 && specifiedPrimaryKeyJoinColumnsSize() == 0) {
- addDefaultPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(null));
- }
- }
-
- protected OrmPrimaryKeyJoinColumn buildVirtualPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn javaSecondaryTable) {
- return buildPrimaryKeyJoinColumn(new VirtualXmlPrimaryKeyJoinColumn(javaSecondaryTable));
- }
-
- protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn resourcePkJoinColumn) {
- return getXmlContextNodeFactory().buildOrmPrimaryKeyJoinColumn(this, createPrimaryKeyJoinColumnOwner(), resourcePkJoinColumn);
- }
-
-
- // *************************************************************************
-
- public String getPrimaryKeyColumnName() {
- return AbstractJavaEntity.getPrimaryKeyColumnName(this);
- }
-
- public PersistentAttribute getIdAttribute() {
- Iterable<AttributeMapping> idAttributeMappings = getAllAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY);
- if (CollectionTools.size(idAttributeMappings) != 1) {
- return null;
- }
- return idAttributeMappings.iterator().next().getPersistentAttribute();
- }
-
- public void addToResourceModel(XmlEntityMappings entityMappings) {
- entityMappings.getEntities().add(this.resourceTypeMapping);
- }
-
- public void removeFromResourceModel(XmlEntityMappings entityMappings) {
- entityMappings.getEntities().remove(this.resourceTypeMapping);
- }
-
-
- //************************* refactoring ************************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createIdClassRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createIdClassRenameTypeEdits(IType originalType, String newName) {
- return this.idClassReference.createRenameTypeEdits(originalType, newName);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createIdClassMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createIdClassMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.idClassReference.createMoveTypeEdits(originalType, newPackage);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createIdClassRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createIdClassRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.idClassReference.createRenamePackageEdits(originalPackage, newName);
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- validatePrimaryKey(messages, reporter);
- validateTable(messages, reporter);
- for (Iterator<OrmSecondaryTable> stream = this.secondaryTables(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter);
- }
- validateInheritance(messages, reporter);
- for (Iterator<OrmPrimaryKeyJoinColumn> stream = this.primaryKeyJoinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter);
- }
- this.generatorContainer.validate(messages, reporter);
- this.queryContainer.validate(messages, reporter);
- this.attributeOverrideContainer.validate(messages, reporter);
- this.associationOverrideContainer.validate(messages, reporter);
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter) {
- buildPrimaryKeyValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator() {
- return new GenericEntityPrimaryKeyValidator(this, buildTextRangeResolver());
- // TODO - JPA 2.0 validation
- }
-
- @Override
- protected EntityTextRangeResolver buildTextRangeResolver() {
- return new OrmEntityTextRangeResolver(this);
- }
-
- protected void validateTable(List<IMessage> messages, IReporter reporter) {
- if (isAbstractTablePerClass()) {
- if (this.isResourceTableSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.getTable().getValidationTextRange()
- )
- );
- }
- return;
- }
- if (isSingleTableDescendant()) {
- if (this.isResourceTableSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.getTable().getValidationTextRange()
- )
- );
- }
- return;
- }
- this.table.validate(messages, reporter);
- }
-
- protected void validateInheritance(List<IMessage> messages, IReporter reporter) {
- validateInheritanceStrategy(messages);
- validateDiscriminatorColumn(messages, reporter);
- validateDiscriminatorValue(messages);
- }
-
- protected void validateDiscriminatorColumn(List<IMessage> messages, IReporter reporter) {
- if (specifiedDiscriminatorColumnIsAllowed() && !discriminatorColumnIsUndefined()) {
- getDiscriminatorColumn().validate(messages, reporter);
- }
- else if (getDiscriminatorColumn().isResourceSpecified()) {
- if (!isRoot()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange()
- )
- );
- }
- else if (isTablePerClass()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange()
- )
- );
-
- }
- }
- }
-
- protected void validateDiscriminatorValue(List<IMessage> messages) {
- if (discriminatorValueIsUndefined() && getSpecifiedDiscriminatorValue() != null) {
- if (isAbstract()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange()
- )
- );
- }
- else if (isTablePerClass()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange()
- )
- );
- }
- }
- }
-
- protected void validateInheritanceStrategy(List<IMessage> messages) {
- Supported tablePerConcreteClassInheritanceIsSupported = getJpaPlatformVariation().getTablePerConcreteClassInheritanceIsSupported();
- if (tablePerConcreteClassInheritanceIsSupported == Supported.YES) {
- return;
- }
- if ((getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS) && isRoot()) {
- if (tablePerConcreteClassInheritanceIsSupported == Supported.NO) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_SUPPORTED_ON_PLATFORM,
- new String[] {this.getName()},
- this,
- this.getInheritanceStrategyTextRange()
- )
- );
- }
- else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_TABLE_PER_CLASS_NOT_PORTABLE_ON_PLATFORM,
- new String[] {this.getName()},
- this,
- this.getInheritanceStrategyTextRange()
- )
- );
- }
- }
- }
-
- protected TextRange getDiscriminatorValueTextRange() {
- return this.resourceTypeMapping.getDiscriminatorValueTextRange();
- }
-
- protected TextRange getDiscriminatorColumnTextRange() {
- return this.resourceTypeMapping.getDiscriminatorColumn().getValidationTextRange();
- }
-
- protected TextRange getInheritanceStrategyTextRange() {
- return this.resourceTypeMapping.getInheritanceStrategyTextRange();
- }
-
- protected class TableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new TableValidator(table, textRangeResolver);
- }
- }
-
- protected class SecondaryTableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new SecondaryTableValidator((SecondaryTable) table, textRangeResolver);
- }
- }
-
- protected class AssociationOverrideContainerOwner
- implements OrmAssociationOverrideContainer.Owner
- {
- public OrmTypeMapping getTypeMapping() {
- return AbstractOrmEntity.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractOrmEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : typeMapping.allOverridableAssociationNames();
- }
-
- public EList<XmlAssociationOverride> getResourceAssociationOverrides() {
- return AbstractOrmEntity.this.resourceTypeMapping.getAssociationOverrides();
- }
-
- public RelationshipReference resolveRelationshipReference(String associationOverrideName) {
- if (!isMetadataComplete()) {
- JavaPersistentType javaPersistentType = getPersistentType().getJavaPersistentType();
- if (javaPersistentType != null) {
- RelationshipReference relationshipReference = javaPersistentType.getMapping().resolveRelationshipReference(associationOverrideName);
- if (relationshipReference != null) {
- return relationshipReference;
- }
- }
- }
- return MappingTools.resolveRelationshipReference(getOverridableTypeMapping(), associationOverrideName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractOrmEntity.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractOrmEntity.this.associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractOrmEntity.this.getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return AbstractOrmEntity.this.getPrimaryTableName();
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AssociationOverrideValidator((AssociationOverride) override, (AssociationOverride.Owner) owner, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinColumnValidator((AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) owner, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinColumnValidator(override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new AssociationOverrideInverseJoinColumnValidator(override, column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinTableValidator(override, (JoinTable) table, textRangeResolver);
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmEntity.this.getValidationTextRange();
- }
- }
-
-
- //********** OrmAttributeOverrideContainer.Owner implementation *********
-
- protected class AttributeOverrideContainerOwner
- implements OrmAttributeOverrideContainer.Owner
- {
- public OrmTypeMapping getTypeMapping() {
- return AbstractOrmEntity.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractOrmEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : allOverridableAttributeNames_(typeMapping);
- }
-
- /* assumes the type mapping is not null */
- protected Iterator allOverridableAttributeNames_(TypeMapping typeMapping) {
- final Collection mappedByRelationshipAttributes = CollectionTools.collection(
- new TransformationIterator<SingleRelationshipMapping2_0, String>(getMapsIdRelationships()) {
- @Override
- protected String transform(SingleRelationshipMapping2_0 next) {
- return next.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue();
- }
- });
- return new FilteringIterator<String>(typeMapping.allOverridableAttributeNames()) {
- @Override
- protected boolean accept(String o) {
- if (mappedByRelationshipAttributes.isEmpty()) {
- return true;
- }
- // overrideable names are (usually?) qualified with a container mapping,
- // which may also be the one mapped by a relationship
- String qualifier =
- (o.indexOf('.') > 0) ?
- o.substring(0, o.indexOf('.'))
- : o;
- return ! mappedByRelationshipAttributes.contains(qualifier);
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(
- new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(
- new CompositeIterable<AttributeMapping>(
- getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)))) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 o) {
- return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
- public EList<XmlAttributeOverride> getResourceAttributeOverrides() {
- return AbstractOrmEntity.this.resourceTypeMapping.getAttributeOverrides();
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- if (!isMetadataComplete()) {
- JavaPersistentType javaPersistentType = getPersistentType().getJavaPersistentType();
- if (javaPersistentType != null) {
- Column column = javaPersistentType.getMapping().resolveOverriddenColumn(attributeOverrideName);
- if (column != null) {
- return column;
- }
- }
- }
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
- public XmlColumn buildVirtualXmlColumn(Column overridableColumn, String attributeName, boolean isMetadataComplete) {
- JavaAttributeOverride javaAttributeOverride = null;
- if (!isMetadataComplete) {
- javaAttributeOverride = getJavaAttributeOverrideNamed(attributeName);
- }
- if (javaAttributeOverride == null) {
- //TODO not the greatest solution here, but things seems to work, so I'm stepping away slowly
- if (overridableColumn instanceof JavaColumn) {
- return new VirtualXmlColumn(AbstractOrmEntity.this, overridableColumn);
- }
- return new VirtualXmlAttributeOverrideColumn(overridableColumn);
- }
- return new VirtualXmlColumn(AbstractOrmEntity.this, javaAttributeOverride.getColumn());
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractOrmEntity.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractOrmEntity.this.associatedTableNamesIncludingInherited();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractOrmEntity.this.getDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return AbstractOrmEntity.this.getPrimaryTableName();
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmEntity.this.getValidationTextRange();
- }
- }
-
-
- protected class PrimaryKeyJoinColumnOwner implements OrmBaseJoinColumn.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractOrmEntity.this;
- }
-
- public String getDefaultTableName() {
- return AbstractOrmEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return AbstractOrmEntity.this.getDbTable(tableName);
- }
-
- public org.eclipse.jpt.db.Table getReferencedColumnDbTable() {
- Entity parentEntity = AbstractOrmEntity.this.getParentEntity();
- return (parentEntity == null) ? null : parentEntity.getPrimaryDbTable();
- }
-
- public int joinColumnsSize() {
- return AbstractOrmEntity.this.primaryKeyJoinColumnsSize();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return AbstractOrmEntity.this.defaultPrimaryKeyJoinColumns.contains(joinColumn);
- }
-
- public String getDefaultColumnName() {
- if (joinColumnsSize() != 1) {
- return null;
- }
- Entity parentEntity = AbstractOrmEntity.this.getParentEntity();
- return (parentEntity == null) ? getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmEntity.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new EntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmGenerator.java
deleted file mode 100644
index 696357b668..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmGenerator.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.java.JavaGenerator;
-import org.eclipse.jpt.core.context.orm.OrmGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlGenerator;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.internal.StringTools;
-
-/**
- *
- */
-public abstract class AbstractOrmGenerator<T extends XmlGenerator>
- extends AbstractOrmXmlContextNode
- implements OrmGenerator
-{
-
- protected String name;
-
- protected Integer specifiedInitialValue;
- protected int defaultInitialValue;
-
- protected Integer specifiedAllocationSize;
- protected int defaultAllocationSize;
-
- protected T resourceGenerator;
-
-
- protected AbstractOrmGenerator(XmlContextNode parent) {
- super(parent);
- }
-
- protected T getResourceGenerator() {
- return this.resourceGenerator;
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.getResourceGenerator().setName(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
-
- // ********** initial value **********
-
- public int getInitialValue() {
- return (this.specifiedInitialValue != null) ? this.specifiedInitialValue.intValue() : this.defaultInitialValue;
- }
-
- public Integer getSpecifiedInitialValue() {
- return this.specifiedInitialValue;
- }
-
- public void setSpecifiedInitialValue(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.getResourceGenerator().setInitialValue(specifiedInitialValue);
- this.firePropertyChanged(SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
- protected void setSpecifiedInitialValue_(Integer specifiedInitialValue) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = specifiedInitialValue;
- this.firePropertyChanged(SPECIFIED_INITIAL_VALUE_PROPERTY, old, specifiedInitialValue);
- }
-
- public int getDefaultInitialValue() {
- return this.defaultInitialValue;
- }
-
- protected void setDefaultInitialValue(int defaultInitialValue) {
- int old = this.defaultInitialValue;
- this.defaultInitialValue = defaultInitialValue;
- this.firePropertyChanged(DEFAULT_INITIAL_VALUE_PROPERTY, old, defaultInitialValue);
- }
-
-
- // ********** allocation size **********
-
- public int getAllocationSize() {
- return (this.specifiedAllocationSize != null) ? this.specifiedAllocationSize.intValue() : this.defaultAllocationSize;
- }
-
- public Integer getSpecifiedAllocationSize() {
- return this.specifiedAllocationSize;
- }
-
- public void setSpecifiedAllocationSize(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.getResourceGenerator().setAllocationSize(specifiedAllocationSize);
- this.firePropertyChanged(SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
- protected void setSpecifiedAllocationSize_(Integer specifiedAllocationSize) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = specifiedAllocationSize;
- this.firePropertyChanged(SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, specifiedAllocationSize);
- }
-
- public int getDefaultAllocationSize() {
- return Generator.DEFAULT_ALLOCATION_SIZE;
- }
-
- protected void setDefaultAllocationSize(int defaultAllocationSize) {
- int old = this.defaultAllocationSize;
- this.defaultAllocationSize = defaultAllocationSize;
- this.firePropertyChanged(DEFAULT_ALLOCATION_SIZE_PROPERTY, old, defaultAllocationSize);
- }
-
-
- // ********** text ranges **********
-
- public TextRange getValidationTextRange() {
- TextRange validationTextRange = this.getResourceGenerator().getValidationTextRange();
- return validationTextRange != null ? validationTextRange : getParent().getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- TextRange nameTextRange = this.getResourceGenerator().getNameTextRange();
- return nameTextRange != null ? nameTextRange : getValidationTextRange();
- }
-
-
- // ********** resource => context **********
-
- protected void initialize(T xmlResourceGenerator) {
- this.resourceGenerator = xmlResourceGenerator;
- this.name = xmlResourceGenerator.getName();
- this.specifiedInitialValue = xmlResourceGenerator.getInitialValue();
- this.specifiedAllocationSize = xmlResourceGenerator.getAllocationSize();
- //TODO defaults
- }
-
- protected void update(T xmlResourceGenerator) {
- this.resourceGenerator = xmlResourceGenerator;
- this.setName_(xmlResourceGenerator.getName());
- this.setSpecifiedInitialValue_(xmlResourceGenerator.getInitialValue());
- this.setSpecifiedAllocationSize_(xmlResourceGenerator.getAllocationSize());
- getPersistenceUnit().addGenerator(this);
- //TODO defaults
- }
-
-
- // ********** database stuff **********
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- protected abstract String getSchema();
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- protected abstract String getCatalog();
-
-
- // ********** misc **********
-
- public boolean isVirtual() {
- return getResourceGenerator().isVirtual();
- }
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- public boolean overrides(Generator other) {
- // this isn't ideal, but it will have to do until we have further adopter input
- return (this.name != null)
- && this.name.equals(other.getName())
- && (other instanceof JavaGenerator);
- }
-
- public boolean duplicates(Generator other) {
- return (this != other)
- && ! StringTools.stringIsEmpty(this.name)
- && this.name.equals(other.getName())
- && ! this.isVirtual()
- && ! this.overrides(other)
- && ! other.overrides(this);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
deleted file mode 100644
index 53fd40cc92..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmIdMapping.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.core.context.orm.OrmConverter;
-import org.eclipse.jpt.core.context.orm.OrmGeneratedValue;
-import org.eclipse.jpt.core.context.orm.OrmGeneratorContainer;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.IdMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.resource.java.JPA;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmIdMapping<T extends XmlId>
- extends AbstractOrmAttributeMapping<T>
- implements OrmIdMapping, IdMapping2_0
-{
- protected final OrmColumn column;
-
- /* 2.0 feature - a relationship may map this id */
- protected boolean mappedByRelationship;
-
- protected OrmGeneratedValue generatedValue;
-
- protected OrmConverter converter;
-
- protected final OrmConverter nullConverter;
-
- protected final OrmGeneratorContainer generatorContainer;
-
-
- protected AbstractOrmIdMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.column = getXmlContextNodeFactory().buildOrmColumn(this, this);
- this.column.initialize(this.resourceAttributeMapping.getColumn());//TODO pass in to constructor
- this.mappedByRelationship = calculateMappedByRelationship();
- this.generatorContainer = buildGeneratorContainer();
- this.initializeGeneratedValue();
- this.nullConverter = this.getXmlContextNodeFactory().buildOrmNullConverter(this);
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
-
- protected OrmGeneratorContainer buildGeneratorContainer() {
- return getXmlContextNodeFactory().buildOrmGeneratorContainer(this, this.resourceAttributeMapping);
- }
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 0;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmIdMapping(this);
- }
-
- @Override
- public void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- super.initializeFromOrmColumnMapping(oldMapping);
- getColumn().initializeFrom(oldMapping.getColumn());
- }
-
- public OrmColumn getColumn() {
- return this.column;
- }
-
- public OrmConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- OrmConverter oldConverter = this.converter;
- OrmConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(OrmConverter newConverter) {
- OrmConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- public OrmGeneratedValue addGeneratedValue() {
- if (getGeneratedValue() != null) {
- throw new IllegalStateException("gemeratedValue already exists"); //$NON-NLS-1$
- }
- XmlGeneratedValue resourceGeneratedValue = OrmFactory.eINSTANCE.createXmlGeneratedValue();
- this.generatedValue = buildGeneratedValue(resourceGeneratedValue);
- this.resourceAttributeMapping.setGeneratedValue(resourceGeneratedValue);
- firePropertyChanged(GENERATED_VALUE_PROPERTY, null, this.generatedValue);
- return this.generatedValue;
- }
-
- public void removeGeneratedValue() {
- if (getGeneratedValue() == null) {
- throw new IllegalStateException("gemeratedValue does not exist, cannot be removed"); //$NON-NLS-1$
- }
- OrmGeneratedValue oldGeneratedValue = this.generatedValue;
- this.generatedValue = null;
- this.resourceAttributeMapping.setGeneratedValue(null);
- firePropertyChanged(GENERATED_VALUE_PROPERTY, oldGeneratedValue, null);
- }
-
- public OrmGeneratedValue getGeneratedValue() {
- return this.generatedValue;
- }
-
- protected void setGeneratedValue(OrmGeneratedValue newGeneratedValue) {
- OrmGeneratedValue oldGeneratedValue = this.generatedValue;
- this.generatedValue = newGeneratedValue;
- firePropertyChanged(GENERATED_VALUE_PROPERTY, oldGeneratedValue, newGeneratedValue);
- }
-
- public OrmGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- @Override
- public String getPrimaryKeyColumnName() {
- return this.getColumn().getName();
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getIds().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getIds().remove(this.resourceAttributeMapping);
- }
-
-
- //***************** XmlColumn.Owner implementation ****************
-
- public XmlColumn getResourceColumn() {
- return this.resourceAttributeMapping.getColumn();
- }
-
- protected boolean isColumnSpecified() {
- if (! isVirtual()) {
- return getResourceColumn() != null;
- }
- else {
- return getJavaResourcePersistentAttribute().getAnnotation(JPA.COLUMN) != null;
- }
- }
-
- public void addResourceColumn() {
- this.resourceAttributeMapping.setColumn(OrmFactory.eINSTANCE.createXmlColumn());
- }
-
- public void removeResourceColumn() {
- this.resourceAttributeMapping.setColumn(null);
- }
-
-
- //************** NamedColumn.Owner implementation ***************
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public String getDefaultColumnName() {
- return (isMappedByRelationship() && ! isColumnSpecified()) ? null : getName();
- }
-
-
- //************** BaseColumn.Owner implementation ***************
-
- public String getDefaultTableName() {
- return (isMappedByRelationship() && ! isColumnSpecified()) ? null : getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
-
- // **************** IdColumn2_0 impl **************************************
-
- public boolean isMappedByRelationship() {
- return this.mappedByRelationship;
- }
-
- protected void setMappedByRelationship(boolean newValue) {
- boolean oldValue = this.mappedByRelationship;
- this.mappedByRelationship = newValue;
- firePropertyChanged(MAPPED_BY_RELATIONSHIP_PROPERTY, oldValue, newValue);
- }
-
- protected boolean calculateMappedByRelationship() {
- for (SingleRelationshipMapping2_0 each : getMapsIdRelationships()) {
- if (each.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getResolvedAttributeMappingValue() == this) {
- return true;
- }
- }
- return false;
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(
- new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(
- new CompositeIterable<AttributeMapping>(
- getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)))) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 o) {
- return o.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
-
- protected void initializeGeneratedValue() {
- if (this.resourceAttributeMapping.getGeneratedValue() != null) {
- this.generatedValue = buildGeneratedValue(this.resourceAttributeMapping.getGeneratedValue());
- }
- }
-
- protected OrmGeneratedValue buildGeneratedValue(XmlGeneratedValue resourceGeneratedValue) {
- return getXmlContextNodeFactory().buildOrmGeneratedValue(this, resourceGeneratedValue);
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update(getResourceColumn());
- setMappedByRelationship(calculateMappedByRelationship());
- this.generatorContainer.update();
- this.updateGeneratedValue();
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update();
- }
- else {
- setConverter(buildConverter(getResourceConverterType()));
- }
- }
-
- protected void updateGeneratedValue() {
- if (this.resourceAttributeMapping.getGeneratedValue() == null) {
- if (getGeneratedValue() != null) {
- setGeneratedValue(null);
- }
- }
- else {
- if (getGeneratedValue() == null) {
- setGeneratedValue(buildGeneratedValue(this.resourceAttributeMapping.getGeneratedValue()));
- }
- else {
- getGeneratedValue().update(this.resourceAttributeMapping.getGeneratedValue());
- }
- }
- }
-
- protected OrmConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getXmlContextNodeFactory().buildOrmTemporalConverter(this, this.resourceAttributeMapping);
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.resourceAttributeMapping.getTemporal() != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
-
- //************ refactoring ************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createConverterRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createConverterRenameTypeEdits(IType originalType, String newName) {
- if (getConverter() != null) {
- return getConverter().createRenameTypeEdits(originalType, newName);
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createConverterMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createConverterMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (getConverter() != null) {
- return getConverter().createMoveTypeEdits(originalType, newPackage);
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createConverterRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (getConverter() != null) {
- return getConverter().createRenamePackageEdits(originalPackage, newName);
- }
- return EmptyIterable.instance();
- }
-
-
- // ****************** validation ****************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- // [JPA 2.0] if the column is specified, or if the id is not mapped by a relationship,
- // then the column is validated.
- // (In JPA 1.0, the column will always be validated, since the id is never mapped by a
- // relationship)
- if (isColumnSpecified() || ! isMappedByRelationship()) {
- getColumn().validate(messages, reporter);
- }
-
- // [JPA 2.0] if the column is specified and the id is mapped by a relationship,
- // then that is an error
- // (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship)
- if (isColumnSpecified() && isMappedByRelationship()) {
- messages.add(
- buildMessage(
- JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
- new String[] {},
- getColumn().getValidationTextRange()));
- }
-
- if (this.generatedValue != null) {
- this.generatedValue.validate(messages, reporter);
- }
- this.generatorContainer.validate(messages, reporter);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- /* TODO - move to AbstractOrmAttributeMapping? */
- protected IMessage buildMessage(String msgID, String[] params, TextRange textRange) {
- String attributeDescString;
- PersistentAttribute attribute = getPersistentAttribute();
- if (attribute.isVirtual()) {
- attributeDescString = NLS.bind(JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC, attribute.getName());
- }
- else {
- attributeDescString = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
- }
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY, msgID, ArrayTools.add(params, 0, attributeDescString), this, textRange);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.java
deleted file mode 100644
index cb82854790..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn.Owner;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumnsMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-
-public abstract class AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy
- extends AbstractOrmJoinColumnJoiningStrategy
-{
-
- protected AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy(
- OrmJoinColumnEnabledRelationshipReference parent,
- XmlJoinColumnsMapping resource) {
- super(parent, resource);
- }
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- @Override
- public OrmJoinColumnEnabledRelationshipReference getRelationshipReference() {
- return (OrmJoinColumnEnabledRelationshipReference) super.getRelationshipReference();
- }
-
- protected abstract Entity getRelationshipTargetEntity();
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- public boolean isOverridableAssociation() {
- return true;
- }
-
- public TextRange getValidationTextRange() {
- return this.getRelationshipReference().getValidationTextRange();
- }
-
- // ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements OrmJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return getRelationshipMapping().getName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.candidateTableNames();
- }
-
- public Table getDbTable(String tableName) {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator(getPersistentAttribute(), (JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnJoiningStrategy.java
deleted file mode 100644
index 7c1f778da8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumnsMapping;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmJoinColumnJoiningStrategy
- extends AbstractOrmXmlContextNode
- implements OrmJoinColumnJoiningStrategy
-{
- protected OrmJoinColumn defaultJoinColumn;
-
- protected final Vector<OrmJoinColumn> specifiedJoinColumns = new Vector<OrmJoinColumn>();
-
- protected final OrmJoinColumn.Owner joinColumnOwner;
-
- protected XmlJoinColumnsMapping resource;
-
-
- protected AbstractOrmJoinColumnJoiningStrategy(
- JoinColumnEnabledRelationshipReference parent,
- XmlJoinColumnsMapping resource) {
- super(parent);
- this.resource = resource;
- this.joinColumnOwner = this.buildJoinColumnOwner();
- this.initializeSpecifiedJoinColumns();
- this.initializeDefaultJoinColumn();
- }
-
- public void initializeFrom(JoinColumnJoiningStrategy oldStrategy) {
- for (JoinColumn joinColumn : CollectionTools.iterable(oldStrategy.joinColumns())) {
- JoinColumn newJoinColumn = this.addSpecifiedJoinColumn(this.specifiedJoinColumnsSize());
- newJoinColumn.setSpecifiedName(joinColumn.getName());
- newJoinColumn.setSpecifiedReferencedColumnName(joinColumn.getReferencedColumnName());
- }
- }
-
- protected abstract OrmJoinColumn.Owner buildJoinColumnOwner();
-
- protected void initializeSpecifiedJoinColumns() {
- for (XmlJoinColumn resourceJoinColumn : this.resource.getJoinColumns()) {
- this.specifiedJoinColumns.add(buildJoinColumn(resourceJoinColumn));
- }
- }
-
- protected void initializeDefaultJoinColumn() {
- if (mayHaveDefaultJoinColumn()) {
- this.defaultJoinColumn = this.buildJoinColumn(null);
- }
- }
-
- @Override
- public JoinColumnEnabledRelationshipReference getParent() {
- return (JoinColumnEnabledRelationshipReference) super.getParent();
- }
-
- public JoinColumnEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? null : getRelationshipSource().getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? null : typeMapping.getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? false : typeMapping.tableNameIsInvalid(tableName);
- }
-
- protected Iterator<String> candidateTableNames() {
- TypeMapping typeMapping = getRelationshipSource();
- return typeMapping == null ? EmptyIterator.<String> instance() : typeMapping.associatedTableNamesIncludingInherited();
- }
-
- public void addStrategy() {
- if (specifiedJoinColumnsSize() == 0) {
- addSpecifiedJoinColumn(0);
- }
- }
-
- public void removeStrategy() {
- for (JoinColumn each : CollectionTools.iterable(specifiedJoinColumns())) {
- removeSpecifiedJoinColumn(each);
- }
- }
-
- public Table getReferencedColumnDbTable() {
- TypeMapping relationshipTarget = getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
-
- // **************** join columns *******************************************
-
- public ListIterator<OrmJoinColumn> joinColumns() {
- return this.hasSpecifiedJoinColumns() ?
- this.specifiedJoinColumns() : this.defaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ?
- this.specifiedJoinColumnsSize() : this.defaultJoinColumnsSize();
- }
-
-
- // **************** default join column ************************************
-
- public OrmJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(OrmJoinColumn joinColumn) {
- OrmJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn);
- }
-
- protected ListIterator<OrmJoinColumn> defaultJoinColumns() {
- if (this.defaultJoinColumn != null) {
- return new SingleElementListIterator<OrmJoinColumn>(this.defaultJoinColumn);
- }
- return EmptyListIterator.instance();
- }
-
- protected int defaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
-
- // **************** specified join columns *********************************
-
- public ListIterator<OrmJoinColumn> specifiedJoinColumns() {
- return new CloneListIterator<OrmJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return ! this.specifiedJoinColumns.isEmpty();
- }
-
- public OrmJoinColumn addSpecifiedJoinColumn(int index) {
- OrmJoinColumn oldDefaultJoinColumn = this.defaultJoinColumn;
- if (oldDefaultJoinColumn != null) {
- //null the default join column now if one already exists.
- //if one does not exist, there is already a specified join column.
- //Remove it now so that it doesn't get removed during an update and
- //cause change notifications to be sent to the UI in the wrong order
- this.defaultJoinColumn = null;
- }
- XmlJoinColumn resourceJoinColumn = OrmFactory.eINSTANCE.createXmlJoinColumn();
- OrmJoinColumn contextJoinColumn = this.buildJoinColumn(resourceJoinColumn);
- this.specifiedJoinColumns.add(index, contextJoinColumn);
- this.resource.getJoinColumns().add(index, resourceJoinColumn);
- this.fireItemAdded(SPECIFIED_JOIN_COLUMNS_LIST, index, contextJoinColumn);
- if (oldDefaultJoinColumn != null) {
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, oldDefaultJoinColumn, null);
- }
- return contextJoinColumn;
- }
-
- protected void addSpecifiedJoinColumn(int index, OrmJoinColumn joinColumn) {
- this.addItemToList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected void addSpecifiedJoinColumn(OrmJoinColumn joinColumn) {
- this.addSpecifiedJoinColumn(this.specifiedJoinColumns.size(), joinColumn);
- }
-
- public void removeSpecifiedJoinColumn(JoinColumn joinColumn) {
- this.removeSpecifiedJoinColumn(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- public void removeSpecifiedJoinColumn(int index) {
- OrmJoinColumn removedJoinColumn = this.specifiedJoinColumns.remove(index);
- if (this.specifiedJoinColumns.isEmpty()) {
- //create the defaultJoinColumn now or this will happen during project update
- //after removing the join column from the resource model. That causes problems
- //in the UI because the change notifications end up in the wrong order.
- this.defaultJoinColumn = this.buildJoinColumn(null);
- }
- this.resource.getJoinColumns().remove(index);
- this.fireItemRemoved(SPECIFIED_JOIN_COLUMNS_LIST, index, removedJoinColumn);
- if (this.defaultJoinColumn != null) {
- //fire change notification if a defaultJoinColumn was created above
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, null, this.defaultJoinColumn);
- }
- }
-
- protected void removeSpecifiedJoinColumn_(OrmJoinColumn joinColumn) {
- removeItemFromList(joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.specifiedJoinColumns, targetIndex, sourceIndex);
- this.resource.getJoinColumns().move(targetIndex, sourceIndex);
- fireItemMoved(SPECIFIED_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
- protected OrmJoinColumn buildJoinColumn(XmlJoinColumn resourceJoinColumn) {
- return this.getXmlContextNodeFactory().buildOrmJoinColumn(this, this.joinColumnOwner, resourceJoinColumn);
- }
-
- // **************** resource => context ************************************
-
- public void update() {
- updateSpecifiedJoinColumns();
- updateDefaultJoinColumn();
- }
-
- protected void updateSpecifiedJoinColumns() {
- // make a copy of the XML join columns (to prevent ConcurrentModificationException)
- Iterator<XmlJoinColumn> xmlJoinColumns =
- new CloneIterator<XmlJoinColumn>(this.resource.getJoinColumns());
-
- for (Iterator<OrmJoinColumn> contextJoinColumns = this.specifiedJoinColumns();
- contextJoinColumns.hasNext(); ) {
- OrmJoinColumn contextJoinColumn = contextJoinColumns.next();
- if (xmlJoinColumns.hasNext()) {
- contextJoinColumn.update(xmlJoinColumns.next());
- }
- else {
- removeSpecifiedJoinColumn_(contextJoinColumn);
- }
- }
-
- while (xmlJoinColumns.hasNext()) {
- addSpecifiedJoinColumn(buildJoinColumn(xmlJoinColumns.next()));
- }
- }
-
- protected void updateDefaultJoinColumn() {
- if (mayHaveDefaultJoinColumn()) {
- if (this.defaultJoinColumn == null) {
- this.setDefaultJoinColumn(this.buildJoinColumn(null));
- } else {
- this.defaultJoinColumn.update(null);
- }
- } else {
- this.setDefaultJoinColumn(null);
- }
- }
-
- protected boolean mayHaveDefaultJoinColumn() {
- return getRelationshipReference().mayHaveDefaultJoinColumn()
- && ! hasSpecifiedJoinColumns();
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- for (Iterator<OrmJoinColumn> stream = this.joinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinTableJoiningStrategy.java
deleted file mode 100644
index 6dbfa49f67..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.JoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.JoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmJoinTableJoiningStrategy
- extends AbstractOrmXmlContextNode
- implements OrmJoinTableJoiningStrategy, Table.Owner
-{
- protected OrmJoinTable joinTable;
-
-
- protected AbstractOrmJoinTableJoiningStrategy(
- JoinTableEnabledRelationshipReference parent) {
- super(parent);
- }
-
- public void initializeFrom(JoinTableJoiningStrategy oldStrategy) {
- JoinTable oldJoinTable = (oldStrategy.getJoinTable());
- if (oldJoinTable != null) {
- this.addStrategy();
- this.getJoinTable().setSpecifiedCatalog(oldJoinTable.getSpecifiedCatalog());
- this.getJoinTable().setSpecifiedSchema(oldJoinTable.getSpecifiedSchema());
- this.getJoinTable().setSpecifiedName(oldJoinTable.getSpecifiedName());
- }
- }
-
- @Override
- public JoinTableEnabledRelationshipReference getParent() {
- return (JoinTableEnabledRelationshipReference) super.getParent();
- }
-
- public JoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- return getJoinTable().getName();
- }
-
- public org.eclipse.jpt.db.Table getDbTable(String tableName) {
- return getJoinTable().getDbTable();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return !StringTools.stringsAreEqual(getTableName(), tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.DOES_NOT_MATCH_JOIN_TABLE;
- }
-
- public String getJoinTableDefaultName() {
- return MappingTools.buildJoinTableDefaultName(this.getRelationshipReference());
- }
-
- public void addStrategy() {
- if (this.joinTable == null) {
- XmlJoinTable resourceJoinTable = OrmFactory.eINSTANCE.createXmlJoinTable();
- this.joinTable = this.buildOrmJoinTable(resourceJoinTable);
- setResourceJoinTable(resourceJoinTable);
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, null, this.joinTable);
- }
- }
-
- public void removeStrategy() {
- if (this.joinTable != null) {
- OrmJoinTable oldJoinTable = this.joinTable;
- this.joinTable = null;
- removeResourceJoinTable();
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, oldJoinTable, null);
- }
- }
-
- protected abstract void setResourceJoinTable(XmlJoinTable resourceJoinTable);
-
-
- // **************** join table *********************************************
-
- public OrmJoinTable getJoinTable() {
- return this.joinTable;
- }
-
- public OrmJoinTable addJoinTable() {
- addStrategy();
- return this.joinTable;
- }
-
- protected void setJoinTable_(OrmJoinTable newJoinTable) {
- OrmJoinTable oldJoinTable = this.joinTable;
- this.joinTable = newJoinTable;
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, oldJoinTable, newJoinTable);
- }
-
- public XmlJoinTable addResourceJoinTable() {
- XmlJoinTable resourceJoinTable = OrmFactory.eINSTANCE.createXmlJoinTable();
- setResourceJoinTable(resourceJoinTable);
- return resourceJoinTable;
- }
-
- protected boolean mayHaveJoinTable() {
- return getResourceJoinTable() != null
- || getRelationshipReference().mayHaveDefaultJoinTable();
- }
-
-
- // **************** resource -> context ************************************
-
- protected void initialize() {
- if (mayHaveJoinTable()) {
- this.joinTable = this.buildOrmJoinTable(getResourceJoinTable());
- }
- }
-
- public void update() {
- if (mayHaveJoinTable()) {
- if (this.joinTable == null) {
- setJoinTable_(this.buildOrmJoinTable(getResourceJoinTable()));
- }
- this.joinTable.update();
- }
- else {
- if (this.joinTable != null) {
- // no resource, so no clean up
- setJoinTable_(null);
- }
- }
- }
-
- protected OrmJoinTable buildOrmJoinTable(XmlJoinTable resourceJoinTable) {
- return getXmlContextNodeFactory().buildOrmJoinTable(this, this, resourceJoinTable);
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- if (this.joinTable != null) {
- this.joinTable.validate(messages, reporter);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToManyMapping.java
deleted file mode 100644
index 51be06cd62..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToManyMapping.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0, which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmManyToManyMapping2_0;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-
-public abstract class AbstractOrmManyToManyMapping<T extends XmlManyToMany>
- extends AbstractOrmMultiRelationshipMapping<T>
- implements OrmManyToManyMapping2_0
-{
- protected AbstractOrmManyToManyMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- }
-
-
- @Override
- protected OrmRelationshipReference buildRelationshipReference() {
- return new GenericOrmManyToManyRelationshipReference(this, this.resourceAttributeMapping);
- }
-
- public int getXmlSequence() {
- return 70;
- }
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmManyToManyMapping(this);
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getManyToManys().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getManyToManys().remove(this.resourceAttributeMapping);
- }
-
- @Override
- public OrmManyToManyRelationshipReference getRelationshipReference() {
- return (OrmManyToManyRelationshipReference) super.getRelationshipReference();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneMapping.java
deleted file mode 100644
index 086df36c77..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneMapping.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmManyToOneMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmManyToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-
-
-public abstract class AbstractOrmManyToOneMapping<T extends XmlManyToOne>
- extends AbstractOrmSingleRelationshipMapping<T>
- implements OrmManyToOneMapping2_0
-{
- protected AbstractOrmManyToOneMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- }
-
-
- public int getXmlSequence() {
- return 40;
- }
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmManyToOneMapping(this);
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getManyToOnes().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getManyToOnes().remove(this.resourceAttributeMapping);
- }
-
- @Override
- public OrmManyToOneRelationshipReference2_0 getRelationshipReference() {
- return (OrmManyToOneRelationshipReference2_0) super.getRelationshipReference();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneRelationshipReference.java
deleted file mode 100644
index b4cd104670..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmManyToOneRelationshipReference.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmManyToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmManyToOneRelationshipReference
- extends AbstractOrmRelationshipReference
- implements OrmManyToOneRelationshipReference2_0
-{
- protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected OrmJoinTableJoiningStrategy joinTableJoiningStrategy;
-
- protected AbstractOrmManyToOneRelationshipReference(
- OrmManyToOneMapping parent, XmlManyToOne resource) {
- super(parent, resource);
- }
-
-
- @Override
- protected void initializeJoiningStrategies() {
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- }
-
- protected OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericOrmJoinColumnJoiningStrategy(this, getResourceMapping());
- }
-
- protected abstract OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy();
-
- public void initializeOn(OrmRelationshipReference newRelationshipReference) {
- newRelationshipReference.initializeFromJoinColumnEnabledRelationshipReference(this);
- }
-
- @Override
- public void initializeFromJoinColumnEnabledRelationshipReference(
- OrmJoinColumnEnabledRelationshipReference oldRelationshipReference) {
- int index = 0;
- for (JoinColumn joinColumn :
- CollectionTools.iterable(
- oldRelationshipReference.getJoinColumnJoiningStrategy().specifiedJoinColumns())) {
- OrmJoinColumn newJoinColumn = getJoinColumnJoiningStrategy().addSpecifiedJoinColumn(index++);
- newJoinColumn.initializeFrom(joinColumn);
- }
- }
-
- @Override
- public OrmManyToOneMapping getRelationshipMapping() {
- return (OrmManyToOneMapping) getParent();
- }
-
- public XmlManyToOne getResourceMapping() {
- return getRelationshipMapping().getResourceAttributeMapping();
- }
-
- public boolean isRelationshipOwner() {
- return true;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return false;
- }
-
-
- // **************** join columns *******************************************
-
- public OrmJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinTableJoiningStrategy.removeStrategy();
- // join columns are default (only strategy in fact) so no need to add to resource
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.getJoinTableJoiningStrategy().getJoinTable() == null;
- }
-
- // **************** join table *********************************************
-
- public OrmJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.addStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void updateJoiningStrategies() {
- this.joinTableJoiningStrategy.update();
- this.joinColumnJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.joinColumnJoiningStrategy.validate(messages, reporter);
- this.joinTableJoiningStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMappedSuperclass.java
deleted file mode 100644
index f8a238a3c3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMappedSuperclass.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericMappedSuperclassPrimaryKeyValidator;
-import org.eclipse.jpt.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmMappedSuperclass extends AbstractOrmTypeMapping<XmlMappedSuperclass>
- implements OrmMappedSuperclass
-{
- protected final OrmIdClassReference idClassReference;
-
-
- protected AbstractOrmMappedSuperclass(OrmPersistentType parent, XmlMappedSuperclass resourceMapping) {
- super(parent, resourceMapping);
- this.idClassReference = buildIdClassReference();
- }
-
-
- protected OrmIdClassReference buildIdClassReference() {
- return new GenericOrmIdClassReference(this, getJavaIdClassReferenceForDefaults());
- }
-
- public int getXmlSequence() {
- return 0;
- }
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- @Override
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
-
- // **************** id class **********************************************
-
- public OrmIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
-
- // ************************************************************************
-
- public JavaMappedSuperclass getJavaMappedSuperclass() {
- JavaPersistentType javaPersistentType = this.getJavaPersistentType();
- if (javaPersistentType != null && javaPersistentType.getMappingKey() == MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY) {
- return (JavaMappedSuperclass) javaPersistentType.getMapping();
- }
- return null;
- }
-
- /**
- * This checks metaDataComplete before returning the JavaMappedSuperclass.
- * As far as defaults are concerned, if metadataComplete is true, the JavaMappedSuperclass is ignored.
- */
- protected JavaMappedSuperclass getJavaMappedSuperclassForDefaults() {
- if (isMetadataComplete()) {
- return null;
- }
- return getJavaMappedSuperclass();
- }
-
- protected JavaIdClassReference getJavaIdClassReferenceForDefaults() {
- JavaMappedSuperclass javaMappedSuperclass = getJavaMappedSuperclassForDefaults();
- return (javaMappedSuperclass == null) ? null : javaMappedSuperclass.getIdClassReference();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- public Iterator<String> associatedTableNamesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public Iterator<Table> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<Table> associatedTablesIncludingInherited() {
- return EmptyIterator.instance();
- }
-
- public void addToResourceModel(XmlEntityMappings entityMappings) {
- entityMappings.getMappedSuperclasses().add(this.resourceTypeMapping);
- }
-
- public void removeFromResourceModel(XmlEntityMappings entityMappings) {
- entityMappings.getMappedSuperclasses().remove(this.resourceTypeMapping);
- }
-
- @Override
- public void update() {
- super.update();
- this.idClassReference.update(getJavaIdClassReferenceForDefaults());
- }
-
-
- //************************* refactoring ************************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createIdClassReplaceTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createIdClassReplaceTypeEdits(IType originalType, String newName) {
- return this.idClassReference.createRenameTypeEdits(originalType, newName);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createIdClassMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createIdClassMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.idClassReference.createMoveTypeEdits(originalType, newPackage);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createIdClassRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createIdClassRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.idClassReference.createRenamePackageEdits(originalPackage, newName);
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- validatePrimaryKey(messages, reporter);
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter) {
- buildPrimaryKeyValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator() {
- return new GenericMappedSuperclassPrimaryKeyValidator(this, buildTextRangeResolver());
- // TODO - JPA 2.0 validation
- }
-
- protected PrimaryKeyTextRangeResolver buildTextRangeResolver() {
- return new OrmMappedSuperclassTextRangeResolver(this);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
deleted file mode 100644
index 95bccc457b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
+++ /dev/null
@@ -1,820 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.AttributeOverride;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseOverride;
-import org.eclipse.jpt.core.context.CollectionMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.Orderable;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmMultiRelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmOrderable;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.MappingTools;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoiningStrategyTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyAttributeOverrideValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.MapKeyColumnValidator;
-import org.eclipse.jpt.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmPersistentAttribute2_0;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlMultiRelationshipMapping;
-import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlClassReference;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * ORM multi-relationship (m:m, 1:m) mapping
- */
-public abstract class AbstractOrmMultiRelationshipMapping<T extends AbstractXmlMultiRelationshipMapping>
- extends AbstractOrmRelationshipMapping<T>
- implements OrmMultiRelationshipMapping, OrmCollectionMapping2_0
-{
- protected final OrmOrderable orderable;
-
- protected String specifiedMapKey;
- protected boolean noMapKey = false;
- protected boolean pkMapKey = false;
- protected boolean customMapKey = false;
-
- protected String specifiedMapKeyClass;
- protected String defaultMapKeyClass;
- protected PersistentType resolvedMapKeyType;
- protected Embeddable resolvedMapKeyEmbeddable;
- protected Entity resolvedMapKeyEntity;
-
- protected Embeddable resolvedTargetEmbeddable;
-
- protected Type valueType;
- protected Type keyType;
-
- protected final OrmColumn mapKeyColumn;
-
- protected final OrmAttributeOverrideContainer mapKeyAttributeOverrideContainer;
-
- protected AbstractOrmMultiRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.orderable = this.buildOrderable();
- this.resolvedTargetEmbeddable = this.resolveTargetEmbeddable();
- this.valueType = this.buildValueType();
- this.resolvedMapKeyType = this.resolveMapKeyType();
- this.resolvedMapKeyEmbeddable = this.resolveMapKeyEmbeddable();
- this.resolvedMapKeyEntity = this.resolveMapKeyEntity();
- this.initializeMapKey();
- this.defaultMapKeyClass = this.buildDefaultMapKeyClass();
- this.specifiedMapKeyClass = this.getResourceMapKeyClass();
- this.mapKeyColumn = getXmlContextNodeFactory().buildOrmColumn(this, this.buildMapKeyColumnOwner());
- this.mapKeyAttributeOverrideContainer = buildMapKeyAttributeOverrideContainer();
- }
-
- @Override
- public void update() {
- super.update();
- this.orderable.update();
- this.resolvedTargetEmbeddable = this.resolveTargetEmbeddable();
- this.updateValueType();
- this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
- this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
- this.resolvedMapKeyType = this.resolveMapKeyType();//no need for change notification, use resolved target embeddable change notification instead?
- this.setResolvedMapKeyEmbeddable(this.resolveMapKeyEmbeddable());
- this.setResolvedMapKeyEntity(this.resolveMapKeyEntity());
- this.updateKeyType();
- this.updateMapKey();
- this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
- this.setSpecifiedMapKeyClass_(this.getResourceMapKeyClass());
- this.mapKeyColumn.update(getResourceMapKeyColumn());
- this.mapKeyColumn.update(getResourceMapKeyColumn());
- this.mapKeyAttributeOverrideContainer.update();
-}
-
- @Override
- protected String getResourceDefaultTargetEntity() {
- return this.getJavaPersistentAttribute().getMultiReferenceTargetTypeName();
- }
-
- public FetchType getDefaultFetch() {
- return CollectionMapping.DEFAULT_FETCH_TYPE;
- }
-
- // **************** order by ***********************************************
-
- protected OrmOrderable buildOrderable() {
- return this.isJpa2_0Compatible() ?
- this.getXmlContextNodeFactory().buildOrmOrderable(this, this.buildOrderableOwner()) :
- this.getXmlContextNodeFactory().buildOrmOrderable(this, new Orderable.Owner() {/*nothing*/});
- }
-
- public OrmOrderable getOrderable() {
- return this.orderable;
- }
-
- protected Orderable2_0.Owner buildOrderableOwner() {
- return new Orderable2_0.Owner() {
- public String getTableName() {
- return getRelationshipReference().getPredominantJoiningStrategy().getTableName();
- }
- public Table getDbTable(String tableName) {
- return getRelationshipReference().getPredominantJoiningStrategy().getDbTable(tableName);
- }
- };
- }
-
- // ********** CollectionMapping implementation **********
-
- protected Embeddable resolveTargetEmbeddable() {
- if (this.resolvedTargetType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedTargetType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- public Embeddable getResolvedMapKeyEmbeddable() {
- return this.resolvedMapKeyEmbeddable;
- }
-
- protected void setResolvedMapKeyEmbeddable(Embeddable embeddable) {
- Embeddable old = this.resolvedMapKeyEmbeddable;
- this.resolvedMapKeyEmbeddable = embeddable;
- this.firePropertyChanged(RESOLVED_MAP_KEY_EMBEDDABLE_PROPERTY, old, embeddable);
- }
-
- public Entity getResolvedMapKeyEntity() {
- return this.resolvedMapKeyEntity;
- }
-
- protected void setResolvedMapKeyEntity(Entity entity) {
- Entity old = this.resolvedMapKeyEntity;
- this.resolvedMapKeyEntity = entity;
- this.firePropertyChanged(RESOLVED_MAP_KEY_ENTITY_PROPERTY, old, entity);
- }
-
- public PersistentType getResolvedMapKeyType() {
- return getResolvedMapKeyEmbeddable() == null ? null : getResolvedMapKeyEmbeddable().getPersistentType();
- }
-
- protected PersistentType resolveMapKeyType() {
- return this.resolvePersistentType(this.getMapKeyClass());
- }
-
- protected Embeddable resolveMapKeyEmbeddable() {
- if (this.resolvedMapKeyType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedMapKeyType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- protected Entity resolveMapKeyEntity() {
- if (this.resolvedMapKeyType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedMapKeyType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- // **************** value type ************************************************
-
- public Type getValueType() {
- return this.valueType;
- }
-
- protected void setValueType(Type newValueType) {
- Type old = this.valueType;
- this.valueType = newValueType;
- firePropertyChanged(VALUE_TYPE_PROPERTY, old, newValueType);
- }
-
- protected Type buildValueType() {
- if (this.getResolvedTargetEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- else if (this.resolvedTargetEmbeddable != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- else if (getTargetEntity() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- protected void initializeValueType() {
- this.valueType = this.buildValueType();
- }
-
- protected void updateValueType() {
- this.setValueType(this.buildValueType());
- }
-
- // **************** key type ************************************************
-
- public Type getKeyType() {
- return this.keyType;
- }
-
- protected void setKeyType(Type newKeyType) {
- Type old = this.keyType;
- this.keyType = newKeyType;
- firePropertyChanged(KEY_TYPE_PROPERTY, old, newKeyType);
- }
-
- protected Type buildKeyType() {
- if (getResolvedMapKeyEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (getResolvedMapKeyEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- else if (getMapKeyClass() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- protected void initializeKeyType() {
- this.keyType = this.buildKeyType();
- }
-
- protected void updateKeyType() {
- this.setKeyType(this.buildKeyType());
- }
-
- // **************** map key ************************************************
-
- public String getMapKey() {
- if (this.noMapKey) {
- return null;
- }
- if (this.pkMapKey) {
- return this.getTargetEntityIdAttributeName();
- }
- if (this.customMapKey) {
- return this.specifiedMapKey;
- }
- throw new IllegalStateException("unknown map key"); //$NON-NLS-1$
- }
-
- public String getSpecifiedMapKey() {
- return this.specifiedMapKey;
- }
-
- public void setSpecifiedMapKey(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- if (this.attributeValueHasChanged(old, mapKey)) {
- MapKey xmlMapKey = this.getXmlMapKey();
- if (mapKey == null) {
- if (xmlMapKey != null) {
- this.removeXmlMapKey();
- }
- } else {
- if (xmlMapKey == null) {
- xmlMapKey = this.addXmlMapKey();
- }
- xmlMapKey.setName(mapKey);
- }
- }
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected void setSpecifiedMapKey_(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected void initializeMapKey() {
- MapKey xmlMapKey = this.getXmlMapKey();
- if (xmlMapKey == null) {
- this.noMapKey = true;
- } else {
- this.specifiedMapKey = xmlMapKey.getName();
- if (this.specifiedMapKey == null) {
- this.pkMapKey = true;
- } else {
- this.customMapKey = true;
- }
- }
- }
-
- protected void updateMapKey() {
- MapKey xmlMapKey = this.getXmlMapKey();
- if (xmlMapKey == null) {
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(true);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(false);
- } else {
- String mk = xmlMapKey.getName();
- this.setSpecifiedMapKey_(mk);
- this.setNoMapKey_(false);
- this.setPkMapKey_(mk == null);
- this.setCustomMapKey_(mk != null);
- }
- }
-
- protected MapKey getXmlMapKey() {
- return this.resourceAttributeMapping.getMapKey();
- }
-
- protected MapKey addXmlMapKey() {
- MapKey mapKey = OrmFactory.eINSTANCE.createMapKey();
- this.resourceAttributeMapping.setMapKey(mapKey);
- return mapKey;
- }
-
- protected void removeXmlMapKey() {
- this.resourceAttributeMapping.setMapKey(null);
- }
-
- public Iterator<String> candidateMapKeyNames() {
- return this.allTargetEntityAttributeNames();
- }
-
-
- // **************** no map key ***********************************************
-
- public boolean isNoMapKey() {
- return this.noMapKey;
- }
-
- public void setNoMapKey(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- if (noMapKey) {
- if (this.getXmlMapKey() != null) {
- this.removeXmlMapKey();
- }
- }
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
- protected void setNoMapKey_(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
-
- // **************** pk map key ***********************************************
-
- public boolean isPkMapKey() {
- return this.pkMapKey;
- }
-
- public void setPkMapKey(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- MapKey xmlMapKey = this.getXmlMapKey();
- if (pkMapKey) {
- if (xmlMapKey == null) {
- this.addXmlMapKey();
- } else {
- xmlMapKey.setName(null);
- }
- }
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
- protected void setPkMapKey_(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
-
- // **************** custom map key ***********************************************
-
- public boolean isCustomMapKey() {
- return this.customMapKey;
- }
-
- public void setCustomMapKey(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- if (customMapKey) {
- this.setSpecifiedMapKey(""); //$NON-NLS-1$
- }
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
- protected void setCustomMapKey_(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
-
- // **************** map key class ******************************************
-
- public char getMapKeyClassEnclosingTypeSeparator() {
- return '$';
- }
-
- public String getMapKeyClass() {
- return (this.specifiedMapKeyClass != null) ? this.specifiedMapKeyClass : this.defaultMapKeyClass;
- }
-
- public String getSpecifiedMapKeyClass() {
- return this.specifiedMapKeyClass;
- }
-
- public void setSpecifiedMapKeyClass(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- if (this.attributeValueHasChanged(old, mapKeyClass)) {
- XmlClassReference xmlMapKeyClass = this.getXmlMapKeyClass();
- if (mapKeyClass == null) {
- if (xmlMapKeyClass != null) {
- this.removeXmlMapKeyClass();
- }
- } else {
- if (xmlMapKeyClass == null) {
- xmlMapKeyClass = this.addXmlMapKeyClass();
- }
- xmlMapKeyClass.setClassName(mapKeyClass);
- }
- }
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected XmlClassReference getXmlMapKeyClass() {
- return this.resourceAttributeMapping.getMapKeyClass();
- }
-
- protected XmlClassReference addXmlMapKeyClass() {
- XmlClassReference mapKeyClass = OrmFactory.eINSTANCE.createXmlClassReference();
- this.resourceAttributeMapping.setMapKeyClass(mapKeyClass);
- return mapKeyClass;
- }
-
- protected void removeXmlMapKeyClass() {
- this.resourceAttributeMapping.setMapKeyClass(null);
- }
-
- public String getDefaultMapKeyClass() {
- return this.defaultMapKeyClass;
- }
-
- protected void setDefaultMapKeyClass(String mapKeyClass) {
- String old = this.defaultMapKeyClass;
- this.defaultMapKeyClass = mapKeyClass;
- this.firePropertyChanged(DEFAULT_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String getResourceMapKeyClass() {
- XmlClassReference mapKeyClass = this.resourceAttributeMapping.getMapKeyClass();
- return mapKeyClass == null ? null : mapKeyClass.getClassName();
- }
-
- protected String buildDefaultMapKeyClass() {
- if (this.getJavaPersistentAttribute() != null) {
- return this.getJavaPersistentAttribute().getMultiReferenceMapKeyTypeName();
- }
- return null;
- }
-
- // ************** value column ********************************************
-
- public OrmColumn getMapKeyColumn() {
- return this.mapKeyColumn;
- }
-
- protected XmlColumn getResourceMapKeyColumn() {
- return this.resourceAttributeMapping.getMapKeyColumn();
- }
-
- protected OrmColumn.Owner buildMapKeyColumnOwner() {
- return new MapKeyColumnOwner();
- }
-
- public OrmAttributeOverrideContainer getMapKeyAttributeOverrideContainer() {
- return this.mapKeyAttributeOverrideContainer;
- }
-
- protected OrmAttributeOverrideContainer buildMapKeyAttributeOverrideContainer() {
- return getXmlContextNodeFactory().buildOrmAttributeOverrideContainer(this, new MapKeyAttributeOverrideContainerOwner());
- }
-
- protected JavaAttributeOverride getJavaMapKeyAttributeOverrideNamed(String attributeName) {
- if (getJavaMultiRelationshipMapping() != null) {
- return getJavaMultiRelationshipMapping().getMapKeyAttributeOverrideContainer().getAttributeOverrideNamed(attributeName);
- }
- return null;
- }
-
- protected JavaCollectionMapping2_0 getJavaMultiRelationshipMapping() {
- if (this.getJavaPersistentAttribute() == null) {
- return null;
- }
- AttributeMapping javaAttributeMapping = this.getJavaPersistentAttribute().getMapping();
- if (javaAttributeMapping.getKey() == this.getKey()) {
- return ((JavaCollectionMapping2_0) javaAttributeMapping);
- }
- return null;
- }
-
- // ********** metamodel **********
-
- @Override
- protected String getMetamodelFieldTypeName() {
- return ((OrmPersistentAttribute2_0) getPersistentAttribute()).getMetamodelContainerFieldTypeName();
- }
-
- @Override
- protected void addMetamodelFieldTypeArgumentNamesTo(ArrayList<String> typeArgumentNames) {
- this.addMetamodelFieldMapKeyTypeArgumentNameTo(typeArgumentNames);
- super.addMetamodelFieldTypeArgumentNamesTo(typeArgumentNames);
- }
-
- protected void addMetamodelFieldMapKeyTypeArgumentNameTo(ArrayList<String> typeArgumentNames) {
- String keyTypeName = ((OrmPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
- if (keyTypeName != null) {
- typeArgumentNames.add(keyTypeName);
- }
- }
-
- public String getMetamodelFieldMapKeyTypeName() {
- return MappingTools.getMetamodelFieldMapKeyTypeName(this);
- }
-
-
- //************* refactoring *************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createMapKeyClassRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createMapKeyClassRenameTypeEdits(IType originalType, String newName) {
- if (this.specifiedMapKeyClass != null) {
- String originalName = originalType.getFullyQualifiedName('.');
- if (this.resolvedMapKeyType != null && this.resolvedMapKeyType.isFor(originalName)) {
- return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenameTypeEdit(originalType, newName));
- }
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createMapKeyClassRenameTypeEdit(IType originalType, String newName) {
- return this.resourceAttributeMapping.createRenameMapKeyClassEdit(originalType, newName);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createMapKeyClassMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createMapKeyClassMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (this.specifiedMapKeyClass != null) {
- String originalName = originalType.getFullyQualifiedName('.');
- if (this.resolvedMapKeyType != null && this.resolvedMapKeyType.isFor(originalName)) {
- return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenamePackageEdit(newPackage.getElementName()));
- }
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createMapKeyClassRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createMapKeyClassRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (this.specifiedMapKeyClass != null) {
- if (this.resolvedMapKeyType != null && this.resolvedMapKeyType.isIn(originalPackage)) {
- return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenamePackageEdit(newName));
- }
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createMapKeyClassRenamePackageEdit(String newName) {
- return this.resourceAttributeMapping.createRenameMapKeyClassPackageEdit(newName);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.orderable.validate(messages, reporter);
- this.validateMapKey(messages, reporter);
- }
-
- public void validateMapKey(List<IMessage> messages, IReporter reporter) {
- if (getMapKey() != null || getMapKeyAnnotation() != null) {
- //TODO validate that the map key refers to an existing attribute
- return;
- }
- if (getKeyType() == Type.BASIC_TYPE) {
- this.getMapKeyColumn().validate(messages, reporter);
- //validate map key converter
- }
- else if (getKeyType() == Type.ENTITY_TYPE) {
- //validate map key join columns
- }
- else if (getKeyType() == Type.EMBEDDABLE_TYPE) {
- getMapKeyAttributeOverrideContainer().validate(messages, reporter);
- //validate map key association overrides
- }
- }
- protected MapKeyAnnotation getMapKeyAnnotation() {
- if (!isVirtual()) {
- return null;
- }
- JavaResourcePersistentAttribute jrpa = getJavaResourcePersistentAttribute();
- return jrpa == null ? null : (MapKeyAnnotation) jrpa.getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
-
- protected class MapKeyColumnOwner implements OrmColumn.Owner {
- public TypeMapping getTypeMapping() {
- return AbstractOrmMultiRelationshipMapping.this.getTypeMapping();
- }
-
- protected OrmJoiningStrategy getPredominantJoiningStrategy() {
- return getRelationshipReference().getPredominantJoiningStrategy();
- }
-
- public String getDefaultTableName() {
- return getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public String getDefaultColumnName() {
- return AbstractOrmMultiRelationshipMapping.this.getName() + "_KEY"; //$NON-NLS-1$
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getRelationshipReference().getPredominantJoiningStrategy().tableNameIsInvalid(tableName);
- }
-
- public java.util.Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- public XmlColumn getResourceColumn() {
- return AbstractOrmMultiRelationshipMapping.this.resourceAttributeMapping.getMapKeyColumn();
- }
-
- public void addResourceColumn() {
- AbstractOrmMultiRelationshipMapping.this.resourceAttributeMapping.setMapKeyColumn(OrmFactory.eINSTANCE.createXmlColumn());
- }
-
- public void removeResourceColumn() {
- AbstractOrmMultiRelationshipMapping.this.resourceAttributeMapping.setMapKeyColumn(null);
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmMultiRelationshipMapping.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new MapKeyColumnValidator(getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new JoiningStrategyTableDescriptionProvider(getPredominantJoiningStrategy()));
- }
- }
-
- protected class MapKeyAttributeOverrideContainerOwner
- implements OrmAttributeOverrideContainer.Owner
- {
- public OrmTypeMapping getTypeMapping() {
- return AbstractOrmMultiRelationshipMapping.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractOrmMultiRelationshipMapping.this.getResolvedMapKeyEmbeddable();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = getOverridableTypeMapping();
- return (typeMapping == null) ?
- EmptyIterator.<String>instance()
- : typeMapping.allOverridableAttributeNames();
- }
-
- protected JavaAttributeOverride getJavaAttributeOverrideNamed(String attributeName) {
- return AbstractOrmMultiRelationshipMapping.this.getJavaMapKeyAttributeOverrideNamed(attributeName);
- }
-
- public EList<XmlAttributeOverride> getResourceAttributeOverrides() {
- return AbstractOrmMultiRelationshipMapping.this.resourceAttributeMapping.getMapKeyAttributeOverrides();
- }
-
- public Column resolveOverriddenColumn(String attributeOverrideName) {
- if (getPersistentAttribute().isVirtual() && !getTypeMapping().isMetadataComplete()) {
- JavaAttributeOverride javaAttributeOverride = getJavaAttributeOverrideNamed(attributeOverrideName);
- if (javaAttributeOverride != null && !javaAttributeOverride.isVirtual()) {
- return javaAttributeOverride.getColumn();
- }
- }
- return MappingTools.resolveOverridenColumn(getOverridableTypeMapping(), attributeOverrideName);
- }
-
-
- public XmlColumn buildVirtualXmlColumn(Column overridableColumn, String attributeName, boolean isMetadataComplete) {
- return new VirtualXmlAttributeOverrideColumn(overridableColumn);
- }
-
- protected OrmJoiningStrategy getPredominantJoiningStrategy() {
- return getRelationshipReference().getPredominantJoiningStrategy();
- }
-
- public String getDefaultTableName() {
- return getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public java.util.Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- /**
- * If there is a specified table name it needs to be the same
- * the default table name. the table is always the collection table
- */
- public boolean tableNameIsInvalid(String tableName) {
- return !StringTools.stringsAreEqual(getDefaultTableName(), tableName);
- }
-
- public JptValidator buildValidator(BaseOverride override, BaseOverride.Owner owner, OverrideTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideValidator(getPersistentAttribute(), (AttributeOverride) override, (AttributeOverride.Owner) owner, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(BaseOverride override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideColumnValidator(getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new JoiningStrategyTableDescriptionProvider(getPredominantJoiningStrategy()));
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmMultiRelationshipMapping.this.getValidationTextRange();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java
deleted file mode 100644
index 74ff5696dd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmNamedColumn.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmNamedColumn;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlNamedColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Column;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmNamedColumn<T extends AbstractXmlNamedColumn> extends AbstractOrmXmlContextNode
- implements OrmNamedColumn
-{
- protected Owner owner;
-
- protected String specifiedName;
-
- protected String defaultName;
-
- protected String columnDefinition;
-
- protected AbstractOrmNamedColumn(XmlContextNode parent, Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- public void initializeFrom(NamedColumn oldColumn) {
- setSpecifiedName(oldColumn.getSpecifiedName());
- setColumnDefinition(oldColumn.getColumnDefinition());
- }
-
- protected abstract T getResourceColumn();
-
- protected abstract void removeResourceColumn();
-
- protected abstract void addResourceColumn();
-
- protected void removeResourceColumnIfFeaturesUnset() {
- if (this.getResourceColumn().isUnset()) {
- removeResourceColumn();
- }
- }
-
- public Owner getOwner() {
- return this.owner;
- }
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- if (this.attributeValueHasChanged(oldSpecifiedName, newSpecifiedName)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setName(newSpecifiedName);
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newSpecifiedName != null) {
- addResourceColumn();
- getResourceColumn().setName(newSpecifiedName);
- }
- }
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- protected void setSpecifiedName_(String newSpecifiedName) {
- String oldSpecifiedName = this.specifiedName;
- this.specifiedName = newSpecifiedName;
- firePropertyChanged(SPECIFIED_NAME_PROPERTY, oldSpecifiedName, newSpecifiedName);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String newDefaultName) {
- String oldDefaultName = this.defaultName;
- this.defaultName = newDefaultName;
- firePropertyChanged(DEFAULT_NAME_PROPERTY, oldDefaultName, newDefaultName);
- }
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- public void setColumnDefinition(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- if (this.attributeValueHasChanged(oldColumnDefinition, newColumnDefinition)) {
- if (this.getResourceColumn() != null) {
- this.getResourceColumn().setColumnDefinition(newColumnDefinition);
- this.removeResourceColumnIfFeaturesUnset();
- }
- else if (newColumnDefinition != null) {
- addResourceColumn();
- getResourceColumn().setColumnDefinition(newColumnDefinition);
- }
- }
- firePropertyChanged(COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- protected void setColumnDefinition_(String newColumnDefinition) {
- String oldColumnDefinition = this.columnDefinition;
- this.columnDefinition = newColumnDefinition;
- firePropertyChanged(COLUMN_DEFINITION_PROPERTY, oldColumnDefinition, newColumnDefinition);
- }
-
- public Column getDbColumn() {
- Table table = this.getDbTable();
- return (table == null) ? null : table.getColumnForIdentifier(getName());
- }
-
- public Table getDbTable() {
- return getOwner().getDbTable(this.getTable());
- }
-
- /**
- * Return the name of the column's table. This is overridden
- * in AbstractOrmBaseColumn where a table can be defined.
- */
- public String getTable() {
- return this.getOwner().getTypeMapping().getPrimaryTableName();
- }
-
- public boolean isResolved() {
- return getDbColumn() != null;
- }
-
- public TextRange getNameTextRange() {
- if (getResourceColumn() != null) {
- TextRange textRange = getResourceColumn().getNameTextRange();
- if (textRange != null) {
- return textRange;
- }
- }
- return getOwner().getValidationTextRange();
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = getResourceColumn().getValidationTextRange();
- if (textRange != null) {
- return textRange;
- }
- return getOwner().getValidationTextRange();
- }
-
-
- // ******************* initialization from orm xml resource model ********************
-
- protected void initialize(T column) {
- this.specifiedName = this.getResourceColumnName(column);
- this.defaultName = this.buildDefaultName();
- this.columnDefinition = this.getResourceColumnDefinition(column);
- }
-
- protected void update(T column) {
- setSpecifiedName_(this.getResourceColumnName(column));
- setDefaultName(this.buildDefaultName());
- setColumnDefinition_(this.getResourceColumnDefinition(column));
- }
-
- protected String getResourceColumnName(T column) {
- return column == null ? null : column.getName();
- }
-
- protected String getResourceColumnDefinition(T column) {
- return column == null ? null : column.getColumnDefinition();
- }
-
- /**
- * Return the default column name.
- */
- protected String buildDefaultName() {
- return this.getOwner().getDefaultColumnName();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.buildColumnValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildColumnValidator() {
- return this.getOwner().buildColumnValidator(this, buildTextRangeResolver());
- }
-
- protected NamedColumnTextRangeResolver buildTextRangeResolver() {
- return new OrmNamedColumnTextRangeResolver(this);
- }
-} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyMapping.java
deleted file mode 100644
index e10221dabb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyMapping.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0, which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToManyMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToManyRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
-
-
-public abstract class AbstractOrmOneToManyMapping<T extends XmlOneToMany>
- extends AbstractOrmMultiRelationshipMapping<T>
- implements OrmOneToManyMapping2_0, OrmOrphanRemovalHolder2_0
-{
- protected final OrmOrphanRemovable2_0 orphanRemoval;
-
- // ********** constructor **********
- protected AbstractOrmOneToManyMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.orphanRemoval = ((OrmXml2_0ContextNodeFactory) getXmlContextNodeFactory()).buildOrmOrphanRemoval(this, resourceMapping);
- }
-
- // ********** update **********
-
- @Override
- public void update() {
- super.update();
- this.getOrphanRemoval().update();
- }
-
- public int getXmlSequence() {
- return 50;
- }
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmOneToManyMapping(this);
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getOneToManys().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getOneToManys().remove(this.resourceAttributeMapping);
- }
-
- @Override
- public OrmOneToManyRelationshipReference2_0 getRelationshipReference() {
- return (OrmOneToManyRelationshipReference2_0) super.getRelationshipReference();
- }
-
- // ********** OrmOrphanRemovalHolder2_0 implementation **********
-
- public OrmOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java
deleted file mode 100644
index 9037e773e0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToManyRelationshipReference.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToManyRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmOneToManyRelationshipReference
- extends AbstractOrmRelationshipReference
- implements OrmOneToManyRelationshipReference2_0
-{
- protected OrmMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected OrmJoinTableJoiningStrategy joinTableJoiningStrategy;
-
- protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected AbstractOrmOneToManyRelationshipReference(
- OrmOneToManyMapping parent, XmlOneToMany resource) {
- super(parent, resource);
- }
-
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
-
- // initialize join table last, as the existence of a default join
- // table is dependent on the other mechanisms (mappedBy)
- // not being specified
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
- protected OrmMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericOrmMappedByJoiningStrategy(this, getResourceMapping());
- }
-
- protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping());
- }
-
- protected abstract OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy();
-
- public void initializeOn(OrmRelationshipReference newRelationshipReference) {
- newRelationshipReference.initializeFromOwnableRelationshipReference(this);
- newRelationshipReference.initializeFromJoinTableEnabledRelationshipReference(this);
- }
-
- @Override
- public void initializeFromOwnableRelationshipReference(
- OrmOwnableRelationshipReference oldRelationshipReference) {
- super.initializeFromOwnableRelationshipReference(oldRelationshipReference);
- this.mappedByJoiningStrategy.setMappedByAttribute(
- oldRelationshipReference.getMappedByJoiningStrategy().getMappedByAttribute());
- }
-
- @Override
- public void initializeFromJoinTableEnabledRelationshipReference(
- OrmJoinTableEnabledRelationshipReference oldRelationshipReference) {
- super.initializeFromJoinTableEnabledRelationshipReference(oldRelationshipReference);
- OrmJoinTable oldTable =
- oldRelationshipReference.getJoinTableJoiningStrategy().getJoinTable();
- if (oldTable != null) {
- this.joinTableJoiningStrategy.addJoinTable().initializeFrom(oldTable);
- }
- }
-
- @Override
- public OrmOneToManyMapping getRelationshipMapping() {
- return (OrmOneToManyMapping) getParent();
- }
-
- public XmlOneToMany getResourceMapping() {
- return getRelationshipMapping().getResourceAttributeMapping();
- }
-
- public boolean isRelationshipOwner() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public boolean isTargetForeignKeyRelationship() {
- return getJoinColumnJoiningStrategy().isTargetForeignKeyRelationship();
- }
-
-
- // **************** mapped by **********************************************
-
- public OrmMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public final void setMappedByJoiningStrategy() {
- setMappedByJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void setMappedByJoiningStrategy_() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public final void unsetMappedByJoiningStrategy() {
- unsetMappedByJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetMappedByJoiningStrategy_() {
- this.mappedByJoiningStrategy.removeStrategy();
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return this.getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join table *********************************************
-
- public OrmJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- setJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void setJoinTableJoiningStrategy_() {
- // join table is default, so no need to add to resource
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null
- && ! this.joinColumnJoiningStrategy.hasSpecifiedJoinColumns();
- }
-
-
- // **************** join columns *******************************************
-
- public OrmJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.joinColumnJoiningStrategy.update();
-
- // update join table last, as the existence of a default join
- // table is dependent on the other mechanisms (mappedBy)
- // not being specified
- this.joinTableJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.mappedByJoiningStrategy.validate(messages, reporter);
- this.joinTableJoiningStrategy.validate(messages, reporter);
- this.joinColumnJoiningStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneMapping.java
deleted file mode 100644
index 277405cd38..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneMapping.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToOneMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-
-
-public abstract class AbstractOrmOneToOneMapping<T extends XmlOneToOne>
- extends AbstractOrmSingleRelationshipMapping<T>
- implements OrmOneToOneMapping2_0, OrmOrphanRemovalHolder2_0
-{
- protected final OrmOrphanRemovable2_0 orphanRemoval;
-
- // ********** constructor **********
- protected AbstractOrmOneToOneMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.orphanRemoval = ((OrmXml2_0ContextNodeFactory) getXmlContextNodeFactory()).buildOrmOrphanRemoval(this, resourceMapping);
- }
-
- // ********** update **********
-
- @Override
- public void update() {
- super.update();
- this.getOrphanRemoval().update();
- }
-
- public int getXmlSequence() {
- return 60;
- }
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmOneToOneMapping(this);
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getOneToOnes().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getOneToOnes().remove(this.resourceAttributeMapping);
- }
-
- @Override
- public OrmOneToOneRelationshipReference2_0 getRelationshipReference() {
- return (OrmOneToOneRelationshipReference2_0) super.getRelationshipReference();
- }
-
- // ********** OrmOrphanRemovalHolder2_0 implementation **********
-
- public OrmOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneRelationshipReference.java
deleted file mode 100644
index 136371467a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmOneToOneRelationshipReference.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOneToOneRelationshipReference2_0;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmOneToOneRelationshipReference
- extends AbstractOrmRelationshipReference
- implements OrmOneToOneRelationshipReference2_0
-{
- protected OrmMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected OrmJoinColumnJoiningStrategy joinColumnJoiningStrategy;
-
- protected OrmPrimaryKeyJoinColumnJoiningStrategy primaryKeyJoinColumnJoiningStrategy;
-
- protected OrmJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
- protected AbstractOrmOneToOneRelationshipReference(
- OrmOneToOneMapping parent, XmlOneToOne resource) {
- super(parent, resource);
- }
-
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
- this.primaryKeyJoinColumnJoiningStrategy = buildPrimaryKeyJoinColumnJoiningStrategy();
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
-
- // initialize join columns last, as the existence of a default join
- // column is dependent on the other mechanisms (mappedBy, join table)
- // not being specified
- this.joinColumnJoiningStrategy = buildJoinColumnJoiningStrategy();
- }
-
- protected OrmMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericOrmMappedByJoiningStrategy(this, getResourceMapping());
- }
-
- protected OrmJoinColumnJoiningStrategy buildJoinColumnJoiningStrategy() {
- return new GenericOrmJoinColumnJoiningStrategy(this, getResourceMapping());
- }
-
- protected OrmPrimaryKeyJoinColumnJoiningStrategy buildPrimaryKeyJoinColumnJoiningStrategy() {
- return new GenericOrmPrimaryKeyJoinColumnJoiningStrategy(this, getResourceMapping());
- }
-
- protected abstract OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy();
-
- public void initializeOn(OrmRelationshipReference newRelationshipReference) {
- newRelationshipReference.initializeFromOwnableRelationshipReference(this);
- newRelationshipReference.initializeFromJoinColumnEnabledRelationshipReference(this);
- // no other primary key reference as of yet, so no initialization based on pk join columns
- }
-
- @Override
- public void initializeFromOwnableRelationshipReference(
- OrmOwnableRelationshipReference oldRelationshipReference) {
- this.mappedByJoiningStrategy.setMappedByAttribute(
- oldRelationshipReference.getMappedByJoiningStrategy().getMappedByAttribute());
- }
-
- @Override
- public void initializeFromJoinColumnEnabledRelationshipReference(
- OrmJoinColumnEnabledRelationshipReference oldRelationshipReference) {
- int index = 0;
- for (JoinColumn joinColumn :
- CollectionTools.iterable(
- oldRelationshipReference.getJoinColumnJoiningStrategy().specifiedJoinColumns())) {
- OrmJoinColumn newJoinColumn = getJoinColumnJoiningStrategy().addSpecifiedJoinColumn(index++);
- newJoinColumn.initializeFrom(joinColumn);
- }
- }
-
- @Override
- public OrmOneToOneMapping getRelationshipMapping() {
- return (OrmOneToOneMapping) getParent();
- }
-
- public XmlOneToOne getResourceMapping() {
- return getRelationshipMapping().getResourceAttributeMapping();
- }
-
- public boolean isRelationshipOwner() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- // **************** mapped by **********************************************
-
- public OrmMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public void setMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join columns *******************************************
-
- public OrmJoinColumnJoiningStrategy getJoinColumnJoiningStrategy() {
- return this.joinColumnJoiningStrategy;
- }
-
- public boolean usesJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinColumnJoiningStrategy;
- }
-
- public void setJoinColumnJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- // join columns are default, so no need to add annotations
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinColumnJoiningStrategy() {
- this.joinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.getMappedByJoiningStrategy().getMappedByAttribute() == null
- && this.getPrimaryKeyJoinColumnJoiningStrategy().primaryKeyJoinColumnsSize() == 0
- && this.getJoinTableJoiningStrategy().getJoinTable() == null;
- }
-
-
- // **************** primary key join columns *******************************
-
- public OrmPrimaryKeyJoinColumnJoiningStrategy getPrimaryKeyJoinColumnJoiningStrategy() {
- return this.primaryKeyJoinColumnJoiningStrategy;
- }
-
- public boolean usesPrimaryKeyJoinColumnJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.primaryKeyJoinColumnJoiningStrategy;
- }
-
- public void setPrimaryKeyJoinColumnJoiningStrategy() {
- this.primaryKeyJoinColumnJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetPrimaryKeyJoinColumnJoiningStrategy() {
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultPrimaryKeyJoinColumn() {
- return false;
- }
-
-
- // **************** join table *********************************************
-
- public OrmJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public final void setJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.addStrategy();
- this.mappedByJoiningStrategy.removeStrategy();
- this.joinColumnJoiningStrategy.removeStrategy();
- this.primaryKeyJoinColumnJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public final void unsetJoinTableJoiningStrategy() {
- unsetJoinTableJoiningStrategy_();
- setPredominantJoiningStrategy();
- }
-
- protected void unsetJoinTableJoiningStrategy_() {
- this.joinTableJoiningStrategy.removeStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
- this.primaryKeyJoinColumnJoiningStrategy.update();
- this.joinTableJoiningStrategy.update();
- // update join columns last, as the existence of a default join
- // column is dependent on the other mechanisms (mappedBy, join table)
- // not being specified
- this.joinColumnJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.mappedByJoiningStrategy.validate(messages, reporter);
- this.primaryKeyJoinColumnJoiningStrategy.validate(messages, reporter);
- this.joinColumnJoiningStrategy.validate(messages, reporter);
- this.joinTableJoiningStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java
deleted file mode 100644
index 995652fe54..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmPersistentAttribute.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.CollectionMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmStructureNodes;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmPersistentAttribute2_0;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * ORM persistent attribute
- */
-public abstract class AbstractOrmPersistentAttribute
- extends AbstractOrmXmlContextNode
- implements OrmPersistentAttribute2_0
-{
- protected final Owner owner;
-
- protected OrmAttributeMapping attributeMapping;
-
- protected JavaPersistentAttribute javaPersistentAttribute;
-
- protected AccessType defaultAccess;
-
- protected AbstractOrmPersistentAttribute(OrmPersistentType parent, Owner owner, XmlAttributeMapping resourceMapping) {
- super(parent);
- this.owner = owner;
- this.attributeMapping = buildAttributeMapping(resourceMapping);
- this.javaPersistentAttribute = findJavaPersistentAttribute();
- this.defaultAccess = buildDefaultAccess();
- }
-
- public XmlAttributeMapping getResourceAttributeMapping() {
- return this.attributeMapping.getResourceAttributeMapping();
- }
-
- public JavaPersistentAttribute getJavaPersistentAttribute() {
- return this.javaPersistentAttribute;
- }
-
- protected void setJavaPersistentAttribute(JavaPersistentAttribute javaPersistentAttribute) {
- JavaPersistentAttribute old = this.javaPersistentAttribute;
- this.javaPersistentAttribute = javaPersistentAttribute;
- this.firePropertyChanged(JAVA_PERSISTENT_ATTRIBUTE_PROPERTY, old, javaPersistentAttribute);
- }
-
- protected OrmAttributeMapping buildAttributeMapping(XmlAttributeMapping resourceMapping) {
- OrmAttributeMappingDefinition mappingDefinition =
- getMappingFileDefinition().getOrmAttributeMappingDefinition(resourceMapping.getMappingKey());
- return mappingDefinition.buildContextMapping(this, resourceMapping, getXmlContextNodeFactory());
- }
-
- public String getId() {
- return OrmStructureNodes.PERSISTENT_ATTRIBUTE_ID;
- }
-
- public AccessType getAccess() {
- return getSpecifiedAccess() != null ? getSpecifiedAccess() : getDefaultAccess();
- }
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType newAccess) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = newAccess;
- firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, this.defaultAccess);
- }
-
- public String getName() {
- return this.attributeMapping.getName();
- }
-
- public void nameChanged(String oldName, String newName) {
- firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
- public OrmAttributeMapping getSpecifiedMapping() {
- return this.attributeMapping;
- }
-
- public OrmAttributeMapping getMapping() {
- return this.attributeMapping;
- }
-
- public String getMappingKey() {
- return this.attributeMapping.getKey();
- }
-
- public String getDefaultMappingKey() {
- return null;
- }
-
- public void setSpecifiedMappingKey(String newMappingKey) {
- if (this.valuesAreEqual(this.getMappingKey(), newMappingKey)) {
- return;
- }
- OrmAttributeMapping oldMapping = this.attributeMapping;
- OrmAttributeMappingDefinition mappingDefinition =
- getMappingFileDefinition().getOrmAttributeMappingDefinition(newMappingKey);
- XmlAttributeMapping resourceAttributeMapping =
- mappingDefinition.buildResourceMapping(getResourceNodeFactory());
- this.attributeMapping = buildAttributeMapping(resourceAttributeMapping);
-
- getOwningPersistentType().changeMapping(this, oldMapping, this.attributeMapping);
- firePropertyChanged(SPECIFIED_MAPPING_PROPERTY, oldMapping, this.attributeMapping);
- }
-
- public OrmPersistentType getOwningPersistentType() {
- return (OrmPersistentType) getParent();
- }
-
- public OrmTypeMapping getOwningTypeMapping() {
- return getOwningPersistentType().getMapping();
- }
-
- public boolean isVirtual() {
- return getOwningPersistentType().containsVirtualAttribute(this);
- }
-
- public void makeVirtual() {
- if (isVirtual()) {
- throw new IllegalStateException("Attribute is already virtual"); //$NON-NLS-1$
- }
- getOwningPersistentType().makeAttributeVirtual(this);
- }
-
- public void makeSpecified() {
- if (!isVirtual()) {
- throw new IllegalStateException("Attribute is already specified"); //$NON-NLS-1$
- }
- if (getMappingKey() == MappingKeys.NULL_ATTRIBUTE_MAPPING_KEY) {
- throw new IllegalStateException("Use makeSpecified(String) instead and specify a mapping type"); //$NON-NLS-1$
- }
- getOwningPersistentType().makeAttributeSpecified(this);
- }
-
- public void makeSpecified(String mappingKey) {
- if (!isVirtual()) {
- throw new IllegalStateException("Attribute is already specified"); //$NON-NLS-1$
- }
- getOwningPersistentType().makeAttributeSpecified(this, mappingKey);
- }
-
- public String getPrimaryKeyColumnName() {
- return this.attributeMapping.getPrimaryKeyColumnName();
- }
-
- public String getTypeName() {
- JavaPersistentAttribute javaAttribute = getJavaPersistentAttribute();
- return (javaAttribute == null) ? null : javaAttribute.getTypeName();
- }
-
- public void update() {
- this.attributeMapping.update();
- this.setJavaPersistentAttribute(findJavaPersistentAttribute());
- this.owner.updateJavaPersistentAttribute();
- this.setDefaultAccess(buildDefaultAccess());
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- getMapping().postUpdate();
- }
-
- protected JavaPersistentAttribute findJavaPersistentAttribute() {
- return this.owner.findJavaPersistentAttribute(this);
- }
-
- protected AccessType buildDefaultAccess() {
- return getOwningPersistentType().getAccess();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public JpaStructureNode getStructureNode(int offset) {
- return this;
- }
-
- public boolean contains(int textOffset) {
- if (isVirtual()) {
- return false;
- }
- return this.attributeMapping.contains(textOffset);
- }
-
- public TextRange getSelectionTextRange() {
- if (isVirtual()) {
- return null;
- }
- return this.attributeMapping.getSelectionTextRange();
- }
-
- public void dispose() {
- //nothing to dispose
- }
-
-
- // ********** misc overrides **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** refactoring **********
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return this.attributeMapping.createRenameTypeEdits(originalType, newName);
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.attributeMapping.createMoveTypeEdits(originalType, newPackage);
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.attributeMapping.createRenamePackageEdits(originalPackage, newName);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateAttribute(messages, reporter);
- this.attributeMapping.validate(messages, reporter);
- }
-
- protected void validateAttribute(List<IMessage> messages, IReporter reporter) {
- if (this.javaPersistentAttribute == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_UNRESOLVED_NAME,
- new String[] {this.getName(), this.getOwningPersistentType().getMapping().getClass_()},
- this.attributeMapping,
- this.attributeMapping.getNameTextRange()
- )
- );
- }
- else {
- this.buildAttibuteValidator().validate(messages, reporter);
- }
- }
-
- protected PersistentAttributeTextRangeResolver buildTextRangeResolver() {
- return new OrmPersistentAttributeTextRangeResolver(this);
- }
-
- protected abstract JptValidator buildAttibuteValidator();
-
- public TextRange getValidationTextRange() {
- if (isVirtual()) {
- return getOwningPersistentType().getMapping().getAttributesTextRange();
- }
- return this.attributeMapping.getValidationTextRange();
- }
-
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainer().getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainer().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.getMapping());
- }
-
- public String getMetamodelTypeName() {
- JavaPersistentAttribute2_0 javaAttribute = (JavaPersistentAttribute2_0) this.getJavaPersistentAttribute();
- return (javaAttribute == null) ? MetamodelField.DEFAULT_TYPE_NAME : javaAttribute.getMetamodelTypeName();
- }
-
- protected JavaPersistentAttribute.JpaContainer getJpaContainer() {
- JavaPersistentAttribute2_0 javaAttribute = (JavaPersistentAttribute2_0) getJavaPersistentAttribute();
- return javaAttribute == null ? JavaPersistentAttribute.JpaContainer.Null.instance() : javaAttribute.getJpaContainer();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmQuery.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmQuery.java
deleted file mode 100644
index fe9aedf3e6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmQuery.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jpt.core.context.Query;
-import org.eclipse.jpt.core.context.QueryHint;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.java.JavaQuery;
-import org.eclipse.jpt.core.context.orm.OrmQuery;
-import org.eclipse.jpt.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlQuery;
-import org.eclipse.jpt.core.resource.orm.XmlQueryHint;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-
-
-public abstract class AbstractOrmQuery<E extends XmlQuery> extends AbstractOrmXmlContextNode
- implements OrmQuery
-{
-
- protected String name;
-
- protected String query;
-
- protected final List<OrmQueryHint> hints;
-
- protected E resourceQuery;
-
- protected AbstractOrmQuery(XmlContextNode parent, E resourceQuery) {
- super(parent);
- this.hints = new ArrayList<OrmQueryHint>();
- this.initialize(resourceQuery);
- }
-
- protected E getResourceQuery() {
- return this.resourceQuery;
- }
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String newName) {
- String oldName = this.name;
- this.name = newName;
- this.getResourceQuery().setName(newName);
- firePropertyChanged(Query.NAME_PROPERTY, oldName, newName);
- }
-
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String newQuery) {
- String oldQuery = this.query;
- this.query = newQuery;
- this.getResourceQuery().setQuery(newQuery);
- firePropertyChanged(Query.QUERY_PROPERTY, oldQuery, newQuery);
- }
-
- public ListIterator<OrmQueryHint> hints() {
- return new CloneListIterator<OrmQueryHint>(this.hints);
- }
-
- public int hintsSize() {
- return this.hints.size();
- }
-
- public OrmQueryHint addHint(int index) {
- XmlQueryHint resourceQueryHint = OrmFactory.eINSTANCE.createXmlQueryHint();
- OrmQueryHint contextQueryHint = buildQueryHint(resourceQueryHint);
- this.hints.add(index, contextQueryHint);
- this.getResourceQuery().getHints().add(index, resourceQueryHint);
- this.fireItemAdded(Query.HINTS_LIST, index, contextQueryHint);
- return contextQueryHint;
- }
-
- protected void addHint(int index, OrmQueryHint queryHint) {
- addItemToList(index, queryHint, this.hints, Query.HINTS_LIST);
- }
-
- protected void addHint(OrmQueryHint queryHint) {
- this.addHint(this.hints.size(), queryHint);
- }
-
- public void removeHint(QueryHint queryHint) {
- removeHint(this.hints.indexOf(queryHint));
- }
-
- public void removeHint(int index) {
- OrmQueryHint queryHint = this.hints.remove(index);
- this.getResourceQuery().getHints().remove(index);
- fireItemRemoved(Query.HINTS_LIST, index, queryHint);
- }
-
- protected void removeHint_(OrmQueryHint queryHint) {
- removeItemFromList(queryHint, this.hints, Query.HINTS_LIST);
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- this.getResourceQuery().getHints().move(targetIndex, sourceIndex);
- moveItemInList(targetIndex, sourceIndex, this.hints, Query.HINTS_LIST);
- }
-
-
- protected void initialize(E xmlQuery) {
- this.resourceQuery = xmlQuery;
- this.name = xmlQuery.getName();
- this.query = xmlQuery.getQuery();
- this.initializeHints();
- }
-
- protected void initializeHints() {
- for (XmlQueryHint resourceQueryHint : this.resourceQuery.getHints()) {
- this.hints.add(buildQueryHint(resourceQueryHint));
- }
- }
-
- protected OrmQueryHint buildQueryHint(XmlQueryHint resourceQueryHint) {
- return getXmlContextNodeFactory().buildOrmQueryHint(this, resourceQueryHint);
- }
-
- public void update(E xmlQuery) {
- this.resourceQuery = xmlQuery;
- this.setName(xmlQuery.getName());
- this.setQuery(xmlQuery.getQuery());
- this.updateHints();
- getPersistenceUnit().addQuery(this);
- }
-
- protected void updateHints() {
- // make a copy of the XML hints (to prevent ConcurrentModificationException)
- Iterator<XmlQueryHint> xmlHints = new CloneIterator<XmlQueryHint>(this.resourceQuery.getHints());
-
- for (Iterator<OrmQueryHint> contextHints = this.hints(); contextHints.hasNext(); ) {
- OrmQueryHint contextHint = contextHints.next();
- if (xmlHints.hasNext()) {
- contextHint.update(xmlHints.next());
- }
- else {
- removeHint_(contextHint);
- }
- }
-
- while (xmlHints.hasNext()) {
- addHint(buildQueryHint(xmlHints.next()));
- }
- }
-
- public boolean overrides(Query other) {
- // this isn't ideal, but it will have to do until we have further adopter input
- return (this.name != null)
- && this.name.equals(other.getName())
- && (other instanceof JavaQuery);
- }
-
- public boolean duplicates(Query other) {
- return (this != other)
- && ! StringTools.stringIsEmpty(this.name)
- && this.name.equals(other.getName())
- && ! this.overrides(other)
- && ! other.overrides(this);
- }
-
- public TextRange getValidationTextRange() {
- return this.getResourceQuery().getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getResourceQuery().getNameTextRange();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java
deleted file mode 100644
index f6e679a824..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipMapping.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmCascade;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCascade2_0;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlRelationshipMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmRelationshipMapping<T extends AbstractXmlRelationshipMapping>
- extends AbstractOrmAttributeMapping<T>
- implements OrmRelationshipMapping
-{
- protected String specifiedTargetEntity;
- protected String defaultTargetEntity;
- protected PersistentType resolvedTargetType;
- protected Entity resolvedTargetEntity;
-
- protected final OrmRelationshipReference relationshipReference;
-
- protected final OrmCascade2_0 cascade;
-
- protected FetchType specifiedFetch;
-
-
- protected AbstractOrmRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.relationshipReference = buildRelationshipReference();
- this.cascade = buildCascade();
- this.specifiedTargetEntity = getResourceTargetEntity();
- this.defaultTargetEntity = buildDefaultTargetEntity();
- this.resolvedTargetType = this.resolveTargetType();
- this.resolvedTargetEntity = this.resolveTargetEntity();
- this.specifiedFetch = getResourceFetch();
- }
-
- @Override
- public void update() {
- super.update();
- this.relationshipReference.update();
- this.cascade.update();
- this.setSpecifiedTargetEntity_(this.getResourceTargetEntity());
- this.setDefaultTargetEntity(this.buildDefaultTargetEntity());
- this.resolvedTargetType = this.resolveTargetType();
- this.setResolvedTargetEntity(this.resolveTargetEntity());
- this.setSpecifiedFetch_(this.getResourceFetch());
- }
-
- protected abstract OrmRelationshipReference buildRelationshipReference();
-
- @Override
- public OrmPersistentAttribute getParent() {
- return (OrmPersistentAttribute) super.getParent();
- }
-
- @Override
- public boolean isRelationshipOwner() {
- return this.relationshipReference.isRelationshipOwner();
- }
-
- @Override
- public boolean isOwnedBy(AttributeMapping mapping) {
- if (mapping.isRelationshipOwner()) {
- return this.relationshipReference.isOwnedBy((RelationshipMapping) mapping);
- }
- return false;
- }
-
- public RelationshipMapping getRelationshipOwner() {
- Entity targetEntity = this.getResolvedTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- for (PersistentAttribute each :
- CollectionTools.iterable(
- targetEntity.getPersistentType().allAttributes())) {
- if (this.isOwnedBy(each.getMapping())) {
- return (RelationshipMapping) each.getMapping();
- }
- }
- return null;
- }
-
- @Override
- public boolean isOverridableAssociationMapping() {
- return this.relationshipReference.isOverridableAssociation();
- }
-
-
- // **************** target entity ******************************************
-
- public char getTargetEntityEnclosingTypeSeparator() {
- return '$';
- }
-
- public String getTargetEntity() {
- return (this.specifiedTargetEntity != null) ? this.specifiedTargetEntity : this.defaultTargetEntity;
- }
-
- public String getSpecifiedTargetEntity() {
- return this.specifiedTargetEntity;
- }
-
- public void setSpecifiedTargetEntity(String targetEntity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = targetEntity;
- this.resourceAttributeMapping.setTargetEntity(targetEntity);
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- protected void setSpecifiedTargetEntity_(String targetEntity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = targetEntity;
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- public String getDefaultTargetEntity() {
- return this.defaultTargetEntity;
- }
-
- protected void setDefaultTargetEntity(String targetEntity) {
- String old = this.defaultTargetEntity;
- this.defaultTargetEntity = targetEntity;
- this.firePropertyChanged(DEFAULT_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- public Entity getResolvedTargetEntity() {
- return this.resolvedTargetEntity;
- }
-
- protected void setResolvedTargetEntity(Entity targetEntity) {
- Entity old = this.resolvedTargetEntity;
- this.resolvedTargetEntity = targetEntity;
- this.firePropertyChanged(RESOLVED_TARGET_ENTITY_PROPERTY, old, targetEntity);
- }
-
- public PersistentType getResolvedTargetType() {
- return this.resolvedTargetType;
- }
-
- protected PersistentType resolveTargetType() {
- return this.resolvePersistentType(this.getTargetEntity());
- }
-
- protected String getResourceTargetEntity() {
- return this.resourceAttributeMapping.getTargetEntity();
- }
-
- protected String buildDefaultTargetEntity() {
- if (this.getJavaPersistentAttribute() != null) {
- return getResourceDefaultTargetEntity();
- }
- return null;
- }
-
- protected abstract String getResourceDefaultTargetEntity();
-
- protected Entity resolveTargetEntity() {
- if (this.resolvedTargetType == null) {
- return null;
- }
- TypeMapping typeMapping = this.resolvedTargetType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
-
- // **************** reference **********************************************
-
- public OrmRelationshipReference getRelationshipReference() {
- return this.relationshipReference;
- }
-
-
- // **************** cascade ************************************************
-
- protected OrmCascade2_0 buildCascade() {
- return new GenericOrmCascade(this, this.resourceAttributeMapping);
- }
-
- public OrmCascade2_0 getCascade() {
- return this.cascade;
- }
-
-
- // **************** fetch **************************************************
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.getDefaultFetch();
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.resourceAttributeMapping.setFetch(FetchType.toOrmResourceModel(fetch));
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
- protected FetchType getResourceFetch() {
- return FetchType.fromOrmResourceModel(this.resourceAttributeMapping.getFetch());
- }
-
-
- // ********** RelationshipMapping implementation **********
-
- @Override
- public void initializeFromOrmRelationshipMapping(OrmRelationshipMapping oldMapping) {
- super.initializeFromOrmRelationshipMapping(oldMapping);
- setSpecifiedTargetEntity(oldMapping.getSpecifiedTargetEntity());
- setSpecifiedFetch(oldMapping.getSpecifiedFetch());
- oldMapping.getRelationshipReference().initializeOn(this.relationshipReference);
- this.cascade.initializeFrom(oldMapping.getCascade());
- //TODO should we set the fetch type from a BasicMapping??
- }
-
- public Iterator<String> allTargetEntityAttributeNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEntityAttributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allMappingNames();
- }
- });
- }
-
- public Iterator<AttributeMapping> allTargetEntityAttributeMappings() {
- return (this.resolvedTargetEntity != null) ?
- this.resolvedTargetEntity.allAttributeMappings() :
- EmptyIterator.<AttributeMapping> instance();
- }
-
- protected String getTargetEntityIdAttributeName() {
- PersistentAttribute attribute = this.getTargetEntityIdAttribute();
- return (attribute == null) ? null : attribute.getName();
- }
-
- protected PersistentAttribute getTargetEntityIdAttribute() {
- return (this.resolvedTargetEntity == null) ? null : this.resolvedTargetEntity.getIdAttribute();
- }
-
-
- //************ refactoring ************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createTargetEntityRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createTargetEntityRenameTypeEdits(IType originalType, String newName) {
- if (this.specifiedTargetEntity != null) {
- String originalName = originalType.getFullyQualifiedName('.');
- if (this.resolvedTargetType != null && this.resolvedTargetType.isFor(originalName)) {
- return new SingleElementIterable<ReplaceEdit>(this.createTargetEntityRenameTypeEdit(originalType, newName));
- }
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createTargetEntityRenameTypeEdit(IType originalType, String newName) {
- return this.resourceAttributeMapping.createRenameTargetEntityEdit(originalType, newName);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createTargetEntityMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createTargetEntityMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (this.specifiedTargetEntity != null) {
- String originalName = originalType.getFullyQualifiedName('.');
- if (this.resolvedTargetType != null && this.resolvedTargetType.isFor(originalName)) {
- return new SingleElementIterable<ReplaceEdit>(this.createTargetEntityRenamePackageEdit(newPackage.getElementName()));
- }
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createTargetEntityRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createTargetEntityRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (this.specifiedTargetEntity != null) {
- if (this.resolvedTargetType != null && this.resolvedTargetType.isIn(originalPackage)) {
- return new SingleElementIterable<ReplaceEdit>(this.createTargetEntityRenamePackageEdit(newName));
- }
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createTargetEntityRenamePackageEdit(String newName) {
- return this.resourceAttributeMapping.createRenameTargetEntityPackageEdit(newName);
- }
-
-
- //*********** validation ***********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- validateTargetEntity(messages);
- this.relationshipReference.validate(messages, reporter);
- }
-
- protected void validateTargetEntity(List<IMessage> messages) {
- if (getTargetEntity() == null) {
- if (getPersistentAttribute().isVirtual()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange()
- )
- );
- }
- else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange()
- )
- );
- }
- }
- else if (getResolvedTargetEntity() == null) {
- if (getPersistentAttribute().isVirtual()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY,
- new String[] {this.getName(), getTargetEntity()},
- this,
- this.getValidationTextRange()
- )
- );
- }
- else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY,
- new String[] {getTargetEntity(), this.getName()},
- this,
- this.getTargetEntityTextRange()
- )
- );
- }
- }
- }
-
- protected TextRange getTextRange(TextRange textRange) {
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
- }
-
- protected TextRange getTargetEntityTextRange() {
- return this.getTextRange(this.getResourceAttributeMapping().getTargetEntityTextRange());
- }
-
-
- // ********** metamodel **********
-
- @Override
- public String getMetamodelTypeName() {
- if (this.resolvedTargetType == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- String targetTypeName = this.resolvedTargetType.getName();
- return (targetTypeName != null) ? targetTypeName : MetamodelField.DEFAULT_TYPE_NAME;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipReference.java
deleted file mode 100644
index 5f522255ae..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmRelationshipReference.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlRelationshipMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public abstract class AbstractOrmRelationshipReference
- extends AbstractOrmXmlContextNode
- implements OrmRelationshipReference
-{
- protected AbstractXmlRelationshipMapping resourceMapping;
-
- // cache the strategy for property change notification
- protected OrmJoiningStrategy cachedPredominantJoiningStrategy;
-
-
- protected AbstractOrmRelationshipReference(
- OrmRelationshipMapping parent, AbstractXmlRelationshipMapping resourceMapping) {
-
- super(parent);
- this.resourceMapping = resourceMapping;
- this.initialize();
- }
-
- public void initializeFromOwnableRelationshipReference(
- OrmOwnableRelationshipReference oldRelationshipReference) {
- // no op
- }
-
- public void initializeFromJoinColumnEnabledRelationshipReference(
- OrmJoinColumnEnabledRelationshipReference oldRelationshipReference) {
- // no op
- }
-
- public void initializeFromJoinTableEnabledRelationshipReference(
- OrmJoinTableEnabledRelationshipReference oldRelationshipReference) {
- // no op
- }
-
- public OrmRelationshipMapping getRelationshipMapping() {
- return (OrmRelationshipMapping) getParent();
- }
-
- public TypeMapping getTypeMapping() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isOverridableAssociation() {
- return getPredominantJoiningStrategy().isOverridableAssociation();
- }
-
- public boolean isParentVirtual() {
- return getRelationshipMapping().getPersistentAttribute().isVirtual();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-
-
- // **************** predominant joining strategy ***************************
-
- public OrmJoiningStrategy getPredominantJoiningStrategy() {
- return this.cachedPredominantJoiningStrategy;
- }
-
- protected void setPredominantJoiningStrategy() {
- setPredominantJoiningStrategy(calculatePredominantJoiningStrategy());
- }
-
- protected void setPredominantJoiningStrategy(OrmJoiningStrategy newJoiningStrategy) {
- JoiningStrategy oldJoiningStrategy = this.cachedPredominantJoiningStrategy;
- this.cachedPredominantJoiningStrategy = newJoiningStrategy;
- firePropertyChanged(PREDOMINANT_JOINING_STRATEGY_PROPERTY, oldJoiningStrategy, newJoiningStrategy);
- }
-
-
- // **************** resource -> context ************************************
-
- protected void initialize() {
- initializeJoiningStrategies();
- this.cachedPredominantJoiningStrategy = calculatePredominantJoiningStrategy();
- }
-
- protected abstract void initializeJoiningStrategies();
-
-
- public void update() {
- updateJoiningStrategies();
- setPredominantJoiningStrategy();
- }
-
- protected abstract void updateJoiningStrategies();
-
- protected abstract OrmJoiningStrategy calculatePredominantJoiningStrategy();
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange() {
- return getRelationshipMapping().getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSequenceGenerator.java
deleted file mode 100644
index 4f3f6df0be..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSequenceGenerator.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.SequenceGenerator;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-
-/**
- *
- */
-public abstract class AbstractOrmSequenceGenerator
- extends AbstractOrmGenerator<XmlSequenceGenerator>
- implements OrmSequenceGenerator
-{
-
- protected String specifiedSequenceName;
- protected String defaultSequenceName;
-
-
- protected AbstractOrmSequenceGenerator(XmlContextNode parent, XmlSequenceGenerator resourceSequenceGenerator) {
- super(parent);
- this.initialize(resourceSequenceGenerator);
- }
-
-
- @Override
- public int getDefaultInitialValue() {
- return SequenceGenerator.DEFAULT_INITIAL_VALUE;
- }
-
- // ********** sequence name **********
-
- public String getSequenceName() {
- return (this.specifiedSequenceName != null) ? this.specifiedSequenceName : this.defaultSequenceName;
- }
-
- public String getSpecifiedSequenceName() {
- return this.specifiedSequenceName;
- }
-
- public void setSpecifiedSequenceName(String specifiedSequenceName) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = specifiedSequenceName;
- this.getResourceGenerator().setSequenceName(specifiedSequenceName);
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, specifiedSequenceName);
- }
-
- protected void setSpecifiedSequenceName_(String specifiedSequenceName) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = specifiedSequenceName;
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, specifiedSequenceName);
- }
-
- public String getDefaultSequenceName() {
- return this.defaultSequenceName;
- }
-
- protected void setDefaultSequenceName(String defaultSequenceName) {
- String old = this.defaultSequenceName;
- this.defaultSequenceName = defaultSequenceName;
- this.firePropertyChanged(DEFAULT_SEQUENCE_NAME_PROPERTY, old, defaultSequenceName);
- }
-
-
- // ********** resource => context **********
-
- @Override
- protected void initialize(XmlSequenceGenerator sequenceGenerator) {
- super.initialize(sequenceGenerator);
- this.specifiedSequenceName = sequenceGenerator.getSequenceName();
- //TODO default sequence name
- }
-
- @Override
- public void update(XmlSequenceGenerator sequenceGenerator) {
- super.update(sequenceGenerator);
- this.setSpecifiedSequenceName_(sequenceGenerator.getSequenceName());
- //TODO default sequence name
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
deleted file mode 100644
index a4244858e4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.context.FetchType;
-import org.eclipse.jpt.core.context.Nullable;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmSingleRelationshipMapping;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlSingleRelationshipMapping;
-import org.eclipse.jpt.core.resource.orm.v2_0.XmlSingleRelationshipMapping_2_0;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmSingleRelationshipMapping<T extends AbstractXmlSingleRelationshipMapping>
- extends AbstractOrmRelationshipMapping<T>
- implements OrmSingleRelationshipMapping2_0
-{
- protected Boolean specifiedOptional;
-
- protected final OrmDerivedIdentity2_0 derivedIdentity;
-
-
- protected AbstractOrmSingleRelationshipMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.specifiedOptional = this.getResourceOptional();
- //TODO defaultOptional
- this.derivedIdentity = buildDerivedIdentity();
- }
-
-
- @Override
- public void initializeFromOrmSingleRelationshipMapping(OrmSingleRelationshipMapping oldMapping) {
- super.initializeFromOrmSingleRelationshipMapping(oldMapping);
- getDerivedIdentity().initializeFrom(((OrmSingleRelationshipMapping2_0) oldMapping).getDerivedIdentity());
- }
-
- @Override
- protected String getResourceDefaultTargetEntity() {
- return this.getJavaPersistentAttribute().getSingleReferenceTargetTypeName();
- }
-
- public FetchType getDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- // **************** optional ***********************************************
-
- public boolean isOptional() {
- return (this.specifiedOptional != null) ? this.specifiedOptional.booleanValue() : this.isDefaultOptional();
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.resourceAttributeMapping.setOptional(optional);
- this.firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(Nullable.SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- public boolean isDefaultOptional() {
- return Nullable.DEFAULT_OPTIONAL;
- }
-
-
- // ********** 2.0 derived identity **********
-
- protected OrmDerivedIdentity2_0 buildDerivedIdentity() {
- return ((OrmXml2_0ContextNodeFactory) getXmlContextNodeFactory()).
- buildOrmDerivedIdentity(this, (XmlSingleRelationshipMapping_2_0) this.resourceAttributeMapping);
- }
-
- public OrmDerivedIdentity2_0 getDerivedIdentity() {
- return this.derivedIdentity;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- public void update() {
- super.update();
- this.setSpecifiedOptional_(this.getResourceOptional());
- this.derivedIdentity.update();
- }
-
- protected Boolean getResourceOptional() {
- return this.resourceAttributeMapping.getOptional();
- }
-
-
- // **************** validation ************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.derivedIdentity.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTable.java
deleted file mode 100644
index c567ac4b84..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTable.java
+++ /dev/null
@@ -1,500 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmBaseTable;
-import org.eclipse.jpt.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.resource.orm.AbstractXmlTable;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Catalog;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.SchemaContainer;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.NameTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- *
- */
-public abstract class AbstractOrmTable
- extends AbstractOrmXmlContextNode
- implements OrmBaseTable, UniqueConstraint.Owner
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected final List<OrmUniqueConstraint> uniqueConstraints;
-
- protected final Owner owner;
-
-
- // ********** constructor **********
-
- protected AbstractOrmTable(XmlContextNode parent, Owner owner) {
- super(parent);
- this.uniqueConstraints = new ArrayList<OrmUniqueConstraint>();
- this.owner = owner;
- }
-
- protected Owner getOwner() {
- return this.owner;
- }
-
-
- // ********** abstract methods **********
-
- /**
- * Return null if no resource table exists.
- */
- protected abstract AbstractXmlTable getResourceTable();
-
- /**
- * Return the added resource table.
- */
- protected abstract AbstractXmlTable addResourceTable();
-
- protected abstract void removeResourceTable();
-
- protected abstract String buildDefaultName();
-
- protected abstract String buildDefaultSchema();
-
- protected abstract String buildDefaultCatalog();
-
-
- public boolean isResourceSpecified() {
- return this.getResourceTable() != null;
- }
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- if (this.attributeValueHasChanged(old, name)) {
- AbstractXmlTable resourceTable = this.getResourceTable();
- if (resourceTable == null) {
- resourceTable = this.addResourceTable();
- }
- resourceTable.setName(name);
- if (resourceTable.isUnset()) {
- this.removeResourceTable();
- }
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
- }
-
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- public String getDefaultName() {
- return this.defaultName;
- }
-
- protected void setDefaultName(String name) {
- String old = this.defaultName;
- this.defaultName = name;
- this.firePropertyChanged(DEFAULT_NAME_PROPERTY, old, name);
- }
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- if (this.attributeValueHasChanged(old, schema)) {
- AbstractXmlTable resourceTable = this.getResourceTable();
- if (resourceTable == null) {
- resourceTable = this.addResourceTable();
- }
- resourceTable.setSchema(schema);
- if (resourceTable.isUnset()) {
- this.removeResourceTable();
- }
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
- }
-
- protected void setSpecifiedSchema_(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- if (this.attributeValueHasChanged(old, catalog)) {
- AbstractXmlTable resourceTable = this.getResourceTable();
- if (resourceTable == null) {
- resourceTable = this.addResourceTable();
- }
- resourceTable.setCatalog(catalog);
- if (resourceTable.isUnset()) {
- this.removeResourceTable();
- }
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
- }
-
- protected void setSpecifiedCatalog_(String newSpecifiedCatalog) {
- String oldSpecifiedCatalog = this.specifiedCatalog;
- this.specifiedCatalog = newSpecifiedCatalog;
- firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, oldSpecifiedCatalog, newSpecifiedCatalog);
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String newDefaultCatalog) {
- String oldDefaultCatalog = this.defaultCatalog;
- this.defaultCatalog = newDefaultCatalog;
- firePropertyChanged(DEFAULT_CATALOG_PROPERTY, oldDefaultCatalog, newDefaultCatalog);
- }
-
-
- // ********** unique constraints **********
-
- public @SuppressWarnings("unchecked") ListIterator<OrmUniqueConstraint> uniqueConstraints() {
- return new CloneListIterator<OrmUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public OrmUniqueConstraint addUniqueConstraint(int index) {
- XmlUniqueConstraint resourceConstraint = OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- OrmUniqueConstraint contextConstraint = this.buildUniqueConstraint(resourceConstraint);
- this.uniqueConstraints.add(index, contextConstraint);
-
- AbstractXmlTable resourceTable = this.getResourceTable();
- if (resourceTable == null) {
- resourceTable = this.addResourceTable();
- }
- resourceTable.getUniqueConstraints().add(index, resourceConstraint);
-
- this.fireItemAdded(UNIQUE_CONSTRAINTS_LIST, index, contextConstraint);
- return contextConstraint;
- }
-
- protected void addUniqueConstraint(int index, OrmUniqueConstraint uniqueConstraint) {
- this.addItemToList(index, uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected void addUniqueConstraint(OrmUniqueConstraint uniqueConstraint) {
- this.addUniqueConstraint(this.uniqueConstraints.size(), uniqueConstraint);
- }
-
- public void removeUniqueConstraint(UniqueConstraint uniqueConstraint) {
- this.removeUniqueConstraint(this.uniqueConstraints.indexOf(uniqueConstraint));
- }
-
- public void removeUniqueConstraint(int index) {
- OrmUniqueConstraint removedUniqueConstraint = this.uniqueConstraints.remove(index);
- this.getResourceTable().getUniqueConstraints().remove(index);
- this.fireItemRemoved(UNIQUE_CONSTRAINTS_LIST, index, removedUniqueConstraint);
- }
-
- protected void removeUniqueConstraint_(OrmUniqueConstraint uniqueConstraint) {
- this.removeItemFromList(uniqueConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- public void moveUniqueConstraint(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.uniqueConstraints, targetIndex, sourceIndex);
- this.getResourceTable().getUniqueConstraints().move(targetIndex, sourceIndex);
- this.fireItemMoved(UNIQUE_CONSTRAINTS_LIST, targetIndex, sourceIndex);
- }
-
-
- // ********** convenience methods **********
-
- protected TextRange getTextRange(TextRange textRange) {
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getTextRange(this.getResourceTableNameTextRange());
- }
-
- protected TextRange getResourceTableNameTextRange() {
- AbstractXmlTable resourceTable = this.getResourceTable();
- return (resourceTable == null) ? null : resourceTable.getNameTextRange();
- }
-
- public TextRange getSchemaTextRange() {
- return this.getTextRange(this.getResourceTableSchemaTextRange());
- }
-
- protected TextRange getResourceTableSchemaTextRange() {
- AbstractXmlTable resourceTable = this.getResourceTable();
- return (resourceTable == null) ? null : resourceTable.getSchemaTextRange();
- }
-
- public TextRange getCatalogTextRange() {
- return this.getTextRange(this.getResourceTableCatalogTextRange());
- }
-
- protected TextRange getResourceTableCatalogTextRange() {
- AbstractXmlTable resourceTable = this.getResourceTable();
- return (resourceTable == null) ? null : resourceTable.getCatalogTextRange();
- }
-
- protected OrmUniqueConstraint buildUniqueConstraint(XmlUniqueConstraint resourceUniqueConstraint) {
- return this.getXmlContextNodeFactory().buildOrmUniqueConstraint(this, this, resourceUniqueConstraint);
- }
-
-
- // ********** resource => context **********
-
- protected void initialize(AbstractXmlTable xmlTable) {
- this.defaultName = this.buildDefaultName();
- this.specifiedName = this.getResourceTableName(xmlTable);
-
- this.defaultSchema = this.buildDefaultSchema();
- this.specifiedSchema = this.getResourceTableSchema(xmlTable);
-
- this.defaultCatalog = this.buildDefaultCatalog();
- this.specifiedCatalog = this.getResourceTableCatalog(xmlTable);
-
- this.initializeUniqueContraints(xmlTable);
- }
-
- protected void initializeUniqueContraints(AbstractXmlTable xmlTable) {
- if (xmlTable == null) {
- return;
- }
- for (XmlUniqueConstraint uniqueConstraint : xmlTable.getUniqueConstraints()) {
- this.uniqueConstraints.add(this.buildUniqueConstraint(uniqueConstraint));
- }
- }
-
- protected void update(AbstractXmlTable xmlTable) {
- this.setDefaultName(this.buildDefaultName());
- this.setSpecifiedName_(this.getResourceTableName(xmlTable));
-
- this.setDefaultSchema(this.buildDefaultSchema());
- this.setSpecifiedSchema_(this.getResourceTableSchema(xmlTable));
-
- this.setDefaultCatalog(this.buildDefaultCatalog());
- this.setSpecifiedCatalog_(this.getResourceTableCatalog(xmlTable));
-
- this.updateUniqueConstraints(xmlTable);
- }
-
- protected String getResourceTableName(AbstractXmlTable xmlTable) {
- return (xmlTable == null) ? null : xmlTable.getName();
- }
-
- protected String getResourceTableSchema(AbstractXmlTable xmlTable) {
- return (xmlTable == null) ? null : xmlTable.getSchema();
- }
-
- protected String getResourceTableCatalog(AbstractXmlTable xmlTable) {
- return (xmlTable == null) ? null : xmlTable.getCatalog();
- }
-
- protected void updateUniqueConstraints(AbstractXmlTable xmlTable) {
- Iterator<XmlUniqueConstraint> xmlConstraints = this.xmlUniqueConstraints(xmlTable);
-
- for (Iterator<OrmUniqueConstraint> contextConstraints = this.uniqueConstraints(); contextConstraints.hasNext(); ) {
- OrmUniqueConstraint contextConstraint = contextConstraints.next();
- if (xmlConstraints.hasNext()) {
- contextConstraint.update(xmlConstraints.next());
- } else {
- this.removeUniqueConstraint_(contextConstraint);
- }
- }
-
- while (xmlConstraints.hasNext()) {
- this.addUniqueConstraint(this.buildUniqueConstraint(xmlConstraints.next()));
- }
- }
-
- protected Iterator<XmlUniqueConstraint> xmlUniqueConstraints(AbstractXmlTable xmlTable) {
- // make a copy of the XML constraints (to prevent ConcurrentModificationException)
- return (xmlTable == null) ? EmptyIterator.<XmlUniqueConstraint>instance()
- : new CloneIterator<XmlUniqueConstraint>(xmlTable.getUniqueConstraints());
- }
-
- public void initializeFrom(Table oldTable) {
- this.setSpecifiedName(oldTable.getSpecifiedName());
- this.setSpecifiedCatalog(oldTable.getSpecifiedCatalog());
- this.setSpecifiedSchema(oldTable.getSpecifiedSchema());
- }
-
-
- // ********** database stuff **********
-
- public org.eclipse.jpt.db.Table getDbTable() {
- Schema dbSchema = this.getDbSchema();
- return (dbSchema == null) ? null : dbSchema.getTableForIdentifier(this.getName());
- }
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.getDbCatalog(catalog) : this.getDatabase();
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.getDbCatalog(catalog);
- }
-
- public boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- public boolean hasResolvedSchema() {
- return this.getDbSchema() != null;
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public boolean hasResolvedCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.getDbCatalog(catalog) != null);
- }
-
-
- // ********** UniqueConstraint.Owner implementation **********
-
- public Iterator<String> candidateUniqueConstraintColumnNames() {
- org.eclipse.jpt.db.Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers().iterator() : EmptyIterator.<String>instance();
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange() {
- return this.getTextRange(this.getResourceTableValidationTextRange());
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.buildTableValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildTableValidator() {
- return this.getOwner().buildTableValidator(this, buildTextRangeResolver());
- }
-
- protected TableTextRangeResolver buildTextRangeResolver() {
- return new OrmTableTextRangeResolver(this);
- }
-
- protected TextRange getResourceTableValidationTextRange() {
- AbstractXmlTable resourceTable = this.getResourceTable();
- return (resourceTable == null) ? null : resourceTable.getValidationTextRange();
- }
-
-
- // ********** misc **********
-
- /**
- * covariant override
- */
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.getQualifiedName());
- }
-
- protected String getQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java
deleted file mode 100644
index 4ffb0f12ff..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmTypeMapping.java
+++ /dev/null
@@ -1,432 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.RelationshipReference;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.GenericTypeMappingValidator;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Schema;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmTypeMapping<T extends XmlTypeMapping>
- extends AbstractOrmXmlContextNode
- implements OrmTypeMapping
-{
- protected String class_;
-
- public boolean defaultMetadataComplete;
-
- protected Boolean specifiedMetadataComplete;
-
- protected final T resourceTypeMapping;
-
-
- protected AbstractOrmTypeMapping(OrmPersistentType parent, T resourceMapping) {
- super(parent);
- this.resourceTypeMapping = resourceMapping;
- this.class_ = this.getResourceClassName();
- this.specifiedMetadataComplete = this.getResourceMetadataComplete();
- this.defaultMetadataComplete = this.getPersistentType().isDefaultMetadataComplete();
- }
-
- // **************** Type Mapping implementation *****************************
-
- @Override
- public OrmPersistentType getParent() {
- return (OrmPersistentType) super.getParent();
- }
-
- public String getName() {
- return getPersistentType().getName();
- }
-
- public OrmPersistentType getPersistentType() {
- return this.getParent();
- }
-
- protected JavaPersistentType getJavaPersistentType() {
- return this.getPersistentType().getJavaPersistentType();
- }
-
- public boolean isMapped() {
- return true;
- }
-
- /* default implementation */
- public JavaPersistentType getIdClass() {
- return null;
- }
-
- public String getPrimaryTableName() {
- return null;
- }
-
- public String getClass_() {
- return this.class_;
- }
-
- public void setClass(String newClass) {
- String oldClass = this.class_;
- this.class_ = newClass;
- this.resourceTypeMapping.setClassName(newClass);
- firePropertyChanged(CLASS_PROPERTY, oldClass, newClass);
- getPersistentType().classChanged(oldClass, newClass);
- }
-
-
- public boolean isMetadataComplete() {
- if (isDefaultMetadataComplete()) {
- //entity-mappings/persistence-unit-metadata/xml-mapping-metadata-complete is specified, then it overrides
- //anything set here
- return true;
- }
- return (this.getSpecifiedMetadataComplete() == null) ? this.isDefaultMetadataComplete() : this.getSpecifiedMetadataComplete().booleanValue();
- }
-
- public boolean isDefaultMetadataComplete() {
- return this.defaultMetadataComplete;
- }
-
- protected void setDefaultMetadataComplete(boolean newDefaultMetadataComplete) {
- boolean oldMetadataComplete = this.defaultMetadataComplete;
- this.defaultMetadataComplete = newDefaultMetadataComplete;
- firePropertyChanged(DEFAULT_METADATA_COMPLETE_PROPERTY, oldMetadataComplete, newDefaultMetadataComplete);
- }
-
- public Boolean getSpecifiedMetadataComplete() {
- return this.specifiedMetadataComplete;
- }
-
- public void setSpecifiedMetadataComplete(Boolean newSpecifiedMetadataComplete) {
- Boolean oldMetadataComplete = this.specifiedMetadataComplete;
- this.specifiedMetadataComplete = newSpecifiedMetadataComplete;
- this.resourceTypeMapping.setMetadataComplete(newSpecifiedMetadataComplete);
- firePropertyChanged(SPECIFIED_METADATA_COMPLETE_PROPERTY, oldMetadataComplete, newSpecifiedMetadataComplete);
- }
-
- /**
- * ITypeMapping is changed and various ITypeMappings may have
- * common settings. In this method initialize the new ITypeMapping (this)
- * fromthe old ITypeMapping (oldMapping)
- */
- public void initializeFrom(OrmTypeMapping oldMapping) {
- this.setClass(oldMapping.getClass_());
- this.setSpecifiedMetadataComplete(oldMapping.getSpecifiedMetadataComplete());
- this.setDefaultMetadataComplete(oldMapping.isDefaultMetadataComplete());
- }
-
- public Table getPrimaryDbTable() {
- return null;
- }
-
- public Table getDbTable(String tableName) {
- return null;
- }
-
- public Schema getDbSchema() {
- return null;
- }
-
- public boolean attributeMappingKeyAllowed(String attributeMappingKey) {
- return true;
- }
-
- public Iterator<OrmAttributeMapping> attributeMappings() {
- return new TransformationIterator<OrmPersistentAttribute, OrmAttributeMapping>(getPersistentType().attributes()) {
- @Override
- protected OrmAttributeMapping transform(OrmPersistentAttribute attribute) {
- return attribute.getMapping();
- }
- };
- }
-
- public Iterable<OrmAttributeMapping> getAttributeMappings(final String mappingKey) {
- return new FilteringIterable<OrmAttributeMapping>(CollectionTools.collection(attributeMappings())) {
- @Override
- protected boolean accept(OrmAttributeMapping o) {
- return StringTools.stringsAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterator<AttributeMapping> allAttributeMappings() {
- return new CompositeIterator<AttributeMapping>(
- new TransformationIterator<TypeMapping, Iterator<AttributeMapping>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<AttributeMapping> transform(TypeMapping typeMapping) {
- return typeMapping.attributeMappings();
- }
- });
- }
-
- public Iterable<AttributeMapping> getAllAttributeMappings(final String mappingKey) {
- return new FilteringIterable<AttributeMapping>(CollectionTools.collection(allAttributeMappings())) {
- @Override
- protected boolean accept(AttributeMapping o) {
- return StringTools.stringsAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public TypeMapping getSuperTypeMapping() {
- return (getPersistentType().getSuperPersistentType() == null) ?
- null
- : getPersistentType().getSuperPersistentType().getMapping();
- }
-
- /**
- * Return an iterator of TypeMappings, each which inherits from the one before,
- * and terminates at the root entity (or at the point of cyclicity).
- */
- public Iterator<TypeMapping> inheritanceHierarchy() {
- return new TransformationIterator<PersistentType, TypeMapping>(getPersistentType().inheritanceHierarchy()) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
- public Iterator<String> overridableAttributeNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAttributeMappingNames();
- }
- });
- }
-
- public Iterator<String> allOverridableAttributeNames() {
- return new CompositeIterator<String>(new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAttributeNames();
- }
- });
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(attributeMappings())) {
- Column resolvedColumn = attributeMapping.resolveOverriddenColumn(attributeName);
- if (resolvedColumn != null) {
- return resolvedColumn;
- }
- }
- if (!isMetadataComplete()) {
- JavaPersistentType javaPersistentType = getJavaPersistentType();
- if (javaPersistentType != null) {
- return javaPersistentType.getMapping().resolveOverriddenColumn(attributeName);
- }
- }
- return null;
- }
-
- public Iterator<String> overridableAssociationNames() {
- return new CompositeIterator<String>(
- new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings()) {
- @Override
- protected Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverrideableAssociationMappingNames();
- }
- });
- }
-
- public Iterator<String> allOverridableAssociationNames() {
- return new CompositeIterator<String>(new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy()) {
- @Override
- protected Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAssociationNames();
- }
- });
- }
-
- public RelationshipReference resolveRelationshipReference(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(attributeMappings())) {
- RelationshipReference resolvedRelationshipReference = attributeMapping.resolveRelationshipReference(attributeName);
- if (resolvedRelationshipReference != null) {
- return resolvedRelationshipReference;
- }
- }
- if (!isMetadataComplete()) {
- JavaPersistentType javaPersistentType = getJavaPersistentType();
- if (javaPersistentType != null) {
- return javaPersistentType.getMapping().resolveRelationshipReference(attributeName);
- }
- }
- return null;
- }
-
- public T getResourceTypeMapping() {
- return this.resourceTypeMapping;
- }
-
- public void update() {
- this.setClass(this.getResourceClassName());
- this.setSpecifiedMetadataComplete(this.getResourceMetadataComplete());
- this.setDefaultMetadataComplete(this.getPersistentType().isDefaultMetadataComplete());
- }
-
- protected String getResourceClassName() {
- return this.resourceTypeMapping.getClassName();
- }
-
- protected Boolean getResourceMetadataComplete() {
- return this.resourceTypeMapping.getMetadataComplete();
- }
-
-
- // *************************************************************************
-
- protected JavaResourcePersistentType getJavaResourcePersistentType() {
- if (getPersistentType().getJavaPersistentType() != null) {
- return getPersistentType().getJavaPersistentType().getResourcePersistentType();
- }
- return null;
- }
-
- public JpaStructureNode getStructureNode(int offset) {
- if (this.resourceTypeMapping.containsOffset(offset)) {
- return getPersistentType();
- }
- return null;
- }
-
- public TextRange getSelectionTextRange() {
- return this.resourceTypeMapping.getSelectionTextRange();
- }
-
- public TextRange getClassTextRange() {
- return this.resourceTypeMapping.getClassTextRange();
- }
-
- public TextRange getAttributesTextRange() {
- return this.resourceTypeMapping.getAttributesTextRange();
- }
-
- public boolean containsOffset(int textOffset) {
- return this.resourceTypeMapping.containsOffset(textOffset);
- }
-
-
- //************************* validation ************************
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateClass(messages, reporter);
- }
-
- protected void validateClass(List<IMessage> messages, IReporter reporter) {
- if (StringTools.stringIsEmpty(this.class_)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENT_TYPE_UNSPECIFIED_CLASS,
- this,
- this.getClassTextRange()
- )
- );
- return;
- }
- this.buildTypeMappingValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildTypeMappingValidator() {
- return new GenericTypeMappingValidator(this, this.getJavaResourcePersistentType(), buildTextRangeResolver());
- }
-
- protected TypeMappingTextRangeResolver buildTextRangeResolver() {
- return new OrmTypeMappingTextRangeResolver(this);
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return getPersistenceUnit().shouldValidateAgainstDatabase();
- }
-
- public TextRange getValidationTextRange() {
- return this.resourceTypeMapping.getValidationTextRange();
- }
-
-
- //************************* refactoring ************************
-
- public DeleteEdit createDeleteEdit() {
- return this.resourceTypeMapping.createDeleteEdit();
- }
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- if (getPersistentType().isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenameTypeEdit(originalType, newName));
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createRenameTypeEdit(IType originalType, String newName) {
- return this.resourceTypeMapping.createRenameTypeEdit(originalType, newName);
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (getPersistentType().isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newPackage.getElementName()));
- }
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (getPersistentType().isIn(originalPackage)) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newName));
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createRenamePackageEdit(String newName) {
- return this.resourceTypeMapping.createRenamePackageEdit(newName);
- }
-
-
- // ********** misc **********
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getPersistentType().getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java
deleted file mode 100644
index 1265b806b7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmVersionMapping.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.core.context.orm.OrmConverter;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.core.resource.orm.Attributes;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractOrmVersionMapping<T extends XmlVersion>
- extends AbstractOrmAttributeMapping<T>
- implements OrmVersionMapping
-{
- protected final OrmColumn column;
-
- protected OrmConverter converter;
-
- protected final OrmConverter nullConverter;
-
- protected AbstractOrmVersionMapping(OrmPersistentAttribute parent, T resourceMapping) {
- super(parent, resourceMapping);
- this.column = getXmlContextNodeFactory().buildOrmColumn(this, this);
- this.column.initialize(this.getResourceColumn());//TODO pass in to constructor
- this.nullConverter = this.getXmlContextNodeFactory().buildOrmNullConverter(this);
- this.converter = this.buildConverter(this.getResourceConverterType());
- }
-
- public int getXmlSequence() {
- return 30;
- }
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmVersionMapping(this);
- }
-
- @Override
- public void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- super.initializeFromOrmColumnMapping(oldMapping);
- getColumn().initializeFrom(oldMapping.getColumn());
- }
-
- public OrmColumn getColumn() {
- return this.column;
- }
-
- public OrmConverter getConverter() {
- return this.converter;
- }
-
- protected String getConverterType() {
- return this.converter.getType();
- }
-
- public void setConverter(String converterType) {
- if (this.valuesAreEqual(getConverterType(), converterType)) {
- return;
- }
- OrmConverter oldConverter = this.converter;
- OrmConverter newConverter = buildConverter(converterType);
- this.converter = this.nullConverter;
- if (oldConverter != null) {
- oldConverter.removeFromResourceModel();
- }
- this.converter = newConverter;
- if (newConverter != null) {
- newConverter.addToResourceModel();
- }
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- protected void setConverter(OrmConverter newConverter) {
- OrmConverter oldConverter = this.converter;
- this.converter = newConverter;
- firePropertyChanged(CONVERTER_PROPERTY, oldConverter, newConverter);
- }
-
- public void addToResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getVersions().add(this.resourceAttributeMapping);
- }
-
- public void removeFromResourceModel(Attributes resourceAttributes) {
- resourceAttributes.getVersions().remove(this.resourceAttributeMapping);
- }
-
- //************** NamedColumn.Owner implementation ***************
-
- public String getDefaultColumnName() {
- return getName();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- //************** BaseColumn.Owner implementation ***************
-
- public String getDefaultTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update(this.getResourceColumn());
- if (this.valuesAreEqual(getResourceConverterType(), getConverterType())) {
- getConverter().update();
- }
- else {
- setConverter(buildConverter(getResourceConverterType()));
- }
- }
-
- protected OrmConverter buildConverter(String converterType) {
- if (this.valuesAreEqual(converterType, Converter.NO_CONVERTER)) {
- return this.nullConverter;
- }
- if (this.valuesAreEqual(converterType, Converter.TEMPORAL_CONVERTER)) {
- return getXmlContextNodeFactory().buildOrmTemporalConverter(this, this.resourceAttributeMapping);
- }
- return null;
- }
-
- protected String getResourceConverterType() {
- if (this.resourceAttributeMapping.getTemporal() != null) {
- return Converter.TEMPORAL_CONVERTER;
- }
- return Converter.NO_CONVERTER;
- }
-
- //***************** XmlColumn.Owner implementation ****************
-
- public XmlColumn getResourceColumn() {
- return this.resourceAttributeMapping.getColumn();
- }
-
- public void addResourceColumn() {
- this.resourceAttributeMapping.setColumn(OrmFactory.eINSTANCE.createXmlColumn());
- }
-
- public void removeResourceColumn() {
- this.resourceAttributeMapping.setColumn(null);
- }
-
-
- //************ refactoring ************
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenameTypeEdits(originalType, newName),
- this.createConverterRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createConverterRenameTypeEdits(IType originalType, String newName) {
- if (getConverter() != null) {
- return getConverter().createRenameTypeEdits(originalType, newName);
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- super.createMoveTypeEdits(originalType, newPackage),
- this.createConverterMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createConverterMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (getConverter() != null) {
- return getConverter().createMoveTypeEdits(originalType, newPackage);
- }
- return EmptyIterable.instance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- super.createRenamePackageEdits(originalPackage, newName),
- this.createConverterRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createConverterRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (getConverter() != null) {
- return getConverter().createRenamePackageEdits(originalPackage, newName);
- }
- return EmptyIterable.instance();
- }
-
-
- // ****************** validation ****************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- this.getColumn().validate(messages, reporter);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java
deleted file mode 100644
index a6441f79c0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNode.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.context.JpaContextNode;
-import org.eclipse.jpt.core.context.orm.OrmXmlDefinition;
-import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
-
-/**
- * Use this abstract class for context nodes that are part of an
- * <code>orm.xml</code> file.
- * This will not work for a pure {@link org.eclipse.jpt.core.context.MappingFile}
- * implementation.
- */
-public abstract class AbstractOrmXmlContextNode
- extends AbstractXmlContextNode
-{
- // ********** constructor **********
-
- protected AbstractOrmXmlContextNode(JpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** convenience methods **********
-
- protected OrmXmlDefinition getMappingFileDefinition() {
- return (OrmXmlDefinition) this.getJpaPlatform().getResourceDefinition(this.getResourceType());
- }
-
- protected EFactory getResourceNodeFactory() {
- return this.getMappingFileDefinition().getResourceNodeFactory();
- }
-
- protected OrmXml2_0ContextNodeFactory getXmlContextNodeFactory() {
- return (OrmXml2_0ContextNodeFactory) this.getMappingFileDefinition().getContextNodeFactory();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java
deleted file mode 100644
index b0eb724e47..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java
+++ /dev/null
@@ -1,448 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.Orderable;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.context.java.JavaTransientMapping;
-import org.eclipse.jpt.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.core.context.orm.EntityMappings;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.core.context.orm.OrmBaseJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmColumn;
-import org.eclipse.jpt.core.context.orm.OrmConverter;
-import org.eclipse.jpt.core.context.orm.OrmDiscriminatorColumn;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddedIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmGeneratedValue;
-import org.eclipse.jpt.core.context.orm.OrmGeneratorContainer;
-import org.eclipse.jpt.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.context.orm.OrmNamedColumn;
-import org.eclipse.jpt.core.context.orm.OrmNamedNativeQuery;
-import org.eclipse.jpt.core.context.orm.OrmNamedQuery;
-import org.eclipse.jpt.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistenceUnitDefaults;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmQuery;
-import org.eclipse.jpt.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.core.context.orm.OrmSecondaryTable;
-import org.eclipse.jpt.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.core.context.orm.OrmTable;
-import org.eclipse.jpt.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.core.context.orm.OrmTransientMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmXml;
-import org.eclipse.jpt.core.context.orm.PersistenceUnitMetadata;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericEntityMappings;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmAssociationOverride;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmAssociationOverrideContainer;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmAttributeOverride;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmAttributeOverrideContainer;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmBasicMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmColumn;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmDiscriminatorColumn;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmEmbeddable;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmEmbeddedIdMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmEmbeddedMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmEntity;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmEnumeratedConverter;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmGeneratedValue;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmGeneratorContainer;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmIdMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmJoinColumn;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmJoinTable;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmLobConverter;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmManyToManyMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmManyToOneMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmMappedSuperclass;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmNamedNativeQuery;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmNamedQuery;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmNullAttributeMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmNullConverter;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmOneToManyMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmOneToOneMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmOrderable;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmPersistentType;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmQueryContainer;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmQueryHint;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmSecondaryTable;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmSequenceGenerator;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmTable;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmTableGenerator;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmTemporalConverter;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmTransientMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmUniqueConstraint;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericOrmVersionMapping;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericPersistenceUnitDefaults;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.GenericPersistenceUnitMetadata;
-import org.eclipse.jpt.core.internal.jpa1.context.orm.UnsupportedOrmAttributeMapping;
-import org.eclipse.jpt.core.internal.jpa2.context.orm.GenericOrmOrderColumn2_0;
-import org.eclipse.jpt.core.internal.jpa2.context.orm.NullOrmCacheable2_0;
-import org.eclipse.jpt.core.internal.jpa2.context.orm.NullOrmDerivedIdentity2_0;
-import org.eclipse.jpt.core.internal.jpa2.context.orm.NullOrmOrphanRemoval2_0;
-import org.eclipse.jpt.core.jpa2.context.java.JavaElementCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheableHolder2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmCollectionTable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmDerivedIdentity2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmElementCollectionMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmEmbeddedMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrderColumn2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrderable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0;
-import org.eclipse.jpt.core.jpa2.context.orm.OrmXml2_0ContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.orm.XmlCollectionTable;
-import org.eclipse.jpt.core.resource.orm.XmlConvertibleMapping;
-import org.eclipse.jpt.core.resource.orm.XmlElementCollection;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.core.resource.orm.XmlGeneratorContainer;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.core.resource.orm.XmlNamedNativeQuery;
-import org.eclipse.jpt.core.resource.orm.XmlNamedQuery;
-import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlQueryContainer;
-import org.eclipse.jpt.core.resource.orm.XmlQueryHint;
-import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.core.resource.orm.v2_0.XmlCacheable_2_0;
-import org.eclipse.jpt.core.resource.orm.v2_0.XmlOrphanRemovable_2_0;
-import org.eclipse.jpt.core.resource.orm.v2_0.XmlSingleRelationshipMapping_2_0;
-
-public abstract class AbstractOrmXmlContextNodeFactory
- implements OrmXml2_0ContextNodeFactory
-{
- public EntityMappings buildEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) {
- return new GenericEntityMappings(parent, xmlEntityMappings);
- }
-
- public PersistenceUnitMetadata buildPersistenceUnitMetadata(EntityMappings parent) {
- return new GenericPersistenceUnitMetadata(parent);
- }
-
- public OrmPersistenceUnitDefaults buildPersistenceUnitDefaults(PersistenceUnitMetadata parent) {
- return new GenericPersistenceUnitDefaults(parent);
- }
-
- public OrmPersistentType buildOrmPersistentType(EntityMappings parent, XmlTypeMapping resourceMapping) {
- return new GenericOrmPersistentType(parent, resourceMapping);
- }
-
- public OrmEntity buildOrmEntity(OrmPersistentType parent, XmlEntity resourceMapping) {
- return new GenericOrmEntity(parent, resourceMapping);
- }
-
- public OrmMappedSuperclass buildOrmMappedSuperclass(OrmPersistentType parent, XmlMappedSuperclass resourceMapping) {
- return new GenericOrmMappedSuperclass(parent, resourceMapping);
- }
-
- public OrmEmbeddable buildOrmEmbeddable(OrmPersistentType parent, XmlEmbeddable resourceMapping) {
- return new GenericOrmEmbeddable(parent, resourceMapping);
- }
-
- public OrmPersistentAttribute buildOrmPersistentAttribute(OrmPersistentType parent, OrmPersistentAttribute.Owner owner, XmlAttributeMapping resourceMapping) {
- return new GenericOrmPersistentAttribute(parent, owner, resourceMapping);
- }
-
- public OrmTable buildOrmTable(OrmEntity parent, Table.Owner owner) {
- return new GenericOrmTable(parent, owner);
- }
-
- public OrmSecondaryTable buildOrmSecondaryTable(OrmEntity parent, Table.Owner owner, XmlSecondaryTable xmlSecondaryTable) {
- return new GenericOrmSecondaryTable(parent, owner, xmlSecondaryTable);
- }
-
- public OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(XmlContextNode parent, OrmBaseJoinColumn.Owner owner, XmlPrimaryKeyJoinColumn resourcePkJoinColumn) {
- return new GenericOrmPrimaryKeyJoinColumn(parent, owner, resourcePkJoinColumn);
- }
-
- public OrmJoinTable buildOrmJoinTable(OrmJoinTableJoiningStrategy parent, Table.Owner owner, XmlJoinTable resourceJoinTable) {
- return new GenericOrmJoinTable(parent, owner, resourceJoinTable);
- }
-
- public OrmJoinColumn buildOrmJoinColumn(XmlContextNode parent, OrmJoinColumn.Owner owner, XmlJoinColumn resourceJoinColumn) {
- return new GenericOrmJoinColumn(parent, owner, resourceJoinColumn);
- }
-
- public OrmAttributeOverrideContainer buildOrmAttributeOverrideContainer(XmlContextNode parent, OrmAttributeOverrideContainer.Owner owner) {
- return new GenericOrmAttributeOverrideContainer(parent, owner);
- }
-
- public OrmAssociationOverrideContainer buildOrmAssociationOverrideContainer(XmlContextNode parent, OrmAssociationOverrideContainer.Owner owner) {
- return new GenericOrmAssociationOverrideContainer(parent, owner);
- }
-
- public OrmAssociationOverrideContainer buildOrmAssociationOverrideContainer(OrmEmbeddedMapping2_0 parent, OrmAssociationOverrideContainer.Owner owner) {
- return new NullOrmAssociationOverrideContainer(parent, owner);
- }
-
- public OrmAttributeOverride buildOrmAttributeOverride(OrmAttributeOverrideContainer parent, OrmAttributeOverride.Owner owner, XmlAttributeOverride xmlAttributeOverride) {
- return new GenericOrmAttributeOverride(parent, owner, xmlAttributeOverride);
- }
-
- public OrmAssociationOverride buildOrmAssociationOverride(OrmAssociationOverrideContainer parent, OrmAssociationOverride.Owner owner, XmlAssociationOverride xmlAssociationOverride) {
- return new GenericOrmAssociationOverride(parent, owner, xmlAssociationOverride);
- }
-
- public OrmAssociationOverrideRelationshipReference buildOrmAssociationOverrideRelationshipReference(OrmAssociationOverride parent, XmlAssociationOverride associationOverride) {
- return new GenericOrmAssociationOverrideRelationshipReference(parent, associationOverride);
- }
-
- public OrmDiscriminatorColumn buildOrmDiscriminatorColumn(OrmEntity parent, OrmDiscriminatorColumn.Owner owner) {
- return new GenericOrmDiscriminatorColumn(parent, owner);
- }
-
- public OrmColumn buildOrmColumn(XmlContextNode parent, OrmColumn.Owner owner) {
- return new GenericOrmColumn(parent, owner);
- }
-
- public OrmGeneratedValue buildOrmGeneratedValue(XmlContextNode parent, XmlGeneratedValue resourceGeneratedValue) {
- return new GenericOrmGeneratedValue(parent, resourceGeneratedValue);
- }
-
- public OrmGeneratorContainer buildOrmGeneratorContainer(XmlContextNode parent, XmlGeneratorContainer resourceGeneratorContainer) {
- return new GenericOrmGeneratorContainer(parent, resourceGeneratorContainer);
- }
-
- public OrmSequenceGenerator buildOrmSequenceGenerator(XmlContextNode parent, XmlSequenceGenerator resourceSequenceGenerator) {
- return new GenericOrmSequenceGenerator(parent, resourceSequenceGenerator);
- }
-
- public OrmTableGenerator buildOrmTableGenerator(XmlContextNode parent, XmlTableGenerator resourceTableGenerator) {
- return new GenericOrmTableGenerator(parent, resourceTableGenerator);
- }
-
- public OrmQueryContainer buildOrmQueryContainer(XmlContextNode parent, XmlQueryContainer resourceQueryContainer) {
- return new GenericOrmQueryContainer(parent, resourceQueryContainer);
- }
-
- public OrmNamedNativeQuery buildOrmNamedNativeQuery(XmlContextNode parent, XmlNamedNativeQuery resourceNamedNativeQuery) {
- return new GenericOrmNamedNativeQuery(parent, resourceNamedNativeQuery);
- }
-
- public OrmNamedQuery buildOrmNamedQuery(XmlContextNode parent, XmlNamedQuery resourceNamedQuery) {
- return new GenericOrmNamedQuery(parent, resourceNamedQuery);
- }
-
- public OrmQueryHint buildOrmQueryHint(OrmQuery parent, XmlQueryHint resourceQueryHint) {
- return new GenericOrmQueryHint(parent, resourceQueryHint);
- }
-
- public OrmBasicMapping buildOrmBasicMapping(OrmPersistentAttribute parent, XmlBasic resourceMapping) {
- return new GenericOrmBasicMapping(parent, resourceMapping);
- }
-
- public OrmEmbeddedMapping buildOrmEmbeddedMapping(OrmPersistentAttribute parent, XmlEmbedded resourceMapping) {
- return new GenericOrmEmbeddedMapping(parent, resourceMapping);
- }
-
- public OrmEmbeddedIdMapping buildOrmEmbeddedIdMapping(OrmPersistentAttribute parent, XmlEmbeddedId resourceMapping) {
- return new GenericOrmEmbeddedIdMapping(parent, resourceMapping);
- }
-
- public OrmIdMapping buildOrmIdMapping(OrmPersistentAttribute parent, XmlId resourceMapping) {
- return new GenericOrmIdMapping(parent, resourceMapping);
- }
-
- public OrmManyToManyMapping buildOrmManyToManyMapping(OrmPersistentAttribute parent, XmlManyToMany resourceMapping) {
- return new GenericOrmManyToManyMapping(parent, resourceMapping);
- }
-
- public OrmManyToOneMapping buildOrmManyToOneMapping(OrmPersistentAttribute parent, XmlManyToOne resourceMapping) {
- return new GenericOrmManyToOneMapping(parent, resourceMapping);
- }
-
- public OrmOneToManyMapping buildOrmOneToManyMapping(OrmPersistentAttribute parent, XmlOneToMany resourceMapping) {
- return new GenericOrmOneToManyMapping(parent, resourceMapping);
- }
-
- public OrmOneToOneMapping buildOrmOneToOneMapping(OrmPersistentAttribute parent, XmlOneToOne resourceMapping) {
- return new GenericOrmOneToOneMapping(parent, resourceMapping);
- }
-
- public OrmTransientMapping buildOrmTransientMapping(OrmPersistentAttribute parent, XmlTransient resourceMapping) {
- return new GenericOrmTransientMapping(parent, resourceMapping);
- }
-
- public OrmVersionMapping buildOrmVersionMapping(OrmPersistentAttribute parent, XmlVersion resourceMapping) {
- return new GenericOrmVersionMapping(parent, resourceMapping);
- }
-
- public OrmAttributeMapping buildOrmNullAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping resourceMapping) {
- return new GenericOrmNullAttributeMapping(parent, resourceMapping);
- }
-
- public OrmAttributeMapping buildUnsupportedOrmAttributeMapping(OrmPersistentAttribute parent, XmlNullAttributeMapping resourceMapping) {
- return new UnsupportedOrmAttributeMapping(parent, resourceMapping);
- }
-
- public OrmUniqueConstraint buildOrmUniqueConstraint(XmlContextNode parent, UniqueConstraint.Owner owner, XmlUniqueConstraint resourceUniqueConstraint) {
- return new GenericOrmUniqueConstraint(parent, owner, resourceUniqueConstraint);
- }
-
- public OrmConverter buildOrmEnumeratedConverter(OrmAttributeMapping parent, XmlConvertibleMapping resourceMapping) {
- return new GenericOrmEnumeratedConverter(parent, resourceMapping);
- }
-
- public OrmConverter buildOrmLobConverter(OrmAttributeMapping parent, XmlConvertibleMapping resourceMapping) {
- return new GenericOrmLobConverter(parent, resourceMapping);
- }
-
- public OrmConverter buildOrmTemporalConverter(OrmAttributeMapping parent, XmlConvertibleMapping resourceMapping) {
- return new GenericOrmTemporalConverter(parent, resourceMapping);
- }
-
- public OrmConverter buildOrmNullConverter(OrmAttributeMapping parent) {
- return new GenericOrmNullConverter(parent);
- }
-
- public OrmOrderable2_0 buildOrmOrderable(OrmAttributeMapping parent, Orderable.Owner owner) {
- return new GenericOrmOrderable(parent, owner);
- }
-
- public OrmOrderColumn2_0 buildOrmOrderColumn(OrmOrderable2_0 parent, OrmNamedColumn.Owner owner) {
- return new GenericOrmOrderColumn2_0(parent, owner);
- }
-
- public OrmDerivedIdentity2_0 buildOrmDerivedIdentity(
- OrmSingleRelationshipMapping2_0 parent, XmlSingleRelationshipMapping_2_0 resource) {
- return new NullOrmDerivedIdentity2_0(parent);
- }
-
- public OrmElementCollectionMapping2_0 buildOrmElementCollectionMapping2_0(
- OrmPersistentAttribute parent, XmlElementCollection resourceMapping) {
-
- throw new UnsupportedOperationException();
- }
-
- public OrmCacheable2_0 buildOrmCacheable(OrmCacheableHolder2_0 parent, XmlCacheable_2_0 resource) {
- return new NullOrmCacheable2_0(parent);
- }
-
- public OrmOrphanRemovable2_0 buildOrmOrphanRemoval(OrmOrphanRemovalHolder2_0 parent, XmlOrphanRemovable_2_0 resource) {
- return new NullOrmOrphanRemoval2_0(parent);
- }
-
- public OrmCollectionTable2_0 buildOrmCollectionTable(OrmElementCollectionMapping2_0 parent, Table.Owner owner, XmlCollectionTable resource) {
- throw new UnsupportedOperationException();
- }
-
- // ********** ORM Virtual Resource Model **********
-
- public XmlAssociationOverride buildVirtualXmlAssociationOverride(String name, OrmTypeMapping parent, JoiningStrategy joiningStrategy) {
- return new VirtualXmlAssociationOverride(name, parent, joiningStrategy);
- }
-
- public XmlBasic buildVirtualXmlBasic(OrmTypeMapping ormTypeMapping, JavaBasicMapping javaBasicMapping) {
- return new VirtualXmlBasic(ormTypeMapping, javaBasicMapping);
- }
-
- public XmlEmbeddedId buildVirtualXmlEmbeddedId(OrmTypeMapping ormTypeMapping, JavaEmbeddedIdMapping javaEmbeddedIdMapping) {
- return new VirtualXmlEmbeddedId(ormTypeMapping, javaEmbeddedIdMapping);
- }
-
- public XmlEmbedded buildVirtualXmlEmbedded(OrmTypeMapping ormTypeMapping, JavaEmbeddedMapping javaEmbeddedMapping) {
- return new VirtualXmlEmbedded(ormTypeMapping, javaEmbeddedMapping);
- }
-
- public XmlId buildVirtualXmlId(OrmTypeMapping ormTypeMapping, JavaIdMapping javaIdMapping) {
- return new VirtualXmlId(ormTypeMapping, javaIdMapping);
- }
-
- public XmlManyToMany buildVirtualXmlManyToMany(OrmTypeMapping ormTypeMapping, JavaManyToManyMapping javaManyToManyMapping) {
- return new VirtualXmlManyToMany(ormTypeMapping, javaManyToManyMapping);
- }
-
- public XmlManyToOne buildVirtualXmlManyToOne(OrmTypeMapping ormTypeMapping, JavaManyToOneMapping javaManyToOneMapping) {
- return new VirtualXmlManyToOne(ormTypeMapping, javaManyToOneMapping);
- }
-
- public XmlOneToMany buildVirtualXmlOneToMany(OrmTypeMapping ormTypeMapping, JavaOneToManyMapping javaOneToManyMapping) {
- return new VirtualXmlOneToMany(ormTypeMapping, javaOneToManyMapping);
- }
-
- public XmlOneToOne buildVirtualXmlOneToOne(OrmTypeMapping ormTypeMapping, JavaOneToOneMapping javaOneToOneMapping) {
- return new VirtualXmlOneToOne(ormTypeMapping, javaOneToOneMapping);
- }
-
- public XmlTransient buildVirtualXmlTransient(OrmTypeMapping ormTypeMapping, JavaTransientMapping javaTransientMapping) {
- return new VirtualXmlTransient(ormTypeMapping, javaTransientMapping);
- }
-
- public XmlVersion buildVirtualXmlVersion(OrmTypeMapping ormTypeMapping, JavaVersionMapping javaVersionMapping) {
- return new VirtualXmlVersion(ormTypeMapping, javaVersionMapping);
- }
-
- public XmlNullAttributeMapping buildVirtualXmlNullAttributeMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping) {
- return new VirtualXmlNullAttributeMapping(ormTypeMapping, javaAttributeMapping);
- }
-
- public XmlElementCollection buildVirtualXmlElementCollection2_0(OrmTypeMapping ormTypeMapping, JavaElementCollectionMapping2_0 javaMapping) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlDefinition.java
deleted file mode 100644
index 367f38c895..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/AbstractOrmXmlDefinition.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.context.orm.OrmXmlDefinition;
-import org.eclipse.jpt.core.context.orm.UnsupportedOrmAttributeMappingDefinition;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.Tools;
-import org.eclipse.jpt.utility.internal.iterators.ArrayListIterator;
-
-/**
- * All the state in the definition should be "static" (i.e. unchanging once it is initialized).
- */
-public abstract class AbstractOrmXmlDefinition
- implements OrmXmlDefinition
-{
- private OrmTypeMappingDefinition[] ormTypeMappingDefinitions;
-
- private OrmAttributeMappingDefinition[] ormAttributeMappingDefinitions;
-
- private final OrmXmlContextNodeFactory factory;
-
-
- /**
- * zero-argument constructor
- */
- protected AbstractOrmXmlDefinition() {
- super();
- this.factory = buildContextNodeFactory();
- }
-
-
- protected abstract OrmXmlContextNodeFactory buildContextNodeFactory();
-
- public OrmXmlContextNodeFactory getContextNodeFactory() {
- return this.factory;
- }
-
-
- // ********** ORM type mappings **********
-
- public OrmTypeMappingDefinition getOrmTypeMappingDefinition(String mappingKey) {
- for (OrmTypeMappingDefinition definition : CollectionTools.iterable(ormTypeMappingDefinitions())) {
- if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) {
- return definition;
- }
- }
- throw new IllegalArgumentException("Illegal type mapping key: " + mappingKey); //$NON-NLS-1$
- }
-
- public ListIterator<OrmTypeMappingDefinition> ormTypeMappingDefinitions() {
- return new ArrayListIterator<OrmTypeMappingDefinition>(getOrmTypeMappingDefinitions());
- }
-
- protected synchronized OrmTypeMappingDefinition[] getOrmTypeMappingDefinitions() {
- if (this.ormTypeMappingDefinitions == null) {
- this.ormTypeMappingDefinitions = this.buildOrmTypeMappingDefinitions();
- }
- return this.ormTypeMappingDefinitions;
- }
-
- /**
- * Return an array of mapping definitions to use for types in mapping files of this type.
- * The order is unimportant.
- */
- protected abstract OrmTypeMappingDefinition[] buildOrmTypeMappingDefinitions();
-
-
- // ********** ORM attribute mappings **********
-
- public OrmAttributeMappingDefinition getOrmAttributeMappingDefinition(String mappingKey) {
- for (OrmAttributeMappingDefinition definition : CollectionTools.iterable(ormAttributeMappingDefinitions())) {
- if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) {
- return definition;
- }
- }
- return UnsupportedOrmAttributeMappingDefinition.instance();
- }
-
- public ListIterator<OrmAttributeMappingDefinition> ormAttributeMappingDefinitions() {
- return new ArrayListIterator<OrmAttributeMappingDefinition>(getOrmAttributeMappingDefinitions());
- }
-
- protected synchronized OrmAttributeMappingDefinition[] getOrmAttributeMappingDefinitions() {
- if (this.ormAttributeMappingDefinitions == null) {
- this.ormAttributeMappingDefinitions = this.buildOrmAttributeMappingDefinitions();
- }
- return this.ormAttributeMappingDefinitions;
- }
-
- /**
- * Return an array of mapping definitions to use for attributes in mapping files of this type.
- * The order is unimportant.
- */
- protected abstract OrmAttributeMappingDefinition[] buildOrmAttributeMappingDefinitions();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdClassReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdClassReference.java
deleted file mode 100644
index d1aec207e9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmIdClassReference.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.orm.EntityMappings;
-import org.eclipse.jpt.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlClassReference;
-import org.eclipse.jpt.core.resource.orm.XmlIdClassContainer;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmIdClassReference
- extends AbstractXmlContextNode
- implements OrmIdClassReference
-{
- protected String specifiedIdClassName;
-
- protected String defaultIdClassName;
-
- protected JavaPersistentType idClass;
-
-
- public GenericOrmIdClassReference(OrmTypeMapping parent, JavaIdClassReference javaIdClassReference) {
- super(parent);
- this.specifiedIdClassName = buildSpecifiedIdClassName();
- this.defaultIdClassName = buildDefaultIdClassName(javaIdClassReference);
- this.idClass = buildIdClass();
- }
-
-
- protected OrmTypeMapping getTypeMapping() {
- return (OrmTypeMapping) getParent();
- }
-
- protected OrmPersistentType getPersistentType() {
- return getTypeMapping().getPersistentType();
- }
-
-
- // **************** PersistentType.Owner impl *****************************
-
- public AccessType getOverridePersistentTypeAccess() {
- return getPersistentType().getAccess();
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- // this shouldn't be needed, since we've specified an override access, but just to be safe ...
- return getPersistentType().getAccess();
- }
-
-
- // **************** IdClassReference impl *********************************
-
- public String getSpecifiedIdClassName() {
- return this.specifiedIdClassName;
- }
-
- public void setSpecifiedIdClassName(String newClassName) {
- String oldClassName = this.specifiedIdClassName;
- this.specifiedIdClassName = newClassName;
- if (valuesAreDifferent(oldClassName, newClassName)) {
- if (getIdXmlClassRef() != null) {
- getIdXmlClassRef().setClassName(newClassName);
- if (getIdXmlClassRef().isUnset()) {
- removeIdClassElement();
- }
- }
- else if (newClassName != null) {
- addIdClassElement();
- getIdXmlClassRef().setClassName(newClassName);
- }
- }
- firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected void setSpecifiedIdClassName_(String newClassName) {
- String oldClassName = this.specifiedIdClassName;
- this.specifiedIdClassName = newClassName;
- firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected String buildSpecifiedIdClassName() {
- XmlClassReference idXmlClassRef = this.getIdXmlClassRef();
- return (idXmlClassRef == null) ? null : idXmlClassRef.getClassName();
- }
-
- public String getDefaultIdClassName() {
- return this.defaultIdClassName;
- }
-
- protected void setDefaultIdClassName_(String newClassName) {
- String oldClassName = this.defaultIdClassName;
- this.defaultIdClassName = newClassName;
- firePropertyChanged(DEFAULT_ID_CLASS_NAME_PROPERTY, oldClassName, newClassName);
- }
-
- protected String buildDefaultIdClassName(JavaIdClassReference javaIdClassReference) {
- return (javaIdClassReference == null) ? null : javaIdClassReference.getFullyQualifiedIdClassName();
- }
-
- public String getIdClassName() {
- return (this.specifiedIdClassName == null) ? this.defaultIdClassName : this.specifiedIdClassName;
- }
-
- public boolean isSpecified() {
- return getIdClassName() != null;
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClass;
- }
-
- protected void setIdClass_(JavaPersistentType newIdClass) {
- JavaPersistentType oldIdClass = this.idClass;
- this.idClass = newIdClass;
- firePropertyChanged(ID_CLASS_PROPERTY, oldIdClass, newIdClass);
- }
-
- protected JavaPersistentType buildIdClass() {
- JavaResourcePersistentType resourceIdClass = getResourceIdClass();
- return (resourceIdClass == null) ?
- null : this.buildIdClass(resourceIdClass);
- }
-
- protected JavaPersistentType buildIdClass(JavaResourcePersistentType resourceClass) {
- return getJpaFactory().buildJavaPersistentType(this, resourceClass);
- }
-
- protected XmlTypeMapping getResourceTypeMapping() {
- return getTypeMapping().getResourceTypeMapping();
- }
-
- protected XmlIdClassContainer getResourceIdClassContainer() {
- return (XmlIdClassContainer) getResourceTypeMapping();
- }
-
- protected XmlClassReference getIdXmlClassRef() {
- return this.getResourceIdClassContainer().getIdClass();
- }
-
- protected void addIdClassElement() {
- getResourceIdClassContainer().setIdClass(OrmFactory.eINSTANCE.createXmlClassReference());
- }
-
- protected void removeIdClassElement() {
- getResourceIdClassContainer().setIdClass(null);
- }
-
- protected JavaResourcePersistentType getResourceIdClass() {
- XmlClassReference idXmlClassRef = this.getIdXmlClassRef();
- if (idXmlClassRef == null) {
- return null;
- }
-
- String className = idXmlClassRef.getClassName();
- if (className == null) {
- return null;
- }
-
- return this.getEntityMappings().resolveJavaResourcePersistentType(className);
- }
-
- protected EntityMappings getEntityMappings() {
- return (EntityMappings) getMappingFileRoot();
- }
-
- public char getIdClassEnclosingTypeSeparator() {
- return '$';
- }
-
- public void update(JavaIdClassReference javaIdClassReference) {
- setDefaultIdClassName_(buildDefaultIdClassName(javaIdClassReference));
- setSpecifiedIdClassName_(buildSpecifiedIdClassName());
- updateIdClass();
- }
-
- protected void updateIdClass() {
- JavaResourcePersistentType resourceIdClass = getResourceIdClass();
- if (resourceIdClass == null) {
- setIdClass_(null);
- }
- else {
- if (this.idClass == null || this.idClass.getResourcePersistentType() != resourceIdClass) {
- setIdClass_(buildIdClass(resourceIdClass));
- }
- else {
- this.idClass.update(resourceIdClass);
- }
- }
- }
-
-
- //************************* refactoring ************************
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- if (this.isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenameEdit(originalType, newName));
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createRenameEdit(IType originalType, String newName) {
- return getIdXmlClassRef().createRenameEdit(originalType, newName);
- }
-
- protected boolean isFor(String typeName) {
- if (this.idClass != null && this.idClass.isFor(typeName)) {
- return true;
- }
- return false;
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (this.isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newPackage.getElementName()));
- }
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (this.isIn(originalPackage)) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newName));
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createRenamePackageEdit(String newName) {
- return getIdXmlClassRef().createRenamePackageEdit(newName);
- }
-
- protected boolean isIn(IPackageFragment originalPackage) {
- if (this.idClass != null && this.idClass.isIn(originalPackage)) {
- return true;
- }
- return false;
- }
-
-
- // **************** validation ********************************************
-
- public TextRange getValidationTextRange() {
- XmlClassReference idXmlClassRef = getIdXmlClassRef();
- return (idXmlClassRef == null) ?
- this.getTypeMapping().getValidationTextRange() :
- idXmlClassRef.getClassNameTextRange();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- // most validation is done "holistically" from the type mapping level
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.java
deleted file mode 100644
index f1ec5a66de..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.BaseColumn;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnInAssociationOverrideJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn.Owner;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-
-public class GenericOrmJoinColumnInAssociationOverrideJoiningStrategy
- extends AbstractOrmJoinColumnJoiningStrategy
- implements OrmJoinColumnInAssociationOverrideJoiningStrategy
-{
-
- public GenericOrmJoinColumnInAssociationOverrideJoiningStrategy(OrmAssociationOverrideRelationshipReference parent, XmlAssociationOverride xao) {
- super(parent, xao);
- }
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- if (relationshipMapping != null) {
- return relationshipMapping.getRelationshipReference().isTargetForeignKeyRelationship();
- }
- return false;
- }
-
- public TypeMapping getRelationshipSource() {
- if (isTargetForeignKeyRelationship()) {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
- return getAssociationOverrideOwner().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- if (isTargetForeignKeyRelationship()) {
- return getAssociationOverrideOwner().getTypeMapping();
- }
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping relationshipTarget = getRelationshipTarget();
- return (relationshipTarget != null) && (relationshipTarget.getKey() == MappingKeys.ENTITY_TYPE_MAPPING_KEY) ? (Entity) relationshipTarget : null;
- }
-
- @Override
- public RelationshipMapping getRelationshipMapping() {
- return getAssociationOverrideOwner().getRelationshipMapping(getAttributeName());
- }
-
- protected String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- @Override
- public String getTableName() {
- if (isTargetForeignKeyRelationship()) {
- return super.getTableName();
- }
- return getAssociationOverrideOwner().getDefaultTableName();
- }
-
- @Override
- public Table getDbTable(String tableName) {
- if (isTargetForeignKeyRelationship()) {
- return super.getDbTable(tableName);
- }
- return getAssociationOverrideOwner().getDbTable(tableName);
- }
-
- @Override
- public boolean tableNameIsInvalid(String tableName) {
- if (isTargetForeignKeyRelationship()) {
- return super.tableNameIsInvalid(tableName);
- }
- return getAssociationOverrideOwner().tableNameIsInvalid(tableName);
- }
-
- @Override
- public Iterator<String> candidateTableNames() {
- if (isTargetForeignKeyRelationship()) {
- return super.candidateTableNames();
- }
- return getAssociationOverrideOwner().candidateTableNames();
- }
-
- public String getColumnTableNotValidDescription() {
- return null;
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- protected OrmAssociationOverride getAssociationOverride() {
- return this.getRelationshipReference().getAssociationOverride();
- }
-
- protected OrmAssociationOverride.Owner getAssociationOverrideOwner() {
- return getAssociationOverride().getOwner();
- }
-
- @Override
- public OrmAssociationOverrideRelationshipReference getRelationshipReference() {
- return (OrmAssociationOverrideRelationshipReference) super.getRelationshipReference();
- }
-
- public TextRange getValidationTextRange() {
- return getRelationshipReference().getValidationTextRange();
- }
-
- public void update(XmlAssociationOverride xao) {
- //TODO can we make resource final and then just have an update() method?
- //would need to update the association overrides with the same resource association override
- this.resource = xao;
- super.update();
- }
-
-
-
- // ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements OrmJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- public String getDefaultTableName() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getAttributeName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- RelationshipMapping relationshipMapping = getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.candidateTableNames();
- }
-
- public Table getDbTable(String tableName) {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return false;
- }
-
- public int joinColumnsSize() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange() {
- return GenericOrmJoinColumnInAssociationOverrideJoiningStrategy.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return getAssociationOverrideOwner().buildColumnValidator(getAssociationOverride(), (BaseColumn) column, this, (BaseColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnJoiningStrategy.java
deleted file mode 100644
index 3f5775129d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumnsMapping;
-
-public class GenericOrmJoinColumnJoiningStrategy
- extends AbstractOrmJoinColumnInRelationshipMappingJoiningStrategy
-{
-
- public GenericOrmJoinColumnJoiningStrategy(
- OrmJoinColumnEnabledRelationshipReference parent,
- XmlJoinColumnsMapping resource) {
- super(parent, resource);
- }
-
- public TypeMapping getRelationshipSource() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- return getRelationshipTargetEntity();
- }
-
- @Override
- protected Entity getRelationshipTargetEntity() {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public boolean isTargetForeignKeyRelationship() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTableJoiningStrategy.java
deleted file mode 100644
index 22c0f41cf5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.InverseJoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.core.internal.jpa1.context.JoinTableValidator;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTableMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class GenericOrmJoinTableJoiningStrategy
- extends AbstractOrmJoinTableJoiningStrategy
-{
- protected XmlJoinTableMapping resource;
-
-
- public GenericOrmJoinTableJoiningStrategy(
- OrmJoinTableEnabledRelationshipReference parent,
- XmlJoinTableMapping resource) {
- super(parent);
- this.resource = resource;
- this.initialize();
- }
-
-
- @Override
- public OrmJoinTableEnabledRelationshipReference getParent() {
- return (OrmJoinTableEnabledRelationshipReference) super.getParent();
- }
-
- @Override
- public OrmJoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- @Override
- protected void setResourceJoinTable(XmlJoinTable resourceJoinTable) {
- this.resource.setJoinTable(resourceJoinTable);
- }
-
- public boolean isOverridableAssociation() {
- return getJpaPlatformVariation().isJoinTableOverridable();
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return getRelationshipMapping().shouldValidateAgainstDatabase();
- }
-
- // **************** join table *********************************************
-
- public void removeResourceJoinTable() {
- this.resource.setJoinTable(null);
- }
-
- public XmlJoinTable getResourceJoinTable() {
- return this.resource.getJoinTable();
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange() {
- return getRelationshipReference().getValidationTextRange();
- }
-
- protected PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator(this.getPersistentAttribute(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new InverseJoinColumnValidator(this.getPersistentAttribute(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new JoinTableValidator(getPersistentAttribute(), (JoinTable) table, textRangeResolver);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java
deleted file mode 100644
index 177b534ba7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToManyRelationshipReference.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmManyToManyRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipReference;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmManyToManyRelationshipReference
- extends AbstractOrmRelationshipReference
- implements OrmManyToManyRelationshipReference
-{
- protected OrmMappedByJoiningStrategy mappedByJoiningStrategy;
-
- protected OrmJoinTableJoiningStrategy joinTableJoiningStrategy;
-
-
- public GenericOrmManyToManyRelationshipReference(
- OrmManyToManyMapping parent, XmlManyToMany resource) {
- super(parent, resource);
- }
-
-
- @Override
- protected void initializeJoiningStrategies() {
- this.mappedByJoiningStrategy = buildMappedByJoiningStrategy();
-
- // initialize join table last, as the existence of a default join
- // table is dependent on the other mechanisms (mappedBy)
- // not being specified
- this.joinTableJoiningStrategy = buildJoinTableJoiningStrategy();
- }
-
- protected OrmMappedByJoiningStrategy buildMappedByJoiningStrategy() {
- return new GenericOrmMappedByJoiningStrategy(this, getResourceMapping());
- }
-
- protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new GenericOrmJoinTableJoiningStrategy(this, getResourceMapping());
- }
-
- public void initializeOn(OrmRelationshipReference newRelationshipReference) {
- newRelationshipReference.initializeFromOwnableRelationshipReference(this);
- newRelationshipReference.initializeFromJoinTableEnabledRelationshipReference(this);
- }
-
- @Override
- public void initializeFromOwnableRelationshipReference(
- OrmOwnableRelationshipReference oldRelationshipReference) {
- super.initializeFromOwnableRelationshipReference(oldRelationshipReference);
- this.mappedByJoiningStrategy.setMappedByAttribute(
- oldRelationshipReference.getMappedByJoiningStrategy().getMappedByAttribute());
- }
-
- @Override
- public void initializeFromJoinTableEnabledRelationshipReference(
- OrmJoinTableEnabledRelationshipReference oldRelationshipReference) {
- super.initializeFromJoinTableEnabledRelationshipReference(oldRelationshipReference);
- OrmJoinTable oldTable =
- oldRelationshipReference.getJoinTableJoiningStrategy().getJoinTable();
- if (oldTable != null) {
- this.joinTableJoiningStrategy.addJoinTable().initializeFrom(oldTable);
- }
- }
-
-
- @Override
- public OrmManyToManyMapping getRelationshipMapping() {
- return (OrmManyToManyMapping) super.getRelationshipMapping();
- }
-
- public XmlManyToMany getResourceMapping() {
- return getRelationshipMapping().getResourceAttributeMapping();
- }
-
- public boolean isRelationshipOwner() {
- return this.mappedByJoiningStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByJoiningStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- protected OrmJoiningStrategy calculatePredominantJoiningStrategy() {
- if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
- return this.mappedByJoiningStrategy;
- }
- return this.joinTableJoiningStrategy;
- }
-
-
- // **************** mapped by **********************************************
-
- public OrmMappedByJoiningStrategy getMappedByJoiningStrategy() {
- return this.mappedByJoiningStrategy;
- }
-
- public boolean usesMappedByJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.mappedByJoiningStrategy;
- }
-
- public void setMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.addStrategy();
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetMappedByJoiningStrategy() {
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mappedByMapping) {
- return mappedByMapping.getKey() == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
-
- // **************** join table joining strategy ***************************
-
- public OrmJoinTableJoiningStrategy getJoinTableJoiningStrategy() {
- return this.joinTableJoiningStrategy;
- }
-
- public boolean usesJoinTableJoiningStrategy() {
- return getPredominantJoiningStrategy() == this.joinTableJoiningStrategy;
- }
-
- public void setJoinTableJoiningStrategy() {
- // join table is the default strategy, so no need to add to resource
- this.mappedByJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public void unsetJoinTableJoiningStrategy() {
- this.joinTableJoiningStrategy.removeStrategy();
- setPredominantJoiningStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return getMappedByJoiningStrategy().getMappedByAttribute() == null;
- }
-
-
- // **************** resource => context ************************************
-
- @Override
- protected void updateJoiningStrategies() {
- this.mappedByJoiningStrategy.update();
-
- // update join table last, as the existence of a default join
- // table is dependent on the other mechanisms (mappedBy)
- // not being specified
- this.joinTableJoiningStrategy.update();
- }
-
-
- // **************** Validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.mappedByJoiningStrategy.validate(messages, reporter);
- this.joinTableJoiningStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneRelationshipReference.java
deleted file mode 100644
index 26b5d5f573..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmManyToOneRelationshipReference.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-
-public class GenericOrmManyToOneRelationshipReference
- extends AbstractOrmManyToOneRelationshipReference
-{
-
- public GenericOrmManyToOneRelationshipReference(
- OrmManyToOneMapping parent, XmlManyToOne resource) {
- super(parent, resource);
- }
-
- @Override
- protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new NullOrmJoinTableJoiningStrategy(this);
- }
-
- @Override
- protected OrmJoiningStrategy calculatePredominantJoiningStrategy() {
- // the only joining strategy
- return this.joinColumnJoiningStrategy;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedByJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedByJoiningStrategy.java
deleted file mode 100644
index a637ac4280..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmMappedByJoiningStrategy.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jpt.core.context.AttributeMapping;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.RelationshipMapping;
-import org.eclipse.jpt.core.context.orm.OrmMappedByJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmOwnableRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.orm.XmlMappedByMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.ArrayTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmMappedByJoiningStrategy
- extends AbstractOrmXmlContextNode
- implements OrmMappedByJoiningStrategy
-{
- protected XmlMappedByMapping resource;
-
- protected String mappedByAttribute;
-
-
- public GenericOrmMappedByJoiningStrategy(
- OrmOwnableRelationshipReference parent,
- XmlMappedByMapping resource) {
- super(parent);
- this.resource = resource;
- this.mappedByAttribute = this.resource.getMappedBy();
- }
-
-
- @Override
- public OrmOwnableRelationshipReference getParent() {
- return (OrmOwnableRelationshipReference) super.getParent();
- }
-
- public OrmOwnableRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public String getTableName() {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? null : owner.getRelationshipReference().getPredominantJoiningStrategy().getTableName();
- }
-
- public Table getDbTable(String tableName) {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? null : owner.getRelationshipReference().getPredominantJoiningStrategy().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- RelationshipMapping owner = getRelationshipOwner();
- return owner == null ? false : owner.getRelationshipReference().getPredominantJoiningStrategy().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- //this will not be called if getRelationshipOwner() is null
- return getRelationshipOwner().getRelationshipReference().getPredominantJoiningStrategy().getColumnTableNotValidDescription();
- }
-
- protected RelationshipMapping getRelationshipOwner() {
- return getRelationshipMapping().getRelationshipOwner();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public OrmRelationshipMapping getRelationshipMapping() {
- return getParent().getRelationshipMapping();
- }
-
- public boolean relationshipIsOwnedBy(RelationshipMapping otherMapping) {
- String thisEntity =
- (getRelationshipReference().getEntity()) == null ?
- null : getRelationshipReference().getEntity().getName();
- String targetEntity =
- (otherMapping.getResolvedTargetEntity() == null) ?
- null : otherMapping.getResolvedTargetEntity().getName();
- return StringTools.stringsAreEqual(
- thisEntity,
- targetEntity)
- && StringTools.stringsAreEqual(
- getMappedByAttribute(),
- otherMapping.getName());
- }
-
- public String getMappedByAttribute() {
- return this.mappedByAttribute;
- }
-
- public void setMappedByAttribute(String newMappedByAttribute) {
- String oldMappedByAttribute = this.mappedByAttribute;
- this.mappedByAttribute = newMappedByAttribute;
- this.resource.setMappedBy(newMappedByAttribute);
- firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, oldMappedByAttribute, newMappedByAttribute);
- }
-
- protected void setMappedByAttribute_(String newMappedByAttribute) {
- String oldMappedByAttribute = this.mappedByAttribute;
- this.mappedByAttribute = newMappedByAttribute;
- firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, oldMappedByAttribute, newMappedByAttribute);
- }
-
- public void addStrategy() {
- if (this.mappedByAttribute == null) {
- setMappedByAttribute(""); //$NON-NLS-1$
- }
- }
-
- public void removeStrategy() {
- if (this.mappedByAttribute != null) {
- setMappedByAttribute(null);
- }
- }
-
- public void update() {
- setMappedByAttribute_(this.resource.getMappedBy());
- }
-
- public Iterator<String> candidateMappedByAttributeNames() {
- return getRelationshipMapping().allTargetEntityAttributeNames();
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange() {
- TextRange mappedByTextRange = this.resource.getMappedByTextRange();
- return mappedByTextRange != null ? mappedByTextRange : getRelationshipReference().getValidationTextRange();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- if (getMappedByAttribute() == null) {
- return;
- }
-
- Entity targetEntity = this.getRelationshipMapping().getResolvedTargetEntity();
- if (targetEntity == null) {
- return; // null target entity is validated elsewhere
- }
-
- AttributeMapping mappedByMapping = targetEntity.resolveAttributeMapping(this.mappedByAttribute);
-
- if (mappedByMapping == null) {
- messages.add(
- buildMessage(
- JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
- new String[] {this.mappedByAttribute}));
- return;
- }
-
- if (! this.getRelationshipReference().mayBeMappedBy(mappedByMapping)) {
- messages.add(
- buildMessage(
- JpaValidationMessages.MAPPING_INVALID_MAPPED_BY,
- new String[] {this.mappedByAttribute}));
- return;
- }
-
- // if mappedByMapping is not a relationship owner, then it should have
- // been flagged in above rule (mappedByIsValid)
- if (! ((RelationshipMapping) mappedByMapping).isRelationshipOwner()) {
- messages.add(buildMessage(
- JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
- new String[] {this.mappedByAttribute}));
- }
- }
-
- protected IMessage buildMessage(String msgID, String[] params) {
- String attributeDescString;
- PersistentAttribute attribute = getRelationshipMapping().getPersistentAttribute();
- if (attribute.isVirtual()) {
- attributeDescString = NLS.bind(JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC, attribute.getName());
- }
- else {
- attributeDescString = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
- }
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY, msgID, ArrayTools.add(params, 0, attributeDescString), this, getValidationTextRange());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneRelationshipReference.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneRelationshipReference.java
deleted file mode 100644
index 86673561c6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmOneToOneRelationshipReference.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmJoinTableJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-
-public class GenericOrmOneToOneRelationshipReference
- extends AbstractOrmOneToOneRelationshipReference
-{
-
-
- public GenericOrmOneToOneRelationshipReference(
- OrmOneToOneMapping parent, XmlOneToOne resource) {
- super(parent, resource);
- }
-
-
- @Override
- protected OrmJoinTableJoiningStrategy buildJoinTableJoiningStrategy() {
- return new NullOrmJoinTableJoiningStrategy(this);
- }
-
- @Override
- protected OrmJoiningStrategy calculatePredominantJoiningStrategy() {
- if (this.mappedByJoiningStrategy.getMappedByAttribute() != null) {
- return this.mappedByJoiningStrategy;
- }
- else if (this.primaryKeyJoinColumnJoiningStrategy.primaryKeyJoinColumnsSize() > 0) {
- return this.primaryKeyJoinColumnJoiningStrategy;
- }
- return this.joinColumnJoiningStrategy;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnJoiningStrategy.java
deleted file mode 100644
index 3b7805fccf..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnJoiningStrategy.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.core.context.BaseJoinColumn;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.NamedColumn;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumnEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.jpa1.context.OneToOnePrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.db.Table;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmPrimaryKeyJoinColumnJoiningStrategy
- extends AbstractOrmXmlContextNode
- implements OrmPrimaryKeyJoinColumnJoiningStrategy
-{
- protected XmlOneToOne resource;
-
- protected final Vector<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = new Vector<OrmPrimaryKeyJoinColumn>();
-
- protected final OrmJoinColumn.Owner joinColumnOwner;
-
-
- public GenericOrmPrimaryKeyJoinColumnJoiningStrategy(
- OrmPrimaryKeyJoinColumnEnabledRelationshipReference parent,
- XmlOneToOne resource) {
- super(parent);
- this.resource = resource;
- this.joinColumnOwner = this.buildJoinColumnOwner();
- this.initializePrimaryKeyJoinColumns();
- }
-
- protected OrmJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- if (this.resource != null) {
- for (XmlPrimaryKeyJoinColumn resourceJoinColumn : this.resource.getPrimaryKeyJoinColumns()) {
- this.primaryKeyJoinColumns.add(buildPrimaryKeyJoinColumn(resourceJoinColumn));
- }
- }
- }
-
- protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(
- XmlPrimaryKeyJoinColumn resourceJoinColumn) {
- return this.getXmlContextNodeFactory().buildOrmPrimaryKeyJoinColumn(this, this.joinColumnOwner, resourceJoinColumn);
- }
-
- @Override
- public OrmJoinColumnEnabledRelationshipReference getParent() {
- return (OrmJoinColumnEnabledRelationshipReference) super.getParent();
- }
-
- public OrmJoinColumnEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- public OrmRelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- public String getTableName() {
- return getTypeMapping().getPrimaryTableName();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- protected TypeMapping getTypeMapping() {
- return getRelationshipMapping().getTypeMapping();
- }
-
- public void addStrategy() {
- if (primaryKeyJoinColumnsSize() == 0) {
- addPrimaryKeyJoinColumn(0);
- }
- }
-
- public void removeStrategy() {
- for (PrimaryKeyJoinColumn each : CollectionTools.iterable(primaryKeyJoinColumns())) {
- removePrimaryKeyJoinColumn(each);
- }
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
-
- // **************** primary key join columns *******************************
-
- public ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return new CloneListIterator<OrmPrimaryKeyJoinColumn>(this.primaryKeyJoinColumns);
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.primaryKeyJoinColumns.size();
- }
-
- public boolean hasPrimaryKeyJoinColumns() {
- return ! this.primaryKeyJoinColumns.isEmpty();
- }
-
- public OrmPrimaryKeyJoinColumn addPrimaryKeyJoinColumn(int index) {
- XmlPrimaryKeyJoinColumn resourcePkJoinColumn =
- OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn();
- OrmPrimaryKeyJoinColumn contextPkJoinColumn =
- this.buildPrimaryKeyJoinColumn(resourcePkJoinColumn);
- this.primaryKeyJoinColumns.add(index, contextPkJoinColumn);
- this.resource.getPrimaryKeyJoinColumns().add(index, resourcePkJoinColumn);
- this.fireItemAdded(PRIMARY_KEY_JOIN_COLUMNS_LIST, index, contextPkJoinColumn);
- return contextPkJoinColumn;
- }
-
- protected void addPrimaryKeyJoinColumn(int index, OrmPrimaryKeyJoinColumn joinColumn) {
- this.addItemToList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void addPrimaryKeyJoinColumn(OrmPrimaryKeyJoinColumn joinColumn) {
- this.addPrimaryKeyJoinColumn(this.primaryKeyJoinColumns.size(), joinColumn);
- }
-
- public void removePrimaryKeyJoinColumn(PrimaryKeyJoinColumn pkJoinColumn) {
- this.removePrimaryKeyJoinColumn(this.primaryKeyJoinColumns.indexOf(pkJoinColumn));
- }
-
- public void removePrimaryKeyJoinColumn(int index) {
- OrmPrimaryKeyJoinColumn removedPkJoinColumn = this.primaryKeyJoinColumns.remove(index);
- this.resource.getPrimaryKeyJoinColumns().remove(index);
- this.fireItemRemoved(PRIMARY_KEY_JOIN_COLUMNS_LIST, index, removedPkJoinColumn);
- }
-
- protected void removePrimaryKeyJoinColumn_(OrmPrimaryKeyJoinColumn joinColumn) {
- removeItemFromList(joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void movePrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- CollectionTools.move(this.primaryKeyJoinColumns, targetIndex, sourceIndex);
- this.resource.getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex);
- fireItemMoved(PRIMARY_KEY_JOIN_COLUMNS_LIST, targetIndex, sourceIndex);
- }
-
-
- // **************** resource -> context ************************************
-
- public void update() {
- updatePrimaryKeyJoinColumns();
- }
-
- protected void updatePrimaryKeyJoinColumns() {
- // make a copy of the XML PK join columns (to prevent ConcurrentModificationException)
- Iterator<XmlPrimaryKeyJoinColumn> xmlPkJoinColumns =
- new CloneIterator<XmlPrimaryKeyJoinColumn>(this.resource.getPrimaryKeyJoinColumns());
-
- for (Iterator<OrmPrimaryKeyJoinColumn> contextPkJoinColumns = primaryKeyJoinColumns();
- contextPkJoinColumns.hasNext(); ) {
- OrmPrimaryKeyJoinColumn contextPkJoinColumn = contextPkJoinColumns.next();
- if (xmlPkJoinColumns.hasNext()) {
- contextPkJoinColumn.update(xmlPkJoinColumns.next());
- }
- else {
- removePrimaryKeyJoinColumn_(contextPkJoinColumn);
- }
- }
-
- while (xmlPkJoinColumns.hasNext()) {
- addPrimaryKeyJoinColumn(buildPrimaryKeyJoinColumn(xmlPkJoinColumns.next()));
- }
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange() {
- return this.getRelationshipReference().getValidationTextRange();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- for (Iterator<OrmPrimaryKeyJoinColumn> stream = this.primaryKeyJoinColumns(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter);
- }
- }
-
-
- // ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements OrmJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return GenericOrmPrimaryKeyJoinColumnJoiningStrategy.this.getTableName();
- }
-
- public Entity getRelationshipTarget() {
- return getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- return getRelationshipMapping().getName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return getRelationshipMapping().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public boolean tableIsAllowed() {
- return true;
- }
-
- public Iterator<String> candidateTableNames() {
- return getTypeMapping().associatedTableNamesIncludingInherited();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericOrmPrimaryKeyJoinColumnJoiningStrategy.this.getTypeMapping();
- }
-
- public Table getDbTable(String tableName) {
- return getTypeMapping().getDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- Entity relationshipTarget = getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
- public boolean isVirtual(BaseJoinColumn joinColumn) {
- return false;
- }
-
- public String getDefaultColumnName() {
- return null;
- }
-
- public int joinColumnsSize() {
- return GenericOrmPrimaryKeyJoinColumnJoiningStrategy.this.primaryKeyJoinColumnsSize();
- }
-
- public TextRange getValidationTextRange() {
- return GenericOrmPrimaryKeyJoinColumnJoiningStrategy.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new OneToOnePrimaryKeyJoinColumnValidator(getPersistentAttribute(), (BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java
deleted file mode 100644
index 26b83ea43d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-
-public class GenericOrmXmlContextNodeFactory extends AbstractOrmXmlContextNodeFactory
-{
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmAssociationOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmAssociationOverrideContainer.java
deleted file mode 100644
index 10dd335a0d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmAssociationOverrideContainer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.jpt.core.context.XmlContextNode;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.core.internal.context.orm.AbstractOrmXmlContextNode;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-
-public class NullOrmAssociationOverrideContainer extends AbstractOrmXmlContextNode
- implements OrmAssociationOverrideContainer
-{
-
- protected final OrmAssociationOverrideContainer.Owner owner;
-
- public NullOrmAssociationOverrideContainer(XmlContextNode parent, OrmAssociationOverrideContainer.Owner owner) {
- super(parent);
- this.owner = owner;
- }
-
- protected Owner getOwner() {
- return this.owner;
- }
-
- public ListIterator<OrmAssociationOverride> associationOverrides() {
- return EmptyListIterator.instance();
- }
-
- public int associationOverridesSize() {
- return 0;
- }
-
- public ListIterator<OrmAssociationOverride> virtualAssociationOverrides() {
- return EmptyListIterator.instance();
- }
-
- public int virtualAssociationOverridesSize() {
- return 0;
- }
-
- public ListIterator<OrmAssociationOverride> specifiedAssociationOverrides() {
- return EmptyListIterator.instance();
- }
-
- public int specifiedAssociationOverridesSize() {
- return 0;
- }
-
- public void moveSpecifiedAssociationOverride(int targetIndex, int sourceIndex) {
- throw new UnsupportedOperationException();
- }
-
- public OrmAssociationOverride getAssociationOverrideNamed(String name) {
- return null;
- }
-
- public void update() {
- //no-op
- }
-
-
- public TextRange getValidationTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmJoinTableJoiningStrategy.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmJoinTableJoiningStrategy.java
deleted file mode 100644
index 0c7876bf6e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/NullOrmJoinTableJoiningStrategy.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.Table;
-import org.eclipse.jpt.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.core.context.orm.OrmJoinTableEnabledRelationshipReference;
-import org.eclipse.jpt.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JptValidator;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class NullOrmJoinTableJoiningStrategy
- extends AbstractOrmJoinTableJoiningStrategy
-{
-
-
- public NullOrmJoinTableJoiningStrategy(OrmJoinTableEnabledRelationshipReference parent) {
- super(parent);
- this.initialize();
- }
-
-
- @Override
- public OrmJoinTableEnabledRelationshipReference getParent() {
- return (OrmJoinTableEnabledRelationshipReference) super.getParent();
- }
-
- @Override
- public OrmJoinTableEnabledRelationshipReference getRelationshipReference() {
- return this.getParent();
- }
-
- @Override
- public OrmRelationshipMapping getRelationshipMapping() {
- return this.getRelationshipReference().getRelationshipMapping();
- }
-
- @Override
- protected void setResourceJoinTable(XmlJoinTable resourceJoinTable) {
- throw new UnsupportedOperationException();
- }
-
- public boolean isOverridableAssociation() {
- return false;
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return false;
- }
-
- // **************** join table *********************************************
-
-
- public void removeResourceJoinTable() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected boolean mayHaveJoinTable() {
- return false;
- }
-
- public XmlJoinTable getResourceJoinTable() {
- return null;
- }
-
-
- // **************** validation *********************************************
-
- public TextRange getValidationTextRange() {
- return null;
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- throw new UnsupportedOperationException();
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- throw new UnsupportedOperationException();
- }
-
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java
deleted file mode 100644
index fef9ec8c82..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmBaseColumn;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmBaseColumnTextRangeResolver
- extends OrmNamedColumnTextRangeResolver
- implements BaseColumnTextRangeResolver
-{
-
- public OrmBaseColumnTextRangeResolver(OrmBaseColumn column) {
- super(column);
- }
-
- @Override
- protected OrmBaseColumn getColumn() {
- return (OrmBaseColumn) super.getColumn();
- }
-
- public TextRange getTableTextRange() {
- return this.getColumn().getTableTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingDefinition.java
deleted file mode 100644
index 210c6e2f79..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmBasicMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmBasicMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmBasicMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmBasicMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlBasic(),
- XmlBasic.class);
- }
-
- public OrmBasicMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmBasicMapping(parent, (XmlBasic) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlBasic(ormTypeMapping, (JavaBasicMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableDefinition.java
deleted file mode 100644
index d908024b78..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddableDefinition.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-/**
- * default ORM Embeddable provider
- */
-public class OrmEmbeddableDefinition
- implements OrmTypeMappingDefinition
-{
- // singleton
- private static final OrmEmbeddableDefinition INSTANCE =
- new OrmEmbeddableDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmEmbeddableDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public XmlTypeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlEmbeddable(),
- XmlEmbeddable.class);
- }
-
- public OrmEmbeddable buildContextMapping(
- OrmPersistentType parent,
- XmlTypeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmEmbeddable(parent, (XmlEmbeddable) resourceMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java
deleted file mode 100644
index 133bd4fbb2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmEmbeddedIdMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmEmbeddedIdMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmEmbeddedIdMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlEmbeddedId(),
- XmlEmbeddedId.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmEmbeddedIdMapping(parent, (XmlEmbeddedId) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlEmbeddedId(ormTypeMapping, (JavaEmbeddedIdMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingDefinition.java
deleted file mode 100644
index 26cd121b1a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEmbeddedMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmEmbeddedMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmEmbeddedMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmEmbeddedMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlEmbedded(),
- XmlEmbedded.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmEmbeddedMapping(parent, (XmlEmbedded) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlEmbedded(ormTypeMapping, (JavaEmbeddedMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityDefinition.java
deleted file mode 100644
index cf734f64dc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityDefinition.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-/**
- * default ORM Entity provider
- */
-public class OrmEntityDefinition
- implements OrmTypeMappingDefinition
-{
- // singleton
- private static final OrmEntityDefinition INSTANCE =
- new OrmEntityDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmEntityDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- public XmlTypeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlEntity(),
- XmlEntity.class);
- }
-
- public OrmEntity buildContextMapping(
- OrmPersistentType parent,
- XmlTypeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmEntity(parent, (XmlEntity) resourceMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityTextRangeResolver.java
deleted file mode 100644
index 9ef18175bf..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmEntityTextRangeResolver.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmEntity;
-import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmEntityTextRangeResolver
- implements EntityTextRangeResolver
-{
- private OrmEntity entity;
-
-
- public OrmEntityTextRangeResolver(OrmEntity entity) {
- this.entity = entity;
- }
-
-
- public TextRange getTypeMappingTextRange() {
- return this.entity.getValidationTextRange();
- }
-
- public TextRange getIdClassTextRange() {
- return this.entity.getIdClassReference().getValidationTextRange();
- }
-
- public TextRange getAttributeMappingTextRange(String attributeName) {
- return this.entity.getPersistentType().
- getAttributeNamed(attributeName).getMapping().getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingDefinition.java
deleted file mode 100644
index afedc490bd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmIdMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmIdMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmIdMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmIdMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlId(),
- XmlId.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmIdMapping(parent, (XmlId) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlId(ormTypeMapping, (JavaIdMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java
deleted file mode 100644
index 01fd5de12a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmJoinColumnTextRangeResolver
- extends OrmNamedColumnTextRangeResolver
- implements
- BaseColumnTextRangeResolver,
- JoinColumnTextRangeResolver
-{
-
- public OrmJoinColumnTextRangeResolver(OrmJoinColumn column) {
- super(column);
- }
-
- @Override
- protected OrmJoinColumn getColumn() {
- return (OrmJoinColumn) super.getColumn();
- }
-
- public TextRange getTableTextRange() {
- return this.getColumn().getTableTextRange();
- }
-
- public TextRange getReferencedColumnNameTextRange() {
- return this.getColumn().getReferencedColumnNameTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingDefinition.java
deleted file mode 100644
index c719454455..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToManyMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmManyToManyMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmManyToManyMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmManyToManyMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlManyToMany(),
- XmlManyToMany.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmManyToManyMapping(parent, (XmlManyToMany) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlManyToMany(ormTypeMapping, (JavaManyToManyMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingDefinition.java
deleted file mode 100644
index 2098c673e3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmManyToOneMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmManyToOneMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmManyToOneMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmManyToOneMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlManyToOne(),
- XmlManyToOne.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmManyToOneMapping(parent, (XmlManyToOne) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlManyToOne(ormTypeMapping, (JavaManyToOneMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassDefinition.java
deleted file mode 100644
index c0e2f67d6f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassDefinition.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-/**
- * default ORM MappedSuperclass definition
- */
-public class OrmMappedSuperclassDefinition
- implements OrmTypeMappingDefinition
-{
- // singleton
- private static final OrmMappedSuperclassDefinition INSTANCE =
- new OrmMappedSuperclassDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmTypeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmMappedSuperclassDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- public XmlTypeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlMappedSuperclass(),
- XmlMappedSuperclass.class);
- }
-
- public OrmMappedSuperclass buildContextMapping(
- OrmPersistentType parent,
- XmlTypeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmMappedSuperclass(parent, (XmlMappedSuperclass) resourceMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java
deleted file mode 100644
index bb107bb5b0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmMappedSuperclassTextRangeResolver
- implements PrimaryKeyTextRangeResolver
-{
- private OrmMappedSuperclass mappedSuperclass;
-
-
- public OrmMappedSuperclassTextRangeResolver(OrmMappedSuperclass mappedSuperclass) {
- this.mappedSuperclass = mappedSuperclass;
- }
-
-
- public TextRange getTypeMappingTextRange() {
- return this.mappedSuperclass.getValidationTextRange();
- }
-
- public TextRange getIdClassTextRange() {
- return this.mappedSuperclass.getIdClassReference().getValidationTextRange();
- }
-
- public TextRange getAttributeMappingTextRange(String attributeName) {
- return this.mappedSuperclass.getPersistentType().
- getAttributeNamed(attributeName).getMapping().getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java
deleted file mode 100644
index 6e31d44b5f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmNamedColumn;
-import org.eclipse.jpt.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmNamedColumnTextRangeResolver
- implements NamedColumnTextRangeResolver
-{
- protected final OrmNamedColumn ormNamedColumn;
-
- public OrmNamedColumnTextRangeResolver(OrmNamedColumn javaNamedColumn) {
- this.ormNamedColumn = javaNamedColumn;
- }
-
- protected OrmNamedColumn getColumn() {
- return this.ormNamedColumn;
- }
-
- public TextRange getNameTextRange() {
- return this.ormNamedColumn.getNameTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingDefinition.java
deleted file mode 100644
index f7ea7d8ce8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToManyMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmOneToManyMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmOneToManyMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmOneToManyMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlOneToMany(),
- XmlOneToMany.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmOneToManyMapping(parent, (XmlOneToMany) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlOneToMany(ormTypeMapping, (JavaOneToManyMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingDefinition.java
deleted file mode 100644
index 487b0497ea..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOneToOneMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmOneToOneMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmOneToOneMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmOneToOneMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlOneToOne(),
- XmlOneToOne.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmOneToOneMapping(parent, (XmlOneToOne) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlOneToOne(ormTypeMapping, (JavaOneToOneMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOverrideTextRangeResolver.java
deleted file mode 100644
index f8f9f400bd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmOverrideTextRangeResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmOverride;
-import org.eclipse.jpt.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmOverrideTextRangeResolver
- implements OverrideTextRangeResolver
-{
- protected final OrmOverride ormOverride;
-
- public OrmOverrideTextRangeResolver(OrmOverride ormOverride) {
- this.ormOverride = ormOverride;
- }
-
- protected OrmOverride getOverride() {
- return this.ormOverride;
- }
-
- public TextRange getNameTextRange() {
- return this.ormOverride.getNameTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java
deleted file mode 100644
index 78414a97d6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmPersistentAttributeTextRangeResolver
- implements PersistentAttributeTextRangeResolver
-{
- private OrmPersistentAttribute persistentAttribute;
-
- public OrmPersistentAttributeTextRangeResolver(OrmPersistentAttribute persistentAttribute) {
- this.persistentAttribute = persistentAttribute;
- }
-
- public TextRange getAttributeTextRange() {
- return this.persistentAttribute.getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java
deleted file mode 100644
index b8285a35c6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmPrimaryKeyJoinColumnTextRangeResolver
- extends OrmNamedColumnTextRangeResolver
- implements
- BaseJoinColumnTextRangeResolver
-{
-
- public OrmPrimaryKeyJoinColumnTextRangeResolver(OrmPrimaryKeyJoinColumn column) {
- super(column);
- }
-
- @Override
- protected OrmPrimaryKeyJoinColumn getColumn() {
- return (OrmPrimaryKeyJoinColumn) super.getColumn();
- }
-
- public TextRange getReferencedColumnNameTextRange() {
- return this.getColumn().getReferencedColumnNameTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTableTextRangeResolver.java
deleted file mode 100644
index e54b477d83..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTableTextRangeResolver.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmBaseTable;
-import org.eclipse.jpt.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmTableTextRangeResolver
- implements TableTextRangeResolver
-{
- protected final OrmBaseTable ormTable;
-
- public OrmTableTextRangeResolver(OrmBaseTable ormTable) {
- this.ormTable = ormTable;
- }
-
- protected OrmBaseTable getTable() {
- return this.ormTable;
- }
-
- public TextRange getNameTextRange() {
- return this.ormTable.getNameTextRange();
- }
-
- public TextRange getCatalogTextRange() {
- return this.ormTable.getCatalogTextRange();
- }
-
- public TextRange getSchemaTextRange() {
- return this.ormTable.getSchemaTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingDefinition.java
deleted file mode 100644
index 6177649214..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTransientMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaTransientMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmTransientMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmTransientMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmTransientMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlTransient(),
- XmlTransient.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmTransientMapping(parent, (XmlTransient) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlTransient(ormTypeMapping, (JavaTransientMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java
deleted file mode 100644
index 76ad266db2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class OrmTypeMappingTextRangeResolver
- implements TypeMappingTextRangeResolver
-{
- private OrmTypeMapping typeMapping;
-
- public OrmTypeMappingTextRangeResolver(OrmTypeMapping typeMapping) {
- this.typeMapping = typeMapping;
- }
-
- public TextRange getTypeMappingTextRange() {
- return this.typeMapping.getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingDefinition.java
deleted file mode 100644
index abc841dda2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/OrmVersionMappingDefinition.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.MappingKeys;
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.core.resource.xml.EmfTools;
-
-public class OrmVersionMappingDefinition
- implements OrmAttributeMappingDefinition
-{
- // singleton
- private static final OrmAttributeMappingDefinition INSTANCE =
- new OrmVersionMappingDefinition();
-
-
- /**
- * Return the singleton
- */
- public static OrmAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private OrmVersionMappingDefinition() {
- super();
- }
-
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public XmlAttributeMapping buildResourceMapping(EFactory factory) {
- return EmfTools.create(
- factory,
- OrmPackage.eINSTANCE.getXmlVersion(),
- XmlVersion.class);
- }
-
- public OrmAttributeMapping buildContextMapping(
- OrmPersistentAttribute parent,
- XmlAttributeMapping resourceMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildOrmVersionMapping(parent, (XmlVersion) resourceMapping);
- }
-
- public XmlAttributeMapping buildVirtualResourceMapping(
- OrmTypeMapping ormTypeMapping,
- JavaAttributeMapping javaAttributeMapping,
- OrmXmlContextNodeFactory factory) {
- return factory.buildVirtualXmlVersion(ormTypeMapping, (JavaVersionMapping) javaAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualCascadeType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualCascadeType.java
deleted file mode 100644
index 6ecb0daf86..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualCascadeType.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Cascade;
-import org.eclipse.jpt.core.resource.orm.CascadeType;
-
-public class VirtualCascadeType extends CascadeType
-{
- protected Cascade javaCascade;
-
-
- public VirtualCascadeType(Cascade javaCascade) {
- super();
- this.javaCascade = javaCascade;
- }
-
- @Override
- public boolean isCascadeAll() {
- return this.javaCascade.isAll();
- }
-
- @Override
- public void setCascadeAll(boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public boolean isCascadeMerge() {
- return this.javaCascade.isMerge();
- }
-
- @Override
- public void setCascadeMerge(boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public boolean isCascadePersist() {
- return this.javaCascade.isPersist();
- }
-
- @Override
- public void setCascadePersist(boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public boolean isCascadeRefresh() {
- return this.javaCascade.isRefresh();
- }
-
- @Override
- public void setCascadeRefresh(boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public boolean isCascadeRemove() {
- return this.javaCascade.isRemove();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java
deleted file mode 100644
index 0b75a5c4d3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualMapKey.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.CollectionMapping;
-import org.eclipse.jpt.core.resource.orm.MapKey;
-
-public class VirtualMapKey extends MapKey
-{
- CollectionMapping javaCollectionMapping;
-
- public VirtualMapKey(CollectionMapping collectionMapping) {
- super();
- this.javaCollectionMapping = collectionMapping;
- }
-
- @Override
- public String getName() {
- return this.javaCollectionMapping.getSpecifiedMapKey();
- }
-
- @Override
- public void setName(String newName) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAssociationOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAssociationOverride.java
deleted file mode 100644
index 6f4af8edab..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAssociationOverride.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c)2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinColumnJoiningStrategy;
-import org.eclipse.jpt.core.context.JoiningStrategy;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class VirtualXmlAssociationOverride extends XmlAssociationOverride
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JoiningStrategy joiningStrategy;
-
-
- public VirtualXmlAssociationOverride(String name, OrmTypeMapping ormTypeMapping, JoiningStrategy joiningStrategy) {
- super();
- this.name = name;
- this.ormTypeMapping = ormTypeMapping;
- this.joiningStrategy = joiningStrategy;
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public EList<XmlJoinColumn> getJoinColumns() {
- EList<XmlJoinColumn> joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_ASSOCIATION_OVERRIDE__JOIN_COLUMNS);
- if (this.joiningStrategy instanceof JoinColumnJoiningStrategy) {
- for (JoinColumn joinColumn :
- CollectionTools.iterable(((JoinColumnJoiningStrategy) this.joiningStrategy).joinColumns())) {
- XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, this.isOrmMetadataComplete());
- joinColumns.add(xmlJoinColumn);
- }
- }
- return joinColumns;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java
deleted file mode 100644
index a071e1ce71..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeMapping.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.AccessType;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.core.resource.xml.AbstractJpaEObject;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class VirtualXmlAttributeMapping extends AbstractJpaEObject implements XmlAttributeMapping
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaAttributeMapping javaAttributeMapping;
-
-
- public VirtualXmlAttributeMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaAttributeMapping;
- }
-
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- public String getMappingKey() {
- if (this.isOrmMetadataComplete()) {
- return this.javaAttributeMapping.getPersistentAttribute().getDefaultMappingKey();
- }
- return this.javaAttributeMapping.getKey();
- }
-
- public String getName() {
- return this.javaAttributeMapping.getPersistentAttribute().getName();
- }
-
- public void setName(String newName) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- public TextRange getNameTextRange() {
- return null;
- }
-
- public AccessType getAccess() {
- return org.eclipse.jpt.core.context.AccessType.toOrmResourceModel(
- this.javaAttributeMapping.getPersistentAttribute().getAccess());
- }
-
- public void setAccess(AccessType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverride.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverride.java
deleted file mode 100644
index 86e3490191..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverride.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-
-public class VirtualXmlAttributeOverride extends XmlAttributeOverride
-{
-
- public VirtualXmlAttributeOverride(String name, XmlColumn xmlColumn) {
- super();
- this.name = name;
- this.column = xmlColumn;
- }
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public XmlColumn getColumn() {
- return this.column;
- }
-
- @Override
- public void setColumn(XmlColumn value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverrideColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverrideColumn.java
deleted file mode 100644
index d1383f2d92..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlAttributeOverrideColumn.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Column;
-
-/**
- * javax.persistence.Column
- */
-public class VirtualXmlAttributeOverrideColumn
- extends VirtualXmlColumn
-{
-
- public VirtualXmlAttributeOverrideColumn(Column column) {
- super(null, column);
- }
-
- @Override
- public String getName() {
- return this.column.getSpecifiedName();
- }
-
- @Override
- public String getColumnDefinition() {
- return this.column.getColumnDefinition();
- }
-
- @Override
- public String getTable() {
- return this.column.getSpecifiedTable();
- }
-
- @Override
- public Boolean getInsertable() {
- return this.column.getSpecifiedInsertable();
- }
-
- @Override
- public Boolean getUpdatable() {
- return this.column.getSpecifiedUpdatable();
- }
-
- @Override
- public Boolean getNullable() {
- return this.column.getSpecifiedNullable();
- }
-
- @Override
- public Boolean getUnique() {
- return this.column.getSpecifiedUnique();
- }
-
- @Override
- public Integer getLength() {
- return this.column.getSpecifiedLength();
- }
-
- @Override
- public Integer getScale() {
- return this.column.getSpecifiedScale();
- }
-
- @Override
- public Integer getPrecision() {
- return this.column.getSpecifiedPrecision();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlBasic.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlBasic.java
deleted file mode 100644
index f9d5c52779..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlBasic.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.EnumeratedConverter;
-import org.eclipse.jpt.core.context.TemporalConverter;
-import org.eclipse.jpt.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.EnumType;
-import org.eclipse.jpt.core.resource.orm.FetchType;
-import org.eclipse.jpt.core.resource.orm.TemporalType;
-import org.eclipse.jpt.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualBasic is an implementation of Basic used when there is
- * no tag in the orm.xml and an underlying javaBasicMapping exists.
- */
-public class VirtualXmlBasic extends XmlBasic
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaBasicMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualXmlColumn column;
-
- public VirtualXmlBasic(OrmTypeMapping ormTypeMapping, JavaBasicMapping javaBasicMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaBasicMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaBasicMapping);
- this.column = new VirtualXmlColumn(ormTypeMapping, javaBasicMapping.getColumn());
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public XmlColumn getColumn() {
- return this.column;
- }
-
- @Override
- public void setColumn(XmlColumn value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public FetchType getFetch() {
- if (this.isOrmMetadataComplete()) {
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getDefaultFetch());
- }
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getFetch());
- }
-
- @Override
- public void setFetch(FetchType newFetch) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getOptional() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.javaAttributeMapping.isDefaultOptional());
- }
- return Boolean.valueOf(this.javaAttributeMapping.isOptional());
- }
-
- @Override
- public void setOptional(Boolean newOptional) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public boolean isLob() {
- if (this.isOrmMetadataComplete()) {
- return false;
- }
- return this.javaAttributeMapping.getConverter().getType() == Converter.LOB_CONVERTER;
- }
-
- @Override
- public void setLob(boolean newLob) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TemporalType getTemporal() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getConverter().getType() == Converter.TEMPORAL_CONVERTER) {
- org.eclipse.jpt.core.context.TemporalType javaTemporalType = ((TemporalConverter) this.javaAttributeMapping.getConverter()).getTemporalType();
- return org.eclipse.jpt.core.context.TemporalType.toOrmResourceModel(javaTemporalType);
- }
- return null;
- }
-
- @Override
- public void setTemporal(TemporalType newTemporal){
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public EnumType getEnumerated() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getConverter().getType() == Converter.ENUMERATED_CONVERTER) {
- org.eclipse.jpt.core.context.EnumType javaEnumeratedType = ((EnumeratedConverter) this.javaAttributeMapping.getConverter()).getEnumType();
- return org.eclipse.jpt.core.context.EnumType.toOrmResourceModel(javaEnumeratedType);
- }
- return null;
- }
-
- @Override
- public void setEnumerated(EnumType newEnumerated) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getEnumeratedTextRange() {
- return null;
- }
-
- @Override
- public TextRange getLobTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTemporalTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlColumn.java
deleted file mode 100644
index fea21486c1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlColumn.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Column;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * A virtual column is used to represent the XmlColumn resource object
- * within a virtual mapping. A virtual mapping is one which is not specified
- * in the orm.xml file, but is implied from the underlying java. Virtual column
- * is not used when the mapping is specified in the orm.xml, but the column tag does not exist.
- *
- * A virtual column delegates to the underlying java column for its state. The metadataComplete
- * flag determines whether it will get specified or default information from the java column
- *
- */
-public class VirtualXmlColumn extends XmlColumn
-{
-
- protected Column column;
-
- protected OrmTypeMapping ormTypeMapping;
-
-
- public VirtualXmlColumn(OrmTypeMapping ormTypeMapping, Column column) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.column = column;
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getColumnDefinition() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.column.getColumnDefinition();
- }
-
- @Override
- public void setColumnDefinition(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getInsertable() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.column.isDefaultInsertable());
- }
- return Boolean.valueOf(this.column.isInsertable());
- }
-
- @Override
- public void setInsertable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getLength() {
- if (this.isOrmMetadataComplete()) {
- return Integer.valueOf(this.column.getDefaultLength());
- }
- return Integer.valueOf(this.column.getLength());
- }
-
- @Override
- public void setLength(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getName() {
- if (this.isOrmMetadataComplete()) {
- return this.column.getDefaultName();
- }
- return this.column.getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getNullable() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.column.isDefaultNullable());
- }
- return Boolean.valueOf(this.column.isNullable());
- }
-
- @Override
- public void setNullable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getPrecision() {
- if (this.isOrmMetadataComplete()) {
- return Integer.valueOf(this.column.getDefaultPrecision());
- }
- return Integer.valueOf(this.column.getPrecision());
- }
-
- @Override
- public void setPrecision(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getScale() {
- if (this.isOrmMetadataComplete()) {
- return Integer.valueOf(this.column.getDefaultScale());
- }
- return Integer.valueOf(this.column.getScale());
- }
-
- @Override
- public void setScale(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTable() {
- if (this.isOrmMetadataComplete()) {
- return this.column.getDefaultTable();
- }
- return this.column.getTable();
- }
-
- @Override
- public void setTable(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getUnique() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.column.isDefaultUnique());
- }
- return Boolean.valueOf(this.column.isUnique());
- }
-
- @Override
- public void setUnique(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getUpdatable() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.column.isDefaultUpdatable());
- }
- return Boolean.valueOf(this.column.isUpdatable());
- }
-
- @Override
- public void setUpdatable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTableTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbedded.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbedded.java
deleted file mode 100644
index 206598370f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbedded.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * VirtualEmbedded is an implementation of Embedded used when there is
- * no tag in the orm.xml and an underlying javaEmbeddedMapping exists.
- */
-public class VirtualXmlEmbedded extends XmlEmbedded
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaEmbeddedMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- public VirtualXmlEmbedded(OrmTypeMapping ormTypeMapping, JavaEmbeddedMapping javaEmbeddedMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaEmbeddedMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaEmbeddedMapping);
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public EList<XmlAttributeOverride> getAttributeOverrides() {
- EList<XmlAttributeOverride> attributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_EMBEDDED__ATTRIBUTE_OVERRIDES);
- ListIterator<JavaAttributeOverride> javaAttributeOverrides;
- if (!this.isOrmMetadataComplete()) {
- javaAttributeOverrides = this.javaAttributeMapping.getAttributeOverrideContainer().attributeOverrides();
- }
- else {
- javaAttributeOverrides = this.javaAttributeMapping.getAttributeOverrideContainer().virtualAttributeOverrides();
- }
- for (JavaAttributeOverride javaAttributeOverride : CollectionTools.iterable(javaAttributeOverrides)) {
- XmlColumn xmlColumn = new VirtualXmlColumn(this.ormTypeMapping, javaAttributeOverride.getColumn());
- XmlAttributeOverride xmlAttributeOverride = new VirtualXmlAttributeOverride(javaAttributeOverride.getName(), xmlColumn);
- attributeOverrides.add(xmlAttributeOverride);
- }
- return attributeOverrides;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbeddedId.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbeddedId.java
deleted file mode 100644
index 4dae7d00e3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlEmbeddedId.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import java.util.ListIterator;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.core.context.java.JavaEmbeddedIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlEmbeddedId;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * VirtualEmbeddedId is an implementation of EmbeddedId used when there is
- * no tag in the orm.xml and an underlying javaEmbeddedIdMapping exists.
- */
-public class VirtualXmlEmbeddedId extends XmlEmbeddedId
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaEmbeddedIdMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- public VirtualXmlEmbeddedId(OrmTypeMapping ormTypeMapping, JavaEmbeddedIdMapping javaEmbeddedIdMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaEmbeddedIdMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaEmbeddedIdMapping);
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public EList<XmlAttributeOverride> getAttributeOverrides() {
- EList<XmlAttributeOverride> attributeOverrides = new EObjectContainmentEList<XmlAttributeOverride>(XmlAttributeOverride.class, this, OrmPackage.XML_EMBEDDED_ID__ATTRIBUTE_OVERRIDES);
- ListIterator<JavaAttributeOverride> javaAttributeOverrides;
- if (!this.isOrmMetadataComplete()) {
- javaAttributeOverrides = this.javaAttributeMapping.getAttributeOverrideContainer().attributeOverrides();
- }
- else {
- javaAttributeOverrides = this.javaAttributeMapping.getAttributeOverrideContainer().virtualAttributeOverrides();
- }
- for (JavaAttributeOverride javaAttributeOverride : CollectionTools.iterable(javaAttributeOverrides)) {
- XmlColumn xmlColumn = new VirtualXmlColumn(this.ormTypeMapping, javaAttributeOverride.getColumn());
- XmlAttributeOverride xmlAttributeOverride = new VirtualXmlAttributeOverride(javaAttributeOverride.getName(), xmlColumn);
- attributeOverrides.add(xmlAttributeOverride);
- }
- return attributeOverrides;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlGeneratedValue.java
deleted file mode 100644
index 828999cb40..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlGeneratedValue.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaGeneratedValue;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.resource.orm.GenerationType;
-import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class VirtualXmlGeneratedValue extends XmlGeneratedValue
-{
- JavaIdMapping javaIdMapping;
-
- protected boolean metadataComplete;
-
-
- public VirtualXmlGeneratedValue(JavaIdMapping javaIdMapping, boolean metadataComplete) {
- super();
- this.javaIdMapping = javaIdMapping;
- this.metadataComplete = metadataComplete;
- }
-
- protected JavaGeneratedValue getJavaGeneratedValue() {
- return this.javaIdMapping.getGeneratedValue();
- }
-
-
- @Override
- public String getGenerator() {
- return this.metadataComplete ? null : this.getJavaGeneratedValue().getGenerator();
- }
-
- @Override
- public GenerationType getStrategy() {
- return this.metadataComplete ? null : org.eclipse.jpt.core.context.GenerationType.toOrmResourceModel(this.getJavaGeneratedValue().getStrategy());
- }
-
- @Override
- public void setGenerator(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public void setStrategy(GenerationType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getGeneratorTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlId.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlId.java
deleted file mode 100644
index 00743c702e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlId.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.TemporalConverter;
-import org.eclipse.jpt.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.EnumType;
-import org.eclipse.jpt.core.resource.orm.TemporalType;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.core.resource.orm.XmlId;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualId is an implementation of Id used when there is
- * no tag in the orm.xml and an underlying javaIdMapping exists.
- */
-public class VirtualXmlId extends XmlId
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaIdMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualXmlColumn column;
-
- protected final VirtualXmlGeneratedValue virtualGeneratedValue;
-
- protected final VirtualXmlTableGenerator virtualTableGenerator;
-
- protected final VirtualXmlSequenceGenerator virtualSequenceGenerator;
-
-
- public VirtualXmlId(OrmTypeMapping ormTypeMapping, JavaIdMapping javaIdMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaIdMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaIdMapping);
- this.column = new VirtualXmlColumn(ormTypeMapping, javaIdMapping.getColumn());
- this.virtualGeneratedValue = new VirtualXmlGeneratedValue(javaIdMapping, this.isOrmMetadataComplete());
- this.virtualTableGenerator = new VirtualXmlTableGenerator(javaIdMapping.getGeneratorContainer(), this.isOrmMetadataComplete());
- this.virtualSequenceGenerator = new VirtualXmlSequenceGenerator(javaIdMapping.getGeneratorContainer(), this.isOrmMetadataComplete());
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public XmlColumn getColumn() {
- return this.column;
- }
-
- @Override
- public void setColumn(XmlColumn value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TemporalType getTemporal() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getConverter().getType() == Converter.TEMPORAL_CONVERTER) {
- org.eclipse.jpt.core.context.TemporalType javaTemporalType = ((TemporalConverter) this.javaAttributeMapping.getConverter()).getTemporalType();
- return org.eclipse.jpt.core.context.TemporalType.toOrmResourceModel(javaTemporalType);
- }
- return null;
- }
-
- @Override
- public void setTemporal(TemporalType newTemporal){
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public XmlGeneratedValue getGeneratedValue() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getGeneratedValue() != null) {
- return this.virtualGeneratedValue;
- }
- return null;
- }
-
- @Override
- public void setGeneratedValue(XmlGeneratedValue value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public XmlSequenceGenerator getSequenceGenerator() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getGeneratorContainer().getSequenceGenerator() != null) {
- return this.virtualSequenceGenerator;
- }
- return null;
- }
-
- @Override
- public void setSequenceGenerator(XmlSequenceGenerator value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public XmlTableGenerator getTableGenerator() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getGeneratorContainer().getTableGenerator() != null) {
- return this.virtualTableGenerator;
- }
- return null;
- }
-
- @Override
- public void setTableGenerator(XmlTableGenerator value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- //see eclipselink bug 247078 for info one why I made the interface XmlConvertibleMapping
- @Override
- public EnumType getEnumerated() {
- throw new UnsupportedOperationException("enumerated not supported on id mappings"); //$NON-NLS-1$
- }
-
- @Override
- public void setEnumerated(EnumType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- //see eclipselink bug 247078 for info one why I made the interface XmlConvertibleMapping
- @Override
- public boolean isLob() {
- throw new UnsupportedOperationException("lob not supported on id mappings"); //$NON-NLS-1$
- }
-
- @Override
- public void setLob(boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getEnumeratedTextRange() {
- return null;
- }
-
- @Override
- public TextRange getLobTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTemporalTextRange() {
- return null;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinColumn.java
deleted file mode 100644
index 0e862c7c88..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinColumn.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class VirtualXmlJoinColumn extends XmlJoinColumn
-{
- protected JoinColumn javaJoinColumn;
-
- protected boolean metadataComplete;
-
- public VirtualXmlJoinColumn(JoinColumn javaJoinColumn, boolean metadataComplete) {
- super();
- this.javaJoinColumn = javaJoinColumn;
- this.metadataComplete = metadataComplete;
- }
-
- @Override
- public String getColumnDefinition() {
- if (this.metadataComplete) {
- return null;
- }
- return this.javaJoinColumn.getColumnDefinition();
- }
-
- @Override
- public void setColumnDefinition(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getInsertable() {
- if (this.metadataComplete) {
- return Boolean.valueOf(this.javaJoinColumn.isDefaultInsertable());
- }
- return Boolean.valueOf(this.javaJoinColumn.isInsertable());
- }
-
- @Override
- public void setInsertable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getName() {
- if (this.metadataComplete) {
- return this.javaJoinColumn.getDefaultName();
- }
- return this.javaJoinColumn.getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getReferencedColumnName() {
- if (this.metadataComplete) {
- return this.javaJoinColumn.getDefaultReferencedColumnName();
- }
- return this.javaJoinColumn.getReferencedColumnName();
- }
-
- @Override
- public void setReferencedColumnName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getNullable() {
- if (this.metadataComplete) {
- return Boolean.valueOf(this.javaJoinColumn.isDefaultNullable());
- }
- return Boolean.valueOf(this.javaJoinColumn.isNullable());
- }
-
- @Override
- public void setNullable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTable() {
- if (this.metadataComplete) {
- return this.javaJoinColumn.getDefaultTable();
- }
- return this.javaJoinColumn.getTable();
- }
-
- @Override
- public void setTable(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getUnique() {
- if (this.metadataComplete) {
- return Boolean.valueOf(this.javaJoinColumn.isDefaultUnique());
- }
- return Boolean.valueOf(this.javaJoinColumn.isUnique());
- }
-
- @Override
- public void setUnique(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getUpdatable() {
- if (this.metadataComplete) {
- return Boolean.valueOf(this.javaJoinColumn.isDefaultUpdatable());
- }
- return Boolean.valueOf(this.javaJoinColumn.isUpdatable());
- }
-
- @Override
- public void setUpdatable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTableTextRange() {
- return null;
- }
-
- @Override
- public TextRange getReferencedColumnNameTextRange() {
- return null;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinTable.java
deleted file mode 100644
index 1e1fee7ca7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlJoinTable.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.JoinTable;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class VirtualXmlJoinTable
- extends XmlJoinTable
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected JoinTable joinTable;
-
-
- public VirtualXmlJoinTable(OrmTypeMapping ormTypeMapping, JoinTable joinTable) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.joinTable = joinTable;
- }
-
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getName() {
- if (this.isOrmMetadataComplete()) {
- return this.joinTable.getDefaultName();
- }
- return this.joinTable.getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getCatalog() {
- if (this.isOrmMetadataComplete()) {
- return this.joinTable.getDefaultCatalog();
- }
- return this.joinTable.getCatalog();
- }
-
- @Override
- public void setCatalog(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getSchema() {
- if (this.isOrmMetadataComplete()) {
- return this.joinTable.getDefaultSchema();
- }
- return this.joinTable.getSchema();
- }
-
- @Override
- public void setSchema(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- //VirtualXmlJoinTable is rebuilt every time, so just rebuilding the joinColumns list as well
- @Override
- public EList<XmlJoinColumn> getJoinColumns() {
- EList<XmlJoinColumn> joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_JOIN_TABLE__JOIN_COLUMNS);
- if (this.joinTable == null || isOrmMetadataComplete()) {
- return joinColumns;
- }
- for (JoinColumn joinColumn : CollectionTools.iterable(this.joinTable.specifiedJoinColumns())) {
- XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, isOrmMetadataComplete());
- joinColumns.add(xmlJoinColumn);
- }
- return joinColumns;
- }
-
- //VirtualXmlJoinTable is rebuilt every time, so just rebuilding the joinColumns list as well
- @Override
- public EList<XmlJoinColumn> getInverseJoinColumns() {
- EList<XmlJoinColumn> inverseJoinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_JOIN_TABLE__INVERSE_JOIN_COLUMNS);
- if (this.joinTable == null || isOrmMetadataComplete()) {
- return inverseJoinColumns;
- }
- for (JoinColumn joinColumn : CollectionTools.iterable(this.joinTable.specifiedInverseJoinColumns())) {
- XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, isOrmMetadataComplete());
- inverseJoinColumns.add(xmlJoinColumn);
- }
-
- return inverseJoinColumns;
- }
-
- @Override
- public EList<XmlUniqueConstraint> getUniqueConstraints() {
- EList<XmlUniqueConstraint> xmlUniqueConstraints = new EObjectContainmentEList<XmlUniqueConstraint>(XmlUniqueConstraint.class, this, OrmPackage.XML_JOIN_TABLE__UNIQUE_CONSTRAINTS);
- if (this.joinTable == null || isOrmMetadataComplete()) {
- return xmlUniqueConstraints;
- }
- for (UniqueConstraint uniqueConstraint : CollectionTools.iterable(this.joinTable.uniqueConstraints())) {
- XmlUniqueConstraint xmlUniqueConstraint = new VirtualXmlUniqueConstraint(uniqueConstraint, isOrmMetadataComplete());
- xmlUniqueConstraints.add(xmlUniqueConstraint);
- }
-
- return xmlUniqueConstraints;
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-
- @Override
- public TextRange getCatalogTextRange() {
- return null;
- }
-
- @Override
- public TextRange getSchemaTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java
deleted file mode 100644
index 3364c3cf24..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToMany.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.CascadeType;
-import org.eclipse.jpt.core.resource.orm.FetchType;
-import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualManyToMany is an implementation of ManyToMany used when there is
- * no tag in the orm.xml and an underlying javaManyToManyMapping exists.
- */
-public class VirtualXmlManyToMany
- extends XmlManyToMany
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaManyToManyMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualCascadeType virtualCascadeType;
-
- protected final MapKey mapKey;
-
-
- public VirtualXmlManyToMany(
- OrmTypeMapping ormTypeMapping,
- JavaManyToManyMapping javaManyToManyMapping) {
-
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaManyToManyMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaManyToManyMapping);
- this.virtualCascadeType = new VirtualCascadeType(javaManyToManyMapping.getCascade());
- this.mapKey = new VirtualMapKey(javaManyToManyMapping);
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public FetchType getFetch() {
- if (this.isOrmMetadataComplete()) {
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getDefaultFetch());
- }
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getFetch());
- }
-
- @Override
- public void setFetch(FetchType newFetch) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public CascadeType getCascade() {
- if (isOrmMetadataComplete()) {
- return null;
- }
- return this.virtualCascadeType;
- }
-
- @Override
- public void setCascade(CascadeType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public XmlJoinTable getJoinTable() {
- if (this.javaAttributeMapping.getRelationshipReference().getJoinTableJoiningStrategy().getJoinTable() != null) {
- return new VirtualXmlJoinTable(
- this.ormTypeMapping,
- this.javaAttributeMapping.getRelationshipReference().
- getJoinTableJoiningStrategy().getJoinTable());
- }
- return null;
- }
-
- @Override
- public void setJoinTable(XmlJoinTable value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTargetEntity() {
- if (this.isOrmMetadataComplete()) {
- return this.javaAttributeMapping.getDefaultTargetEntity();
- }
- return this.javaAttributeMapping.getFullyQualifiedTargetEntity();
- }
-
- @Override
- public void setTargetEntity(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getMappedBy() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.javaAttributeMapping.getRelationshipReference().getMappedByJoiningStrategy().getMappedByAttribute();
- }
-
- @Override
- public void setMappedBy(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public MapKey getMapKey() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.isNoMapKey()) {
- return null;
- }
- return this.mapKey;
- }
-
- @Override
- public void setMapKey(MapKey value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getOrderBy() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.javaAttributeMapping.getOrderable().getSpecifiedOrderBy();
- }
-
- @Override
- public void setOrderBy(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getMappedByTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTargetEntityTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToOne.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToOne.java
deleted file mode 100644
index e14c5aab8e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlManyToOne.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.CascadeType;
-import org.eclipse.jpt.core.resource.orm.FetchType;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * VirtualManyToOne is an implementation of ManyToOne used when there is
- * no tag in the orm.xml and an underlying javaManyToOneMapping exists.
- */
-public class VirtualXmlManyToOne
- extends XmlManyToOne
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaManyToOneMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualCascadeType virtualCascadeType;
-
-
- public VirtualXmlManyToOne(
- OrmTypeMapping ormTypeMapping, JavaManyToOneMapping javaManyToOneMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaManyToOneMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaManyToOneMapping);
- this.virtualCascadeType = new VirtualCascadeType(javaManyToOneMapping.getCascade());
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public FetchType getFetch() {
- if (this.isOrmMetadataComplete()) {
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getDefaultFetch());
- }
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getFetch());
- }
-
- @Override
- public void setFetch(FetchType newFetch) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getOptional() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.javaAttributeMapping.isDefaultOptional());
- }
- return Boolean.valueOf(this.javaAttributeMapping.isOptional());
- }
-
- @Override
- public void setOptional(Boolean newOptional) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public EList<XmlJoinColumn> getJoinColumns() {
- EList<XmlJoinColumn> joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_MANY_TO_ONE__JOIN_COLUMNS);
- if (isOrmMetadataComplete()) {
- return joinColumns;
- }
- for (JoinColumn joinColumn :
- CollectionTools.iterable(
- this.javaAttributeMapping.getRelationshipReference().
- getJoinColumnJoiningStrategy().specifiedJoinColumns())) {
- XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, isOrmMetadataComplete());
- joinColumns.add(xmlJoinColumn);
- }
- return joinColumns;
- }
-
- @Override
- public CascadeType getCascade() {
- if (isOrmMetadataComplete()) {
- return null;
- }
- return this.virtualCascadeType;
- }
-
- @Override
- public void setCascade(CascadeType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public XmlJoinTable getJoinTable() {
- return null;
- }
-
- @Override
- public void setJoinTable(XmlJoinTable value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTargetEntity() {
- if (this.isOrmMetadataComplete()) {
- return this.javaAttributeMapping.getDefaultTargetEntity();
- }
- return this.javaAttributeMapping.getFullyQualifiedTargetEntity();
- }
-
- @Override
- public void setTargetEntity(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getTargetEntityTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlNullAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlNullAttributeMapping.java
deleted file mode 100644
index 0cc0cd8472..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlNullAttributeMapping.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlNullAttributeMapping;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualVersion is an implementation of Version used when there is
- * no tag in the orm.xml and an underlying javaVersionMapping exists.
- */
-public class VirtualXmlNullAttributeMapping extends XmlNullAttributeMapping
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaAttributeMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- public VirtualXmlNullAttributeMapping(OrmTypeMapping ormTypeMapping, JavaAttributeMapping javaAttributeMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaAttributeMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaAttributeMapping);
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- public String getMappingKey() {
- if (this.isOrmMetadataComplete()) {
- return this.javaAttributeMapping.getPersistentAttribute().getDefaultMappingKey();
- }
- return this.javaAttributeMapping.getKey();
- }
-
- @Override
- public String getName() {
- return this.javaAttributeMapping.getPersistentAttribute().getName();
- }
-
- @Override
- public void setName(String newName) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java
deleted file mode 100644
index 4b5eb5a99d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToMany.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jpt.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.CascadeType;
-import org.eclipse.jpt.core.resource.orm.FetchType;
-import org.eclipse.jpt.core.resource.orm.MapKey;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualOneToMany is an implementation of OneToMany used when there is
- * no tag in the orm.xml and an underlying javaOneToManyMapping exists.
- */
-public class VirtualXmlOneToMany
- extends XmlOneToMany
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaOneToManyMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualCascadeType virtualCascadeType;
-
- protected final MapKey mapKey;
-
- public VirtualXmlOneToMany(
- OrmTypeMapping ormTypeMapping, JavaOneToManyMapping javaOneToManyMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaOneToManyMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaOneToManyMapping);
- this.virtualCascadeType = new VirtualCascadeType(javaOneToManyMapping.getCascade());
- this.mapKey = new VirtualMapKey(javaOneToManyMapping);
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public FetchType getFetch() {
- if (this.isOrmMetadataComplete()) {
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getDefaultFetch());
- }
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getFetch());
- }
-
- @Override
- public void setFetch(FetchType newFetch) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public EList<XmlJoinColumn> getJoinColumns() {
- return null;
- }
-
- @Override
- public CascadeType getCascade() {
- if (isOrmMetadataComplete()) {
- return null;
- }
- return this.virtualCascadeType;
- }
-
- @Override
- public void setCascade(CascadeType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public Boolean getOrphanRemoval() {
- throw new UnsupportedOperationException("operation not supported in JPA 1.0"); //$NON-NLS-1$
- }
-
- @Override
- public void setOrphanRemoval(Boolean newOrphanRemoval) {
- throw new UnsupportedOperationException("operation not supported in JPA 1.0"); //$NON-NLS-1$
- }
-
- @Override
- public XmlJoinTable getJoinTable() {
- if (this.javaAttributeMapping.getRelationshipReference().getJoinTableJoiningStrategy().getJoinTable() != null) {
- return new VirtualXmlJoinTable(
- this.ormTypeMapping,
- this.javaAttributeMapping.getRelationshipReference().
- getJoinTableJoiningStrategy().getJoinTable());
- }
- return null;
- }
-
- @Override
- public void setJoinTable(XmlJoinTable value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTargetEntity() {
- if (this.isOrmMetadataComplete()) {
- return this.javaAttributeMapping.getDefaultTargetEntity();
- }
- return this.javaAttributeMapping.getFullyQualifiedTargetEntity();
- }
-
- @Override
- public void setTargetEntity(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getMappedBy() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.javaAttributeMapping.getRelationshipReference().
- getMappedByJoiningStrategy().getMappedByAttribute();
- }
-
- @Override
- public void setMappedBy(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public MapKey getMapKey() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.isNoMapKey()) {
- return null;
- }
- return this.mapKey;
- }
-
- @Override
- public void setMapKey(MapKey value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getOrderBy() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.javaAttributeMapping.getOrderable().getSpecifiedOrderBy();
- }
-
- @Override
- public void setOrderBy(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getMappedByTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTargetEntityTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToOne.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToOne.java
deleted file mode 100644
index db5947d2e4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOneToOne.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.JoinColumn;
-import org.eclipse.jpt.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.CascadeType;
-import org.eclipse.jpt.core.resource.orm.FetchType;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * VirtualOneToOne is an implementation of OneToOne used when there is
- * no tag in the orm.xml and an underlying javaOneToOneMapping exists.
- */
-public class VirtualXmlOneToOne extends XmlOneToOne
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaOneToOneMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualCascadeType virtualCascadeType;
-
-
- public VirtualXmlOneToOne(
- OrmTypeMapping ormTypeMapping, JavaOneToOneMapping javaOneToOneMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaOneToOneMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaOneToOneMapping);
- this.virtualCascadeType = new VirtualCascadeType(javaOneToOneMapping.getCascade());
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public FetchType getFetch() {
- if (this.isOrmMetadataComplete()) {
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getDefaultFetch());
- }
- return org.eclipse.jpt.core.context.FetchType.toOrmResourceModel(this.javaAttributeMapping.getFetch());
- }
-
- @Override
- public void setFetch(FetchType newFetch) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getOptional() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.javaAttributeMapping.isDefaultOptional());
- }
- return Boolean.valueOf(this.javaAttributeMapping.isOptional());
- }
-
- @Override
- public void setOptional(Boolean newOptional) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public EList<XmlJoinColumn> getJoinColumns() {
- EList<XmlJoinColumn> joinColumns = new EObjectContainmentEList<XmlJoinColumn>(XmlJoinColumn.class, this, OrmPackage.XML_ONE_TO_ONE__JOIN_COLUMNS);
- if (isOrmMetadataComplete()) {
- return joinColumns;
- }
- for (JoinColumn joinColumn :
- CollectionTools.iterable(
- this.javaAttributeMapping.getRelationshipReference().
- getJoinColumnJoiningStrategy().specifiedJoinColumns())) {
- XmlJoinColumn xmlJoinColumn = new VirtualXmlJoinColumn(joinColumn, isOrmMetadataComplete());
- joinColumns.add(xmlJoinColumn);
- }
- return joinColumns;
- }
-
- @Override
- public CascadeType getCascade() {
- if (isOrmMetadataComplete()) {
- return null;
- }
- return this.virtualCascadeType;
- }
-
- @Override
- public void setCascade(CascadeType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getOrphanRemoval() {
- throw new UnsupportedOperationException("operation not supported in JPA 1.0"); //$NON-NLS-1$
- }
-
- @Override
- public void setOrphanRemoval(Boolean newOrphanRemoval) {
- throw new UnsupportedOperationException("operation not supported in JPA 1.0"); //$NON-NLS-1$
- }
-
- @Override
- public XmlJoinTable getJoinTable() {
- return null;
- }
-
- @Override
- public void setJoinTable(XmlJoinTable value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTargetEntity() {
- if (this.isOrmMetadataComplete()) {
- return this.javaAttributeMapping.getDefaultTargetEntity();
- }
- return this.javaAttributeMapping.getFullyQualifiedTargetEntity();
- }
-
- @Override
- public void setTargetEntity(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getMappedBy() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.javaAttributeMapping.getRelationshipReference().
- getMappedByJoiningStrategy().getMappedByAttribute();
- }
-
- @Override
- public void setMappedBy(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public EList<XmlPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- EList<XmlPrimaryKeyJoinColumn> joinColumns = new EObjectContainmentEList<XmlPrimaryKeyJoinColumn>(XmlPrimaryKeyJoinColumn.class, this, OrmPackage.XML_ONE_TO_ONE__PRIMARY_KEY_JOIN_COLUMNS);
- if (!this.isOrmMetadataComplete()) {
- for (JavaPrimaryKeyJoinColumn joinColumn :
- CollectionTools.iterable(
- this.javaAttributeMapping.getRelationshipReference().
- getPrimaryKeyJoinColumnJoiningStrategy().primaryKeyJoinColumns())) {
- XmlPrimaryKeyJoinColumn xmlJoinColumn = new VirtualXmlPrimaryKeyJoinColumn(joinColumn/*, this.metadataComplete*/);
- joinColumns.add(xmlJoinColumn);
- }
- }
- return joinColumns;
- }
-
- @Override
- public TextRange getMappedByTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTargetEntityTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOrderColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOrderColumn.java
deleted file mode 100644
index 371d08a907..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlOrderColumn.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.jpa2.context.OrderColumn2_0;
-import org.eclipse.jpt.core.resource.orm.XmlOrderColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class VirtualXmlOrderColumn extends XmlOrderColumn
-{
- protected OrderColumn2_0 javaOrderColumn;
-
- protected OrmTypeMapping ormTypeMapping;
-
- public VirtualXmlOrderColumn(OrderColumn2_0 javaOrderColumn, OrmTypeMapping ormTypeMapping) {
- super();
- this.javaOrderColumn = javaOrderColumn;
- this.ormTypeMapping = ormTypeMapping;
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getColumnDefinition() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- return this.javaOrderColumn.getColumnDefinition();
- }
-
- @Override
- public void setColumnDefinition(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getInsertable() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.javaOrderColumn.isDefaultInsertable());
- }
- return Boolean.valueOf(this.javaOrderColumn.isInsertable());
- }
-
- @Override
- public void setInsertable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getName() {
- if (this.isOrmMetadataComplete()) {
- return this.javaOrderColumn.getDefaultName();
- }
- return this.javaOrderColumn.getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
-
- @Override
- public Boolean getNullable() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.javaOrderColumn.isDefaultNullable());
- }
- return Boolean.valueOf(this.javaOrderColumn.isNullable());
- }
-
- @Override
- public void setNullable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Boolean getUpdatable() {
- if (this.isOrmMetadataComplete()) {
- return Boolean.valueOf(this.javaOrderColumn.isDefaultUpdatable());
- }
- return Boolean.valueOf(this.javaOrderColumn.isUpdatable());
- }
-
- @Override
- public void setUpdatable(Boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java
deleted file mode 100644
index 34127e1e98..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlPrimaryKeyJoinColumn.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * A virtual primary key join column is used to represent the XmlPrimaryKeyJoinColumn resource object
- * within a virtual secondary table. A virtual secondary table is one which is not specified
- * in the orm.xml file, but is implied from the underlying java. Virtual pk join column
- * is not used when the secondary table is specified in the orm.xml.
- *
- * A virtual pk join column delegates to the underlying java pk join column for its state.
- */
-public class VirtualXmlPrimaryKeyJoinColumn extends XmlPrimaryKeyJoinColumn
-{
-
- protected JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn;
-
-
- protected VirtualXmlPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn) {
- super();
- this.javaPrimaryKeyJoinColumn = javaPrimaryKeyJoinColumn;
- }
-
- @Override
- public String getName() {
- return this.javaPrimaryKeyJoinColumn.getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getColumnDefinition() {
- return this.javaPrimaryKeyJoinColumn.getColumnDefinition();
- }
-
- @Override
- public void setColumnDefinition(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getReferencedColumnName() {
- return this.javaPrimaryKeyJoinColumn.getReferencedColumnName();
- }
-
- @Override
- public void setReferencedColumnName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-
- @Override
- public TextRange getReferencedColumnNameTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java
deleted file mode 100644
index b25ddcb3f6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSecondaryTable.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.core.resource.orm.XmlSecondaryTable;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-/**
- * A virtual secondary table is used to represent the XmlSecondaryTable resource object.
- * A virtual secondary table is one which is not specified in the orm.xml file,
- * but is implied from the underlying java. Virtual secondary table
- * is not used when the secondary table is specified in the orm.xml.
- *
- * A virtual secondary table delegates to the underlying java secondary table for its state.
- */
-public class VirtualXmlSecondaryTable extends XmlSecondaryTable
-{
-
- protected JavaSecondaryTable javaSecondaryTable;
-
- protected VirtualXmlSecondaryTable(JavaSecondaryTable javaSecondaryTable) {
- super();
- this.javaSecondaryTable = javaSecondaryTable;
- }
-
- @Override
- public String getName() {
- return this.javaSecondaryTable.getSpecifiedName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getCatalog() {
- return this.javaSecondaryTable.getSpecifiedCatalog();
- }
-
- @Override
- public void setCatalog(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getSchema() {
- return this.javaSecondaryTable.getSpecifiedSchema();
- }
-
- @Override
- public void setSchema(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- //VirtualXmlSecondaryTable is rebuilt everytime, so rebuilding the joinColumns list as well
- @Override
- public EList<XmlPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- EList<XmlPrimaryKeyJoinColumn> primaryKeyJoinColumns = new EObjectContainmentEList<XmlPrimaryKeyJoinColumn>(XmlPrimaryKeyJoinColumn.class, this, OrmPackage.XML_SECONDARY_TABLE__PRIMARY_KEY_JOIN_COLUMNS);
-
- for (JavaPrimaryKeyJoinColumn pkJoinColumn : CollectionTools.iterable(this.javaSecondaryTable.specifiedPrimaryKeyJoinColumns())) {
- XmlPrimaryKeyJoinColumn xmlPkJoinColumn = new VirtualXmlPrimaryKeyJoinColumn(pkJoinColumn);
- primaryKeyJoinColumns.add(xmlPkJoinColumn);
- }
-
- return primaryKeyJoinColumns;
- }
-
- @Override
- public EList<XmlUniqueConstraint> getUniqueConstraints() {
- EList<XmlUniqueConstraint> xmlUniqueConstraints = new EObjectContainmentEList<XmlUniqueConstraint>(XmlUniqueConstraint.class, this, OrmPackage.XML_SECONDARY_TABLE__UNIQUE_CONSTRAINTS);
-
- for (JavaUniqueConstraint uniqueConstraint : CollectionTools.iterable(this.javaSecondaryTable.uniqueConstraints())) {
- XmlUniqueConstraint xmlUniqueConstraint = new VirtualXmlUniqueConstraint(uniqueConstraint, true);
- xmlUniqueConstraints.add(xmlUniqueConstraint);
- }
-
- return xmlUniqueConstraints;
- }
-
- @Override
- public TextRange getNameTextRange() {
- return null;
- }
-
- @Override
- public TextRange getCatalogTextRange() {
- return null;
- }
-
- @Override
- public TextRange getSchemaTextRange() {
- return null;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSequenceGenerator.java
deleted file mode 100644
index 06a8ffb50d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlSequenceGenerator.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.core.context.java.JavaSequenceGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.core.utility.TextRange;
-
-public class VirtualXmlSequenceGenerator extends XmlSequenceGenerator
-{
- JavaGeneratorContainer javaGeneratorHolder;
-
- protected boolean metadataComplete;
-
-
- public VirtualXmlSequenceGenerator(JavaGeneratorContainer javaGeneratorHolder, boolean metadataComplete) {
- super();
- this.javaGeneratorHolder = javaGeneratorHolder;
- this.metadataComplete = metadataComplete;
- }
-
- protected JavaSequenceGenerator getJavaSequenceGenerator() {
- return this.javaGeneratorHolder.getSequenceGenerator();
- }
-
- @Override
- public String getSequenceName() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaSequenceGenerator().getSequenceName();
- }
-
- @Override
- public void setSequenceName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getAllocationSize() {
- if (this.metadataComplete) {
- return null;
- }
- return Integer.valueOf(this.getJavaSequenceGenerator().getAllocationSize());
- }
-
- @Override
- public void setAllocationSize(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getInitialValue() {
- if (this.metadataComplete) {
- return null;
- }
- return Integer.valueOf(this.getJavaSequenceGenerator().getInitialValue());
- }
-
- @Override
- public void setInitialValue(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getName() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaSequenceGenerator().getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getNameTextRange() {
- return getValidationTextRange();
- }
-
- @Override
- public boolean isVirtual() {
- return true;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTableGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTableGenerator.java
deleted file mode 100644
index 26121e2f4b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTableGenerator.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.jpt.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.core.context.java.JavaTableGenerator;
-import org.eclipse.jpt.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class VirtualXmlTableGenerator extends XmlTableGenerator
-{
- JavaGeneratorContainer javaGeneratorHolder;
-
- protected boolean metadataComplete;
-
-
- public VirtualXmlTableGenerator(JavaGeneratorContainer javaGeneratorHolder, boolean metadataComplete) {
- super();
- this.javaGeneratorHolder = javaGeneratorHolder;
- this.metadataComplete = metadataComplete;
- }
-
- protected JavaTableGenerator getJavaTableGenerator() {
- return this.javaGeneratorHolder.getTableGenerator();
- }
-
- @Override
- public String getCatalog() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getCatalog();
- }
-
- @Override
- public void setCatalog(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getPkColumnName() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getPkColumnName();
- }
-
- @Override
- public void setPkColumnName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getPkColumnValue() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getPkColumnValue();
- }
-
- @Override
- public void setPkColumnValue(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getSchema() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getSchema();
- }
-
- @Override
- public void setSchema(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getTable() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getTable();
- }
-
- @Override
- public void setTable(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getValueColumnName() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getValueColumnName();
- }
-
- @Override
- public void setValueColumnName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getAllocationSize() {
- if (this.metadataComplete) {
- return null;
- }
- return Integer.valueOf(this.getJavaTableGenerator().getAllocationSize());
- }
-
- @Override
- public void setAllocationSize(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public Integer getInitialValue() {
- if (this.metadataComplete) {
- return null;
- }
- return Integer.valueOf(this.getJavaTableGenerator().getInitialValue());
- }
-
- @Override
- public void setInitialValue(Integer value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public String getName() {
- if (this.metadataComplete) {
- return null;
- }
- return this.getJavaTableGenerator().getName();
- }
-
- @Override
- public void setName(String value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public EList<XmlUniqueConstraint> getUniqueConstraints() {
- EList<XmlUniqueConstraint> xmlUniqueConstraints = new EObjectContainmentEList<XmlUniqueConstraint>(XmlUniqueConstraint.class, this, OrmPackage.XML_TABLE_GENERATOR__UNIQUE_CONSTRAINTS);
-
- for (JavaUniqueConstraint uniqueConstraint : CollectionTools.iterable(this.getJavaTableGenerator().uniqueConstraints())) {
- XmlUniqueConstraint xmlUniqueConstraint = new VirtualXmlUniqueConstraint(uniqueConstraint, this.metadataComplete);
- xmlUniqueConstraints.add(xmlUniqueConstraint);
- }
-
- return xmlUniqueConstraints;
- }
-
- @Override
- public TextRange getNameTextRange() {
- return getValidationTextRange();
- }
-
- @Override
- public boolean isVirtual() {
- return true;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTransient.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTransient.java
deleted file mode 100644
index e80ebe5273..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlTransient.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.java.JavaTransientMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualTransient is an implementation of Transient used when there is
- * no tag in the orm.xml and an underlying javaTransientMapping exists.
- */
-public class VirtualXmlTransient extends XmlTransient
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaTransientMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- public VirtualXmlTransient(OrmTypeMapping ormTypeMapping, JavaTransientMapping javaTransientMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaTransientMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaTransientMapping);
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlUniqueConstraint.java
deleted file mode 100644
index 2be593ccbb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlUniqueConstraint.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.util.EDataTypeEList;
-import org.eclipse.jpt.core.context.UniqueConstraint;
-import org.eclipse.jpt.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-
-public class VirtualXmlUniqueConstraint extends XmlUniqueConstraint
-{
- protected UniqueConstraint uniqueConstraint;
-
- protected boolean metadataComplete;
-
- public VirtualXmlUniqueConstraint(UniqueConstraint uniqueConstraint, boolean metadataComplete) {
- super();
- this.uniqueConstraint = uniqueConstraint;
- this.metadataComplete = metadataComplete;
- }
-
- @Override
- public EList<String> getColumnNames() {
- EList<String> columnNames = new EDataTypeEList<String>(String.class, this, OrmPackage.XML_UNIQUE_CONSTRAINT__COLUMN_NAMES);
-
- for (String columnName : CollectionTools.iterable(this.uniqueConstraint.columnNames())) {
- columnNames.add(columnName);
- }
- return columnNames;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlVersion.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlVersion.java
deleted file mode 100644
index 14be7a4cbd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/orm/VirtualXmlVersion.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.orm;
-
-import org.eclipse.jpt.core.context.Converter;
-import org.eclipse.jpt.core.context.TemporalConverter;
-import org.eclipse.jpt.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.core.resource.orm.EnumType;
-import org.eclipse.jpt.core.resource.orm.TemporalType;
-import org.eclipse.jpt.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.core.utility.TextRange;
-
-/**
- * VirtualVersion is an implementation of Version used when there is
- * no tag in the orm.xml and an underlying javaVersionMapping exists.
- */
-public class VirtualXmlVersion extends XmlVersion
-{
- protected OrmTypeMapping ormTypeMapping;
-
- protected final JavaVersionMapping javaAttributeMapping;
-
- protected final VirtualXmlAttributeMapping virtualXmlAttributeMapping;
-
- protected final VirtualXmlColumn column;
-
- public VirtualXmlVersion(OrmTypeMapping ormTypeMapping, JavaVersionMapping javaVersionMapping) {
- super();
- this.ormTypeMapping = ormTypeMapping;
- this.javaAttributeMapping = javaVersionMapping;
- this.virtualXmlAttributeMapping = new VirtualXmlAttributeMapping(ormTypeMapping, javaVersionMapping);
- this.column = new VirtualXmlColumn(ormTypeMapping, javaVersionMapping.getColumn());
- }
-
- protected boolean isOrmMetadataComplete() {
- return this.ormTypeMapping.isMetadataComplete();
- }
-
- @Override
- public String getMappingKey() {
- return this.virtualXmlAttributeMapping.getMappingKey();
- }
-
- @Override
- public String getName() {
- return this.virtualXmlAttributeMapping.getName();
- }
-
- @Override
- public void setName(String newName) {
- this.virtualXmlAttributeMapping.setName(newName);
- }
-
- @Override
- public TextRange getNameTextRange() {
- return this.virtualXmlAttributeMapping.getNameTextRange();
- }
-
- @Override
- public XmlColumn getColumn() {
- return this.column;
- }
-
- @Override
- public void setColumn(XmlColumn value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TemporalType getTemporal() {
- if (this.isOrmMetadataComplete()) {
- return null;
- }
- if (this.javaAttributeMapping.getConverter().getType() == Converter.TEMPORAL_CONVERTER) {
- org.eclipse.jpt.core.context.TemporalType javaTemporalType = ((TemporalConverter) this.javaAttributeMapping.getConverter()).getTemporalType();
- return org.eclipse.jpt.core.context.TemporalType.toOrmResourceModel(javaTemporalType);
- }
- return null;
- }
-
- @Override
- public void setTemporal(TemporalType newTemporal){
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- //see eclipselink bug 247078 for info one why I made the interface XmlConvertibleMapping
- @Override
- public EnumType getEnumerated() {
- throw new UnsupportedOperationException("enumerated not supported on version mappings"); //$NON-NLS-1$
- }
-
- @Override
- public void setEnumerated(EnumType value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- //see eclipselink bug 247078 for info one why I made the interface XmlConvertibleMapping
- @Override
- public boolean isLob() {
- throw new UnsupportedOperationException("lob not supported on version mappings"); //$NON-NLS-1$
- }
-
- @Override
- public void setLob(boolean value) {
- throw new UnsupportedOperationException("cannot set values on a virtual mapping"); //$NON-NLS-1$
- }
-
- @Override
- public TextRange getEnumeratedTextRange() {
- return null;
- }
-
- @Override
- public TextRange getLobTextRange() {
- return null;
- }
-
- @Override
- public TextRange getTemporalTextRange() {
- return null;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractJarFileRef.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractJarFileRef.java
deleted file mode 100644
index c490df634b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractJarFileRef.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jpt.core.JpaFile;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.java.JarFile;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.persistence.JarFileRef;
-import org.eclipse.jpt.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot;
-import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualFile;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-
-public abstract class AbstractJarFileRef
- extends AbstractPersistenceXmlContextNode
- implements JarFileRef
-{
- protected XmlJarFileRef xmlJarFileRef;
-
- protected String fileName;
-
- protected JarFile jarFile;
-
-
- // **************** construction/initialization ****************************
-
- public AbstractJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef) {
- super(parent);
- this.xmlJarFileRef = xmlJarFileRef;
- this.fileName = xmlJarFileRef.getFileName();
- this.jarFile = this.buildJarFile();
- }
-
- protected JarFile buildJarFile() {
- if (StringTools.stringIsEmpty(this.fileName)) {
- return null;
- }
- JavaResourcePackageFragmentRoot jrpfr = this.getJpaProject().getJavaResourcePackageFragmentRoot(this.getFileName());
- return (jrpfr == null) ? null : this.buildJarFile(jrpfr);
- }
-
- @Override
- public PersistenceUnit getParent() {
- return (PersistenceUnit) super.getParent();
- }
-
-
- // **************** file name **********************************************
-
- public String getFileName() {
- return this.fileName;
- }
-
- public void setFileName(String newFileName) {
- String old = this.fileName;
- this.fileName = newFileName;
- this.xmlJarFileRef.setFileName(newFileName);
- this.firePropertyChanged(FILE_NAME_PROPERTY, old, newFileName);
- }
-
- protected void setFileName_(String newFileName) {
- String old = this.fileName;
- this.fileName = newFileName;
- this.firePropertyChanged(FILE_NAME_PROPERTY, old, newFileName);
- }
-
-
- // **************** JAR file ***********************************************
-
- public JarFile getJarFile() {
- return this.jarFile;
- }
-
- protected void setJarFile(JarFile jarFile) {
- JarFile old = this.jarFile;
- this.jarFile = jarFile;
- this.firePropertyChanged(JAR_FILE_PROPERTY, old, jarFile);
- }
-
-
- // ********** JarFileRef implementation **********
-
- public PersistentType getPersistentType(String typeName) {
- return (this.jarFile == null) ? null : this.jarFile.getPersistentType(typeName);
- }
-
- public boolean containsOffset(int textOffset) {
- return (this.xmlJarFileRef != null) && this.xmlJarFileRef.containsOffset(textOffset);
- }
-
-
- // ********** PersistentTypeContainer implementation **********
-
- public Iterable<? extends PersistentType> getPersistentTypes() {
- return (this.jarFile != null) ? this.jarFile.getPersistentTypes() : EmptyIterable.<JavaPersistentType>instance();
- }
-
-
- // **************** JpaStructureNode impl **********************************
-
- public String getId() {
- return PersistenceStructureNodes.JAR_FILE_REF_ID;
- }
-
- public JpaStructureNode getStructureNode(int textOffset) {
- return this;
- }
-
- public TextRange getSelectionTextRange() {
- return (this.xmlJarFileRef == null) ? null : this.xmlJarFileRef.getSelectionTextRange();
- }
-
- public void dispose() {
- if (this.jarFile != null) {
- this.jarFile.dispose();
- }
- }
-
-
- // **************** XmlContextNode impl ************************************
-
- public TextRange getValidationTextRange() {
- return (this.xmlJarFileRef == null) ? null : this.xmlJarFileRef.getValidationTextRange();
- }
-
-
- // **************** updating ***********************************************
-
- public void update(XmlJarFileRef xjfr) {
- this.xmlJarFileRef = xjfr;
- this.setFileName_(xjfr.getFileName());
- this.updateJarFile();
- }
-
- protected void updateJarFile() {
- JavaResourcePackageFragmentRoot jrpfr = null;
-
- if (! StringTools.stringIsEmpty(this.fileName)) {
-
- // first, attempt to resolve location specifically
- jrpfr = javaPackageRoot_specifically();
-
- // then ... guess, basically
- if (jrpfr == null) {
- jrpfr = javaPackageRoot_guess();
- }
- }
-
- if (jrpfr == null) {
- if (this.jarFile != null) {
- this.jarFile.dispose();
- this.setJarFile(null);
- }
- } else {
- if (this.jarFile == null) {
- this.setJarFile(this.buildJarFile(jrpfr));
- } else {
- this.jarFile.update(jrpfr);
- }
- }
- }
-
- private JavaResourcePackageFragmentRoot javaPackageRoot_specifically() {
- for (IPath runtimePath : resolveRuntimeJarFilePath(new Path(this.fileName))) {
- IVirtualFile virtualJar = ComponentCore.createFile(this.getProject(), runtimePath);
- IFile realJar = virtualJar.getUnderlyingFile();
- if (realJar.exists() && realJar.getProject().equals(this.getProject())) {
- return getJpaProject().getJavaResourcePackageFragmentRoot(realJar.getProjectRelativePath().toString());
- }
- }
-
- return null;
- }
-
- private JavaResourcePackageFragmentRoot javaPackageRoot_guess() {
- String jarFileName = new Path(this.fileName).lastSegment();
- for (JpaFile jpaFile : CollectionTools.iterable(getJpaProject().jpaFiles())) {
- if (jpaFile.getFile().getName().equals(jarFileName)
- && JptCorePlugin.JAR_CONTENT_TYPE.equals(jpaFile.getContentType())) {
- return (JavaResourcePackageFragmentRoot) jpaFile.getResourceModel();
- }
- }
-
- return null;
- }
-
- /**
- * Return an array of runtime paths that may correspond
- * to the given persistence.xml jar file entry
- */
- protected IPath[] resolveRuntimeJarFilePath(IPath jarFilePath) {
- IPath root = this.getJarRuntimeRootPath();
- return this.projectHasWebFacet() ?
- this.resolveRuntimeJarFilePathWeb(root, jarFilePath) :
- this.resolveRuntimeJarFilePathNonWeb(root, jarFilePath);
- }
-
- protected IPath getJarRuntimeRootPath() {
- return JptCorePlugin.getJarRuntimeRootPath(this.getProject());
- }
-
- protected boolean projectHasWebFacet() {
- return JptCorePlugin.projectHasWebFacet(this.getProject());
- }
-
- protected IPath[] resolveRuntimeJarFilePathWeb(IPath root, IPath jarFilePath) {
- return new IPath[] {
- // first path entry assumes form "../lib/other.jar"
- root.append(jarFilePath.removeFirstSegments(1)),
- // second path entry assumes form of first, without ".." ("lib/other.jar")
- root.append(jarFilePath)
- };
- }
-
- protected IPath[] resolveRuntimeJarFilePathNonWeb(IPath root, IPath jarFilePath) {
- return new IPath[] {
- // assumes form "../lib/other.jar"
- root.append(jarFilePath)
- };
- }
-
-
- protected JarFile buildJarFile(JavaResourcePackageFragmentRoot jrpfr) {
- return this.getContextNodeFactory().buildJarFile(this, jrpfr);
- }
-
- protected IProject getProject() {
- return this.getJpaProject().getProject();
- }
-
-
- // ********** refactoring **********
-
- public Iterable<ReplaceEdit> createReplaceFolderEdits(IFolder originalFolder, String newName) {
- if (this.isIn(originalFolder)) {
- return new SingleElementIterable<ReplaceEdit>(this.createReplaceFolderEdit(originalFolder, newName));
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createReplaceFolderEdit(IFolder originalFolder, String newName) {
- return this.xmlJarFileRef.createReplaceFolderEdit(originalFolder, newName);
- }
-
- protected boolean isIn(IFolder folder) {
- if (this.jarFile == null) {
- return false;
- }
- return this.jarFile.isIn(folder);
- }
-
-
- // **************** validation *********************************************
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- if (StringTools.stringIsEmpty(this.xmlJarFileRef.getFileName())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_JAR_FILE,
- this,
- this.getValidationTextRange()));
- return;
- }
-
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_JAR_FILE_DEPLOYMENT_PATH_WARNING,
- this,
- this.getValidationTextRange()));
-
- if (this.jarFile == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_JAR_FILE,
- new String[] {this.xmlJarFileRef.getFileName()},
- this,
- this.getValidationTextRange()
- )
- );
- return;
- }
-
- this.jarFile.validate(messages, reporter);
- }
-
-
- // **************** misc ***************************************************
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.getFileName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java
deleted file mode 100644
index 3951749e28..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractMappingFileRef.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import java.util.List;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaResourceType;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.context.MappingFile;
-import org.eclipse.jpt.core.context.MappingFilePersistenceUnitDefaults;
-import org.eclipse.jpt.core.context.MappingFileRoot;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.resource.xml.JpaXmlResource;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>persistence.xml</code> file
- * <br>
- * <code>mapping-file</code> element
- */
-public abstract class AbstractMappingFileRef
- extends AbstractPersistenceXmlContextNode
- implements MappingFileRef
-{
- protected String fileName;
-
- /**
- * the mapping file corresponding to the ref's file name;
- * this can be null if the name is invalid
- */
- protected MappingFile mappingFile;
-
-
- // ********** construction/initialization **********
-
- protected AbstractMappingFileRef(PersistenceUnit parent, String resourceFileName) {
- super(parent);
- this.fileName = resourceFileName;
- this.mappingFile = this.buildMappingFile();
- }
-
-
- // ********** overrides **********
-
- @Override
- public PersistenceUnit getParent() {
- return (PersistenceUnit) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.fileName);
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return PersistenceStructureNodes.MAPPING_FILE_REF_ID;
- }
-
- public JpaStructureNode getStructureNode(int textOffset) {
- return this;
- }
-
- public void dispose() {
- if (this.mappingFile != null) {
- this.mappingFile.dispose();
- }
- }
-
-
- // ********** queries **********
-
- public boolean persistenceUnitDefaultsExists() {
- MappingFilePersistenceUnitDefaults defaults = this.getPersistenceUnitDefaults();
- return (defaults != null) && defaults.resourceExists();
- }
-
- public MappingFilePersistenceUnitDefaults getPersistenceUnitDefaults() {
- MappingFileRoot root = this.getChildMappingFileRoot();
- return (root == null) ? null : root.getPersistenceUnitDefaults();
- }
-
- /**
- * The method {@link #getMappingFileRoot()} is already defined by
- * {@link org.eclipse.jpt.core.internal.context.AbstractJpaContextNode}
- * for getting what would be the "mapping file root" that <em>contains</em>
- * the context node. We want something slightly different here: i.e. the
- * "mapping file root" contained by the mapping file ref (since, actually,
- * the mapping file ref is not even contained by a "mapping file root").
- */
- protected MappingFileRoot getChildMappingFileRoot() {
- return (this.mappingFile == null) ? null : this.mappingFile.getRoot();
- }
-
- public PersistentType getPersistentType(String typeName) {
- return (this.mappingFile == null) ? null : this.mappingFile.getPersistentType(typeName);
- }
-
-
- // ********** file name **********
-
- public String getFileName() {
- return this.fileName;
- }
-
- public boolean isFor(IFile file) {
- return this.mappingFile != null && file.equals(this.mappingFile.getXmlResource().getFile());
- }
-
- protected boolean isIn(IFolder folder) {
- if (this.mappingFile == null) {
- return false;
- }
- return this.mappingFile.isIn(folder);
- }
-
-
- // ********** mapping file **********
-
- public MappingFile getMappingFile() {
- return this.mappingFile;
- }
-
- protected void setMappingFile(MappingFile mappingFile) {
- MappingFile old = this.mappingFile;
- this.mappingFile = mappingFile;
- this.firePropertyChanged(MAPPING_FILE_PROPERTY, old, mappingFile);
- }
-
- protected MappingFile buildMappingFile() {
- JpaXmlResource xmlResource = this.resolveMappingFileXmlResource();
- return (xmlResource == null) ? null : this.buildMappingFile(xmlResource);
- }
-
- protected void updateMappingFile() {
- JpaXmlResource xmlResource = this.resolveMappingFileXmlResource();
-
- if (xmlResource == null) {
- if (this.mappingFile != null) {
- this.mappingFile.dispose();
- this.setMappingFile(null);
- }
- } else {
- if (this.mappingFile == null) {
- this.setMappingFile(this.buildMappingFile(xmlResource));
- } else {
- if (this.mappingFile.getXmlResource() == xmlResource) {
- this.mappingFile.update();
- } else {
- // if the resource's content type has changed, we completely rebuild the mapping file
- this.mappingFile.dispose();
- this.setMappingFile(this.buildMappingFile(xmlResource));
- }
- }
- }
- }
-
- /**
- * The mapping file ref resource is in the persistence xml resource
- * (<code>persistence.xml</code>). This returns the resource of
- * the mapping file itself (<code>orm.xml</code>).
- */
- protected JpaXmlResource resolveMappingFileXmlResource() {
- if (this.fileName == null) {
- return null;
- }
- JpaXmlResource xmlResource = this.getJpaProject().getMappingFileXmlResource(new Path(this.fileName));
- if (xmlResource == null) {
- return null;
- }
- if (xmlResource.isReverting()) {
- // 308254 - this can happen when orm.xml is closed without saving;
- // the model is completely whacked in another thread - so wipe our model(?)
- return null;
- }
- JpaResourceType resourceType = xmlResource.getResourceType();
- if (resourceType == null) {
- return null;
- }
- if ( ! this.getJpaPlatform().supportsResourceType(resourceType)) {
- return null;
- }
- return xmlResource;
- }
-
- /**
- * pre-condition: 'resource' is not null
- */
- protected MappingFile buildMappingFile(JpaXmlResource resource) {
- return this.getJpaFactory().buildMappingFile(this, resource);
- }
-
-
- // ********** PersistentTypeContainer implementation **********
-
- public Iterable<? extends PersistentType> getPersistentTypes() {
- return (this.mappingFile != null) ? this.mappingFile.getPersistentTypes() : EmptyIterable.<JavaPersistentType>instance();
- }
-
- // ********** updating **********
-
- protected void update() {
- this.updateMappingFile();
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- if (this.mappingFile != null) {
- this.mappingFile.postUpdate();
- }
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- if (StringTools.stringIsEmpty(this.fileName)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_UNSPECIFIED_MAPPING_FILE,
- this,
- this.getValidationTextRange()));
- return;
- }
-
- if (this.mappingFile == null) {
- messages.add(buildMappingFileValidationMessage());
- return;
- }
-
- this.mappingFile.validate(messages, reporter);
- }
-
- protected IMessage buildMappingFileValidationMessage() {
- int severity = IMessage.HIGH_SEVERITY;
- IFile file = getPlatformFile();
- if (file.exists()) {
- JpaXmlResource xmlResource = getJpaProject().getMappingFileXmlResource(new Path(this.fileName));
- if (xmlResource != null
- && ! getJpaPlatform().supportsResourceType(xmlResource.getResourceType())) {
- return DefaultJpaValidationMessages.buildMessage(
- severity,
- JpaValidationMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT,
- new String[] {file.getName()},
- file);
- }
- return DefaultJpaValidationMessages.buildMessage(
- severity,
- JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE,
- new String[] {file.getName()},
- file);
- }
- return DefaultJpaValidationMessages.buildMessage(
- severity,
- JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE,
- new String[] {this.fileName},
- this,
- getValidationTextRange());
- }
-
- protected IFile getPlatformFile() {
- return this.getJpaProject().getPlatformFile(new Path(this.fileName));
- }
-
-
- // ********** refactoring **********
-
- public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) {
- if (this.mappingFile != null) {
- return this.mappingFile.createDeleteTypeEdits(type);
- }
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- if (this.mappingFile != null) {
- return this.mappingFile.createRenameTypeEdits(originalType, newName);
- }
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- if (this.mappingFile != null) {
- return this.mappingFile.createMoveTypeEdits(originalType, newPackage);
- }
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- if (this.mappingFile != null) {
- return this.mappingFile.createRenamePackageEdits(originalPackage, newName);
- }
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenameMappingFileEdits(IFile originalFile, String newName) {
- if (this.isFor(originalFile)) {
- return new SingleElementIterable<ReplaceEdit>(this.createRenameEdit(originalFile, newName));
- }
- return EmptyIterable.instance();
- }
-
- protected abstract ReplaceEdit createRenameEdit(IFile originalFile, String newName);
-
- public Iterable<ReplaceEdit> createMoveMappingFileEdits(IFile originalFile, IPath runtineDestination) {
- if (this.isFor(originalFile)) {
- return new SingleElementIterable<ReplaceEdit>(this.createMoveEdit(originalFile, runtineDestination));
- }
- return EmptyIterable.instance();
- }
-
- protected abstract ReplaceEdit createMoveEdit(IFile originalFile, IPath runtineDestination);
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
deleted file mode 100644
index 6474b7c972..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ /dev/null
@@ -1,2116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.JpaStructureNode;
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.AccessType;
-import org.eclipse.jpt.core.context.Embeddable;
-import org.eclipse.jpt.core.context.Entity;
-import org.eclipse.jpt.core.context.Generator;
-import org.eclipse.jpt.core.context.MappingFilePersistenceUnitDefaults;
-import org.eclipse.jpt.core.context.PersistentAttribute;
-import org.eclipse.jpt.core.context.PersistentType;
-import org.eclipse.jpt.core.context.Query;
-import org.eclipse.jpt.core.context.TypeMapping;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.context.persistence.JarFileRef;
-import org.eclipse.jpt.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.core.context.persistence.Persistence;
-import org.eclipse.jpt.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.core.context.persistence.PersistentTypeContainer;
-import org.eclipse.jpt.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.core.jpa2.JpaProject2_0;
-import org.eclipse.jpt.core.jpa2.context.MappingFilePersistenceUnitDefaults2_0;
-import org.eclipse.jpt.core.jpa2.context.MetamodelSourceType;
-import org.eclipse.jpt.core.jpa2.context.PersistentType2_0;
-import org.eclipse.jpt.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.core.jpa2.context.persistence.options.ValidationMode;
-import org.eclipse.jpt.core.jpa2.resource.java.JavaResourcePersistentType2_0;
-import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef;
-import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.resource.persistence.XmlProperties;
-import org.eclipse.jpt.core.resource.persistence.XmlProperty;
-import org.eclipse.jpt.core.utility.BodySourceWriter;
-import org.eclipse.jpt.core.utility.TextRange;
-import org.eclipse.jpt.utility.internal.CollectionTools;
-import org.eclipse.jpt.utility.internal.HashBag;
-import org.eclipse.jpt.utility.internal.NotNullFilter;
-import org.eclipse.jpt.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.utility.internal.iterables.CompositeListIterable;
-import org.eclipse.jpt.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
-import org.eclipse.jpt.utility.internal.iterators.CloneListIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>persistence.xml</code> file
- * <br>
- * <code>persistence-unit</code> element
- */
-public abstract class AbstractPersistenceUnit
- extends AbstractPersistenceXmlContextNode
- implements PersistenceUnit2_0
-{
- protected XmlPersistenceUnit xmlPersistenceUnit;
-
- protected String name;
-
- protected PersistenceUnitTransactionType specifiedTransactionType;
- protected PersistenceUnitTransactionType defaultTransactionType;
-
- protected String description;
-
- protected String provider;
-
- protected String jtaDataSource;
- protected String nonJtaDataSource;
-
- protected final Vector<MappingFileRef> specifiedMappingFileRefs = new Vector<MappingFileRef>();
- protected MappingFileRef impliedMappingFileRef;
-
- protected final Vector<JarFileRef> jarFileRefs = new Vector<JarFileRef>();
-
- protected final Vector<ClassRef> specifiedClassRefs = new Vector<ClassRef>();
- protected final Vector<ClassRef> impliedClassRefs = new Vector<ClassRef>();
-
- protected Boolean specifiedExcludeUnlistedClasses;
-
- protected final Vector<Property> properties = new Vector<Property>();
-
- /* global generator definitions, defined elsewhere in model */
- protected final Vector<Generator> generators = new Vector<Generator>();
-
- /* global query definitions, defined elsewhere in model */
- protected final Vector<Query> queries = new Vector<Query>();
-
- protected final Set<String> rootEntityNames = Collections.synchronizedSet(new HashSet<String>());
-
- protected AccessType defaultAccess;
- protected String defaultCatalog;
- protected String defaultSchema;
- protected boolean defaultCascadePersist;
- protected boolean defaultDelimitedIdentifiers;
-
- //****** PersistenceUnit2_0 features
- protected PersistenceUnitProperties connection;
- protected PersistenceUnitProperties options;
-
- protected SharedCacheMode specifiedSharedCacheMode;
- protected SharedCacheMode defaultSharedCacheMode;
-
- protected ValidationMode specifiedValidationMode;
- protected ValidationMode defaultValidationMode;
-
- protected final Set<IFile> metamodelFiles = Collections.synchronizedSet(new HashSet<IFile>());
-
-
- // ********** construction/initialization **********
-
- /**
- * NB: Be careful changing the order of the statements in this method
- * (bug 258701 is one reason).
- */
- protected AbstractPersistenceUnit(Persistence parent, XmlPersistenceUnit xmlPersistenceUnit) {
- super(parent);
- this.xmlPersistenceUnit = xmlPersistenceUnit;
- this.name = xmlPersistenceUnit.getName();
- this.specifiedExcludeUnlistedClasses = xmlPersistenceUnit.getExcludeUnlistedClasses();
- this.specifiedTransactionType = this.buildSpecifiedTransactionType();
- this.defaultTransactionType = this.buildDefaultTransactionType();
- this.description = xmlPersistenceUnit.getDescription();
- this.provider = xmlPersistenceUnit.getProvider();
- this.jtaDataSource = xmlPersistenceUnit.getJtaDataSource();
- this.nonJtaDataSource = xmlPersistenceUnit.getNonJtaDataSource();
- this.specifiedExcludeUnlistedClasses = xmlPersistenceUnit.getExcludeUnlistedClasses();
-
- // initialize the properties before building the entities because the
- // entities will need the properties
- this.initializeProperties();
-
- this.initializeJarFileRefs();
-
- //initialize specified classRefs before mappingFileRefs because of
- //JpaFile rootStructureNode, we want the mapping file to "win",
- //as it would in a Jpa runtime implementation
- this.initializeSpecifiedClassRefs();
- this.initializeMappingFileRefs();
- //initialize implied classRefs last since they depend on both
- //specified classRefs and mappingFileRefs
- this.initializeImpliedClassRefs();
- this.initializePersistenceUnitDefaults();
-
- this.specifiedSharedCacheMode = this.buildSpecifiedSharedCacheMode();
- this.defaultSharedCacheMode = this.buildDefaultSharedCacheMode();
-
- this.specifiedValidationMode = this.buildSpecifiedValidationMode();
- this.defaultValidationMode = this.buildDefaultValidationMode();
-
- this.initializeMetamodelFiles();
- }
-
- /**
- * These lists are just copies of what is distributed across the context
- * model; so, if they have (virtually) changed, the resulting update has
- * already been triggered. We don't need to trigger another one here.
- */
- @Override
- protected void addNonUpdateAspectNamesTo(Set<String> nonUpdateAspectNames) {
- super.addNonUpdateAspectNamesTo(nonUpdateAspectNames);
- nonUpdateAspectNames.add(GENERATORS_LIST);
- nonUpdateAspectNames.add(QUERIES_LIST);
- }
-
-
- // ********** updating **********
-
- public void update(XmlPersistenceUnit xpu) {
- this.xmlPersistenceUnit = xpu;
-
- // the 'generators' and 'queries' lists are simply cleared out with each
- // "update" and completely rebuilt as the "update" cascades through
- // the persistence unit. When the persistence unit's "update" is
- // complete, the lists have been populated and we fire the change event.
- // @see #addGenerator(Generator) (and references)
- // @see #addQuery(Query) (and references)
- // see bug 311093 before attempting to change how this works
- this.generators.clear();
- this.queries.clear();
-
- this.rootEntityNames.clear();
-
- this.setName(xpu.getName());
- this.setSpecifiedTransactionType(this.buildSpecifiedTransactionType());
- this.setDefaultTransactionType(this.buildDefaultTransactionType());
- this.setDescription(xpu.getDescription());
- this.setProvider(xpu.getProvider());
- this.setJtaDataSource(xpu.getJtaDataSource());
- this.setNonJtaDataSource(xpu.getNonJtaDataSource());
- this.updateJarFileRefs();
-
- // update 'specifiedClassRefs' before 'mappingFileRefs' because of
- // JpaFile rootStructureNode, we want the mapping file to "win",
- // as it would in a JPA runtime implementation
- this.updateSpecifiedClassRefs();
- this.updateMappingFileRefs();
-
- // update 'impliedClassRefs' last since it depends on the contents of
- // both 'specifiedClassRefs' and 'mappingFileRefs'
- this.updateImpliedClassRefs();
-
- this.setSpecifiedExcludeUnlistedClasses(xpu.getExcludeUnlistedClasses());
- this.updateProperties();
- this.updatePersistenceUnitDefaults();
-
- this.setSpecifiedSharedCacheMode_(this.buildSpecifiedSharedCacheMode());
- this.setDefaultSharedCacheMode(this.buildDefaultSharedCacheMode());
- this.setSpecifiedValidationMode(this.buildSpecifiedValidationMode());
- this.setDefaultValidationMode(this.buildDefaultValidationMode());
-
- // see comment at top of method
- this.fireListChanged(GENERATORS_LIST, this.generators);
- this.fireListChanged(QUERIES_LIST, this.queries);
- }
-
- @Override
- public void postUpdate() {
- super.postUpdate();
- for (ClassRef classRef : this.getSpecifiedClassRefs()) {
- classRef.postUpdate();
- }
- for (ClassRef classRef : this.getImpliedClassRefs()) {
- classRef.postUpdate();
- }
- for (MappingFileRef mappingFileRef : CollectionTools.iterable(this.specifiedMappingFileRefs())) {
- mappingFileRef.postUpdate();
- }
- if (this.impliedMappingFileRef != null) {
- this.impliedMappingFileRef.postUpdate();
- }
- }
-
-
- // ********** JpaContextNode implementation **********
-
- @Override
- public Persistence getParent() {
- return (Persistence) super.getParent();
- }
-
- @Override
- public PersistenceUnit getPersistenceUnit() {
- return this;
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return PersistenceStructureNodes.PERSISTENCE_UNIT_ID;
- }
-
- public TextRange getSelectionTextRange() {
- return this.xmlPersistenceUnit.getSelectionTextRange();
- }
-
- public void dispose() {
- for (ClassRef classRef : this.getClassRefs()) {
- classRef.dispose();
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- mappingFileRef.dispose();
- }
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- String old = this.name;
- this.name = name;
- this.xmlPersistenceUnit.setName(name);
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
-
- // ********** transaction type **********
-
- public PersistenceUnitTransactionType getTransactionType() {
- return (this.specifiedTransactionType != null) ? this.specifiedTransactionType : this.defaultTransactionType;
- }
-
- public PersistenceUnitTransactionType getSpecifiedTransactionType() {
- return this.specifiedTransactionType;
- }
-
- public void setSpecifiedTransactionType(PersistenceUnitTransactionType specifiedTransactionType) {
- PersistenceUnitTransactionType old = this.specifiedTransactionType;
- this.specifiedTransactionType = specifiedTransactionType;
- this.xmlPersistenceUnit.setTransactionType(PersistenceUnitTransactionType.toXmlResourceModel(specifiedTransactionType));
- this.firePropertyChanged(SPECIFIED_TRANSACTION_TYPE_PROPERTY, old, specifiedTransactionType);
- }
-
- public PersistenceUnitTransactionType getDefaultTransactionType() {
- return this.defaultTransactionType;
- }
-
- protected void setDefaultTransactionType(PersistenceUnitTransactionType defaultTransactionType) {
- PersistenceUnitTransactionType old = this.defaultTransactionType;
- this.defaultTransactionType = defaultTransactionType;
- this.firePropertyChanged(DEFAULT_TRANSACTION_TYPE_PROPERTY, old, defaultTransactionType);
- }
-
- protected PersistenceUnitTransactionType buildSpecifiedTransactionType() {
- return PersistenceUnitTransactionType.fromXmlResourceModel(this.xmlPersistenceUnit.getTransactionType());
- }
-
- /**
- * TODO - calculate default
- * From the JPA spec: "In a Java EE environment, if this element is not
- * specified, the default is JTA. In a Java SE environment, if this element
- * is not specified, a default of RESOURCE_LOCAL may be assumed."
- */
- protected PersistenceUnitTransactionType buildDefaultTransactionType() {
- return PersistenceUnitTransactionType.JTA; //return JTA for now, fixing regression in bug 277524
- }
-
-
- // ********** description **********
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- String old = this.description;
- this.description = description;
- this.xmlPersistenceUnit.setDescription(description);
- this.firePropertyChanged(DESCRIPTION_PROPERTY, old, description);
- }
-
-
- // ********** provider **********
-
- public String getProvider() {
- return this.provider;
- }
-
- public void setProvider(String provider) {
- String old = this.provider;
- this.provider = provider;
- this.xmlPersistenceUnit.setProvider(provider);
- this.firePropertyChanged(PROVIDER_PROPERTY, old, provider);
- }
-
-
- // ********** JTA/non-JTA data source **********
-
- public String getJtaDataSource() {
- return this.jtaDataSource;
- }
-
- public void setJtaDataSource(String jtaDataSource) {
- String old = this.jtaDataSource;
- this.jtaDataSource = jtaDataSource;
- this.xmlPersistenceUnit.setJtaDataSource(jtaDataSource);
- this.firePropertyChanged(JTA_DATA_SOURCE_PROPERTY, old, jtaDataSource);
- }
-
- public String getNonJtaDataSource() {
- return this.nonJtaDataSource;
- }
-
- public void setNonJtaDataSource(String nonJtaDataSource) {
- String old = this.nonJtaDataSource;
- this.nonJtaDataSource = nonJtaDataSource;
- this.xmlPersistenceUnit.setNonJtaDataSource(nonJtaDataSource);
- this.firePropertyChanged(NON_JTA_DATA_SOURCE_PROPERTY, old, nonJtaDataSource);
- }
-
-
- // ********** mapping file refs **********
-
- public ListIterator<MappingFileRef> mappingFileRefs() {
- return this.getMappingFileRefs().iterator();
- }
-
- protected ListIterable<MappingFileRef> getMappingFileRefs() {
- return (this.impliedMappingFileRef == null) ? this.getSpecifiedMappingFileRefs() : this.getCombinedMappingFileRefs();
- }
-
- protected ListIterator<MappingFileRef> combinedMappingFileRefs() {
- return getCombinedMappingFileRefs().iterator();
- }
-
- protected ListIterable<MappingFileRef> getCombinedMappingFileRefs() {
- return new CompositeListIterable<MappingFileRef>(this.getSpecifiedMappingFileRefs(), this.impliedMappingFileRef);
- }
-
- public int mappingFileRefsSize() {
- return (this.impliedMappingFileRef == null) ? this.specifiedMappingFileRefsSize() : this.combinedMappingFileRefsSize();
- }
-
- protected int combinedMappingFileRefsSize() {
- return this.specifiedMappingFileRefsSize() + 1;
- }
-
- public Iterator<MappingFileRef> mappingFileRefsContaining(final String typeName) {
- return new FilteringIterator<MappingFileRef> (this.mappingFileRefs()) {
- @Override
- protected boolean accept(MappingFileRef mappingFileRef) {
- return mappingFileRef.getPersistentType(typeName) != null;
- }
- };
- }
-
- protected void initializeMappingFileRefs() {
- for (XmlMappingFileRef xmlMappingFileRef : this.xmlPersistenceUnit.getMappingFiles()) {
- this.specifiedMappingFileRefs.add(this.buildSpecifiedMappingFileRef(xmlMappingFileRef));
- }
- if ( ! this.impliedMappingFileIsSpecified() && this.impliedMappingFileExists()) {
- this.impliedMappingFileRef = this.buildImpliedMappingFileRef();
- }
- }
-
- /**
- * Since this is a *list*, we simply loop through the elements and match
- * the context to the resource element by index, not by name like we do
- * with 'impliedClassRefs'.
- */
- protected void updateMappingFileRefs() {
- // first update the specified mapping file refs...
- // make a copy of the XML file refs (to prevent ConcurrentModificationException)
- Iterator<XmlMappingFileRef> xmlFileRefs = new CloneIterator<XmlMappingFileRef>(this.xmlPersistenceUnit.getMappingFiles());
-
- for (Iterator<MappingFileRef> contextFileRefs = this.specifiedMappingFileRefs(); contextFileRefs.hasNext(); ) {
- MappingFileRef contextFileRef = contextFileRefs.next();
- if (xmlFileRefs.hasNext()) {
- contextFileRef.update(xmlFileRefs.next());
- } else {
- this.removeSpecifiedMappingFileRef_(contextFileRef);
- }
- }
-
- while (xmlFileRefs.hasNext()) {
- this.addSpecifiedMappingFileRef_(this.buildSpecifiedMappingFileRef(xmlFileRefs.next()));
- }
-
- // ...then update the implied mapping file ref
- if (this.impliedMappingFileIsSpecified()) {
- if (this.impliedMappingFileRef != null) {
- this.unsetImpliedMappingFileRef();
- }
- } else {
- if (this.impliedMappingFileExists()) {
- if (this.impliedMappingFileRef == null) {
- this.setImpliedMappingFileRef();
- }
- this.impliedMappingFileRef.update(null);
- } else {
- if (this.impliedMappingFileRef != null) {
- this.unsetImpliedMappingFileRef();
- }
- }
- }
- }
-
- protected MappingFileRef buildSpecifiedMappingFileRef(XmlMappingFileRef xmlMappingFileRef) {
- return this.getContextNodeFactory().buildMappingFileRef(this, xmlMappingFileRef);
- }
-
- protected boolean impliedMappingFileIsSpecified() {
- String impliedMappingFileName = JptCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString();
- for (Iterator<MappingFileRef> stream = this.specifiedMappingFileRefs(); stream.hasNext(); ) {
- if (impliedMappingFileName.equals(stream.next().getFileName())) {
- return true;
- }
- }
- return false;
- }
-
- protected boolean impliedMappingFileExists() {
- return getJpaProject().getDefaultOrmXmlResource() != null;
- }
-
-
- // ********** specified mapping file refs **********
-
- public ListIterator<MappingFileRef> specifiedMappingFileRefs() {
- return this.getSpecifiedMappingFileRefs().iterator();
- }
-
- protected ListIterable<MappingFileRef> getSpecifiedMappingFileRefs() {
- return new LiveCloneListIterable<MappingFileRef>(this.specifiedMappingFileRefs);
- }
-
- public int specifiedMappingFileRefsSize() {
- return this.specifiedMappingFileRefs.size();
- }
-
- public MappingFileRef addSpecifiedMappingFileRef(String fileName) {
- return this.addSpecifiedMappingFileRef(fileName, this.specifiedMappingFileRefs.size());
- }
-
- public MappingFileRef addSpecifiedMappingFileRef(String fileName, int index) {
- XmlMappingFileRef xmlMappingFileRef = this.buildXmlMappingFileRef(fileName);
- MappingFileRef mappingFileRef = this.buildSpecifiedMappingFileRef(xmlMappingFileRef);
- this.specifiedMappingFileRefs.add(index, mappingFileRef);
- this.xmlPersistenceUnit.getMappingFiles().add(index, xmlMappingFileRef);
- this.fireItemAdded(SPECIFIED_MAPPING_FILE_REFS_LIST, index, mappingFileRef);
- return mappingFileRef;
- }
-
- protected XmlMappingFileRef buildXmlMappingFileRef(String fileName) {
- XmlMappingFileRef mappingFileRef = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- mappingFileRef.setFileName(fileName);
- return mappingFileRef;
- }
-
- public void removeSpecifiedMappingFileRef(MappingFileRef mappingFileRef) {
- this.removeSpecifiedMappingFileRef(this.specifiedMappingFileRefs.indexOf(mappingFileRef));
- }
-
- public void removeSpecifiedMappingFileRef(int index) {
- MappingFileRef mappingFileRef = this.specifiedMappingFileRefs.remove(index);
- mappingFileRef.dispose();
- this.xmlPersistenceUnit.getMappingFiles().remove(index);
- this.fireItemRemoved(SPECIFIED_MAPPING_FILE_REFS_LIST, index, mappingFileRef);
- }
-
- protected void addSpecifiedMappingFileRef_(MappingFileRef mappingFileRef) {
- this.addItemToList(mappingFileRef, this.specifiedMappingFileRefs, SPECIFIED_MAPPING_FILE_REFS_LIST);
- }
-
- protected void removeSpecifiedMappingFileRef_(MappingFileRef mappingFileRef) {
- mappingFileRef.dispose();
- this.removeItemFromList(mappingFileRef, this.specifiedMappingFileRefs, SPECIFIED_MAPPING_FILE_REFS_LIST);
- }
-
-
- // ********** implied mapping file ref **********
-
- public MappingFileRef getImpliedMappingFileRef() {
- return this.impliedMappingFileRef;
- }
-
- protected MappingFileRef setImpliedMappingFileRef() {
- if (this.impliedMappingFileRef != null) {
- throw new IllegalStateException("The implied mapping file ref is already set."); //$NON-NLS-1$
- }
- this.impliedMappingFileRef = this.buildImpliedMappingFileRef();
- this.firePropertyChanged(IMPLIED_MAPPING_FILE_REF_PROPERTY, null, this.impliedMappingFileRef);
- return this.impliedMappingFileRef;
- }
-
- protected MappingFileRef buildImpliedMappingFileRef() {
- return this.getContextNodeFactory().buildImpliedMappingFileRef(this);
- }
-
- protected void unsetImpliedMappingFileRef() {
- if (this.impliedMappingFileRef == null) {
- throw new IllegalStateException("The implied mapping file ref is already unset."); //$NON-NLS-1$
- }
- MappingFileRef old = this.impliedMappingFileRef;
- this.impliedMappingFileRef.dispose();
- this.impliedMappingFileRef = null;
- this.firePropertyChanged(IMPLIED_MAPPING_FILE_REF_PROPERTY, old, null);
- }
-
-
- // ********** JAR file refs **********
-
- public ListIterator<JarFileRef> jarFileRefs() {
- return new CloneListIterator<JarFileRef>(this.jarFileRefs);
- }
-
- protected Iterable<JarFileRef> getJarFileRefs() {
- return new LiveCloneIterable<JarFileRef>(this.jarFileRefs);
- }
-
- public int jarFileRefsSize() {
- return this.jarFileRefs.size();
- }
-
- public JarFileRef addJarFileRef(String fileName) {
- return this.addJarFileRef(fileName, this.jarFileRefs.size());
- }
-
- public JarFileRef addJarFileRef(String fileName, int index) {
- XmlJarFileRef xmlJarFileRef = this.buildXmlJarFileRef(fileName);
- JarFileRef jarFileRef = this.buildJarFileRef(xmlJarFileRef);
- this.jarFileRefs.add(index, jarFileRef);
- this.xmlPersistenceUnit.getJarFiles().add(index, xmlJarFileRef);
- this.fireItemAdded(JAR_FILE_REFS_LIST, index, jarFileRef);
- return jarFileRef;
- }
-
- protected XmlJarFileRef buildXmlJarFileRef(String fileName) {
- XmlJarFileRef jarFileRef = PersistenceFactory.eINSTANCE.createXmlJarFileRef();
- jarFileRef.setFileName(fileName);
- return jarFileRef;
- }
-
- public void removeJarFileRef(JarFileRef jarFileRef) {
- this.removeJarFileRef(this.jarFileRefs.indexOf(jarFileRef));
- }
-
- public void removeJarFileRef(int index) {
- JarFileRef jarFileRef = this.jarFileRefs.remove(index);
- jarFileRef.dispose();
- this.xmlPersistenceUnit.getJarFiles().remove(index);
- this.fireItemRemoved(JAR_FILE_REFS_LIST, index, jarFileRef);
- }
-
- protected void addJarFileRef_(JarFileRef jarFileRef) {
- this.addItemToList(jarFileRef, this.jarFileRefs, JAR_FILE_REFS_LIST);
- }
-
- protected void removeJarFileRef_(JarFileRef jarFileRef) {
- jarFileRef.dispose();
- this.removeItemFromList(jarFileRef, this.jarFileRefs, JAR_FILE_REFS_LIST);
- }
-
- protected void initializeJarFileRefs() {
- for (XmlJarFileRef xmlJarFileRef : this.xmlPersistenceUnit.getJarFiles()) {
- this.jarFileRefs.add(this.buildJarFileRef(xmlJarFileRef));
- }
- }
-
- /**
- * Since this is a *list*, we simply loop through the elements and match
- * the context to the resource element by index, not by name like we do
- * with 'impliedClassRefs'.
- */
- protected void updateJarFileRefs() {
- // make a copy of the XML file refs (to prevent ConcurrentModificationException)
- Iterator<XmlJarFileRef> xmlFileRefs = new CloneIterator<XmlJarFileRef>(this.xmlPersistenceUnit.getJarFiles());
-
- for (Iterator<JarFileRef> contextFileRefs = this.jarFileRefs(); contextFileRefs.hasNext(); ) {
- JarFileRef contextFileRef = contextFileRefs.next();
- if (xmlFileRefs.hasNext()) {
- contextFileRef.update(xmlFileRefs.next());
- } else {
- this.removeJarFileRef_(contextFileRef);
- }
- }
-
- while (xmlFileRefs.hasNext()) {
- this.addJarFileRef_(this.buildJarFileRef(xmlFileRefs.next()));
- }
- }
-
- protected JarFileRef buildJarFileRef(XmlJarFileRef xmlJarFileRef) {
- return this.getContextNodeFactory().buildJarFileRef(this, xmlJarFileRef);
- }
-
-
- // ********** class refs **********
-
- public Iterator<ClassRef> classRefs() {
- return this.getClassRefs().iterator();
- }
-
- @SuppressWarnings("unchecked")
- protected Iterable<ClassRef> getClassRefs() {
- return new CompositeIterable<ClassRef>(
- this.getSpecifiedClassRefs(),
- this.getImpliedClassRefs()
- );
- }
-
- public int classRefsSize() {
- return this.specifiedClassRefs.size() + this.impliedClassRefs.size();
- }
-
- protected Iterable<PersistentType> getNonNullClassRefPersistentTypes() {
- return new FilteringIterable<PersistentType>(this.getClassRefPersistentTypes(), NotNullFilter.<PersistentType>instance());
- }
-
- protected Iterable<PersistentType> getClassRefPersistentTypes() {
- return new TransformationIterable<ClassRef, PersistentType>(this.getClassRefs()) {
- @Override
- protected PersistentType transform(ClassRef classRef) {
- return classRef.getJavaPersistentType();
- }
- };
- }
-
-
- // ********** specified class refs **********
-
- public ListIterator<ClassRef> specifiedClassRefs() {
- return new CloneListIterator<ClassRef>(this.specifiedClassRefs);
- }
-
- protected Iterable<ClassRef> getSpecifiedClassRefs() {
- return new LiveCloneIterable<ClassRef>(this.specifiedClassRefs);
- }
-
- public int specifiedClassRefsSize() {
- return this.specifiedClassRefs.size();
- }
-
- public ClassRef addSpecifiedClassRef(String className) {
- return this.addSpecifiedClassRef(className, this.specifiedClassRefs.size());
- }
-
- public ClassRef addSpecifiedClassRef(String className, int index) {
- XmlJavaClassRef xmlClassRef = this.buildXmlJavaClassRef(className);
- ClassRef classRef = this.buildClassRef(xmlClassRef);
- this.specifiedClassRefs.add(index, classRef);
- this.xmlPersistenceUnit.getClasses().add(index, xmlClassRef);
- this.fireItemAdded(SPECIFIED_CLASS_REFS_LIST, index, classRef);
- return classRef;
- }
-
- protected XmlJavaClassRef buildXmlJavaClassRef(String className) {
- XmlJavaClassRef xmlClassRef = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- xmlClassRef.setJavaClass(className);
- return xmlClassRef;
- }
-
- public void removeSpecifiedClassRef(ClassRef classRef) {
- this.removeSpecifiedClassRef(this.specifiedClassRefs.indexOf(classRef));
- }
-
- public void removeSpecifiedClassRef(int index) {
- ClassRef classRef = this.specifiedClassRefs.remove(index);
- classRef.dispose();
- this.xmlPersistenceUnit.getClasses().remove(index);
- this.fireItemRemoved(SPECIFIED_CLASS_REFS_LIST, index, classRef);
- }
-
- protected void addSpecifiedClassRef_(int index, ClassRef classRef) {
- this.addItemToList(index, classRef, this.specifiedClassRefs, SPECIFIED_CLASS_REFS_LIST);
- }
-
- protected void removeSpecifiedClassRef_(ClassRef classRef) {
- classRef.dispose();
- this.removeItemFromList(classRef, this.specifiedClassRefs, SPECIFIED_CLASS_REFS_LIST);
- }
-
- private void moveSpecifiedClassRef_(int index, ClassRef classRef) {
- this.moveItemInList(index, this.specifiedClassRefs.indexOf(classRef), this.specifiedClassRefs, SPECIFIED_CLASS_REFS_LIST);
- }
-
- protected void initializeSpecifiedClassRefs() {
- for (XmlJavaClassRef xmlJavaClassRef : this.xmlPersistenceUnit.getClasses()) {
- this.specifiedClassRefs.add(this.buildClassRef(xmlJavaClassRef));
- }
- }
-
- /**
- * Since this is a *list*, we simply loop through the elements and match
- * the context to the resource element by index, not by name like we do
- * with 'impliedClassRefs'.
- */
- protected void updateSpecifiedClassRefs() {
- HashBag<ClassRef> contextClassRefsToRemove = CollectionTools.bag(this.specifiedClassRefs(), this.specifiedClassRefsSize());
- ArrayList<ClassRef> contextClassRefsToUpdate = new ArrayList<ClassRef>(this.specifiedClassRefsSize());
- int resourceIndex = 0;
-
- for (Iterator<XmlJavaClassRef> xmlClassRefs = new CloneIterator<XmlJavaClassRef>(this.xmlPersistenceUnit.getClasses()); xmlClassRefs.hasNext(); ) {
- XmlJavaClassRef resourceClassRef = xmlClassRefs.next();
- boolean match = false;
- for (Iterator<ClassRef> contextClassRefs = contextClassRefsToRemove.iterator(); contextClassRefs.hasNext(); ) {
- ClassRef contextClassRef = contextClassRefs.next();
- if (contextClassRef.getResourceClassRef() == resourceClassRef) {
- this.moveSpecifiedClassRef_(resourceIndex, contextClassRef);
- contextClassRefs.remove();
- contextClassRefsToUpdate.add(contextClassRef);
- match = true;
- break;
- }
- }
- if ( ! match) {
- this.addSpecifiedClassRef_(resourceIndex, this.buildClassRef(resourceClassRef));
- }
- resourceIndex++;
- }
- for (ClassRef contextClassRef : contextClassRefsToRemove) {
- this.removeSpecifiedClassRef_(contextClassRef);
- }
- // handle adding and removing class refs first, update the
- // remaining class refs last; this reduces the churn during "update"
- for (ClassRef contextClassRef : contextClassRefsToUpdate) {
- contextClassRef.update();
- }
- }
-
- protected ClassRef buildClassRef(XmlJavaClassRef xmlClassRef) {
- return this.getContextNodeFactory().buildClassRef(this, xmlClassRef);
- }
-
-
- // ********** implied class refs **********
-
- public Iterator<ClassRef> impliedClassRefs() {
- return new CloneIterator<ClassRef>(this.impliedClassRefs);
- }
-
- protected Iterable<ClassRef> getImpliedClassRefs() {
- return new LiveCloneIterable<ClassRef>(this.impliedClassRefs);
- }
-
- public int impliedClassRefsSize() {
- return this.impliedClassRefs.size();
- }
-
- protected ClassRef addImpliedClassRef(String className) {
- ClassRef classRef = this.buildClassRef(className);
- this.addItemToCollection(classRef, this.impliedClassRefs, IMPLIED_CLASS_REFS_COLLECTION);
- return classRef;
- }
-
- protected ClassRef buildClassRef(String className) {
- return this.getContextNodeFactory().buildClassRef(this, className);
- }
-
- protected void removeImpliedClassRef(ClassRef classRef) {
- classRef.dispose();
- this.removeItemFromCollection(classRef, this.impliedClassRefs, IMPLIED_CLASS_REFS_COLLECTION);
- }
-
- protected void initializeImpliedClassRefs() {
- if ( ! this.excludesUnlistedClasses()) {
- this.initializeImpliedClassRefs_();
- }
- }
-
- protected void initializeImpliedClassRefs_() {
- for (String typeName : this.getJpaProject().getMappedJavaSourceClassNames()) {
- if ( ! this.specifiesPersistentType(typeName)) {
- this.impliedClassRefs.add(this.buildClassRef(typeName));
- }
- }
- }
-
- protected void updateImpliedClassRefs() {
- if (this.excludesUnlistedClasses()) {
- this.clearImpliedClassRefs_();
- } else {
- this.updateImpliedClassRefs_();
- }
- }
-
- protected void updateImpliedClassRefs_() {
- HashBag<ClassRef> impliedRefsToRemove = CollectionTools.bag(this.impliedClassRefs(), this.impliedClassRefsSize());
- ArrayList<ClassRef> impliedRefsToUpdate = new ArrayList<ClassRef>(this.impliedClassRefsSize());
-
- for (String mappedClassName : this.getJpaProject().getMappedJavaSourceClassNames()) {
- if ( ! this.specifiesPersistentType(mappedClassName)) {
- boolean match = false;
- for (Iterator<ClassRef> classRefs = impliedRefsToRemove.iterator(); classRefs.hasNext(); ) {
- ClassRef classRef = classRefs.next();
- if (mappedClassName.equals(classRef.getClassName())) {
- classRefs.remove();
- impliedRefsToUpdate.add(classRef);
- match = true;
- break;
- }
- }
- if ( ! match) {
- this.addImpliedClassRef(mappedClassName);
- }
- }
- }
- for (ClassRef classRef : impliedRefsToRemove) {
- this.removeImpliedClassRef(classRef);
- }
- // handle adding and removing implied class refs first, update the
- // remaining implied class refs last; this reduces the churn during "update"
- for (ClassRef classRef : impliedRefsToUpdate) {
- classRef.update(classRef.getClassName());
- }
- }
-
- protected void clearImpliedClassRefs_() {
- for (ClassRef classRef : this.getImpliedClassRefs()) {
- this.removeImpliedClassRef(classRef);
- }
- }
-
-
- // ********** exclude unlisted classes **********
-
- public boolean excludesUnlistedClasses() {
- return (this.specifiedExcludeUnlistedClasses != null) ? this.specifiedExcludeUnlistedClasses.booleanValue() : this.getDefaultExcludeUnlistedClasses();
- }
-
- public Boolean getSpecifiedExcludeUnlistedClasses() {
- return this.specifiedExcludeUnlistedClasses;
- }
-
- public void setSpecifiedExcludeUnlistedClasses(Boolean specifiedExcludeUnlistedClasses) {
- Boolean old = this.specifiedExcludeUnlistedClasses;
- this.specifiedExcludeUnlistedClasses = specifiedExcludeUnlistedClasses;
- this.xmlPersistenceUnit.setExcludeUnlistedClasses(this.specifiedExcludeUnlistedClasses);
- this.firePropertyChanged(SPECIFIED_EXCLUDE_UNLISTED_CLASSES_PROPERTY, old, specifiedExcludeUnlistedClasses);
- }
-
- public boolean getDefaultExcludeUnlistedClasses() {
- return false; // ???
- }
-
-
- // ********** properties **********
-
- public ListIterator<Property> properties() {
- return new CloneListIterator<Property>(this.properties);
- }
-
- protected Iterable<Property> getProperties() {
- return new LiveCloneIterable<Property>(this.properties);
- }
-
- public int propertiesSize() {
- return this.properties.size();
- }
-
- public Property getProperty(String propertyName) {
- if (propertyName == null) {
- throw new NullPointerException();
- }
- for (Property property : this.getProperties()) {
- if (propertyName.equals(property.getName())) {
- return property;
- }
- }
- return null;
- }
-
- public Iterable<Property> getPropertiesNamed(final String propertyName) {
- if (propertyName == null) {
- throw new NullPointerException();
- }
- return new FilteringIterable<Property>(this.getProperties()) {
- @Override
- protected boolean accept(Property property) {
- String pName = property.getName();
- return (pName != null) && pName.equals(propertyName);
- }
- };
- }
-
- public Iterator<Property> propertiesWithNamePrefix(final String propertyNamePrefix) {
- if (propertyNamePrefix == null) {
- throw new NullPointerException();
- }
- return new FilteringIterator<Property>(this.properties()) {
- @Override
- protected boolean accept(Property property) {
- String pName = property.getName();
- return (pName != null) && pName.startsWith(propertyNamePrefix);
- }
- };
- }
-
- public Property addProperty() {
- return this.addProperty(this.properties.size());
- }
-
- public Property addProperty(int index) {
- return this.addProperty(this.buildXmlProperty(), index);
- }
-
- protected XmlProperty buildXmlProperty() {
- return PersistenceFactory.eINSTANCE.createXmlProperty();
- }
-
- protected Property addProperty(XmlProperty xmlProperty, int index) {
- Property property = this.buildProperty(xmlProperty);
-
- XmlProperties xmlProperties = this.xmlPersistenceUnit.getProperties();
- if (xmlProperties == null) {
- xmlProperties = this.buildXmlProperties();
- this.xmlPersistenceUnit.setProperties(xmlProperties);
- }
-
- this.properties.add(index, property);
- xmlProperties.getProperties().add(index, xmlProperty);
- this.fireItemAdded(PROPERTIES_LIST, index, property);
- if (property.getName() != null) {
- this.propertyAdded(property.getName(), property.getValue());
- }
- return property;
- }
-
- protected Property buildProperty(XmlProperty xmlProperty) {
- return this.getContextNodeFactory().buildProperty(this, xmlProperty);
- }
-
- protected XmlProperties buildXmlProperties() {
- return PersistenceFactory.eINSTANCE.createXmlProperties();
- }
-
- public void setProperty(String propertyName, String value) {
- this.setProperty(propertyName, value, false);
- }
-
- public void setProperty(String propertyName, String value, boolean duplicatePropertyNamesAllowed) {
- Property prev = this.getProperty(propertyName);
- if (prev == null) {
- if (value != null) {
- this.addProperty(propertyName, value); // add [first] property
- }
- } else {
- if (duplicatePropertyNamesAllowed) {
- if (value == null) {
- // do nothing?
- } else {
- this.addProperty(propertyName, value); // add [duplicate] property
- }
- } else {
- if (value == null) {
- this.removeProperty(prev); // remove existing property
- } else {
- prev.setValue(value); // change existing property
- }
- }
- }
- }
-
- protected void addProperty(String propertyName, String value) {
- Property property = this.addProperty();
- property.setName(propertyName);
- property.setValue(value);
- }
-
- public void removeProperty(Property property) {
- this.removeProperty(this.properties.indexOf(property));
- }
-
- public void removeProperty(String propertyName) {
- if (propertyName == null) {
- throw new NullPointerException();
- }
- for (ListIterator<Property> stream = this.properties.listIterator(); stream.hasNext(); ) {
- Property property = stream.next();
- if (propertyName.equals(property.getName())) {
- this.removeProperty(stream.previousIndex());
- return;
- }
- }
- throw new IllegalArgumentException("invalid property name: " + propertyName); //$NON-NLS-1$
- }
-
- public void removeProperty(String propertyName, String value) {
- if ((propertyName == null) || (value == null)) {
- throw new NullPointerException();
- }
- for (ListIterator<Property> stream = this.properties.listIterator(); stream.hasNext(); ) {
- Property property = stream.next();
- if (propertyName.equals(property.getName()) && value.equals(property.getValue())) {
- this.removeProperty(stream.previousIndex());
- return;
- }
- }
- throw new IllegalArgumentException("invalid property name/value pair: " + propertyName + " = " + value); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected void removeProperty(int index) {
- Property removedProperty = this.properties.remove(index);
- this.xmlPersistenceUnit.getProperties().getProperties().remove(index);
-
- if (this.xmlPersistenceUnit.getProperties().getProperties().isEmpty()) {
- this.xmlPersistenceUnit.setProperties(null);
- }
-
- this.fireItemRemoved(PROPERTIES_LIST, index, removedProperty);
- if (removedProperty.getName() != null) {
- this.propertyRemoved(removedProperty.getName());
- }
- }
-
- protected void addProperty_(int index, Property property) {
- this.addItemToList(index, property, this.properties, PROPERTIES_LIST);
- if (property.getName() != null) {
- this.propertyAdded(property.getName(), property.getValue());
- }
- }
-
- protected void removeProperty_(int index) {
- removeProperty_(this.properties.get(index));
- }
-
- protected void removeProperty_(Property property) {
- this.removeItemFromList(property, this.properties, PROPERTIES_LIST);
- if (property.getName() != null) {
- this.propertyRemoved(property.getName());
- }
- }
-
- protected void moveProperty_(int index, Property property) {
- this.moveItemInList(index, this.properties.indexOf(property), this.properties, PROPERTIES_LIST);
- }
-
- public void propertyNameChanged(String oldPropertyName, String newPropertyName, String value) {
- if (oldPropertyName == null && value == null) {
- //this is a property that is currently being added, we don't need to deal with it until the value is set
- return;
- }
- if (oldPropertyName != null) {
- this.propertyRemoved(oldPropertyName);
- }
- if (newPropertyName != null) {
- this.propertyAdded(newPropertyName, value);
- }
- }
-
- public void propertyValueChanged(String propertyName, String newValue) {
- this.connection.propertyValueChanged(propertyName, newValue);
- this.options.propertyValueChanged(propertyName, newValue);
- }
-
- public void propertyAdded(String propertyName, String value) {
- this.propertyValueChanged(propertyName, value);
- }
-
- public void propertyRemoved(String propertyName) {
- this.connection.propertyRemoved(propertyName);
- this.options.propertyRemoved(propertyName);
- }
-
- protected void initializeProperties() {
- XmlProperties xmlProperties = this.xmlPersistenceUnit.getProperties();
- if (xmlProperties != null) {
- for (XmlProperty xmlProperty : xmlProperties.getProperties()) {
- this.properties.add(this.buildProperty(xmlProperty));
- }
- }
- this.connection = this.getContextNodeFactory().buildConnection(this);
- this.options = this.getContextNodeFactory().buildOptions(this);
- }
-
- /**
- * Match the elements based on the XmlProperty resource object and also keep the order
- * the same as the source.
- */
- protected void updateProperties() {
- HashBag<Property> contextPropertiesToRemove = CollectionTools.bag(this.properties(), this.propertiesSize());
- int resourceIndex = 0;
-
- for (Iterator<XmlProperty> xmlProperties = this.xmlProperties(); xmlProperties.hasNext(); ) {
- XmlProperty xmlProperty = xmlProperties.next();
- boolean match = false;
- for (Iterator<Property> contextProperties = contextPropertiesToRemove.iterator(); contextProperties.hasNext();) {
- Property contextProperty = contextProperties.next();
- if (contextProperty.getXmlProperty() == xmlProperty) {
- contextProperties.remove();
- this.moveProperty_(resourceIndex, contextProperty);
- contextProperty.update();
- match = true;
- break;
- }
- }
- if ( ! match) {
- this.addProperty_(resourceIndex, this.buildProperty(xmlProperty));
- }
- resourceIndex++;
- }
- for (Property contextProperty : contextPropertiesToRemove) {
- this.removeProperty_(contextProperty);
- }
- }
-
- protected Iterator<XmlProperty> xmlProperties() {
- XmlProperties xmlProperties = this.xmlPersistenceUnit.getProperties();
- // make a copy of the XML properties (to prevent ConcurrentModificationException)
- return (xmlProperties != null) ? new CloneIterator<XmlProperty>(xmlProperties.getProperties()) : EmptyIterator.<XmlProperty>instance();
- }
-
- protected int xmlPropertiesSize() {
- XmlProperties xmlProperties = this.xmlPersistenceUnit.getProperties();
- return xmlProperties == null ? 0 : xmlProperties.getProperties().size();
- }
-
-
- // ********** ORM persistence unit defaults **********
-
- public AccessType getDefaultAccess() {
- return this.defaultAccess;
- }
-
- protected void setDefaultAccess(AccessType defaultAccess) {
- AccessType old = this.defaultAccess;
- this.defaultAccess = defaultAccess;
- this.firePropertyChanged(DEFAULT_ACCESS_PROPERTY, old, defaultAccess);
- }
-
- protected AccessType buildDefaultAccess(MappingFilePersistenceUnitDefaults defaults) {
- return (defaults == null) ? null : defaults.getAccess();
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String defaultCatalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = defaultCatalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, defaultCatalog);
- }
-
- protected String buildDefaultCatalog(MappingFilePersistenceUnitDefaults defaults) {
- String catalog = (defaults == null) ? null : defaults.getCatalog();
- return (catalog != null) ? catalog : this.getJpaProject().getDefaultCatalog();
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String defaultSchema) {
- String old = this.defaultSchema;
- this.defaultSchema = defaultSchema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, defaultSchema);
- }
-
- protected String buildDefaultSchema(MappingFilePersistenceUnitDefaults defaults) {
- String schema = (defaults == null) ? null : defaults.getSchema();
- return (schema != null) ? schema : this.getJpaProject().getDefaultSchema();
- }
-
- public boolean getDefaultCascadePersist() {
- return this.defaultCascadePersist;
- }
-
- protected void setDefaultCascadePersist(boolean defaultCascadePersist) {
- boolean old = this.defaultCascadePersist;
- this.defaultCascadePersist = defaultCascadePersist;
- this.firePropertyChanged(DEFAULT_CASCADE_PERSIST_PROPERTY, old, defaultCascadePersist);
- }
-
- protected boolean buildDefaultCascadePersist(MappingFilePersistenceUnitDefaults defaults) {
- return (defaults == null) ? false : defaults.isCascadePersist();
- }
-
- public boolean getDefaultDelimitedIdentifiers() {
- return this.defaultDelimitedIdentifiers;
- }
-
- protected void setDefaultDelimitedIdentifiers(boolean defaultDelimitedIdentifiers) {
- boolean old = this.defaultDelimitedIdentifiers;
- this.defaultDelimitedIdentifiers = defaultDelimitedIdentifiers;
- this.firePropertyChanged(DEFAULT_DELIMITED_IDENTIFIERS_PROPERTY, old, defaultDelimitedIdentifiers);
- }
-
- protected boolean buildDefaultDelimitedIdentifiers(MappingFilePersistenceUnitDefaults defaults) {
- return ( ! this.isJpa2_0Compatible()) ? false :
- (defaults == null) ? false : ((MappingFilePersistenceUnitDefaults2_0) defaults).isDelimitedIdentifiers();
- }
-
- protected void initializePersistenceUnitDefaults() {
- MappingFilePersistenceUnitDefaults defaults = this.getDefaults();
- this.defaultAccess = this.buildDefaultAccess(defaults);
- this.defaultCatalog = this.buildDefaultCatalog(defaults);
- this.defaultSchema = this.buildDefaultSchema(defaults);
- this.defaultCascadePersist = this.buildDefaultCascadePersist(defaults);
- this.defaultDelimitedIdentifiers = this.buildDefaultDelimitedIdentifiers(defaults);
- }
-
- protected void updatePersistenceUnitDefaults() {
- MappingFilePersistenceUnitDefaults defaults = this.getDefaults();
- this.setDefaultAccess(this.buildDefaultAccess(defaults));
- this.setDefaultCatalog(this.buildDefaultCatalog(defaults));
- this.setDefaultSchema(this.buildDefaultSchema(defaults));
- this.setDefaultDelimitedIdentifiers(this.buildDefaultDelimitedIdentifiers(defaults));
- }
-
- /**
- * return the first persistence unit defaults we encounter in a mapping file
- */
- protected MappingFilePersistenceUnitDefaults getDefaults() {
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.persistenceUnitDefaultsExists()) {
- return mappingFileRef.getPersistenceUnitDefaults();
- }
- }
- return null;
- }
-
-
- //************** PersistenceUnit2_0 implementation ***********
-
- public PersistenceUnitProperties getConnection() {
- return this.connection;
- }
-
- public PersistenceUnitProperties getOptions() {
- return this.options;
- }
-
- // ********** shared cache mode **********
-
- public SharedCacheMode getSharedCacheMode() {
- return (this.specifiedSharedCacheMode != null) ? this.specifiedSharedCacheMode : this.defaultSharedCacheMode;
- }
-
- public SharedCacheMode getSpecifiedSharedCacheMode() {
- return this.specifiedSharedCacheMode;
- }
-
- public void setSpecifiedSharedCacheMode(SharedCacheMode specifiedSharedCacheMode) {
- SharedCacheMode old = this.specifiedSharedCacheMode;
- this.specifiedSharedCacheMode = specifiedSharedCacheMode;
- this.xmlPersistenceUnit.setSharedCacheMode(SharedCacheMode.toXmlResourceModel(specifiedSharedCacheMode));
- this.firePropertyChanged(SPECIFIED_SHARED_CACHE_MODE_PROPERTY, old, specifiedSharedCacheMode);
- }
-
- protected void setSpecifiedSharedCacheMode_(SharedCacheMode specifiedSharedCacheMode) {
- SharedCacheMode old = this.specifiedSharedCacheMode;
- this.specifiedSharedCacheMode = specifiedSharedCacheMode;
- this.firePropertyChanged(SPECIFIED_SHARED_CACHE_MODE_PROPERTY, old, specifiedSharedCacheMode);
- }
-
- public SharedCacheMode getDefaultSharedCacheMode() {
- return this.defaultSharedCacheMode;
- }
-
- protected void setDefaultSharedCacheMode(SharedCacheMode defaultSharedCacheMode) {
- SharedCacheMode old = this.defaultSharedCacheMode;
- this.defaultSharedCacheMode = defaultSharedCacheMode;
- this.firePropertyChanged(DEFAULT_SHARED_CACHE_MODE_PROPERTY, old, defaultSharedCacheMode);
- }
-
- public boolean calculateDefaultCacheable() {
- switch (getSharedCacheMode()) {
- case NONE:
- case ENABLE_SELECTIVE:
- case UNSPECIFIED:
- return false;
- case ALL:
- case DISABLE_SELECTIVE:
- return true;
- }
- return false;//null
- }
-
- protected SharedCacheMode buildSpecifiedSharedCacheMode() {
- return SharedCacheMode.fromXmlResourceModel(this.xmlPersistenceUnit.getSharedCacheMode());
- }
-
- protected SharedCacheMode buildDefaultSharedCacheMode() {
- return SharedCacheMode.UNSPECIFIED;
- }
-
- // ********** validation mode **********
-
- public ValidationMode getValidationMode() {
- return (this.specifiedValidationMode != null) ? this.specifiedValidationMode : this.defaultValidationMode;
- }
-
- public ValidationMode getSpecifiedValidationMode() {
- return this.specifiedValidationMode;
- }
-
- public void setSpecifiedValidationMode(ValidationMode specifiedValidationMode) {
- ValidationMode old = this.specifiedValidationMode;
- this.specifiedValidationMode = specifiedValidationMode;
- this.xmlPersistenceUnit.setValidationMode(ValidationMode.toXmlResourceModel(specifiedValidationMode));
- this.firePropertyChanged(SPECIFIED_VALIDATION_MODE_PROPERTY, old, specifiedValidationMode);
- }
-
- public ValidationMode getDefaultValidationMode() {
- return this.defaultValidationMode;
- }
-
- protected void setDefaultValidationMode(ValidationMode defaultValidationMode) {
- ValidationMode old = this.defaultValidationMode;
- this.defaultValidationMode = defaultValidationMode;
- this.firePropertyChanged(DEFAULT_VALIDATION_MODE_PROPERTY, old, defaultValidationMode);
- }
-
- protected ValidationMode buildSpecifiedValidationMode() {
- return ValidationMode.fromXmlResourceModel(this.xmlPersistenceUnit.getValidationMode());
- }
-
- protected ValidationMode buildDefaultValidationMode() {
- return DEFAULT_VALIDATION_MODE;
- }
-
-
- // ********** generators **********
-
- public ListIterator<Generator> generators() {
- return new CloneListIterator<Generator>(this.generators);
- }
-
- public int generatorsSize() {
- return this.generators.size();
- }
-
- public void addGenerator(Generator generator) {
- this.generators.add(generator);
- }
-
- public String[] uniqueGeneratorNames() {
- HashSet<String> names = new HashSet<String>(this.generators.size());
- this.addNonNullGeneratorNamesTo(names);
- return names.toArray(new String[names.size()]);
- }
-
- protected void addNonNullGeneratorNamesTo(Set<String> names) {
- for (Iterator<Generator> stream = this.generators(); stream.hasNext(); ) {
- String generatorName = stream.next().getName();
- if (generatorName != null) {
- names.add(generatorName);
- }
- }
- }
-
-
- // ********** queries **********
-
- public ListIterator<Query> queries() {
- return new CloneListIterator<Query>(this.queries);
- }
-
- public int queriesSize() {
- return this.queries.size();
- }
-
- public void addQuery(Query query) {
- this.queries.add(query);
- }
-
-
- // ********** root entities **********
-
- public void addRootEntityWithSubEntities(String entityName) {
- this.rootEntityNames.add(entityName);
- }
-
- public boolean entityIsRootWithSubEntities(String entityName) {
- return this.rootEntityNames.contains(entityName);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateMappingFiles(messages, reporter);
- this.validateClassRefs(messages, reporter);
- this.validateJarFileRefs(messages, reporter);
- this.validateProperties(messages, reporter);
- }
-
- protected void validateMappingFiles(List<IMessage> messages, IReporter reporter) {
- this.checkForMultiplePersistenceUnitDefaults(messages);
- this.checkForDuplicateMappingFiles(messages);
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- mappingFileRef.validate(messages, reporter);
- }
- }
-
- protected void checkForMultiplePersistenceUnitDefaults(List<IMessage> messages) {
- boolean first = true;
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.persistenceUnitDefaultsExists()) {
- if (first) {
- first = false;
- } else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_DEFAULTS,
- new String[] {mappingFileRef.getFileName()},
- mappingFileRef
- )
- );
- }
- }
- }
- }
-
- protected void checkForDuplicateMappingFiles(List<IMessage> messages) {
- HashBag<String> fileNames = new HashBag<String>();
- CollectionTools.addAll(fileNames, this.mappingFileRefNames());
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- String fileName = mappingFileRef.getFileName();
- if (fileNames.count(fileName) > 1) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_MAPPING_FILE,
- new String[] {fileName},
- mappingFileRef,
- mappingFileRef.getValidationTextRange()
- )
- );
- }
- }
- }
-
- protected Iterator<String> mappingFileRefNames() {
- return new TransformationIterator<MappingFileRef, String>(this.mappingFileRefs()) {
- @Override
- protected String transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.getFileName();
- }
- };
- }
-
- protected void validateClassRefs(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateClasses(messages);
- for (Iterator<ClassRef> stream = this.classRefs(); stream.hasNext(); ) {
- stream.next().validate(messages, reporter);
- }
- }
-
- protected void checkForDuplicateClasses(List<IMessage> messages) {
- HashBag<String> classNames = new HashBag<String>();
- CollectionTools.addAll(classNames, this.classRefNames());
- for (Iterator<ClassRef> stream = this.classRefs(); stream.hasNext(); ) {
- ClassRef classRef = stream.next();
- String className = classRef.getClassName();
- if ((className != null) && (classNames.count(className) > 1)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS,
- new String[] {className},
- classRef,
- classRef.getValidationTextRange()
- )
- );
- }
- }
- }
-
- protected Iterator<String> classRefNames() {
- return new TransformationIterator<ClassRef, String>(this.classRefs()) {
- @Override
- protected String transform(ClassRef classRef) {
- return classRef.getClassName();
- }
- };
- }
-
- protected void validateJarFileRefs(List<IMessage> messages, IReporter reporter) {
- checkForDuplicateJarFileRefs(messages);
- for (JarFileRef each : CollectionTools.iterable(jarFileRefs())) {
- each.validate(messages, reporter);
- }
- }
-
- protected void checkForDuplicateJarFileRefs(List<IMessage> messages) {
- HashBag<String> jarFileNames = new HashBag<String>();
- CollectionTools.addAll(jarFileNames, jarFileNames());
- for (JarFileRef jarFileRef : CollectionTools.iterable(jarFileRefs())) {
- String jarFileName = jarFileRef.getFileName();
- if ((jarFileName != null) && (jarFileNames.count(jarFileName) > 1)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_JAR_FILE,
- new String[] {jarFileName},
- jarFileRef,
- jarFileRef.getValidationTextRange()
- )
- );
- }
- }
- }
-
- protected Iterator<String> jarFileNames() {
- return new TransformationIterator<JarFileRef, String>(jarFileRefs()) {
- @Override
- protected String transform(JarFileRef jarFileRef) {
- return jarFileRef.getFileName();
- }
- };
- }
-
- @SuppressWarnings("unused")
- protected void validateProperties(List<IMessage> messages, IReporter reporter) {
- // do nothing by default
- }
-
-
- // ********** refactoring **********
-
- public Iterable<DeleteEdit> createDeleteTypeEdits(final IType type) {
- return new CompositeIterable<DeleteEdit>(
- new TransformationIterable<ClassRef, Iterable<DeleteEdit>>(getSpecifiedClassRefs()) {
- @Override
- protected Iterable<DeleteEdit> transform(ClassRef classRef) {
- return classRef.createDeleteTypeEdits(type);
- }
- }
- );
- }
-
- public Iterable<DeleteEdit> createDeleteMappingFileEdits(final IFile file) {
- return new CompositeIterable<DeleteEdit>(
- new TransformationIterable<MappingFileRef, Iterable<DeleteEdit>>(getSpecifiedMappingFileRefs()) {
- @Override
- protected Iterable<DeleteEdit> transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.createDeleteMappingFileEdits(file);
- }
- }
- );
- }
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- createSpecifiedClassRefRenameTypeEdits(originalType, newName),
- createPersistenceUnitPropertiesRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createSpecifiedClassRefRenameTypeEdits(final IType originalType, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<ClassRef, Iterable<ReplaceEdit>>(getSpecifiedClassRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(ClassRef classRef) {
- return classRef.createRenameTypeEdits(originalType, newName);
- }
- }
- );
- }
-
- protected Iterable<ReplaceEdit> createPersistenceUnitPropertiesRenameTypeEdits(IType originalType, String newName) {
- return this.options.createRenameTypeEdits(originalType, newName);
- }
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- createSpecifiedClassRefMoveTypeEdits(originalType, newPackage),
- createPersistenceUnitPropertiesMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createSpecifiedClassRefMoveTypeEdits(final IType originalType, final IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<ClassRef, Iterable<ReplaceEdit>>(getSpecifiedClassRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(ClassRef classRef) {
- return classRef.createMoveTypeEdits(originalType, newPackage);
- }
- }
- );
- }
-
- protected Iterable<ReplaceEdit> createPersistenceUnitPropertiesMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.options.createMoveTypeEdits(originalType, newPackage);
- }
-
-
- @SuppressWarnings("unchecked")
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return new CompositeIterable<ReplaceEdit>(
- createSpecifiedClassRefRenamePackageEdits(originalPackage, newName),
- createPersistenceUnitPropertiesRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createSpecifiedClassRefRenamePackageEdits(final IPackageFragment originalPackage, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<ClassRef, Iterable<ReplaceEdit>>(getSpecifiedClassRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(ClassRef classRef) {
- return classRef.createRenamePackageEdits(originalPackage, newName);
- }
- }
- );
- }
-
- protected Iterable<ReplaceEdit> createPersistenceUnitPropertiesRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.options.createRenamePackageEdits(originalPackage, newName);
- }
-
- public Iterable<ReplaceEdit> createRenameFolderEdits(final IFolder originalFolder, final String newName) {
- return this.createMappingFileRefRenameFolderEdits(originalFolder, newName);
- }
-
- protected Iterable<ReplaceEdit> createMappingFileRefRenameFolderEdits(final IFolder originalFolder, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<MappingFileRef, Iterable<ReplaceEdit>>(getSpecifiedMappingFileRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.createRenameFolderEdits(originalFolder, newName);
- }
- }
- );
- }
-
- public Iterable<ReplaceEdit> createRenameMappingFileEdits(final IFile originalFile, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<MappingFileRef, Iterable<ReplaceEdit>>(getMappingFileRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.createRenameMappingFileEdits(originalFile, newName);
- }
- }
- );
- }
-
- public int findInsertLocationForMappingFileRef() {
- return this.xmlPersistenceUnit.getLocationToInsertMappingFileRef();
- }
-
- public Iterable<ReplaceEdit> createMoveMappingFileEdits(final IFile originalFile, final IPath runtineDestination) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<MappingFileRef, Iterable<ReplaceEdit>>(getMappingFileRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.createMoveMappingFileEdits(originalFile, runtineDestination);
- }
- }
- );
- }
-
- public Iterable<ReplaceEdit> createMoveFolderEdits(final IFolder originalFolder, final IPath runtimeDestination) {
- return this.createMappingFileRefMoveFolderReplaceEdits(originalFolder, runtimeDestination);
- }
-
- protected Iterable<ReplaceEdit> createMappingFileRefMoveFolderReplaceEdits(final IFolder originalFolder, final IPath runtimeDestination) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<MappingFileRef, Iterable<ReplaceEdit>>(getSpecifiedMappingFileRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.createMoveFolderEdits(originalFolder, runtimeDestination);
- }
- }
- );
- }
-
-
- // ********** misc **********
-
- public JpaStructureNode getStructureNode(int textOffset) {
- for (Iterator<JarFileRef> stream = this.jarFileRefs(); stream.hasNext(); ) {
- JarFileRef jarFileRef = stream.next();
- if (jarFileRef.containsOffset(textOffset)) {
- return jarFileRef;
- }
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.containsOffset(textOffset)) {
- return mappingFileRef;
- }
- }
- for (Iterator<ClassRef> stream = this.classRefs(); stream.hasNext(); ) {
- ClassRef classRef = stream.next();
- if (classRef.containsOffset(textOffset)) {
- return classRef;
- }
- }
- return this;
- }
-
- public boolean shouldValidateAgainstDatabase() {
- return connectionProfileIsActive();
- }
-
- public TextRange getValidationTextRange() {
- return this.xmlPersistenceUnit.getValidationTextRange();
- }
-
- public PersistentType getPersistentType(String typeName) {
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- PersistentType persistentType = mappingFileRef.getPersistentType(typeName);
- if (persistentType != null) {
- return persistentType;
- }
- }
- for (Iterator<ClassRef> stream = this.classRefs(); stream.hasNext(); ) {
- ClassRef classRef = stream.next();
- if (classRef.isFor(typeName)) {
- return classRef.getJavaPersistentType();
- }
- }
- for (Iterator<JarFileRef> stream = this.jarFileRefs(); stream.hasNext(); ) {
- PersistentType persistentType = stream.next().getPersistentType(typeName);
- if (persistentType != null) {
- return persistentType;
- }
- }
- return null;
- }
-
- public boolean specifiesPersistentType(String className) {
- for (ClassRef classRef : this.getSpecifiedClassRefs()) {
- if (classRef.isFor(className)) {
- return true;
- }
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.getPersistentType(className) != null) {
- return true;
- }
- }
- return false;
- }
-
- public Entity getEntity(String typeName) {
- PersistentType persistentType = this.getPersistentType(typeName);
- if (persistentType == null) {
- return null;
- }
- TypeMapping typeMapping = persistentType.getMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public Embeddable getEmbeddable(String typeName) {
- PersistentType persistentType = this.getPersistentType(typeName);
- if (persistentType == null) {
- return null;
- }
- TypeMapping typeMapping = persistentType.getMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- public boolean containsOffset(int textOffset) {
- return (this.xmlPersistenceUnit != null) && this.xmlPersistenceUnit.containsOffset(textOffset);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.name);
- }
-
-
- // ********** metamodel **********
- // put metamodel stuff here so it can be shared by Generic and EclipseLink implementations
-
- public void initializeMetamodel() {
- this.initializeMetamodelFiles();
- }
-
- protected void initializeMetamodelFiles() {
- CollectionTools.addAll(this.metamodelFiles, this.getGeneratedMetamodelFiles());
- }
-
- protected Iterable<IFile> getGeneratedMetamodelFiles() {
- return new TransformationIterable<JavaResourcePersistentType2_0, IFile>(this.getGeneratedMetamodelTopLevelTypes()) {
- @Override
- protected IFile transform(JavaResourcePersistentType2_0 jrpt) {
- return jrpt.getFile();
- }
- };
- }
-
- protected Iterable<JavaResourcePersistentType2_0> getGeneratedMetamodelTopLevelTypes() {
- return ((JpaProject2_0) this.getJpaProject()).getGeneratedMetamodelTopLevelTypes();
- }
-
- /**
- * Not the prettiest code....
- */
- public void synchronizeMetamodel() {
- // gather up the persistent unit's types, eliminating duplicates;
- // if we have persistent types with the same name in multiple locations,
- // the last one we encounter wins (i.e. the classes in the orm.xml take
- // precedence)
- HashMap<String, PersistentType2_0> allPersistentTypes = new HashMap<String, PersistentType2_0>();
- this.addPersistentTypesTo_(this.getJarFileRefs(), allPersistentTypes);
- this.addPersistentTypesTo(this.getNonNullClassRefPersistentTypes(), allPersistentTypes);
- this.addPersistentTypesTo_(this.getMappingFileRefs(), allPersistentTypes);
-
- // build a list of the top-level types and a tree of their associated
- // member types etc.
- ArrayList<MetamodelSourceType> topLevelTypes = new ArrayList<MetamodelSourceType>(allPersistentTypes.size());
- HashMap<String, Collection<MetamodelSourceType>> memberTypeTree = new HashMap<String, Collection<MetamodelSourceType>>();
- for (PersistentType2_0 type : allPersistentTypes.values()) {
- String declaringTypeName = type.getDeclaringTypeName();
- MetamodelSourceType memberType = type;
- while (true) {
- if (declaringTypeName == null) {
- topLevelTypes.add(memberType);
- break; // stop at the top-level type
- }
-
- // associate the member type with its declaring type
- Collection<MetamodelSourceType> memberTypes = memberTypeTree.get(declaringTypeName);
- if (memberTypes == null) {
- memberTypes = new ArrayList<MetamodelSourceType>();
- memberTypeTree.put(declaringTypeName, memberTypes);
- }
- memberTypes.add(memberType);
-
- // move out to the member type's declaring type
- String memberTypeName = declaringTypeName;
- // check for a context persistent type
- memberType = allPersistentTypes.get(memberTypeName);
- if (memberType != null) {
- break; // stop - this will be processed in the outer 'for' loop
- }
- // check for a Java resource persistent type
- JavaResourcePersistentType jrpt = this.getJpaProject().getJavaResourcePersistentType(memberTypeName);
- if (jrpt != null) {
- declaringTypeName = jrpt.getDeclaringTypeName();
- } else {
- // check for a JDT type
- IType jdtType = this.findJdtType(memberTypeName);
- if (jdtType != null) {
- IType jdtDeclaringType = jdtType.getDeclaringType();
- declaringTypeName = (jdtDeclaringType == null) ? null : jdtDeclaringType.getFullyQualifiedName('.');
- } else {
- // assume we have a non-persistent top-level type...?
- declaringTypeName = null;
- }
- }
- if (declaringTypeName == null) {
- memberType = this.selectSourceType(topLevelTypes, memberTypeName);
- } else {
- memberType = this.selectSourceType(memberTypeTree.get(declaringTypeName), memberTypeName);
- }
- if (memberType != null) {
- break; // stop - this type has already been processed
- }
- memberType = this.buildNonPersistentMetamodelSourceType(memberTypeName);
- }
- }
-
- // remove any top-level type whose name differs from another only by case,
- // since, on Windows, file names are case-insensitive :-(
- // sort the original list so we end up with the same top-level type
- // remaining every time (i.e. the one that sorts out first)
- Collections.sort(topLevelTypes, MetamodelSourceType.COMPARATOR);
- HashSet<String> names = new HashSet<String>(topLevelTypes.size());
- for (Iterator<MetamodelSourceType> stream = topLevelTypes.iterator(); stream.hasNext(); ) {
- MetamodelSourceType topLevelType = stream.next();
- // hopefully this is case-insensitive enough...
- if ( ! names.add(topLevelType.getName().toLowerCase())) {
- stream.remove();
- }
- }
-
- // copy the list of metamodel files...
- HashSet<IFile> deadMetamodelFiles = new HashSet<IFile>(this.metamodelFiles);
- this.metamodelFiles.clear();
- for (MetamodelSourceType topLevelType : topLevelTypes) {
- IFile metamodelFile = topLevelType.getMetamodelFile();
- // ...remove whatever files are still present...
- deadMetamodelFiles.remove(metamodelFile);
- // ...rebuild the list of metamodel files...
- if (this.fileIsGeneratedMetamodel(metamodelFile)) { // only add files with the Dali tag
- this.metamodelFiles.add(metamodelFile);
- }
- }
- // ...delete the files that are now gone
- // [perform the deletes first - this is critical when a file has been
- // renamed by only altering its name's case; since we will try to write
- // out a new file that, on Windows, collides with the old file :-( ]
- for (IFile deadMetamodelFile : deadMetamodelFiles) {
- this.deleteMetamodelFile(deadMetamodelFile);
- }
-
- // now generate the metamodel classes
- for (MetamodelSourceType topLevelType : topLevelTypes) {
- topLevelType.synchronizeMetamodel(memberTypeTree);
- }
- }
-
- protected void addPersistentTypesTo_(Iterable<? extends PersistentTypeContainer> ptContainers, HashMap<String, PersistentType2_0> persistentTypeMap) {
- for (PersistentTypeContainer ptContainer : ptContainers) {
- this.addPersistentTypesTo(ptContainer.getPersistentTypes(), persistentTypeMap);
- }
- }
-
- protected void addPersistentTypesTo(Iterable<? extends PersistentType> persistentTypes, HashMap<String, PersistentType2_0> persistentTypeMap) {
- for (PersistentType persistentType : persistentTypes) {
- if (persistentType.getName() != null) {
- persistentTypeMap.put(persistentType.getName(), (PersistentType2_0) persistentType);
- }
- }
- }
-
- protected MetamodelSourceType selectSourceType(Iterable<MetamodelSourceType> types, String typeName) {
- if (types != null) {
- for (MetamodelSourceType type : types) {
- if (type.getName().equals(typeName)) {
- return type;
- }
- }
- }
- return null;
- }
-
- protected MetamodelSourceType buildNonPersistentMetamodelSourceType(String nonPersistentTypeName) {
- return new NonPersistentMetamodelSourceType(nonPersistentTypeName, this.getJpaProject());
- }
-
- protected IType findJdtType(String typeName) {
- try {
- return this.getJpaProject().getJavaProject().findType(typeName);
- } catch (JavaModelException ex) {
- JptCorePlugin.log(ex);
- return null;
- }
- }
-
- protected void deleteMetamodelFile(IFile file) {
- try {
- this.deleteMetamodelFile_(file);
- } catch (CoreException ex) {
- JptCorePlugin.log(ex);
- }
- }
-
- protected void deleteMetamodelFile_(IFile file) throws CoreException {
- if (this.fileIsGeneratedMetamodel(file)) {
- file.delete(true, null); // true = force
- }
- }
-
- protected boolean fileIsGeneratedMetamodel(IFile file) {
- return ((JpaProject2_0) this.getJpaProject()).getGeneratedMetamodelTopLevelType(file) != null;
- }
-
- public void disposeMetamodel() {
- this.metamodelFiles.clear();
- }
-
- // ***** Metamodel source for non-persistent types
- protected static class NonPersistentMetamodelSourceType
- implements MetamodelSourceType
- {
- protected final String name;
- protected final JpaProject jpaProject;
- protected final MetamodelSourceType.Synchronizer metamodelSynchronizer;
-
- protected NonPersistentMetamodelSourceType(String name, JpaProject jpaProject) {
- super();
- this.name = name;
- this.jpaProject = jpaProject;
- this.metamodelSynchronizer = this.buildMetamodelSynchronizer();
- }
-
- protected MetamodelSourceType.Synchronizer buildMetamodelSynchronizer() {
- return this.getJpaFactory().buildMetamodelSynchronizer(this);
- }
-
- protected JpaFactory2_0 getJpaFactory() {
- return (JpaFactory2_0) this.getJpaProject().getJpaPlatform().getJpaFactory();
- }
-
- public String getName() {
- return this.name;
- }
-
- public boolean isManaged() {
- return false;
- }
-
- public PersistentType getSuperPersistentType() {
- return null;
- }
-
- public <T extends PersistentAttribute> ListIterator<T> attributes() {
- return EmptyListIterator.instance();
- }
-
- public IFile getMetamodelFile() {
- return this.metamodelSynchronizer.getFile();
- }
-
- public JpaProject getJpaProject() {
- return this.jpaProject;
- }
-
- public void synchronizeMetamodel(Map<String, Collection<MetamodelSourceType>> memberTypeTree) {
- this.metamodelSynchronizer.synchronize(memberTypeTree);
- }
-
- public void printBodySourceOn(BodySourceWriter pw, Map<String, Collection<MetamodelSourceType>> memberTypeTree) {
- this.metamodelSynchronizer.printBodySourceOn(pw, memberTypeTree);
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnitProperties.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnitProperties.java
deleted file mode 100644
index f1e126898e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceUnitProperties.java
+++ /dev/null
@@ -1,529 +0,0 @@
-/*******************************************************************************
-* Copyright (c) 2009, 2010 Oracle. All rights reserved.
-* This program and the accompanying materials are made available under the
-* terms of the Eclipse Public License v1.0, which accompanies this distribution
-* and is available at http://www.eclipse.org/legal/epl-v10.html.
-*
-* Contributors:
-* Oracle - initial API and implementation
-*******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.utility.internal.ReflectionTools;
-import org.eclipse.jpt.utility.internal.StringTools;
-import org.eclipse.jpt.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.utility.internal.model.AbstractModel;
-import org.eclipse.text.edits.ReplaceEdit;
-
-/**
- * AbstractPersistenceUnitProperties
- */
-public abstract class AbstractPersistenceUnitProperties extends AbstractModel
- implements PersistenceUnitProperties
-{
- private PersistenceUnit persistenceUnit;
-
- // key = PersistenceUnit property key; value = property id
- private Map<String, String> propertyNames;
-
- public static final String PROPERTY_VALUE_DELIMITER = ","; //$NON-NLS-1$
- private static final long serialVersionUID = 1L;
-
- // ********** constructors / initialization **********
- protected AbstractPersistenceUnitProperties(PersistenceUnit parent) {
- super();
- this.initialize();
- this.initialize(parent);
- this.postInitialize();
- }
-
- /**
- * Base initialization.
- */
- protected void initialize() {
- this.propertyNames = new HashMap<String, String>();
- }
-
- /**
- * Initialization based on the persistence unit.
- */
- protected void initialize(PersistenceUnit parent) {
- this.persistenceUnit = parent;
-
- this.initializePropertyNames();
- this.initializeProperties();
- }
-
- protected void initializePropertyNames() {
- this.addPropertyNames(this.propertyNames);
- }
-
- /**
- * Initializes properties with values from the persistence unit.
- */
- protected abstract void initializeProperties();
-
- /**
- * Does all post treatment in this method after the properties are initialized
- */
- protected void postInitialize() {
- // do nothing by default
- }
-
- // ********** behavior **********
- public PersistenceUnit getPersistenceUnit() {
- return this.persistenceUnit;
- }
-
- public JpaProject getJpaProject() {
- return this.persistenceUnit.getJpaProject();
- }
-
- /**
- * Adds property names key/value pairs, used by the methods: itemIsProperty
- * and propertyIdFor.
- *
- * key = property key; value = property id
- */
- protected abstract void addPropertyNames(Map<String, String> pNames);
-
- /**
- * Method used for identifying the given property.
- */
- public boolean itemIsProperty(PersistenceUnit.Property item) {
- if (item == null) {
- throw new NullPointerException();
- }
- return this.propertyNames().keySet().contains(item.getName());
- }
-
- /**
- * Returns the property name used for change notification of the given
- * property.
- */
- public String propertyIdOf(PersistenceUnit.Property property) {
- String propertyId = this.propertyNames().get(property.getName());
- if (propertyId == null) {
- throw new IllegalArgumentException("Illegal property: " + property); //$NON-NLS-1$
- }
- return propertyId;
- }
-
- public String propertyIdOf(String eclipseLinkkey) {
- String propertyId = this.propertyNames().get(eclipseLinkkey);
- if (propertyId == null) {
- throw new IllegalArgumentException("Illegal property: " + eclipseLinkkey); //$NON-NLS-1$
- }
- return propertyId;
- }
-
- /*
- * Get the PersistenceUnit property key of the given property
- */
- protected String persistenceUnitKeyOf(String propertyId) {
- for (String persistenceUnitKey : this.propertyNames().keySet()) {
- if (this.propertyNames().get(persistenceUnitKey).equals(propertyId)) {
- return persistenceUnitKey;
- }
- }
- throw new IllegalArgumentException("Illegal property ID: " + propertyId); //$NON-NLS-1$
- }
-
- // ******** Convenience methods ********
- /**
- * Put into persistenceUnit properties.
- *
- * @param key -
- * property name
- * @param value -
- * property value
- */
- protected void putProperty(String key, Object value) {
- this.putProperty(key, value, false);
- }
-
- @SuppressWarnings("unchecked")
- protected void putProperty(String key, Object value, boolean allowDuplicates) {
- String persistenceUnitKey = this.persistenceUnitKeyOf(key);
- if ((value != null) && value.getClass().isEnum()) {
- this.putEnumValue(persistenceUnitKey, (Enum) value, allowDuplicates);
- }
- else {
- this.putPersistenceUnitProperty(persistenceUnitKey, null, value, allowDuplicates);
- }
- }
-
- /**
- * Removes a persistenceUnit property.
- *
- * @param key -
- * property name
- * @param value -
- * property value
- */
- protected void removeProperty(String key, String value) {
- String persistenceUnitKey = this.persistenceUnitKeyOf(key);
-
- this.getPersistenceUnit().removeProperty(persistenceUnitKey, value);
- }
-
- /**
- * Returns true when the given key exits in the PersistenceXml.
- */
- protected boolean persistenceUnitKeyExists(String persistenceUnitKey) {
- return (this.getStringValue(persistenceUnitKey) != null);
- }
-
- // ****** get/set String convenience methods *******
- /**
- * Returns the String value of the given Property from the PersistenceXml.
- */
- protected String getStringValue(String persistenceUnitKey) {
- PersistenceUnit.Property p = this.getPersistenceUnit().getProperty(persistenceUnitKey);
- return (p == null) ? null : p.getValue();
- }
-
- protected String getStringValue(String key, String keySuffix) {
- return this.getStringValue((keySuffix == null) ? key : key + keySuffix);
- }
-
- /**
- * Put the given String value into the PersistenceXml.
- * @param key -
- * property key
- * @param newValue
- * value to be associated with the key
- */
- protected void putStringValue(String key, String newValue) {
- this.putStringValue(key, null, newValue, false);
- }
-
- /**
- * Put the given String value into the PersistenceXml.
- * @param key
- * property key
- * @param newValue
- * value to be associated with the key
- * @param allowDuplicate
- */
- protected void putStringValue(String key, String newValue, boolean allowDuplicate) {
- this.putStringValue(key, null, newValue, allowDuplicate);
- }
-
- /**
- * Put the given String value into the PersistenceXml.
- * @param key
- * property key
- * @param keySuffix
- * e.g. entity name
- * @param newValue
- * value to be associated with the key
- * @param allowDuplicate
- */
- protected void putStringValue(String key, String keySuffix, String newValue, boolean allowDuplicate) {
- this.putPersistenceUnitProperty(key, keySuffix, newValue, allowDuplicate);
- }
-
- // ****** Integer convenience methods *******
- /**
- * Returns the Integer value of the given Property from the PersistenceXml.
- */
- protected Integer getIntegerValue(String persistenceUnitKey) {
- PersistenceUnit.Property p = this.getPersistenceUnit().getProperty(persistenceUnitKey);
- return (p == null) ? null : getIntegerValueOf(p.getValue());
- }
-
- protected Integer getIntegerValue(String key, String keySuffix) {
- return this.getIntegerValue((keySuffix == null) ? key : key + keySuffix);
- }
-
- /**
- * Put the given Integer value into the PersistenceXml.
- * @param key -
- * property key
- * @param newValue
- * value to be associated with the key
- */
- protected void putIntegerValue(String key, Integer newValue) {
- this.putIntegerValue(key, null, newValue, false);
- }
-
- /**
- * Put the given Integer value into the PersistenceXml.
- * @param key
- * property key
- * @param newValue
- * value to be associated with the key
- * @param allowDuplicate
- */
- protected void putIntegerValue(String key, Integer newValue, boolean allowDuplicate) {
- this.putIntegerValue(key, null, newValue, allowDuplicate);
- }
-
- /**
- * Put the given Integer value into the PersistenceXml.
- * @param key
- * property key
- * @param keySuffix
- * e.g. entity name
- * @param newValue
- * value to be associated with the key
- * @param allowDuplicate
- */
- protected void putIntegerValue(String key, String keySuffix, Integer newValue, boolean allowDuplicate) {
- this.putPersistenceUnitProperty(key, keySuffix, newValue, allowDuplicate);
- }
-
- // ****** Boolean convenience methods *******
- /**
- * Returns the Boolean value of the given Property from the PersistenceXml.
- */
- protected Boolean getBooleanValue(String persistenceUnitKey) {
- PersistenceUnit.Property p = this.getPersistenceUnit().getProperty(persistenceUnitKey);
- return (p == null) ? null : getBooleanValueOf(p.getValue());
- }
-
- protected Boolean getBooleanValue(String key, String keySuffix) {
- return this.getBooleanValue((keySuffix == null) ? key : key + keySuffix);
- }
-
- /**
- * Put the given Boolean value into the PersistenceXml.
- * @param key
- * property key
- * @param newValue
- * value to be associated with the key
- */
- protected void putBooleanValue(String key, Boolean newValue) {
- this.putBooleanValue(key, null, newValue, false);
- }
-
- /**
- * Put the given Boolean value into the PersistenceXml.
- * @param key
- * property key
- * @param newValue
- * value to be associated with the key
- * @param allowDuplicate
- */
- protected void putBooleanValue(String key, Boolean newValue, boolean allowDuplicate) {
- this.putBooleanValue(key, null, newValue, allowDuplicate);
- }
-
- /**
- * Put the given Boolean value into the PersistenceXml.
- * @param key
- * property key
- * @param keySuffix
- * e.g. entity name
- * @param newValue
- * value to be associated with the key
- * @param allowDuplicate
- */
- protected void putBooleanValue(String key, String keySuffix, Boolean newValue, boolean allowDuplicate) {
- this.putPersistenceUnitProperty(key, keySuffix, newValue, allowDuplicate);
- }
-
- // ****** Enum convenience methods *******
- /**
- * Returns the Enum value of the given Property from the PersistenceXml.
- */
- protected <T extends Enum<T>> T getEnumValue(String persistenceUnitKey, T[] enumValues) {
- PersistenceUnit.Property p = this.getPersistenceUnit().getProperty(persistenceUnitKey);
- return (p == null) ? null : getEnumValueOf(p.getValue(), enumValues);
- }
-
- protected <T extends Enum<T>> T getEnumValue(String key, String keySuffix, T[] enumValues) {
- return this.getEnumValue((keySuffix == null) ? key : key + keySuffix, enumValues);
- }
-
- /**
- * Put the given Enum value into the PersistenceXml.
- *
- * @param key -
- * property key
- */
- protected <T extends Enum<T>> void putEnumValue(String key, T newValue) {
- this.putEnumValue(key, null, newValue, false);
- }
-
- protected <T extends Enum<T>> void putEnumValue(String key, T newValue, boolean allowDuplicate) {
- this.putEnumValue(key, null, newValue, allowDuplicate);
- }
-
- protected <T extends Enum<T>> void putEnumValue(String key, String keySuffix, T newValue, boolean allowDuplicate) {
- this.putPersistenceUnitProperty(key, keySuffix, getPropertyStringValueOf(newValue), allowDuplicate);
- }
-
- // ****** get/set CompositeValue convenience methods *******
- /**
- * Returns the String values of the given Property from the PersistenceXml.
- */
- protected List<String> getCompositeValue(String persistenceUnitKey) {
- String values = this.getStringValue(persistenceUnitKey);
- return this.extractCompositeValue(values);
- }
-
- /**
- * Put into persistenceUnit properties. If the property already exists,
- * it appends the given value at the end of the property value.
- *
- * @param key
- * @param valueToAppend
- */
- protected void putPropertyCompositeValue(String key, String valueToAppend) {
- String persistenceUnitKey = this.persistenceUnitKeyOf(key);
-
- String persistenceUnitValue = this.buildCompositeValue(
- this.getStringValue(persistenceUnitKey), valueToAppend);
-
- this.putPersistenceUnitProperty(persistenceUnitKey, null, persistenceUnitValue, false);
- }
-
- /**
- * Removes a value from a property with composite values.
- * If the resulting value is empty, the property is removed from the persistenceUnit.
- *
- * @param key -
- * property name
- * @param valueToRemove -
- * value to remove from the property
- */
- protected void removePropertyCompositeValue(String key, String valueToRemove) {
- String persistenceUnitKey = this.persistenceUnitKeyOf(key);
-
- String persistenceUnitValue = this.removeValueFrom(
- this.getStringValue(persistenceUnitKey), valueToRemove.trim());
-
- this.putPersistenceUnitProperty(persistenceUnitKey, null, persistenceUnitValue, false);
- }
-
- // ****** Static methods *******
-
- public static Boolean getBooleanValueOf(String puStringValue) {
- if (StringTools.stringIsEmpty(puStringValue)) {
- return null;
- }
- return Boolean.valueOf(puStringValue);
- }
-
- public static Integer getIntegerValueOf(String puStringValue) {
- if (StringTools.stringIsEmpty(puStringValue)) {
- return null;
- }
- try {
- return Integer.valueOf(puStringValue);
- }
- catch (NumberFormatException nfe) {
- return null;
- }
- }
-
- /**
- * Returns the enum constant of the specified enum type with the specified
- * Property string value.
- */
- public static <T extends Enum<T>> T getEnumValueOf(String puStringValue, T[] enumValues) {
- for (T enumValue : enumValues) {
- if (getPropertyStringValueOf(enumValue).equals(puStringValue)) {
- return enumValue;
- }
- }
- return null;
- }
-
- /**
- * Returns the Property string value of the given property value.
- */
- public static String getPropertyStringValueOf(Object value) {
- if (value == null) {
- return null;
- }
- if (value.getClass().isEnum()) {
- return (String) ReflectionTools.getStaticFieldValue(value.getClass(), value.toString().toUpperCase(Locale.ENGLISH));
- }
- return value.toString();
- }
-
- // ********** internal methods **********
-
- private Map<String, String> propertyNames() {
- return this.propertyNames;
- }
-
- private void putPersistenceUnitProperty(String key, String keySuffix, Object value, boolean allowDuplicates) {
- String persistenceUnitKey = (keySuffix == null) ? key : key + keySuffix;
- String stringValue = (value == null) ? null : value.toString();
- this.getPersistenceUnit().setProperty(persistenceUnitKey, stringValue, allowDuplicates);
- }
-
- private String buildCompositeValue(String value, String valueToAppend) {
- if((StringTools.stringIsEmpty(valueToAppend)) ) {
- return value;
- }
- return (StringTools.stringIsEmpty(value)) ?
- valueToAppend :
- (value + PROPERTY_VALUE_DELIMITER + valueToAppend);
- }
-
- protected List<String> extractCompositeValue(String compositeValue) {
- if(StringTools.stringIsEmpty(compositeValue)) {
- return new ArrayList<String>(0);
- }
- String[] values = compositeValue.split(PROPERTY_VALUE_DELIMITER);
- List<String> results = new ArrayList<String>(values.length);
- for(String value : values) {
- results.add(value.trim());
- }
- return results;
- }
-
- private String removeValueFrom(String compositeValue, String valueToRemove) {
- if((StringTools.stringIsEmpty(valueToRemove))) {
- return compositeValue;
- }
- String[] values = compositeValue.split(PROPERTY_VALUE_DELIMITER);
- ArrayList<String> results = new ArrayList<String>(values.length);
-
- for(String value : values) {
- if(value.trim().equals(valueToRemove)) {
- continue;
- }
- results.add(value);
- }
- if(results.isEmpty()) {
- return null;
- }
- StringBuilder sb = new StringBuilder(values.length);
- for(String value : results) {
- sb.append(value).append(PROPERTY_VALUE_DELIMITER);
- }
- sb.deleteCharAt(sb.length() - 1); // remove the last delimiter
- return sb.toString();
- }
-
-
- // ********** refactoring ************
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return EmptyIterable.instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return EmptyIterable.instance();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java
deleted file mode 100644
index 71a4449f83..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.core.context.JpaContextNode;
-import org.eclipse.jpt.core.context.persistence.PersistenceXmlContextNodeFactory;
-import org.eclipse.jpt.core.context.persistence.PersistenceXmlDefinition;
-import org.eclipse.jpt.core.internal.context.AbstractXmlContextNode;
-
-/**
- * Use this abstract class for context nodes that are part of an
- * <code>orm.xml</code> file.
- * This will not work for a pure {@link org.eclipse.jpt.core.context.MappingFile}
- * implementation.
- */
-public abstract class AbstractPersistenceXmlContextNode
- extends AbstractXmlContextNode
-{
- // ********** constructor **********
-
- protected AbstractPersistenceXmlContextNode(JpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** convenience methods **********
-
- protected PersistenceXmlDefinition getPersistenceXmlDefinition() {
- return (PersistenceXmlDefinition) this.getJpaPlatform().getResourceDefinition(this.getResourceType());
- }
-
- protected EFactory getResourceNodeFactory() {
- return this.getPersistenceXmlDefinition().getResourceNodeFactory();
- }
-
- protected PersistenceXmlContextNodeFactory getContextNodeFactory() {
- return this.getPersistenceXmlDefinition().getContextNodeFactory();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java
deleted file mode 100644
index ba9c5c2b75..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import org.eclipse.jpt.core.JptCorePlugin;
-import org.eclipse.jpt.core.context.java.JarFile;
-import org.eclipse.jpt.core.context.persistence.ClassRef;
-import org.eclipse.jpt.core.context.persistence.JarFileRef;
-import org.eclipse.jpt.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.core.context.persistence.Persistence;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.core.context.persistence.PersistenceXmlContextNodeFactory;
-import org.eclipse.jpt.core.internal.jpa1.context.java.GenericJarFile;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericClassRef;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericJarFileRef;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericMappingFileRef;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericPersistence;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericPersistenceUnit;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.GenericPersistenceUnitProperty;
-import org.eclipse.jpt.core.internal.jpa1.context.persistence.ImpliedMappingFileRef;
-import org.eclipse.jpt.core.resource.java.JavaResourcePackageFragmentRoot;
-import org.eclipse.jpt.core.resource.persistence.XmlJarFileRef;
-import org.eclipse.jpt.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistence;
-import org.eclipse.jpt.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.core.resource.persistence.XmlProperty;
-
-public abstract class AbstractPersistenceXmlContextNodeFactory implements PersistenceXmlContextNodeFactory
-{
-
- public Persistence buildPersistence(PersistenceXml parent, XmlPersistence xmlPersistence) {
- return new GenericPersistence(parent, xmlPersistence);
- }
-
- public PersistenceUnit buildPersistenceUnit(Persistence parent, XmlPersistenceUnit xmlPersistenceUnit) {
- return new GenericPersistenceUnit(parent, xmlPersistenceUnit);
- }
-
- public MappingFileRef buildMappingFileRef(PersistenceUnit parent, XmlMappingFileRef xmlMappingFileRef) {
- return new GenericMappingFileRef(parent, xmlMappingFileRef);
- }
-
- public MappingFileRef buildImpliedMappingFileRef(PersistenceUnit parent) {
- return new ImpliedMappingFileRef(parent, JptCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString());
- }
-
- public ClassRef buildClassRef(PersistenceUnit parent, XmlJavaClassRef classRef) {
- return new GenericClassRef(parent, classRef);
- }
-
- public ClassRef buildClassRef(PersistenceUnit parent, String className) {
- return new GenericClassRef(parent, className);
- }
-
- public JarFileRef buildJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef) {
- return new GenericJarFileRef(parent, xmlJarFileRef);
- }
-
- public JarFile buildJarFile(JarFileRef parent, JavaResourcePackageFragmentRoot jarResourcePackageFragmentRoot) {
- return new GenericJarFile(parent, jarResourcePackageFragmentRoot);
- }
-
- public PersistenceUnit.Property buildProperty(PersistenceUnit parent, XmlProperty xmlProperty) {
- return new GenericPersistenceUnitProperty(parent, xmlProperty);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java
deleted file mode 100644
index 86c07e8b1d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceXmlContextNodeFactory;
-import org.eclipse.jpt.core.context.persistence.PersistenceXmlDefinition;
-
-/**
- * All the state in the definition should be "static" (i.e. unchanging once it is initialized).
- */
-public abstract class AbstractPersistenceXmlDefinition
- implements PersistenceXmlDefinition
-{
-
- private final PersistenceXmlContextNodeFactory factory;
-
-
- /**
- * zero-argument constructor
- */
- protected AbstractPersistenceXmlDefinition() {
- super();
- this.factory = buildContextNodeFactory();
- }
-
-
- protected abstract PersistenceXmlContextNodeFactory buildContextNodeFactory();
-
- public PersistenceXmlContextNodeFactory getContextNodeFactory() {
- return this.factory;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java
deleted file mode 100644
index 64b67b65b2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.core.internal.context.persistence;
-
-import org.eclipse.jpt.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.core.internal.jpa2.context.persistence.connection.NullConnection2_0;
-import org.eclipse.jpt.core.internal.jpa2.context.persistence.options.NullOptions2_0;
-
-
-public class GenericPersistenceXmlContextNodeFactory extends AbstractPersistenceXmlContextNodeFactory
-{
-
- public PersistenceUnitProperties buildConnection(PersistenceUnit parent) {
- return new NullConnection2_0(parent);
- }
-
- public PersistenceUnitProperties buildOptions(PersistenceUnit parent) {
- return new NullOptions2_0(parent);
- }
-
-}

Back to the top