Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context')
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractJpaContextNode.java143
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AttributeMappingTools.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/BaseColumnTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/BaseJoinColumnTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/ContextContainerTools.java148
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/EntityTextRangeResolver.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JoinColumnTextRangeResolver.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JptValidator.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/MappingTools.java450
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/NamedColumnTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/OverrideTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributeTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PrimaryKeyTextRangeResolver.java24
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TableTextRangeResolver.java25
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTextRangeResolver.java21
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTools.java119
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java323
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java360
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java323
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBasicMapping.java383
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddable.java48
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java1839
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java248
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java486
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java348
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinTableRelationshipStrategy.java196
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJpaContextNode.java80
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToManyMapping.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToOneMapping.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappedSuperclass.java113
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappingRelationship.java132
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java784
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java295
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToManyMapping.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToOneMapping.java86
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java214
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java787
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java722
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java284
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaReadOnlyUniqueConstraint.java61
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java363
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java135
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java156
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java581
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java293
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java294
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualBaseColumn.java238
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualNamedColumn.java142
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualOverride.java63
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualReferenceTable.java200
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualTable.java320
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/DefaultJavaAttributeMappingDefinitionWrapper.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaIdClassReference.java274
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToManyRelationship.java198
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToOneRelationship.java194
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java270
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappingJoinColumnRelationshipStrategy.java222
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToManyRelationship.java272
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToOneRelationship.java300
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOverrideJoinColumnRelationshipStrategy.java249
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.java391
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaVirtualJoinTable.java333
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaAttributeMappingDefinitionWrapper.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBaseColumnTextRangeResolver.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBasicMappingDefinition.java81
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddableDefinition.java62
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedMappingDefinition.java77
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityDefinition.java116
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityTextRangeResolver.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaIdMappingDefinition.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaJoinColumnTextRangeResolver.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToManyMappingDefinition.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToOneMappingDefinition.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassDefinition.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java46
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNamedColumnTextRangeResolver.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNullTypeMapping.java84
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToManyMappingDefinition.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToOneMappingDefinition.java79
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOverrideTextRangeResolver.java37
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTableTextRangeResolver.java45
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTransientMappingDefinition.java65
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaVersionMappingDefinition.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java972
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java416
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java302
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java299
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java425
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEmbeddable.java102
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java2293
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java245
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java506
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java332
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java194
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToManyMapping.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToOneMapping.java66
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappedSuperclass.java214
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappingRelationship.java136
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java799
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java288
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToManyMapping.java99
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToOneMapping.java102
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java310
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmReadOnlyUniqueConstraint.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java400
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java91
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java141
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java538
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java499
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java343
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualBaseColumn.java238
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualNamedColumn.java141
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualReferenceTable.java200
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualTable.java319
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java73
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java386
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java115
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmIdClassReference.java375
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java172
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java177
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java220
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinColumnRelationshipStrategy.java164
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinTableRelationshipStrategy.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java241
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java263
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOverrideJoinColumnRelationshipStrategy.java209
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java344
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualJoinTable.java333
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.java333
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualSecondaryTable.java272
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java17
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/NullOrmJoinTableRelationshipStrategy.java123
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java34
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBasicMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddableDefinition.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityDefinition.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityTextRangeResolver.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmIdMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java39
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToManyMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToOneMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassDefinition.java67
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java44
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToManyMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToOneMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOverrideTextRangeResolver.java33
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTableTextRangeResolver.java40
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTransientMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java29
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmVersionMappingDefinition.java64
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java442
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java601
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java389
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java361
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java2836
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnitProperties.java529
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java47
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java75
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java29
171 files changed, 0 insertions, 38163 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractJpaContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractJpaContextNode.java
deleted file mode 100644
index 22507e4026..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractJpaContextNode.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.jpa.core.JpaNode;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-import org.eclipse.jpt.jpa.core.context.MappingFileRoot;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.internal.AbstractJpaNode;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-
-public abstract class AbstractJpaContextNode
- extends AbstractJpaNode
- implements JpaContextNode
-{
- protected AbstractJpaContextNode(JpaNode parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- public void synchronizeWithResourceModel() {
- // NOP
- }
-
- /**
- * convenience method
- */
- protected void synchronizeNodesWithResourceModel(Iterable<? extends JpaContextNode> nodes) {
- for (JpaContextNode node : nodes) {
- node.synchronizeWithResourceModel();
- }
- }
-
- public void update() {
- // NOP
- }
-
- /**
- * convenience method
- */
- protected void updateNodes(Iterable<? extends JpaContextNode> nodes) {
- for (JpaContextNode node : nodes) {
- node.update();
- }
- }
-
-
- // ********** containment hierarchy **********
-
- /**
- * covariant override
- */
- @Override
- public JpaContextNode getParent() {
- return (JpaContextNode) super.getParent();
- }
-
- /**
- * Overridden in:<ul>
- * <li>{@link org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode#getResourceType() AbstractJavaJpaContextNode}
- * <li>{@link org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJarFile#getResourceType() GenericJarFile}
- * <li>{@link org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml#getResourceType() GenericOrmXml}
- * <li>{@link org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml#getResourceType() GenericPersistenceXml}
- * </ul>
- */
- public JptResourceType getResourceType() {
- return this.getParent().getResourceType();
- }
-
- /**
- * Overridden in:<ul>
- * <li>{@link org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit#getPersistenceUnit() AbstractPersistenceUnit}
- * to return itself
- * <li>{@link org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode#getPersistenceUnit() GenericRootContextNode}
- * to return <code>null</code>
- * </ul>
- */
- public PersistenceUnit getPersistenceUnit() {
- return this.getParent().getPersistenceUnit();
- }
-
- /**
- * Overridden in:<ul>
- * <li>{@link org.eclipse.jpt.jpa.core.internal.context.orm.AbstractEntityMappings#getMappingFileRoot() AbstractEntityMappings}
- * to return itself
- * <li>{@link org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode#getMappingFileRoot() GenericRootContextNode}
- * to return <code>null</code>
- * </ul>
- */
- public MappingFileRoot getMappingFileRoot() {
- return this.getParent().getMappingFileRoot();
- }
-
-
- // ********** database stuff **********
-
- public Schema getContextDefaultDbSchema() {
- SchemaContainer dbSchemaContainer = this.getContextDefaultDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getContextDefaultSchema());
- }
-
- 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; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getContextDefaultDbSchemaContainer() {
- String catalog = this.getContextDefaultCatalog();
- return (catalog != null) ? this.resolveDbCatalog(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 getContextDefaultDbCatalog() {
- String catalog = this.getContextDefaultCatalog();
- return (catalog == null) ? null : this.resolveDbCatalog(catalog);
- }
-
- protected String getContextDefaultCatalog() {
- MappingFileRoot mfr = this.getMappingFileRoot();
- return (mfr != null) ? mfr.getCatalog() : this.getPersistenceUnit().getDefaultCatalog();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java
deleted file mode 100644
index 48c80d43a2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AbstractXmlContextNode.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import java.util.List;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-import org.eclipse.jpt.jpa.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
-{
- protected AbstractXmlContextNode(JpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** validation **********
-
- /**
- * All subclass implementations should be have a "super" call to this method.
- */
- public void validate(List<IMessage> messages, IReporter reporter) {
- if (reporter.isCancelled()) {
- throw new ValidationCancelledException();
- }
- }
-
- /**
- * Return the specified text range if it is not <code>null</code>; if it is
- * <code>null</code>, return the node's validation text range.
- */
- protected TextRange getValidationTextRange(TextRange textRange) {
- return (textRange != null) ? textRange : this.getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AttributeMappingTools.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AttributeMappingTools.java
deleted file mode 100644
index ea6a5dbdb9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/AttributeMappingTools.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-
-/**
- * Gather some of the behavior common to the Java and XML models. :-(
- */
-public final class AttributeMappingTools
-{
-
- // ********** all mapping names transformer **********
-
- public static final Transformer<AttributeMapping, Iterator<String>> ALL_MAPPING_NAMES_TRANSFORMER = new AllMappingNamesTransformer();
- static class AllMappingNamesTransformer
- implements Transformer<AttributeMapping, Iterator<String>>
- {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allMappingNames();
- }
- }
-
-
- // ********** all overridable attribute mapping names transformer **********
-
- public static final Transformer<AttributeMapping, Iterator<String>> ALL_OVERRIDABLE_ATTRIBUTE_MAPPING_NAMES_TRANSFORMER = new AllOverridableAttributeMappingNamesTransformer();
- static class AllOverridableAttributeMappingNamesTransformer
- implements Transformer<AttributeMapping, Iterator<String>>
- {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverridableAttributeMappingNames();
- }
- }
-
-
- // ********** all overridable association mapping names transformer **********
-
- public static final Transformer<AttributeMapping, Iterator<String>> ALL_OVERRIDABLE_ASSOCIATION_MAPPING_NAMES_TRANSFORMER = new AllOverridableAssociationMappingNamesTransformer();
- static class AllOverridableAssociationMappingNamesTransformer
- implements Transformer<AttributeMapping, Iterator<String>>
- {
- public Iterator<String> transform(AttributeMapping mapping) {
- return mapping.allOverridableAssociationMappingNames();
- }
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private AttributeMappingTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/BaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/BaseColumnTextRangeResolver.java
deleted file mode 100644
index 07cc664f27..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/BaseJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/BaseJoinColumnTextRangeResolver.java
deleted file mode 100644
index 8918e1ce48..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/ContextContainerTools.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/ContextContainerTools.java
deleted file mode 100644
index f8c958501b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/ContextContainerTools.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-
-/**
- * Utility methods for manipulating context containers.
- */
-public class ContextContainerTools {
-
- /**
- * Adapter used to synchronize a context container with its corresponding
- * resource container.
- *
- * @param <C> the type of context elements
- * @param <R> the type of resource elements
- */
- public interface Adapter<C extends JpaContextNode, R> {
-
- /**
- * Return the container's context elements.
- */
- Iterable<C> getContextElements();
-
- /**
- * Return the container's current set of resource elements.
- * These are what the context elements will be synchronized to.
- */
- Iterable<R> getResourceElements();
-
- /**
- * Return the resource element corresponding to the specified context
- * element.
- */
- R getResourceElement(C contextElement);
-
- /**
- * Move the specified context element to the specified index.
- */
- void moveContextElement(int index, C element);
-
- /**
- * Add a context element for the specified resource element at the
- * specified index.
- */
- void addContextElement(int index, R resourceElement);
-
- /**
- * Remove the specified context element from the container.
- */
- void removeContextElement(C element);
- }
-
-
- /**
- * Using the specified adapter, synchronize a context container with its
- * corresponding resource container: moving, removing, and adding elements
- * as necessary.
- * <p>
- * We can do this because:<ul>
- * <li>the XML translators will <em>move</em> the EMF elements when
- * appropriate (as opposed to simply rebuilding them in place).
- * <li>the Java resource model will re-use existing annotations when
- * appropriate (as opposed to simply rebuilding them in place).
- * </ul>
- */
- public static <C extends JpaContextNode, R> void synchronizeWithResourceModel(Adapter<C, R> adapter) {
- sync(adapter, true); // true = sync
- }
-
- /**
- * @see #synchronizeWithResourceModel(Adapter)
- */
- public static <C extends JpaContextNode, R> void update(Adapter<C, R> adapter) {
- sync(adapter, false); // false = update
- }
-
- /**
- * The specified <code>sync</code> flag controls whether any surviving
- * context nodes are either <em>synchronized</em> (<code>true</code>) or
- * <em>updated</em> (<code>false</code>).
- */
- protected static <C extends JpaContextNode, R> void sync(Adapter<C, R> adapter, boolean sync) {
- HashSet<C> contextElements = CollectionTools.set(adapter.getContextElements());
- ArrayList<C> contextElementsToSync = new ArrayList<C>(contextElements.size());
- int resourceIndex = 0;
-
- for (R resourceElement : adapter.getResourceElements()) {
- boolean match = false;
- for (Iterator<C> stream = contextElements.iterator(); stream.hasNext(); ) {
- C contextElement = stream.next();
- if (Tools.valuesAreEqual(adapter.getResourceElement(contextElement), resourceElement)) {
- // we don't know the source index because the element has been moved by previously moved elements
- adapter.moveContextElement(resourceIndex, contextElement);
- stream.remove();
- // TODO perform update here someday...
- contextElementsToSync.add(contextElement);
- match = true;
- break;
- }
- }
- if ( ! match) {
- // added elements are sync'ed during construction or will be
- // updated during the next "update" (which is triggered by
- // their addition to the model)
- adapter.addContextElement(resourceIndex, resourceElement);
- }
- resourceIndex++;
- }
- // remove any leftover context elements
- for (C contextElement : contextElements) {
- adapter.removeContextElement(contextElement);
- }
- // TODO bjv
- // take care of the structural changes before sync'ing the remaining elements;
- // we might be able to do this inline once we get rid of the "list change" events
- // and go with only add, remove, etc. list events
- // (these syncs will trigger "list change" events with list aspect adapters, which
- // trigger refreshes of UI adapters (e.g. TableModelAdapter) which will prematurely
- // discover any structural changes... :( )
- // see ItemAspectListValueModelAdapter.itemAspectChanged(EventObject)
- for (C contextElement : contextElementsToSync) {
- if (sync) {
- contextElement.synchronizeWithResourceModel();
- } else {
- contextElement.update();
- }
- }
- }
-
- private ContextContainerTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/EntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/EntityTextRangeResolver.java
deleted file mode 100644
index 19b118f3b4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-
-public interface EntityTextRangeResolver
- extends PrimaryKeyTextRangeResolver
-{
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JoinColumnTextRangeResolver.java
deleted file mode 100644
index 5c7ac1ede2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-/**
- * Interface to resolve text ranges on join columns
- */
-public interface JoinColumnTextRangeResolver
- extends BaseJoinColumnTextRangeResolver, BaseColumnTextRangeResolver
-{
- // combine interfaces
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JptValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/JptValidator.java
deleted file mode 100644
index 0bc515e2a1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/MappingTools.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/MappingTools.java
deleted file mode 100644
index b105998e43..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/MappingTools.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.ColumnMapping;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.JpaNamedContextNode;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship;
-import org.eclipse.jpt.jpa.core.context.ReferenceTable;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.CollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.ElementCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.db.Table;
-
-/**
- * Gather some of the behavior common to the Java and XML models. :-(
- */
-public final 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(ReadOnlyRelationship relationship) {
- if (relationship.getJpaProject().getDataSource().connectionProfileIsActive()) {
- return buildDbJoinTableDefaultName(relationship);
- }
- // continue with a "best effort":
- String owningTableName = relationship.getTypeMapping().getPrimaryTableName();
- if (owningTableName == null) {
- return null;
- }
- RelationshipMapping relationshipMapping = relationship.getMapping();
- 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.
- */
- private static String buildDbJoinTableDefaultName(ReadOnlyRelationship relationship) {
- Table owningTable = relationship.getTypeMapping().getPrimaryDbTable();
- if (owningTable == null) {
- return null;
- }
- RelationshipMapping relationshipMapping = relationship.getMapping();
- 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<pre>
- * [attribute name]_[referenced column name]
- * </pre>
- * But, if we don't have an attribute name (e.g. in a unidirectional
- * one-to-many or many-to-many) is<pre>
- * [target entity name]_[referenced column name]
- * </pre>
- * @see #buildJoinTableDefaultName(ReadOnlyRelationship)
- */
- public static String buildJoinColumnDefaultName(ReadOnlyJoinColumn joinColumn, ReadOnlyJoinColumn.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();
- }
- // It's not clear which of these is correct....
- // The spec implies that the referenced column is always the
- // *primary key* column of the target entity; i.e. the primary key as
- // defined on the *database* (or, possibly, the primary key as defined
- // by the target entity's Id mapping?), not the name of the referenced
- // column irrespective of whether it is the primary key on the target
- // entity's table. But this seems like it would be wrong; since the
- // referenced column need not be a primary key and we don't always have
- // access to the database.
- //
- // Column targetColumn = joinColumn.getTargetPrimaryKeyDbColumn();
- String targetColumnName = joinColumn.getReferencedColumnName();
- if (targetColumnName == null) {
- return null;
- }
- String name = prefix + '_' + targetColumnName;
- // Again, it's not clear 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;
- }
-
- /**
- * Return the name of the attribute in the specified mapping's target entity
- * that is owned by the mapping.
- */
- public static String getTargetAttributeName(RelationshipMapping relationshipMapping) {
- if (relationshipMapping == null) {
- return null;
- }
- Entity targetEntity = relationshipMapping.getResolvedTargetEntity();
- if (targetEntity == null) {
- return null;
- }
- for (ReadOnlyPersistentAttribute attribute : CollectionTools.iterable(targetEntity.getPersistentType().allAttributes())) {
- if (attribute.getMapping().isOwnedBy(relationshipMapping)) {
- return attribute.getName();
- }
- }
- return null;
- }
-
- /**
- * 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(ReadOnlyJoinColumn.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<ReadOnlyPersistentAttribute> stream = persistentType.allAttributes(); stream.hasNext(); ) {
- ReadOnlyPersistentAttribute 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();
- 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;
- }
- ReadOnlyPersistentAttribute 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();
- }
-
- // TODO move to TypeMapping? may need different name (or may need to rename existing #resolve...)
- public static Column resolveOverriddenColumn(TypeMapping overridableTypeMapping, String attributeName) {
- // convenience null check to simplify client code
- if (overridableTypeMapping == null) {
- return null;
- }
-
- for (TypeMapping typeMapping : CollectionTools.iterable(overridableTypeMapping.inheritanceHierarchy())) {
- Column column = typeMapping.resolveOverriddenColumn(attributeName);
- if (column != null) {
- return column;
- }
- }
- return null;
- }
-
- // TODO move to TypeMapping? may need different name (or may need to rename existing #resolve...)
- public static Relationship resolveOverriddenRelationship(TypeMapping overridableTypeMapping, String attributeName) {
- // convenience null check to simplify client code
- if (overridableTypeMapping == null) {
- return null;
- }
-
- for (TypeMapping typeMapping : CollectionTools.iterable(overridableTypeMapping.inheritanceHierarchy())) {
- Relationship relationship = typeMapping.resolveOverriddenRelationship(attributeName);
- if (relationship != null) {
- return relationship;
- }
- }
- return null;
- }
-
- /**
- * Return whether the specified nodes are "duplicates".
- * @see JpaNamedContextNode#duplicates(Object)
- */
- public static <T extends JpaNamedContextNode<? super T>> boolean nodesAreDuplicates(T node1, T node2) {
- return nodesArePotentalDuplicates_(node1, node2) &&
- ! node1.overrides(node2) &&
- ! node2.overrides(node1);
- }
-
- /**
- * Return whether the specified nodes<ul>
- * <li>are <em>not</em> the same node
- * <li>have the same non-empty name
- * <li>are in the same persistence unit
- * </ul>
- */
- private static <T extends JpaNamedContextNode<? super T>> boolean nodesArePotentalDuplicates_(T node1, T node2) {
- return (node1 != node2) &&
- StringTools.stringIsNotEmpty(node1.getName()) &&
- node1.getName().equals(node2.getName()) &&
- (node1.getPersistenceUnit() == node2.getPersistenceUnit());
- }
-
- /**
- * Return whether the first specified node "overrides" the second,
- * based on the "precedence" of their classes.
- * @see JpaNamedContextNode#overrides(Object)
- */
- public static <T extends JpaNamedContextNode<? super T>> boolean nodeOverrides(T node1, T node2, Iterable<Class<? extends T>> precedenceTypeList) {
- // this isn't ideal, but use it until adopters protest...
- return nodesArePotentalDuplicates_(node1, node2) &&
- calculatePrecedence(node1, precedenceTypeList) < calculatePrecedence(node2, precedenceTypeList);
- }
-
- /**
- * Loop through the specified classes; return the index of the first class
- * the specified node is an instance of.
- */
- private static <T extends JpaNamedContextNode<? super T>> int calculatePrecedence(T node, Iterable<Class<? extends T>> precedenceTypeList) {
- int precedence = 0;
- for (Class<?> nodeClass : precedenceTypeList) {
- if (nodeClass.isInstance(node)) {
- return precedence;
- }
- precedence++;
- }
- throw new IllegalArgumentException("unknown named node: " + node); //$NON-NLS-1$
- }
-
- public static String getPrimaryKeyColumnName(Entity entity) {
- String pkColumnName = null;
- for (Iterator<ReadOnlyPersistentAttribute> stream = entity.getPersistentType().allAttributes(); stream.hasNext(); ) {
- ReadOnlyPersistentAttribute 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
- ReadOnlyAttributeOverride attributeOverride = entity.getAttributeOverrideContainer().getOverrideNamed(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;
- }
-
- /**
- * "Unqualify" the specified attribute name, removing the mapping's name
- * from the front of the attribute name if it is present. For example, if
- * the mapping's name is <code>"foo"</code>, the attribute name
- * <code>"foo.bar"</code> would be converted to <code>"bar"</code>).
- * Return <code>null</code> if the attribute name cannot be "unqualified".
- */
- public static String unqualify(String mappingName, String attributeName) {
- if (mappingName == null) {
- return null;
- }
- if ( ! attributeName.startsWith(mappingName)) {
- return null;
- }
- int mappingNameLength = mappingName.length();
- if (attributeName.length() <= mappingNameLength) {
- return null;
- }
- return (attributeName.charAt(mappingNameLength) == '.') ? attributeName.substring(mappingNameLength + 1) : null;
- }
-
- /**
- * This transformer will prepend a specified qualifier, followed by a
- * dot ('.'), to a string. For example, if a mapping's name is
- * <code>"foo"</code> and one of its attribute's is named
- * <code>"bar"</code>, the attribute's name will be transformed
- * into <code>"foo.bar"</code>. If the specified qualifier is
- * <code>null</code> (or an empty string), only a dot will be prepended
- * to a string.
- */
- public static class QualifierTransformer
- implements Transformer<String, String>
- {
- private final String prefix;
- public QualifierTransformer(String qualifier) {
- super();
- this.prefix = (qualifier == null) ? "." : qualifier + '.'; //$NON-NLS-1$
- }
- public String transform(String s) {
- return this.prefix + s;
- }
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private MappingTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/NamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/NamedColumnTextRangeResolver.java
deleted file mode 100644
index da477387e9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on named columns
- */
-public interface NamedColumnTextRangeResolver
-{
- TextRange getNameTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/OverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/OverrideTextRangeResolver.java
deleted file mode 100644
index 901eae1c02..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on named columns
- */
-public interface OverrideTextRangeResolver
-{
- TextRange getNameTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java
deleted file mode 100644
index 7620a04d2e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributePropertyTester.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-
-public class PersistentAttributePropertyTester
- extends PropertyTester
-{
- public static final String IS_MAPPED = "isMapped"; //$NON-NLS-1$
-
- public static final String IS_VIRTUAL = "isVirtual"; //$NON-NLS-1$
-
-
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (property == null) {
- return false;
- }
- if ( ! (expectedValue instanceof Boolean)) {
- return false;
- }
- return this.test_(receiver, property, ((Boolean) expectedValue).booleanValue());
- }
-
- /**
- * pre-condition: property is not <code>null</code>
- */
- protected boolean test_(Object receiver, String property, boolean expected) {
- if (property.equals(IS_MAPPED)) {
- boolean actual = ((ReadOnlyPersistentAttribute) receiver).getMapping().getKey() != null;
- return actual == expected;
- }
- if (property.equals(IS_VIRTUAL)) {
- boolean actual = ((ReadOnlyPersistentAttribute) receiver).isVirtual();
- return actual == expected;
- }
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PersistentAttributeTextRangeResolver.java
deleted file mode 100644
index a2345cc459..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-
-/**
- * Interface to resolve text ranges on persistent attributes
- */
-public interface PersistentAttributeTextRangeResolver
-{
- TextRange getAttributeTextRange();
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PrimaryKeyTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/PrimaryKeyTextRangeResolver.java
deleted file mode 100644
index 8a759ea107..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TableTextRangeResolver.java
deleted file mode 100644
index a66f0ede07..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTextRangeResolver.java
deleted file mode 100644
index a30cac215c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context;
-
-import org.eclipse.jpt.common.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTools.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTools.java
deleted file mode 100644
index 78deca4bf8..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/TypeMappingTools.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
-
-/**
- * Gather some of the behavior common to the Java and XML models. :-(
- */
-public class TypeMappingTools
-{
- // ********** single relationship mappings **********
-
- public static Iterable<String> getMappedByRelationshipAttributeNames(TypeMapping typeMapping) {
- return new TransformationIterable<SingleRelationshipMapping2_0, String>(getMapsIdRelationshipMappings(typeMapping)) {
- @Override
- protected String transform(SingleRelationshipMapping2_0 attributeMapping) {
- return attributeMapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue();
- }
- };
- }
-
- public static Iterable<SingleRelationshipMapping2_0> getMapsIdRelationshipMappings(TypeMapping typeMapping) {
- return new FilteringIterable<SingleRelationshipMapping2_0>(getSingleRelationshipMappings(typeMapping)) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 attributeMapping) {
- return attributeMapping.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
- protected static Iterable<SingleRelationshipMapping2_0> getSingleRelationshipMappings(TypeMapping typeMapping) {
- return new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(getSingleRelationshipMappings_(typeMapping));
- }
-
- @SuppressWarnings("unchecked")
- protected static Iterable<AttributeMapping> getSingleRelationshipMappings_(TypeMapping typeMapping) {
- return new CompositeIterable<AttributeMapping>(
- typeMapping.getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- typeMapping.getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)
- );
- }
-
-
- // ********** attribute mappings transformer **********
-
- public static final Transformer<TypeMapping, Iterator<AttributeMapping>> ATTRIBUTE_MAPPINGS_TRANSFORMER = new AttributeMappingsTransformer();
- static class AttributeMappingsTransformer
- implements Transformer<TypeMapping, Iterator<AttributeMapping>>
- {
- public Iterator<AttributeMapping> transform(TypeMapping mapping) {
- return mapping.attributeMappings();
- }
- }
-
-
- // ********** associated tables transformer **********
-
- public static final Transformer<TypeMapping, Iterator<ReadOnlyTable>> ASSOCIATED_TABLES_TRANSFORMER = new AssociatedTablesTransformer();
- static class AssociatedTablesTransformer
- implements Transformer<TypeMapping, Iterator<ReadOnlyTable>>
- {
- public Iterator<ReadOnlyTable> transform(TypeMapping mapping) {
- return mapping.associatedTables();
- }
- }
-
-
- // ********** overridable attribute names transformer **********
-
- public static final Transformer<TypeMapping, Iterator<String>> OVERRIDABLE_ATTRIBUTE_NAMES_TRANSFORMER = new OverridableAttributeNamesTransformer();
- static class OverridableAttributeNamesTransformer
- implements Transformer<TypeMapping, Iterator<String>>
- {
- public Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAttributeNames();
- }
- }
-
-
- // ********** overridable association names transformer **********
-
- public static final Transformer<TypeMapping, Iterator<String>> OVERRIDABLE_ASSOCIATION_NAMES_TRANSFORMER = new OverridableAssociationNamesTransformer();
- static class OverridableAssociationNamesTransformer
- implements Transformer<TypeMapping, Iterator<String>>
- {
- public Iterator<String> transform(TypeMapping mapping) {
- return mapping.overridableAssociationNames();
- }
- }
-
-
- // ********** constructor **********
-
- /**
- * Suppress default constructor, ensuring non-instantiability.
- */
- private TypeMappingTools() {
- super();
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java
deleted file mode 100644
index 3d56fe46cc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.ColumnMapping;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.SimpleMetamodelField;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java attribute mapping
- * <p>
- * The mapping annotation is <code>null</code> for default mappings.
- * It will be faulted into existence whenever {@link #getAnnotationForUpdate()}
- * is called. It will <em>not</em> return to <code>null</code> automatically
- * when all its state is defaulted; it must be explicitly cleared via
- * {@link JavaPersistentAttribute#setMappingKey(String)}.
- */
-public abstract class AbstractJavaAttributeMapping<A extends Annotation>
- extends AbstractJavaJpaContextNode
- implements JavaAttributeMapping, AttributeMapping2_0
-{
- protected boolean default_;
-
-
- protected AbstractJavaAttributeMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.default_ = this.buildDefault();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.updateDefault();
- }
-
- @Override
- public void update() {
- super.update();
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.getPersistentAttribute().getName();
- }
-
-
- // ********** annotation **********
-
- @SuppressWarnings("unchecked")
- public A getMappingAnnotation() {
- return (A) this.getAnnotation_();
- }
-
- protected Annotation getAnnotation_() {
- return this.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName());
- }
-
- protected abstract String getAnnotationName();
-
- /**
- * This method should only be called on mappings that can occur by default
- * (e.g. <code>Basic</code>, <code>Embedded</code>, <code>OneToOne</code>,
- * and <code>OneToMany</code>).
- */
- public A getAnnotationForUpdate() {
- A annotation = this.getMappingAnnotation();
- if (annotation == null) {
- this.getPersistentAttribute().setMappingKey(this.getKey());
- annotation = this.getMappingAnnotation();
- if (annotation == null) {
- throw new IllegalStateException("missing annotation: " + this); //$NON-NLS-1$
- }
- }
- return annotation;
- }
-
-
- // ********** default **********
-
- public boolean isDefault() {
- return this.default_;
- }
-
- protected void setDefault(boolean default_) {
- boolean old = this.default_;
- this.default_ = default_;
- this.firePropertyChanged(DEFAULT_PROPERTY, old, default_);
- }
-
- public void updateDefault() {
- this.setDefault(this.buildDefault());
- }
-
- protected boolean buildDefault() {
- return this.getMappingAnnotation() == null;
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaPersistentAttribute getParent() {
- return (JavaPersistentAttribute) super.getParent();
- }
-
- public JavaPersistentAttribute getPersistentAttribute() {
- return this.getParent();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getPersistentAttribute().getOwningTypeMapping();
- }
-
- public JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.getPersistentAttribute().getResourcePersistentAttribute();
- }
-
- 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 boolean validatesAgainstDatabase() {
- return this.getTypeMapping().validatesAgainstDatabase();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- protected JavaPersistentAttribute getJavaPersistentAttribute() {
- return this.getPersistentAttribute().getJavaPersistentAttribute();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** embedded mappings **********
-
- public Iterator<String> allMappingNames() {
- return new SingleElementIterator<String>(this.getName());
- }
-
- public Iterator<String> allOverridableAttributeMappingNames() {
- return this.isOverridableAttributeMapping() ?
- new SingleElementIterator<String>(this.getName()) :
- EmptyIterator.<String>instance();
- }
-
- public Iterator<String> allOverridableAssociationMappingNames() {
- return this.isOverridableAssociationMapping() ?
- new SingleElementIterator<String>(this.getName()) :
- EmptyIterator.<String>instance();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- ColumnMapping mapping = this.resolveColumnMapping(attributeName);
- return (mapping == null) ? null : mapping.getColumn();
- }
-
- protected ColumnMapping resolveColumnMapping(String name) {
- AttributeMapping mapping = this.resolveAttributeMapping(name);
- return ((mapping != null) && mapping.isOverridableAttributeMapping()) ? (ColumnMapping) mapping : null;
- }
-
- public Relationship resolveOverriddenRelationship(String attributeName) {
- RelationshipMapping mapping = this.resolveRelationshipMapping(attributeName);
- return (mapping == null) ? null : mapping.getRelationship();
- }
-
- protected RelationshipMapping resolveRelationshipMapping(String name) {
- AttributeMapping mapping = this.resolveAttributeMapping(name);
- return ((mapping != null) && mapping.isOverridableAssociationMapping()) ? (RelationshipMapping) mapping : null;
- }
-
- public AttributeMapping resolveAttributeMapping(String attributeName) {
- return this.getName().equals(attributeName) ? this : null;
- }
-
- protected Transformer<String, String> buildQualifierTransformer() {
- return new MappingTools.QualifierTransformer(this.getName());
- }
-
- protected String unqualify(String attributeName) {
- return MappingTools.unqualify(this.getName(), attributeName);
- }
-
-
- // ********** 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.getPersistentAttribute().getValidationTextRange(astRoot);
- }
-
- protected TextRange getMappingAnnotationTextRange(CompilationUnit astRoot) {
- A annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java
deleted file mode 100644
index 9fccee517c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseColumn.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.java.BaseColumnAnnotation;
-
-/**
- * Java column or join column
- */
-public abstract class AbstractJavaBaseColumn<A extends BaseColumnAnnotation, O extends JavaBaseColumn.Owner>
- extends AbstractJavaNamedColumn<A, O>
- implements JavaBaseColumn
-{
- protected String specifiedTable;
- protected String defaultTable;
-
- protected Boolean specifiedUnique;
- protected boolean defaultUnique;
-
- protected Boolean specifiedNullable;
- protected boolean defaultNullable;
-
- protected Boolean specifiedInsertable;
- protected boolean defaultInsertable;
-
- protected Boolean specifiedUpdatable;
- protected boolean defaultUpdatable;
-
-
- protected AbstractJavaBaseColumn(JavaJpaContextNode parent, O owner) {
- this(parent, owner, null);
- }
-
- protected AbstractJavaBaseColumn(JavaJpaContextNode parent, O owner, A columnAnnotation) {
- super(parent, owner, columnAnnotation);
- this.specifiedTable = this.buildSpecifiedTable();
- this.specifiedUnique = this.buildSpecifiedUnique();
- this.specifiedNullable = this.buildSpecifiedNullable();
- this.specifiedInsertable = this.buildSpecifiedInsertable();
- this.specifiedUpdatable = this.buildSpecifiedUpdatable();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedTable_(this.buildSpecifiedTable());
- this.setSpecifiedUnique_(this.buildSpecifiedUnique());
- this.setSpecifiedNullable_(this.buildSpecifiedNullable());
- this.setSpecifiedInsertable_(this.buildSpecifiedInsertable());
- this.setSpecifiedUpdatable_(this.buildSpecifiedUpdatable());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultTable(this.buildDefaultTable());
- this.setDefaultUnique(this.buildDefaultUnique());
- this.setDefaultNullable(this.buildDefaultNullable());
- this.setDefaultInsertable(this.buildDefaultInsertable());
- this.setDefaultUpdatable(this.buildDefaultUpdatable());
- }
-
-
- // ********** table **********
-
- @Override
- public String getTable() {
- return (this.specifiedTable != null) ? this.specifiedTable : this.defaultTable;
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- public void setSpecifiedTable(String table) {
- if (this.valuesAreDifferent(this.specifiedTable, table)) {
- this.getColumnAnnotation().setTable(table);
- this.removeColumnAnnotationIfUnset();
- this.setSpecifiedTable_(table);
- }
- }
-
- protected void setSpecifiedTable_(String table) {
- String old = this.specifiedTable;
- this.specifiedTable = table;
- this.firePropertyChanged(SPECIFIED_TABLE_PROPERTY, old, table);
- }
-
- protected String buildSpecifiedTable() {
- return this.getColumnAnnotation().getTable();
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String table) {
- String old = this.defaultTable;
- this.defaultTable = table;
- this.firePropertyChanged(DEFAULT_TABLE_PROPERTY, old, table);
- }
-
- protected String buildDefaultTable() {
- return this.owner.getDefaultTableName();
- }
-
- public TextRange getTableTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.getColumnAnnotation().getTableTextRange(astRoot), astRoot);
- }
-
-
- // ********** unique **********
-
- public boolean isUnique() {
- return (this.specifiedUnique != null) ? this.specifiedUnique.booleanValue() : this.isDefaultUnique();
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- public void setSpecifiedUnique(Boolean unique) {
- if (this.valuesAreDifferent(this.specifiedUnique, unique)) {
- this.getColumnAnnotation().setUnique(unique);
- this.removeColumnAnnotationIfUnset();
- this.setSpecifiedUnique_(unique);
- }
- }
-
- protected void setSpecifiedUnique_(Boolean unique) {
- Boolean old = this.specifiedUnique;
- this.specifiedUnique = unique;
- this.firePropertyChanged(SPECIFIED_UNIQUE_PROPERTY, old, unique);
- }
-
- protected Boolean buildSpecifiedUnique() {
- return this.getColumnAnnotation().getUnique();
- }
-
- public boolean isDefaultUnique() {
- return this.defaultUnique;
- }
-
- protected void setDefaultUnique(boolean unique) {
- boolean old = this.defaultUnique;
- this.defaultUnique = unique;
- this.firePropertyChanged(DEFAULT_UNIQUE_PROPERTY, old, unique);
- }
-
- protected boolean buildDefaultUnique() {
- return DEFAULT_UNIQUE;
- }
-
-
- // ********** nullable **********
-
- public boolean isNullable() {
- return (this.specifiedNullable != null) ? this.specifiedNullable.booleanValue() : this.isDefaultNullable();
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- public void setSpecifiedNullable(Boolean nullable) {
- if (this.valuesAreDifferent(this.specifiedNullable, nullable)) {
- this.getColumnAnnotation().setNullable(nullable);
- this.removeColumnAnnotationIfUnset();
- this.setSpecifiedNullable_(nullable);
- }
- }
-
- protected void setSpecifiedNullable_(Boolean nullable) {
- Boolean old = this.specifiedNullable;
- this.specifiedNullable = nullable;
- this.firePropertyChanged(SPECIFIED_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected Boolean buildSpecifiedNullable() {
- return this.getColumnAnnotation().getNullable();
- }
-
- public boolean isDefaultNullable() {
- return this.defaultNullable;
- }
-
- protected void setDefaultNullable(boolean nullable) {
- boolean old = this.defaultNullable;
- this.defaultNullable = nullable;
- this.firePropertyChanged(DEFAULT_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected boolean buildDefaultNullable() {
- return DEFAULT_NULLABLE;
- }
-
-
- // ********** insertable **********
-
- public boolean isInsertable() {
- return (this.specifiedInsertable != null) ? this.specifiedInsertable.booleanValue() : this.isDefaultInsertable();
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- public void setSpecifiedInsertable(Boolean insertable) {
- if (this.valuesAreDifferent(this.specifiedInsertable, insertable)) {
- this.getColumnAnnotation().setInsertable(insertable);
- this.removeColumnAnnotationIfUnset();
- this.setSpecifiedInsertable_(insertable);
- }
- }
-
- protected void setSpecifiedInsertable_(Boolean insertable) {
- Boolean old = this.specifiedInsertable;
- this.specifiedInsertable = insertable;
- this.firePropertyChanged(SPECIFIED_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected Boolean buildSpecifiedInsertable() {
- return this.getColumnAnnotation().getInsertable();
- }
-
- public boolean isDefaultInsertable() {
- return this.defaultInsertable;
- }
-
- protected void setDefaultInsertable(boolean insertable) {
- boolean old = this.defaultInsertable;
- this.defaultInsertable = insertable;
- this.firePropertyChanged(DEFAULT_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected boolean buildDefaultInsertable() {
- return DEFAULT_INSERTABLE;
- }
-
-
- // ********** updatable **********
-
- public boolean isUpdatable() {
- return (this.specifiedUpdatable != null) ? this.specifiedUpdatable.booleanValue() : this.isDefaultUpdatable();
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- public void setSpecifiedUpdatable(Boolean updatable) {
- if (this.valuesAreDifferent(this.specifiedUpdatable, updatable)) {
- this.getColumnAnnotation().setUpdatable(updatable);
- this.removeColumnAnnotationIfUnset();
- this.setSpecifiedUpdatable_(updatable);
- }
- }
-
- protected void setSpecifiedUpdatable_(Boolean updatable) {
- Boolean old = this.specifiedUpdatable;
- this.specifiedUpdatable = updatable;
- this.firePropertyChanged(SPECIFIED_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected Boolean buildSpecifiedUpdatable() {
- return this.getColumnAnnotation().getUpdatable();
- }
-
- public boolean isDefaultUpdatable() {
- return this.defaultUpdatable;
- }
-
- protected void setDefaultUpdatable(boolean updatable) {
- boolean old = this.defaultUpdatable;
- this.defaultUpdatable = updatable;
- this.firePropertyChanged(DEFAULT_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected boolean buildDefaultUpdatable() {
- return DEFAULT_UPDATABLE;
- }
-
-
- // ********** misc **********
-
- protected void initializeFrom(ReadOnlyBaseColumn oldColumn) {
- super.initializeFrom(oldColumn);
- this.setSpecifiedTable(oldColumn.getSpecifiedTable());
- this.setSpecifiedUnique(oldColumn.getSpecifiedUnique());
- this.setSpecifiedNullable(oldColumn.getSpecifiedNullable());
- this.setSpecifiedInsertable(oldColumn.getSpecifiedInsertable());
- this.setSpecifiedUpdatable(oldColumn.getSpecifiedUpdatable());
- }
-
- protected void initializeFromVirtual(ReadOnlyBaseColumn virtualColumn) {
- super.initializeFromVirtual(virtualColumn);
- this.setSpecifiedTable(virtualColumn.getTable());
- // ignore other settings?
- }
-
- public boolean tableNameIsInvalid() {
- return this.owner.tableNameIsInvalid(this.getTable());
- }
-
-
- // ********** 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;
- }
- if (this.tableTouches(pos, astRoot)) {
- return this.javaCandidateTableNames(filter);
- }
- return null;
- }
-
- protected boolean tableTouches(int pos, CompilationUnit astRoot) {
- return this.getColumnAnnotation().tableTouches(pos, astRoot);
- }
-
- protected Iterator<String> javaCandidateTableNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateTableNames(filter));
- }
-
- protected Iterator<String> candidateTableNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateTableNames(), filter);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.owner.candidateTableNames();
- }
-
- @Override
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaBaseColumnTextRangeResolver(this, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java
deleted file mode 100644
index 6d20bd5ba3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBaseEmbeddedMapping.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.OverrideContainer;
-import org.eclipse.jpt.jpa.core.context.Override_;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaBaseEmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> embedded or embedded ID mapping
- */
-public abstract class AbstractJavaBaseEmbeddedMapping<A extends Annotation>
- extends AbstractJavaAttributeMapping<A>
- implements JavaBaseEmbeddedMapping
-{
- protected final JavaAttributeOverrideContainer attributeOverrideContainer;
-
- protected Embeddable targetEmbeddable;
-
-
- protected AbstractJavaBaseEmbeddedMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.attributeOverrideContainer = this.buildAttributeOverrideContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.attributeOverrideContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.attributeOverrideContainer.update();
- this.setTargetEmbeddable(this.buildTargetEmbeddable());
- }
-
-
- // ********** attribute override container **********
-
- public JavaAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- protected JavaAttributeOverrideContainer buildAttributeOverrideContainer() {
- return this.getJpaFactory().buildJavaAttributeOverrideContainer(this, this.buildAttributeOverrideContainerOwner());
- }
-
- protected JavaAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() {
- return new AttributeOverrideContainerOwner();
- }
-
-
- // ********** target embeddable **********
-
- public Embeddable getTargetEmbeddable() {
- return this.targetEmbeddable;
- }
-
- protected void setTargetEmbeddable(Embeddable embeddable) {
- Embeddable old = this.targetEmbeddable;
- this.targetEmbeddable = embeddable;
- this.firePropertyChanged(TARGET_EMBEDDABLE_PROPERTY, old, embeddable);
- }
-
- protected Embeddable buildTargetEmbeddable() {
- return this.getPersistentAttribute().getEmbeddable();
- }
-
-
- // ********** embedded mappings **********
-
- @Override
- public Iterator<String> allOverridableAttributeMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverridableAttributeMappingNames() :
- super.allOverridableAttributeMappingNames();
- }
-
- protected Iterator<String> embeddableOverridableAttributeMappingNames() {
- return this.qualifiedEmbeddableOverridableMappingNames(AttributeMappingTools.ALL_OVERRIDABLE_ATTRIBUTE_MAPPING_NAMES_TRANSFORMER);
- }
-
- @Override
- public Iterator<String> allOverridableAssociationMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverridableAssociationMappingNames() :
- super.allOverridableAssociationMappingNames();
- }
-
- protected Iterator<String> embeddableOverridableAssociationMappingNames() {
- return this.qualifiedEmbeddableOverridableMappingNames(AttributeMappingTools.ALL_OVERRIDABLE_ASSOCIATION_MAPPING_NAMES_TRANSFORMER);
- }
-
- protected Iterator<String> qualifiedEmbeddableOverridableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<String, String>(this.embeddableAttributeMappingNames(transformer), this.buildQualifierTransformer());
- }
-
- protected Iterator<String> embeddableAttributeMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new CompositeIterator<String>(this.embeddableAttributeMappingNamesLists(transformer));
- }
-
- /**
- * Return a list of lists; each nested list holds the names for one of the
- * embedded mapping's target embeddable type mapping's attribute mappings
- * (attribute or association mappings, depending on the specified transformer).
- */
- protected Iterator<Iterator<String>> embeddableAttributeMappingNamesLists(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer);
- }
-
- /**
- * Return the target embeddable's attribute mappings.
- */
- protected Iterator<AttributeMapping> embeddableAttributeMappings() {
- return ((this.targetEmbeddable != null) && (this.targetEmbeddable != this.getTypeMapping())) ?
- this.targetEmbeddable.attributeMappings() :
- EmptyIterator.<AttributeMapping>instance();
- }
-
-
- // ********** misc **********
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- return this.isJpa2_0Compatible() ? this.resolveOverriddenColumn_(attributeName) : null;
- }
-
- protected Column resolveOverriddenColumn_(String attributeName) {
- attributeName = this.unqualify(attributeName);
- if (attributeName == null) {
- return null;
- }
- AttributeOverride override = this.attributeOverrideContainer.getSpecifiedOverrideNamed(attributeName);
- // recurse into the target embeddable if necessary
- return (override != null) ? override.getColumn() : this.resolveOverriddenColumnInTargetEmbeddable(attributeName);
- }
-
- protected Column resolveOverriddenColumnInTargetEmbeddable(String attributeName) {
- return (this.targetEmbeddable == null) ? null : this.targetEmbeddable.resolveOverriddenColumn(attributeName);
- }
-
-
- // ********** 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.attributeOverrideContainer.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 (this.validateTargetEmbeddable(messages, astRoot)) {
- this.validateOverrides(messages, reporter, astRoot);
- }
- }
-
- protected boolean validateTargetEmbeddable(List<IMessage> messages, CompilationUnit astRoot) {
- if (this.targetEmbeddable != null) {
- return true;
- }
- String targetEmbeddableTypeName = this.getPersistentAttribute().getTypeName();
- // if the type isn't resolvable, there will already be a java compile 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;
- }
-
- protected void validateOverrides(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.attributeOverrideContainer.validate(messages, reporter, astRoot);
- }
-
-
- // ********** attribute override container owner *********
-
- protected class AttributeOverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public JavaResourcePersistentMember getResourcePersistentMember() {
- return AbstractJavaBaseEmbeddedMapping.this.getResourcePersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return AbstractJavaBaseEmbeddedMapping.this.getTypeMapping();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaBaseEmbeddedMapping.this.getTargetEmbeddable();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = this.getOverridableTypeMapping();
- return (typeMapping != null) ? this.allOverridableAttributeNames_(typeMapping) : EmptyIterator.<String>instance();
- }
-
- /**
- * pre-condition: type mapping is not <code>null</code>
- * <p>
- * NB: Overridden in {@link GenericOrmEmbeddedIdMapping.AttributeOverrideContainerOwner}
- */
- protected Iterator<String> allOverridableAttributeNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAttributeNames();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- // no maps, so all overrides are relevant
- public boolean isRelevant(String overrideName) {
- return true;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaBaseEmbeddedMapping.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator(this.getPersistentAttribute(), (AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator(this.getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- protected JavaPersistentAttribute getPersistentAttribute() {
- return AbstractJavaBaseEmbeddedMapping.this.getPersistentAttribute();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBasicMapping.java
deleted file mode 100644
index b8444408cd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaBasicMapping.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.Association;
-import org.eclipse.jpt.common.utility.internal.SimpleAssociation;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Converter;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaBasicMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
-import org.eclipse.jpt.jpa.core.context.java.JavaEnumeratedConverter;
-import org.eclipse.jpt.jpa.core.context.java.JavaLobConverter;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaTemporalConverter;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.NullJavaConverter;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java basic mapping
- */
-public abstract class AbstractJavaBasicMapping
- extends AbstractJavaAttributeMapping<BasicAnnotation>
- implements JavaBasicMapping
-{
- protected final JavaColumn column;
-
- protected FetchType specifiedFetch;
- protected FetchType defaultFetch;
-
- protected Boolean specifiedOptional;
- protected boolean defaultOptional;
-
- protected JavaConverter converter; // never null
-
-
- protected static final JavaConverter.Adapter[] CONVERTER_ADAPTER_ARRAY = new JavaConverter.Adapter[] {
- JavaEnumeratedConverter.Adapter.instance(),
- JavaTemporalConverter.Adapter.instance(),
- JavaLobConverter.Adapter.instance()
- };
- protected static final Iterable<JavaConverter.Adapter> CONVERTER_ADAPTERS = new ArrayIterable<JavaConverter.Adapter>(CONVERTER_ADAPTER_ARRAY);
-
-
- protected AbstractJavaBasicMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = this.buildColumn();
- this.specifiedFetch = this.buildSpecifiedFetch();
- this.specifiedOptional = this.buildSpecifiedOptional();
- this.converter = this.buildConverter();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.column.synchronizeWithResourceModel();
- this.setSpecifiedFetch_(this.buildSpecifiedFetch());
- this.setSpecifiedOptional_(this.buildSpecifiedOptional());
- this.syncConverter();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update();
- this.setDefaultFetch(this.buildDefaultFetch());
- this.setDefaultOptional(this.buildDefaultOptional());
- this.converter.update();
- }
-
-
- // ********** column **********
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- protected JavaColumn buildColumn() {
- return this.getJpaFactory().buildJavaColumn(this, this);
- }
-
-
- // ********** fetch **********
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.defaultFetch;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- if (this.valuesAreDifferent(fetch, this.specifiedFetch)) {
- this.getAnnotationForUpdate().setFetch(FetchType.toJavaResourceModel(fetch));
- this.setSpecifiedFetch_(fetch);
- }
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType buildSpecifiedFetch() {
- BasicAnnotation annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : FetchType.fromJavaResourceModel(annotation.getFetch());
- }
-
- public FetchType getDefaultFetch() {
- return this.defaultFetch;
- }
-
- protected void setDefaultFetch(FetchType fetch) {
- FetchType old = this.defaultFetch;
- this.defaultFetch = fetch;
- this.firePropertyChanged(DEFAULT_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType buildDefaultFetch() {
- 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) {
- if (this.valuesAreDifferent(optional, this.specifiedOptional)) {
- this.getAnnotationForUpdate().setOptional(optional);
- this.setSpecifiedOptional_(optional);
- }
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected Boolean buildSpecifiedOptional() {
- BasicAnnotation annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getOptional();
- }
-
- public boolean isDefaultOptional() {
- return defaultOptional;
- }
-
- protected void setDefaultOptional(boolean optional) {
- boolean old = this.defaultOptional;
- this.defaultOptional = optional;
- this.firePropertyChanged(DEFAULT_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected boolean buildDefaultOptional() {
- return DEFAULT_OPTIONAL;
- }
-
-
- // ********** converter **********
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- public void setConverter(Class<? extends Converter> converterType) {
- if (this.converter.getType() != converterType) {
- this.converter.dispose();
- JavaConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.retainConverterAnnotation(converterAdapter);
- this.setConverter_(this.buildConverter(converterAdapter));
- }
- }
-
- protected JavaConverter buildConverter(JavaConverter.Adapter converterAdapter) {
- return (converterAdapter != null) ?
- converterAdapter.buildNewConverter(this, this.getJpaFactory()) :
- this.buildNullConverter();
- }
-
- protected void setConverter_(JavaConverter converter) {
- Converter old = this.converter;
- this.converter = converter;
- this.firePropertyChanged(CONVERTER_PROPERTY, old, converter);
- }
-
- /**
- * Clear all the converter annotations <em>except</em> for the annotation
- * corresponding to the specified adapter. If the specified adapter is
- * <code>null</code>, remove <em>all</em> the converter annotations.
- */
- protected void retainConverterAnnotation(JavaConverter.Adapter converterAdapter) {
- JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter != converterAdapter) {
- adapter.removeConverterAnnotation(resourceAttribute);
- }
- }
- }
-
- protected JavaConverter buildConverter() {
- JpaFactory jpaFactory = this.getJpaFactory();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- JavaConverter javaConverter = adapter.buildConverter(this, jpaFactory);
- if (javaConverter != null) {
- return javaConverter;
- }
- }
- return this.buildNullConverter();
- }
-
- protected void syncConverter() {
- Association<JavaConverter.Adapter, Annotation> assoc = this.getConverterAnnotation();
- if (assoc == null) {
- if (this.converter.getType() != null) {
- this.setConverter_(this.buildNullConverter());
- }
- } else {
- JavaConverter.Adapter adapter = assoc.getKey();
- Annotation annotation = assoc.getValue();
- if ((this.converter.getType() == adapter.getConverterType()) &&
- (this.converter.getConverterAnnotation() == annotation)) {
- this.converter.synchronizeWithResourceModel();
- } else {
- this.setConverter_(adapter.buildConverter(annotation, this, this.getJpaFactory()));
- }
- }
- }
-
- /**
- * Return the first converter annotation we find along with its corresponding
- * adapter. Return <code>null</code> if there are no converter annotations.
- */
- protected Association<JavaConverter.Adapter, Annotation> getConverterAnnotation() {
- JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- Annotation annotation = adapter.getConverterAnnotation(resourceAttribute);
- if (annotation != null) {
- return new SimpleAssociation<JavaConverter.Adapter, Annotation>(adapter, annotation);
- }
- }
- return null;
- }
-
- protected JavaConverter buildNullConverter() {
- return new NullJavaConverter(this);
- }
-
-
- // ********** converter adapters **********
-
- /**
- * Return the converter adapter for the specified converter type.
- */
- protected JavaConverter.Adapter getConverterAdapter(Class<? extends Converter> converterType) {
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.getConverterType() == converterType) {
- return adapter;
- }
- }
- return null;
- }
-
- protected Iterable<JavaConverter.Adapter> getConverterAdapters() {
- return CONVERTER_ADAPTERS;
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return BasicAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
-
- // ********** JavaColumn.Owner implementation **********
-
- public ColumnAnnotation getColumnAnnotation() {
- return (ColumnAnnotation) this.getResourcePersistentAttribute().getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- public void removeColumnAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- public String getDefaultColumnName() {
- return this.getName();
- }
-
- public String getDefaultTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
-
- // ********** 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.column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.converter.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.column.validate(messages, reporter, astRoot);
- this.converter.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddable.java
deleted file mode 100644
index 991d67b0d2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEmbeddable.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.EmbeddableAnnotation;
-
-/**
- * Java embeddable type mapping
- */
-public abstract class AbstractJavaEmbeddable
- extends AbstractJavaTypeMapping<EmbeddableAnnotation>
- implements JavaEmbeddable
-{
- protected AbstractJavaEmbeddable(JavaPersistentType parent, EmbeddableAnnotation mappingAnnotation) {
- super(parent, mappingAnnotation);
- }
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
- public JavaPersistentType getIdClass() {
- return null;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
- @Override
- public boolean validatesAgainstDatabase() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
deleted file mode 100644
index ea61083d54..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaEntity.java
+++ /dev/null
@@ -1,1839 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Collection;
-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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SubIteratorWrapper;
-import org.eclipse.jpt.common.utility.internal.iterators.SuperIteratorWrapper;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.JpaPlatformVariation.Supported;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AssociationOverride;
-import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.context.DiscriminatorType;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.InheritanceType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.OverrideContainer;
-import org.eclipse.jpt.jpa.core.context.Override_;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.SecondaryTable;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaDiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.jpa.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaQueryContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideJoinTableValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.DiscriminatorColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericEntityPrimaryKeyValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MappedSuperclassOverrideDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.SecondaryTableValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.TableValidator;
-import org.eclipse.jpt.jpa.core.internal.resource.java.NullPrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCacheableHolder2_0;
-import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorValueAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.InheritanceAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableSecondaryTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.SecondaryTablesAnnotation;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java entity
- */
-public abstract class AbstractJavaEntity
- extends AbstractJavaTypeMapping<EntityAnnotation>
- implements JavaEntity, JavaCacheableHolder2_0, JavaGeneratorContainer.Owner, JavaQueryContainer.Owner
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected Entity rootEntity;
- protected final Vector<Entity> descendants = new Vector<Entity>();
-
- protected final JavaIdClassReference idClassReference;
-
- protected final JavaTable table;
- protected boolean specifiedTableIsAllowed;
- protected boolean tableIsUndefined;
-
- protected final Vector<JavaSecondaryTable> specifiedSecondaryTables = new Vector<JavaSecondaryTable>();
- protected final SpecifiedSecondaryTableContainerAdapter specifiedSecondaryTableContainerAdapter = new SpecifiedSecondaryTableContainerAdapter();
- protected final Table.Owner specifiedSecondaryTableOwner;
-
- protected final PrimaryKeyJoinColumnOwner primaryKeyJoinColumnOwner;
- protected final Vector<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns = new Vector<JavaPrimaryKeyJoinColumn>();
- protected final SpecifiedPrimaryKeyJoinColumnContainerAdapter specifiedPrimaryKeyJoinColumnContainerAdapter = new SpecifiedPrimaryKeyJoinColumnContainerAdapter();
- protected JavaPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn;
-
- protected InheritanceType specifiedInheritanceStrategy;
- protected InheritanceType defaultInheritanceStrategy;
-
- protected String specifiedDiscriminatorValue;
- protected String defaultDiscriminatorValue;
- 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 JavaGeneratorContainer generatorContainer;
- protected final JavaQueryContainer queryContainer;
-
-
- // ********** construction **********
-
- protected AbstractJavaEntity(JavaPersistentType parent, EntityAnnotation mappingAnnotation) {
- super(parent, mappingAnnotation);
- this.specifiedName = this.mappingAnnotation.getName();
- this.idClassReference = this.buildIdClassReference();
- this.table = this.buildTable();
- this.specifiedSecondaryTableOwner = this.buildSpecifiedSecondaryTableOwner();
- this.initializeSpecifiedSecondaryTables();
- this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner();
- this.initializeSpecifiedPrimaryKeyJoinColumns();
- this.specifiedInheritanceStrategy = this.buildSpecifiedInheritanceStrategy();
- this.specifiedDiscriminatorValue = this.getDiscriminatorValueAnnotation().getValue();
- this.discriminatorColumn = this.buildDiscriminatorColumn();
- // start with the entity as the root - it will be recalculated in update()
- this.rootEntity = this;
- this.attributeOverrideContainer = this.buildAttributeOverrideContainer();
- this.associationOverrideContainer = this.buildAssociationOverrideContainer();
- this.generatorContainer = this.buildGeneratorContainer();
- this.queryContainer = this.buildQueryContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedName_(this.mappingAnnotation.getName());
- this.idClassReference.synchronizeWithResourceModel();
- this.table.synchronizeWithResourceModel();
- this.syncSpecifiedSecondaryTables();
- this.syncSpecifiedPrimaryKeyJoinColumns();
- this.setSpecifiedInheritanceStrategy_(this.buildSpecifiedInheritanceStrategy());
- this.setSpecifiedDiscriminatorValue_(this.getDiscriminatorValueAnnotation().getValue());
- this.discriminatorColumn.synchronizeWithResourceModel();
- this.attributeOverrideContainer.synchronizeWithResourceModel();
- this.associationOverrideContainer.synchronizeWithResourceModel();
- this.generatorContainer.synchronizeWithResourceModel();
- this.queryContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
-
- this.setDefaultName(this.buildDefaultName());
-
- // calculate root entity early - other things depend on it
- this.setRootEntity(this.buildRootEntity());
- this.updateDescendants();
-
- this.idClassReference.update();
-
- this.table.update();
- this.setSpecifiedTableIsAllowed(this.buildSpecifiedTableIsAllowed());
- this.setTableIsUndefined(this.buildTableIsUndefined());
-
- this.updateNodes(this.getSecondaryTables());
-
- this.updateDefaultPrimaryKeyJoinColumn();
- this.updateNodes(this.getPrimaryKeyJoinColumns());
-
- this.setDefaultInheritanceStrategy(this.buildDefaultInheritanceStrategy());
-
- this.setDefaultDiscriminatorValue(this.buildDefaultDiscriminatorValue());
- this.setSpecifiedDiscriminatorValueIsAllowed(this.buildSpecifiedDiscriminatorValueIsAllowed());
- this.setDiscriminatorValueIsUndefined(this.buildDiscriminatorValueIsUndefined());
-
- this.discriminatorColumn.update();
- this.setSpecifiedDiscriminatorColumnIsAllowed(this.buildSpecifiedDiscriminatorColumnIsAllowed());
- this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
-
- this.attributeOverrideContainer.update();
- this.associationOverrideContainer.update();
-
- this.generatorContainer.update();
- this.queryContainer.update();
- }
-
-
- // ********** name **********
-
- @Override
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- this.mappingAnnotation.setName(name);
- this.setSpecifiedName_(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);
- }
-
- protected String buildDefaultName() {
- return this.getResourcePersistentType().getName();
- }
-
-
- // ********** root entity **********
-
- public Entity getRootEntity() {
- return this.rootEntity;
- }
-
- protected void setRootEntity(Entity entity) {
- Entity old = this.rootEntity;
- this.rootEntity = entity;
- this.firePropertyChanged(ROOT_ENTITY_PROPERTY, old, entity);
- }
-
- protected Entity buildRootEntity() {
- Entity root = this;
- for (TypeMapping typeMapping : this.getAncestors()) {
- if (typeMapping instanceof Entity) {
- root = (Entity) typeMapping;
- }
- }
- return root;
- }
-
-
- // ********** descendants **********
-
- public Iterable<Entity> getDescendants() {
- return new LiveCloneListIterable<Entity>(this.descendants);
- }
-
- protected void updateDescendants() {
- this.synchronizeCollection(this.buildDescendants(), this.descendants, DESCENDANTS_COLLECTION);
- }
-
- protected Iterable<Entity> buildDescendants() {
- return new FilteringIterable<Entity>(this.getPersistenceUnit().getEntities()) {
- @Override
- protected boolean accept(Entity entity) {
- return AbstractJavaEntity.this.entityIsDescendant(entity);
- }
- };
- }
-
- /**
- * Return whether specified entity is a descendant of the entity.
- */
- protected boolean entityIsDescendant(Entity entity) {
- String typeName = this.getPersistentType().getName();
- String entityTypeName = entity.getPersistentType().getName();
- String rootEntityTypeName = entity.getRootEntity().getPersistentType().getName();
- return Tools.valuesAreDifferent(typeName, entityTypeName) &&
- Tools.valuesAreEqual(typeName, rootEntityTypeName);
- }
-
-
- // ********** id class **********
-
- public JavaIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
- protected JavaIdClassReference buildIdClassReference() {
- return new GenericJavaIdClassReference(this);
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
-
- // ********** table **********
-
- public JavaTable getTable() {
- return this.table;
- }
-
- protected JavaTable buildTable() {
- return this.getJpaFactory().buildJavaTable(this, this.buildTableOwner());
- }
-
- protected JavaTable.Owner buildTableOwner() {
- return new TableOwner();
- }
-
- public boolean specifiedTableIsAllowed() {
- return this.specifiedTableIsAllowed;
- }
-
- protected void setSpecifiedTableIsAllowed(boolean specifiedTableIsAllowed) {
- boolean old = this.specifiedTableIsAllowed;
- this.specifiedTableIsAllowed = specifiedTableIsAllowed;
- this.firePropertyChanged(SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed);
- }
-
- protected boolean buildSpecifiedTableIsAllowed() {
- return ! this.isAbstractTablePerClass() && ! this.isSingleTableDescendant();
- }
-
- public boolean tableIsUndefined() {
- return this.tableIsUndefined;
- }
-
- protected void setTableIsUndefined(boolean tableIsUndefined) {
- boolean old = this.tableIsUndefined;
- this.tableIsUndefined = tableIsUndefined;
- this.firePropertyChanged(TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined);
- }
-
- protected boolean buildTableIsUndefined() {
- return this.isAbstractTablePerClass();
- }
-
- /**
- * <ul>
- * <li>If the entity is part of a single table inheritance hierarchy, the table
- * name defaults to the root entity's table name.
- * <li>If the entity is abstract and part of a table per class
- * inheritance hierarchy, the table name defaults to null, as no table applies.
- * <li>Otherwise, the table name defaults to the entity name.
- * </ul>
- */
- public String getDefaultTableName() {
- return this.isSingleTableDescendant() ?
- this.rootEntity.getTable().getName() :
- this.isAbstractTablePerClass() ? null : this.getName();
- }
-
- /**
- * @see #getDefaultTableName()
- */
- public String getDefaultSchema() {
- return this.isSingleTableDescendant() ?
- this.rootEntity.getTable().getSchema() :
- this.isAbstractTablePerClass() ? null : this.getContextDefaultSchema();
- }
-
- /**
- * @see #getDefaultTableName()
- */
- public String getDefaultCatalog() {
- return this.isSingleTableDescendant() ?
- this.rootEntity.getTable().getCatalog() :
- this.isAbstractTablePerClass() ? null : this.getContextDefaultCatalog();
- }
-
-
- // ********** secondary tables **********
-
- public ListIterator<JavaSecondaryTable> secondaryTables() {
- return this.specifiedSecondaryTables();
- }
-
- protected ListIterable<JavaSecondaryTable> getSecondaryTables() {
- return this.getSpecifiedSecondaryTables();
- }
-
- public int secondaryTablesSize() {
- return this.specifiedSecondaryTablesSize();
- }
-
-
- // ********** specified secondary tables **********
-
- public ListIterator<JavaSecondaryTable> specifiedSecondaryTables() {
- return this.getSpecifiedSecondaryTables().iterator();
- }
-
- protected ListIterable<JavaSecondaryTable> getSpecifiedSecondaryTables() {
- return new LiveCloneListIterable<JavaSecondaryTable>(this.specifiedSecondaryTables);
- }
-
- public int specifiedSecondaryTablesSize() {
- return this.specifiedSecondaryTables.size();
- }
-
- public JavaSecondaryTable addSpecifiedSecondaryTable() {
- return this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size());
- }
-
- public JavaSecondaryTable addSpecifiedSecondaryTable(int index) {
- SecondaryTableAnnotation annotation = this.buildSecondaryTableAnnotation(index);
- return this.addSpecifiedSecondaryTable_(index, annotation);
- }
-
- protected SecondaryTableAnnotation buildSecondaryTableAnnotation(int index) {
- return (SecondaryTableAnnotation) this.getResourcePersistentType().addAnnotation(index, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- }
-
- public void removeSpecifiedSecondaryTable(SecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- public void removeSpecifiedSecondaryTable(int index) {
- this.getResourcePersistentType().removeAnnotation(index, SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- this.removeSpecifiedSecondaryTable_(index);
- }
-
- protected void removeSpecifiedSecondaryTable_(int index) {
- this.removeItemFromList(index, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- public void moveSpecifiedSecondaryTable(int targetIndex, int sourceIndex) {
- this.getResourceAnnotatedElement().moveAnnotation(targetIndex, sourceIndex, SecondaryTablesAnnotation.ANNOTATION_NAME);
- this.moveItemInList(targetIndex, sourceIndex, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- protected void initializeSpecifiedSecondaryTables() {
- for (SecondaryTableAnnotation annotation : this.getSecondaryTableAnnotations()) {
- this.specifiedSecondaryTables.add(this.buildSecondaryTable(annotation));
- }
- }
-
- protected JavaSecondaryTable buildSecondaryTable(SecondaryTableAnnotation secondaryTableAnnotation) {
- return this.getJpaFactory().buildJavaSecondaryTable(this, this.specifiedSecondaryTableOwner, secondaryTableAnnotation);
- }
-
- protected void syncSpecifiedSecondaryTables() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedSecondaryTableContainerAdapter);
- }
-
- protected Iterable<SecondaryTableAnnotation> getSecondaryTableAnnotations() {
- return CollectionTools.iterable(this.secondaryTableAnnotations());
- }
-
- protected Iterator<SecondaryTableAnnotation> secondaryTableAnnotations() {
- return new SuperIteratorWrapper<SecondaryTableAnnotation>(this.nestableSecondaryTableAnnotations());
- }
-
- protected Iterator<NestableSecondaryTableAnnotation> nestableSecondaryTableAnnotations() {
- return new SubIteratorWrapper<NestableAnnotation, NestableSecondaryTableAnnotation>(this.nestableSecondaryTableAnnotations_());
- }
-
- protected Iterator<NestableAnnotation> nestableSecondaryTableAnnotations_() {
- return this.getResourceAnnotatedElement().annotations(SecondaryTableAnnotation.ANNOTATION_NAME, SecondaryTablesAnnotation.ANNOTATION_NAME);
- }
-
- protected void moveSpecifiedSecondaryTable_(int index, JavaSecondaryTable secondaryTable) {
- this.moveItemInList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- protected JavaSecondaryTable addSpecifiedSecondaryTable_(int index, SecondaryTableAnnotation secondaryTableAnnotation) {
- JavaSecondaryTable secondaryTable = this.buildSecondaryTable(secondaryTableAnnotation);
- this.addItemToList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- return secondaryTable;
- }
-
- protected void removeSpecifiedSecondaryTable_(JavaSecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable_(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- /**
- * specified secondary table container adapter
- */
- protected class SpecifiedSecondaryTableContainerAdapter
- implements ContextContainerTools.Adapter<JavaSecondaryTable, SecondaryTableAnnotation>
- {
- public Iterable<JavaSecondaryTable> getContextElements() {
- return AbstractJavaEntity.this.getSpecifiedSecondaryTables();
- }
- public Iterable<SecondaryTableAnnotation> getResourceElements() {
- return AbstractJavaEntity.this.getSecondaryTableAnnotations();
- }
- public SecondaryTableAnnotation getResourceElement(JavaSecondaryTable contextElement) {
- return contextElement.getTableAnnotation();
- }
- public void moveContextElement(int index, JavaSecondaryTable element) {
- AbstractJavaEntity.this.moveSpecifiedSecondaryTable_(index, element);
- }
- public void addContextElement(int index, SecondaryTableAnnotation resourceElement) {
- AbstractJavaEntity.this.addSpecifiedSecondaryTable_(index, resourceElement);
- }
- public void removeContextElement(JavaSecondaryTable element) {
- AbstractJavaEntity.this.removeSpecifiedSecondaryTable_(element);
- }
- }
-
- protected Table.Owner buildSpecifiedSecondaryTableOwner() {
- return new SecondaryTableOwner();
- }
-
-
- // ********** primary key join columns **********
-
- public ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.getPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<JavaPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.getSpecifiedPrimaryKeyJoinColumns() : this.getDefaultPrimaryKeyJoinColumns();
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumnsSize() : this.defaultPrimaryKeyJoinColumnsSize();
- }
-
-
- // ********** specified primary key join columns **********
-
- public ListIterator<JavaPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() {
- return this.getSpecifiedPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<JavaPrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<JavaPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- public int specifiedPrimaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.size();
- }
-
- protected boolean hasSpecifiedPrimaryKeyJoinColumns() {
- return this.specifiedPrimaryKeyJoinColumns.size() != 0;
- }
-
- public JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn() {
- return this.addSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.size());
- }
-
- public JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) {
- PrimaryKeyJoinColumnAnnotation annotation = this.buildPrimaryKeyJoinColumnAnnotation(index);
- return this.addSpecifiedPrimaryKeyJoinColumn_(index, annotation);
- }
-
- protected PrimaryKeyJoinColumnAnnotation buildPrimaryKeyJoinColumnAnnotation(int index) {
- return (PrimaryKeyJoinColumnAnnotation) this.getResourcePersistentType().addAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.indexOf(primaryKeyJoinColumn));
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(int index) {
- this.getResourcePersistentType().removeAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- this.removeSpecifiedPrimaryKeyJoinColumn_(index);
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(int index) {
- this.removeItemFromList(index, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- this.getResourcePersistentType().moveAnnotation(targetIndex, sourceIndex, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- this.moveItemInList(targetIndex, sourceIndex, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected PrimaryKeyJoinColumnOwner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected void initializeSpecifiedPrimaryKeyJoinColumns() {
- for (PrimaryKeyJoinColumnAnnotation annotation : this.getPrimaryKeyJoinColumnAnnotations()) {
- this.specifiedPrimaryKeyJoinColumns.add(this.buildPrimaryKeyJoinColumn(annotation));
- }
- }
-
- protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(PrimaryKeyJoinColumnAnnotation primaryKeyJoinColumnAnnotation) {
- return this.getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, primaryKeyJoinColumnAnnotation);
- }
-
- protected void syncSpecifiedPrimaryKeyJoinColumns() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedPrimaryKeyJoinColumnContainerAdapter);
- }
-
- protected Iterable<PrimaryKeyJoinColumnAnnotation> getPrimaryKeyJoinColumnAnnotations() {
- return CollectionTools.iterable(this.primaryKeyJoinColumnAnnotations());
- }
-
- protected Iterator<PrimaryKeyJoinColumnAnnotation> primaryKeyJoinColumnAnnotations() {
- return new SuperIteratorWrapper<PrimaryKeyJoinColumnAnnotation>(this.nestablePrimaryKeyJoinColumnAnnotations());
- }
-
- protected Iterator<NestablePrimaryKeyJoinColumnAnnotation> nestablePrimaryKeyJoinColumnAnnotations() {
- return new SubIteratorWrapper<NestableAnnotation, NestablePrimaryKeyJoinColumnAnnotation>(this.nestablePrimaryKeyJoinColumnAnnotations_());
- }
-
- protected Iterator<NestableAnnotation> nestablePrimaryKeyJoinColumnAnnotations_() {
- return this.getResourceAnnotatedElement().annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void moveSpecifiedPrimaryKeyJoinColumn_(int index, JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.moveItemInList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected JavaPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn_(int index, PrimaryKeyJoinColumnAnnotation primaryKeyJoinColumnAnnotation) {
- JavaPrimaryKeyJoinColumn primaryKeyJoinColumn = this.buildPrimaryKeyJoinColumn(primaryKeyJoinColumnAnnotation);
- this.addItemToList(index, primaryKeyJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- return primaryKeyJoinColumn;
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.removeSpecifiedPrimaryKeyJoinColumn_(this.specifiedPrimaryKeyJoinColumns.indexOf(primaryKeyJoinColumn));
- }
-
- /**
- * specified primary key join column container adapter
- */
- protected class SpecifiedPrimaryKeyJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<JavaPrimaryKeyJoinColumn, PrimaryKeyJoinColumnAnnotation>
- {
- public Iterable<JavaPrimaryKeyJoinColumn> getContextElements() {
- return AbstractJavaEntity.this.getSpecifiedPrimaryKeyJoinColumns();
- }
- public Iterable<PrimaryKeyJoinColumnAnnotation> getResourceElements() {
- return AbstractJavaEntity.this.getPrimaryKeyJoinColumnAnnotations();
- }
- public PrimaryKeyJoinColumnAnnotation getResourceElement(JavaPrimaryKeyJoinColumn contextElement) {
- return contextElement.getColumnAnnotation();
- }
- public void moveContextElement(int index, JavaPrimaryKeyJoinColumn element) {
- AbstractJavaEntity.this.moveSpecifiedPrimaryKeyJoinColumn_(index, element);
- }
- public void addContextElement(int index, PrimaryKeyJoinColumnAnnotation resourceElement) {
- AbstractJavaEntity.this.addSpecifiedPrimaryKeyJoinColumn_(index, resourceElement);
- }
- public void removeContextElement(JavaPrimaryKeyJoinColumn element) {
- AbstractJavaEntity.this.removeSpecifiedPrimaryKeyJoinColumn_(element);
- }
- }
-
-
- // ********** default primary key join column **********
-
- public JavaPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() {
- return this.defaultPrimaryKeyJoinColumn;
- }
-
- protected void setDefaultPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn pkJoinColumn) {
- JavaPrimaryKeyJoinColumn old = this.defaultPrimaryKeyJoinColumn;
- this.defaultPrimaryKeyJoinColumn = pkJoinColumn;
- this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN_PROPERTY, old, pkJoinColumn);
- }
-
- protected ListIterable<JavaPrimaryKeyJoinColumn> getDefaultPrimaryKeyJoinColumns() {
- return (this.defaultPrimaryKeyJoinColumn != null) ?
- new SingleElementListIterable<JavaPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn) :
- EmptyListIterable.<JavaPrimaryKeyJoinColumn>instance();
- }
-
- protected int defaultPrimaryKeyJoinColumnsSize() {
- return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultPrimaryKeyJoinColumn() {
- if (this.buildsDefaultPrimaryKeyJoinColumn()) {
- if (this.defaultPrimaryKeyJoinColumn == null) {
- this.setDefaultPrimaryKeyJoinColumn(this.buildDefaultPrimaryKeyJoinColumn());
- } else {
- this.defaultPrimaryKeyJoinColumn.update();
- }
- } else {
- this.setDefaultPrimaryKeyJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultPrimaryKeyJoinColumn() {
- return ! this.hasSpecifiedPrimaryKeyJoinColumns();
- }
-
- protected JavaPrimaryKeyJoinColumn buildDefaultPrimaryKeyJoinColumn() {
- return this.buildPrimaryKeyJoinColumn(new NullPrimaryKeyJoinColumnAnnotation(this.getResourcePersistentType()));
- }
-
-
- // ********** inheritance strategy **********
-
- public InheritanceType getInheritanceStrategy() {
- return (this.specifiedInheritanceStrategy != null) ? this.specifiedInheritanceStrategy : this.defaultInheritanceStrategy;
- }
-
- public InheritanceType getSpecifiedInheritanceStrategy() {
- return this.specifiedInheritanceStrategy;
- }
-
- public void setSpecifiedInheritanceStrategy(InheritanceType inheritanceType) {
- if (this.valuesAreDifferent(this.specifiedInheritanceStrategy, inheritanceType)) {
- this.getInheritanceAnnotation().setStrategy(InheritanceType.toJavaResourceModel(inheritanceType));
- this.removeInheritanceAnnotationIfUnset();
- this.setSpecifiedInheritanceStrategy_(inheritanceType);
- }
- }
-
- protected void setSpecifiedInheritanceStrategy_(InheritanceType inheritanceType) {
- InheritanceType old = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = inheritanceType;
- this.firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, old, inheritanceType);
- }
-
- protected InheritanceType buildSpecifiedInheritanceStrategy() {
- return InheritanceType.fromJavaResourceModel(this.getInheritanceAnnotation().getStrategy());
- }
-
- public InheritanceType getDefaultInheritanceStrategy() {
- return this.defaultInheritanceStrategy;
- }
-
- protected void setDefaultInheritanceStrategy(InheritanceType inheritanceType) {
- InheritanceType old = this.defaultInheritanceStrategy;
- this.defaultInheritanceStrategy = inheritanceType;
- this.firePropertyChanged(DEFAULT_INHERITANCE_STRATEGY_PROPERTY, old, inheritanceType);
- }
-
- protected InheritanceType buildDefaultInheritanceStrategy() {
- return this.isRoot() ? InheritanceType.SINGLE_TABLE : this.rootEntity.getInheritanceStrategy();
- }
-
-
- // ********** inheritance annotation **********
-
- protected InheritanceAnnotation getInheritanceAnnotation() {
- return (InheritanceAnnotation) this.getResourcePersistentType().getNonNullAnnotation(InheritanceAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeInheritanceAnnotationIfUnset() {
- if (this.getInheritanceAnnotation().isUnset()) {
- this.removeInheritanceAnnotation();
- }
- }
-
- protected void removeInheritanceAnnotation() {
- this.getResourcePersistentType().removeAnnotation(InheritanceAnnotation.ANNOTATION_NAME);
- }
-
-
- // ********** discriminator value **********
-
- public String getDiscriminatorValue() {
- return (this.specifiedDiscriminatorValue != null) ? this.specifiedDiscriminatorValue : this.defaultDiscriminatorValue;
- }
-
- public String getSpecifiedDiscriminatorValue() {
- return this.specifiedDiscriminatorValue;
- }
-
- public void setSpecifiedDiscriminatorValue(String discriminatorValue) {
- if (this.valuesAreDifferent(this.specifiedDiscriminatorValue, discriminatorValue)) {
- this.getDiscriminatorValueAnnotation().setValue(discriminatorValue);
- this.removeDiscriminatorValueAnnotationIfUnset();
- this.setSpecifiedDiscriminatorValue_(discriminatorValue);
- }
- }
-
- protected void setSpecifiedDiscriminatorValue_(String discriminatorValue) {
- String old = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = discriminatorValue;
- this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, old, discriminatorValue);
- }
-
- public String getDefaultDiscriminatorValue() {
- return this.defaultDiscriminatorValue;
- }
-
- protected void setDefaultDiscriminatorValue(String discriminatorValue) {
- String old = this.defaultDiscriminatorValue;
- this.defaultDiscriminatorValue = discriminatorValue;
- this.firePropertyChanged(DEFAULT_DISCRIMINATOR_VALUE_PROPERTY, old, discriminatorValue);
- }
-
- /**
- * 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 (this.discriminatorValueIsUndefined) {
- return null;
- }
- return (this.getDiscriminatorType() == DiscriminatorType.STRING) ? this.getName() : null;
- }
-
- protected DiscriminatorType getDiscriminatorType() {
- return this.discriminatorColumn.getDiscriminatorType();
- }
-
- public boolean specifiedDiscriminatorValueIsAllowed() {
- return this.specifiedDiscriminatorValueIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorValueIsAllowed(boolean allowed) {
- boolean old = this.specifiedDiscriminatorValueIsAllowed;
- this.specifiedDiscriminatorValueIsAllowed = allowed;
- this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY, old, allowed);
- }
-
- protected boolean buildSpecifiedDiscriminatorValueIsAllowed() {
- return ! this.isTablePerClass() && ! this.isAbstract();
- }
-
- public boolean discriminatorValueIsUndefined() {
- return this.discriminatorValueIsUndefined;
- }
-
- protected void setDiscriminatorValueIsUndefined(boolean undefined) {
- boolean old = this.discriminatorValueIsUndefined;
- this.discriminatorValueIsUndefined = undefined;
- this.firePropertyChanged(DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, undefined);
- }
-
- protected boolean buildDiscriminatorValueIsUndefined() {
- return this.isTablePerClass() ||
- this.isAbstract() ||
- this.isRootNoDescendantsNoStrategyDefined();
- }
-
-
- // ********** discriminator value annotation **********
-
- protected DiscriminatorValueAnnotation getDiscriminatorValueAnnotation() {
- return (DiscriminatorValueAnnotation) this.getResourcePersistentType().getNonNullAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeDiscriminatorValueAnnotationIfUnset() {
- if (this.getDiscriminatorValueAnnotation().isUnset()) {
- this.removeDiscriminatorValueAnnotation();
- }
- }
-
- protected void removeDiscriminatorValueAnnotation() {
- this.getResourcePersistentType().removeAnnotation(DiscriminatorValueAnnotation.ANNOTATION_NAME);
- }
-
-
- // ********** discriminator column **********
-
- public JavaDiscriminatorColumn getDiscriminatorColumn() {
- return this.discriminatorColumn;
- }
-
- protected JavaDiscriminatorColumn buildDiscriminatorColumn() {
- return this.getJpaFactory().buildJavaDiscriminatorColumn(this, this.buildDiscriminatorColumnOwner());
- }
-
- protected JavaDiscriminatorColumn.Owner buildDiscriminatorColumnOwner() {
- return new DiscriminatorColumnOwner();
- }
-
- public boolean specifiedDiscriminatorColumnIsAllowed() {
- return this.specifiedDiscriminatorColumnIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorColumnIsAllowed(boolean allowed) {
- boolean old = this.specifiedDiscriminatorColumnIsAllowed;
- this.specifiedDiscriminatorColumnIsAllowed = allowed;
- this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, allowed);
- }
-
- protected boolean buildSpecifiedDiscriminatorColumnIsAllowed() {
- return ! this.isTablePerClass() && this.isRoot();
- }
-
- public boolean discriminatorColumnIsUndefined() {
- return this.discriminatorColumnIsUndefined;
- }
-
- protected void setDiscriminatorColumnIsUndefined(boolean undefined) {
- boolean old = this.discriminatorColumnIsUndefined;
- this.discriminatorColumnIsUndefined = undefined;
- this.firePropertyChanged(DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, undefined);
- }
-
- protected boolean buildDiscriminatorColumnIsUndefined() {
- return this.isTablePerClass() ||
- this.isRootNoDescendantsNoStrategyDefined();
- }
-
-
- // ********** attribute override container **********
-
- public JavaAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- protected JavaAttributeOverrideContainer buildAttributeOverrideContainer() {
- return this.getJpaFactory().buildJavaAttributeOverrideContainer(this, new AttributeOverrideContainerOwner());
- }
-
- public TypeMapping getOverridableTypeMapping() {
- PersistentType superPersistentType = this.getPersistentType().getSuperPersistentType();
- return (superPersistentType == null) ? null : superPersistentType.getMapping();
- }
-
-
- // ********** association override container **********
-
- public JavaAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.associationOverrideContainer;
- }
-
- protected JavaAssociationOverrideContainer buildAssociationOverrideContainer() {
- return this.getJpaFactory().buildJavaAssociationOverrideContainer(this, new AssociationOverrideContainerOwner());
- }
-
- @Override
- public Relationship resolveOverriddenRelationship(String attributeName) {
- // check for an override before looking at attribute mappings
- AssociationOverride override = this.associationOverrideContainer.getSpecifiedOverrideNamed(attributeName);
- return (override != null) ? override.getRelationship() : super.resolveOverriddenRelationship(attributeName);
- }
-
-
- // ********** generator container **********
-
- public JavaGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- protected JavaGeneratorContainer buildGeneratorContainer() {
- return this.getJpaFactory().buildJavaGeneratorContainer(this, this);
- }
-
- public JavaResourcePersistentMember getResourceAnnotatedElement() {
- return this.getResourcePersistentType();
- }
-
-
- // ********** query container **********
-
- public JavaQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
- protected JavaQueryContainer buildQueryContainer() {
- return this.getJpaFactory().buildJavaQueryContainer(this, this);
- }
-
-
- // ********** associated tables **********
-
- @Override
- public Iterator<ReadOnlyTable> associatedTables() {
- return this.getAssociatedTables().iterator();
- }
-
- public Iterable<ReadOnlyTable> getAssociatedTables() {
- return new CompositeIterable<ReadOnlyTable>(this.table, this.getSecondaryTables());
- }
-
- @Override
- public Iterator<ReadOnlyTable> allAssociatedTables() {
- return new CompositeIterator<ReadOnlyTable>(this.allAssociatedTablesLists());
- }
-
- public Iterable<ReadOnlyTable> getAllAssociatedTables() {
- return CollectionTools.iterable(this.allAssociatedTables());
- }
-
- // TODO eliminate duplicate tables?
- protected Iterator<Iterator<ReadOnlyTable>> allAssociatedTablesLists() {
- return new TransformationIterator<TypeMapping, Iterator<ReadOnlyTable>>(this.inheritanceHierarchy(), TypeMappingTools.ASSOCIATED_TABLES_TRANSFORMER);
- }
-
- @Override
- public Iterator<String> allAssociatedTableNames() {
- return this.getAllAssociatedTableNames().iterator();
- }
-
- public Iterable<String> getAllAssociatedTableNames() {
- return this.convertToNames(this.getAllAssociatedTables());
- }
-
- /**
- * strip out <code>null</code> names
- */
- protected Iterable<String> convertToNames(Iterable<ReadOnlyTable> tables) {
- return new FilteringIterable<String>(this.convertToNames_(tables), NotNullFilter.<String>instance());
- }
-
- protected Iterable<String> convertToNames_(Iterable<ReadOnlyTable> tables) {
- return new TransformationIterable<ReadOnlyTable, String>(tables) {
- @Override
- protected String transform(ReadOnlyTable t) {
- return t.getName();
- }
- };
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return ! this.tableNameIsValid(tableName);
- }
-
- protected boolean tableNameIsValid(String tableName) {
- return this.tableIsUndefined || CollectionTools.contains(this.getAllAssociatedTableNames(), tableName);
- }
-
-
- // ********** database **********
-
- @Override
- public String getPrimaryTableName() {
- return this.table.getName();
- }
-
- @Override
- public org.eclipse.jpt.jpa.db.Table getPrimaryDbTable() {
- return this.table.getDbTable();
- }
-
- @Override
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- // matching database objects and identifiers is database platform-specific
- return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName);
- }
-
- /**
- * strip out null db tables
- */
- protected Iterable<org.eclipse.jpt.jpa.db.Table> getAllAssociatedDbTables() {
- return new FilteringIterable<org.eclipse.jpt.jpa.db.Table>(this.getAllAssociatedDbTables_(), NotNullFilter.<org.eclipse.jpt.jpa.db.Table>instance());
- }
-
- protected Iterable<org.eclipse.jpt.jpa.db.Table> getAllAssociatedDbTables_() {
- return new TransformationIterable<ReadOnlyTable, org.eclipse.jpt.jpa.db.Table>(this.getAllAssociatedTables()) {
- @Override
- protected org.eclipse.jpt.jpa.db.Table transform(ReadOnlyTable entityTable) {
- return entityTable.getDbTable();
- }
- };
- }
-
- @Override
- public Schema getDbSchema() {
- return this.table.getDbSchema();
- }
-
-
- // ********** primary key **********
-
- public String getPrimaryKeyColumnName() {
- return MappingTools.getPrimaryKeyColumnName(this);
- }
-
- public PersistentAttribute getIdAttribute() {
- Iterator<AttributeMapping> idAttributeMappings = this.getAllAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY).iterator();
- if (idAttributeMappings.hasNext()) {
- PersistentAttribute attribute = idAttributeMappings.next().getPersistentAttribute();
- return idAttributeMappings.hasNext() ? null /*more than one*/: attribute;
- }
- return null;
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- @Override
- public JavaResourcePersistentType getResourcePersistentType() {
- return super.getResourcePersistentType();
- }
-
-
- // ********** attribute mappings **********
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- // check for an override before looking at attribute mappings
- AttributeOverride override = this.attributeOverrideContainer.getSpecifiedOverrideNamed(attributeName);
- return (override != null) ? override.getColumn() : super.resolveOverriddenColumn(attributeName);
- }
-
- @Override
- public Iterator<String> overridableAttributeNames() {
- return this.isTablePerClass() ?
- super.overridableAttributeNames() :
- EmptyIterator.<String>instance();
- }
-
- @Override
- public Iterator<String> overridableAssociationNames() {
- return this.isTablePerClass() ?
- super.overridableAssociationNames() :
- EmptyIterator.<String>instance();
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.allAttributeMappings())) {
- AttributeMapping resolvedMapping = attributeMapping.resolveAttributeMapping(name);
- if (resolvedMapping != null) {
- return resolvedMapping;
- }
- }
- return null;
- }
-
-
- // ********** inheritance **********
-
- public Entity getParentEntity() {
- for (TypeMapping typeMapping : this.getAncestors()) {
- if (typeMapping instanceof Entity) {
- return (Entity) typeMapping;
- }
- }
- return null;
- }
-
- public boolean isRoot() {
- return this == this.rootEntity;
- }
-
- /**
- * 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 a descendant of the root entity
- * of a "single table" inheritance hierarchy.
- */
- protected boolean isSingleTableDescendant() {
- return this.isDescendant() &&
- (this.getInheritanceStrategy() == InheritanceType.SINGLE_TABLE);
- }
-
- /**
- * 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 this.isRoot() &&
- this.descendants.isEmpty() &&
- (this.specifiedInheritanceStrategy == null);
- }
-
- /**
- * Return whether the entity is abstract and is a part of a
- * "table per class" inheritance hierarchy.
- */
- protected boolean isAbstractTablePerClass() {
- return this.isAbstract() && this.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 this.isTablePerClass() && this.isDescendant();
- }
-
- /**
- * Return whether the type is abstract.
- */
- protected boolean isAbstract() {
- return this.getResourcePersistentType().isAbstract();
- }
-
- /**
- * Return whether the entity's type is final.
- */
- protected boolean isFinal() {
- return this.getResourcePersistentType().isFinal();
- }
-
- /**
- * Return whether the entity's type is a member of another type.
- */
- protected boolean isMember() {
- return this.getResourcePersistentType().isMemberType();
- }
-
- /**
- * Return whether the entity's type is static.
- */
- protected boolean isStatic() {
- return this.getResourcePersistentType().isStatic();
- }
-
-
- // ********** 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.table.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- for (JavaSecondaryTable secondaryTable : CollectionTools.iterable(this.secondaryTables())) {
- result = secondaryTable.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- for (JavaPrimaryKeyJoinColumn pkJoinColumn : CollectionTools.iterable(this.primaryKeyJoinColumns())) {
- result = pkJoinColumn.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
- result = this.attributeOverrideContainer.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.associationOverrideContainer.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.discriminatorColumn.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.generatorContainer.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.validatePrimaryKey(messages, reporter, astRoot);
- this.validateTable(messages, reporter, astRoot);
- for (JavaSecondaryTable secondaryTable : this.getSecondaryTables()) {
- secondaryTable.validate(messages, reporter, astRoot);
- }
- this.validateInheritance(messages, reporter, astRoot);
- for (JavaPrimaryKeyJoinColumn pkJoinColumn : this.getPrimaryKeyJoinColumns()) {
- pkJoinColumn.validate(messages, reporter, astRoot);
- }
- this.generatorContainer.validate(messages, reporter, astRoot);
- this.queryContainer.validate(messages, reporter, astRoot);
- this.attributeOverrideContainer.validate(messages, reporter, astRoot);
- this.associationOverrideContainer.validate(messages, reporter, astRoot);
- this.validateEntityName(messages, astRoot);
- this.validateDuplicateEntityNames(messages, astRoot);
- this.idClassReference.validate(messages, reporter, astRoot);
- }
-
- @Override
- public boolean validatesAgainstDatabase() {
- return super.validatesAgainstDatabase() && ! this.isAbstractTablePerClass();
- }
-
- protected void validateEntityName(List<IMessage> messages, CompilationUnit astRoot) {
- if (StringTools.stringIsEmpty(this.getName())){
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NAME_MISSING,
- new String[] {this.getPersistentType().getName()},
- this,
- this.getMappingAnnotation().getNameTextRange(astRoot)
- )
- );
- }
- }
-
- protected void validateDuplicateEntityNames(List<IMessage> messages, CompilationUnit astRoot) {
- HashBag<String> javaEntityNamesExclOverridden = new HashBag<String>();
- CollectionTools.addAll(javaEntityNamesExclOverridden, this.getPersistenceUnit().javaEntityNamesExclOverridden());
- HashBag<String> ormEntityNames = new HashBag<String>();
- CollectionTools.addAll(ormEntityNames, this.getPersistenceUnit().ormEntityNames());
- String javaEntityName = this.getName();
- if ((javaEntityName != null)
- // Check whether or not this entity name has duplicates among
- // the java entities that are not overridden by orm entities
- && ((javaEntityNamesExclOverridden.count(javaEntityName) > 1)
- //Check whether or not this entity name has duplicates
- //with the names of orm entities
- || (ormEntityNames.contains(javaEntityName)))) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NAME_DUPLICATED,
- new String[] {javaEntityName},
- this,
- this.getMappingAnnotation().getNameTextRange(astRoot)
- )
- );
- }
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.buildPrimaryKeyValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) {
- return new GenericEntityPrimaryKeyValidator(this, 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 (this.isAbstractTablePerClass()) {
- if (this.table.isSpecifiedInResource()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.table.getValidationTextRange(astRoot)
- )
- );
- }
- return;
- }
- if (this.isSingleTableDescendant() && this.getDataSource().connectionProfileIsActive()) {
- if (this.specifiedTableDoesNotMatchRootTable()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.table.getValidationTextRange(astRoot)
- )
- );
- }
- return;
- }
- this.table.validate(messages, reporter, astRoot);
- }
-
- /**
- * Return whether the entity specifies a table and it is a different table
- * than the root entity's table.
- */
- protected boolean specifiedTableDoesNotMatchRootTable() {
- return this.table.isSpecifiedInResource() &&
- (this.table.getDbTable() != this.getRootEntity().getTable().getDbTable());
- }
-
- protected void validateInheritance(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.validateInheritanceStrategy(messages, astRoot);
- this.validateDiscriminatorColumn(messages, reporter, astRoot);
- this.validateDiscriminatorValue(messages, astRoot);
- }
-
- protected void validateDiscriminatorColumn(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (this.specifiedDiscriminatorColumnIsAllowed && ! this.discriminatorColumnIsUndefined) {
- this.discriminatorColumn.validate(messages, reporter, astRoot);
- }
- else if (this.discriminatorColumn.isResourceSpecified()) {
- if (this.isDescendant()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange(astRoot)
- )
- );
- }
- else if (this.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 (this.discriminatorValueIsUndefined && (this.specifiedDiscriminatorValue != null)) {
- if (this.isAbstract()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange(astRoot)
- )
- );
- }
- else if (this.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 = this.getJpaPlatformVariation().getTablePerConcreteClassInheritanceIsSupported();
- if (tablePerConcreteClassInheritanceIsSupported == Supported.YES) {
- return;
- }
- if ((this.getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS) && this.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 this.getValidationTextRange(this.getDiscriminatorValueAnnotation().getTextRange(astRoot), astRoot);
- }
-
- protected TextRange getDiscriminatorColumnTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.discriminatorColumn.getValidationTextRange(astRoot), astRoot);
- }
-
- protected TextRange getInheritanceStrategyTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.getInheritanceAnnotation().getStrategyTextRange(astRoot), astRoot);
- }
-
-
- // ********** OrmOverrideContainer.Owner implementation **********
-
- /**
- * some common behavior
- */
- protected abstract class OverrideContainerOwner
- implements JavaOverrideContainer.Owner
- {
- public JavaResourcePersistentMember getResourcePersistentMember() {
- return AbstractJavaEntity.this.getResourcePersistentType();
- }
-
- public JavaTypeMapping getTypeMapping() {
- return AbstractJavaEntity.this;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = this.getOverridableTypeMapping();
- return (typeMapping != null) ? this.allOverridableNames_(typeMapping) : EmptyIterator.<String>instance();
- }
-
- /**
- * pre-condition: <code>typeMapping</code> is not <code>null</code>
- */
- protected abstract Iterator<String> allOverridableNames_(TypeMapping typeMapping);
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractJavaEntity.this.tableNameIsInvalid(tableName);
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return AbstractJavaEntity.this.resolveDbTable(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractJavaEntity.this.allAssociatedTableNames();
- }
-
- public String getPossiblePrefix() {
- return null;
- }
-
- public String getWritePrefix() {
- return null;
- }
-
- // no maps, so all overrides are relevant
- public boolean isRelevant(String overrideName) {
- return true;
- }
-
- }
-
-
- // ********** JavaAttributeOverrideContainer.Owner implementation **********
-
- protected class AttributeOverrideContainerOwner
- extends OverrideContainerOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- @Override
- protected Iterator<String> allOverridableNames_(TypeMapping typeMapping) {
- final Collection<String> mappedByRelationshipAttributes = CollectionTools.collection(
- new TransformationIterator<SingleRelationshipMapping2_0, String>(this.getMapsIdRelationships()) {
- @Override
- protected String transform(SingleRelationshipMapping2_0 mapping) {
- return mapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue();
- }
- });
- return new FilteringIterator<String>(typeMapping.allOverridableAttributeNames()) {
- @Override
- protected boolean accept(String name) {
- if (mappedByRelationshipAttributes.isEmpty()) {
- return true;
- }
- // overridable names are (usually?) qualified with a container mapping,
- // which may also be the one mapped by a relationship
- int index = name.indexOf('.');
- String qualifier = (index > 0) ? name.substring(0, index) : name;
- return ! mappedByRelationshipAttributes.contains(qualifier);
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings()) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 mapping) {
- return mapping.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getSingleRelationshipMappings() {
- return new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings_());
- }
-
- @SuppressWarnings("unchecked")
- protected Iterable<AttributeMapping> getSingleRelationshipMappings_() {
- return new CompositeIterable<AttributeMapping>(
- this.getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- this.getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)
- );
- }
- public Column resolveOverriddenColumn(String attributeName) {
- return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName);
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-
-
- // ********** JavaAssociationOverrideContainer.Owner implementation **********
-
- protected class AssociationOverrideContainerOwner
- extends OverrideContainerOwner
- implements JavaAssociationOverrideContainer.Owner
- {
- @Override
- protected Iterator<String> allOverridableNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAssociationNames();
- }
-
- public Relationship resolveOverriddenRelationship(String attributeName) {
- return MappingTools.resolveOverriddenRelationship(this.getOverridableTypeMapping(), attributeName);
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new AssociationOverrideValidator((AssociationOverride) override, (AssociationOverrideContainer) container, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ 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 t, TableTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinTableValidator(override, (JoinTable) t, textRangeResolver);
- }
- }
-
-
- // ********** JavaNamedColumn.Owner implementation **********
-
- /**
- * some common behavior
- */
- protected abstract class NamedColumnOwner
- implements JavaNamedColumn.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaEntity.this;
- }
-
- public String getDefaultTableName() {
- return AbstractJavaEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return AbstractJavaEntity.this.resolveDbTable(tableName);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaEntity.this.getValidationTextRange(astRoot);
- }
- }
-
-
- // ********** JavaBaseJoinColumn.Owner implementation **********
-
- protected class PrimaryKeyJoinColumnOwner
- extends NamedColumnOwner
- implements JavaBaseJoinColumn.Owner
- {
- public org.eclipse.jpt.jpa.db.Table getReferencedColumnDbTable() {
- Entity parentEntity = AbstractJavaEntity.this.getParentEntity();
- return (parentEntity == null) ? null : parentEntity.getPrimaryDbTable();
- }
-
- public int joinColumnsSize() {
- return AbstractJavaEntity.this.primaryKeyJoinColumnsSize();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return AbstractJavaEntity.this.defaultPrimaryKeyJoinColumn == joinColumn;
- }
-
- public String getDefaultColumnName() {
- if (this.joinColumnsSize() != 1) {
- return null;
- }
- Entity parentEntity = AbstractJavaEntity.this.getParentEntity();
- return (parentEntity == null) ? AbstractJavaEntity.this.getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new EntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-
-
- // ********** JavaDiscriminatorColumn.Owner implementation **********
-
- protected class DiscriminatorColumnOwner
- extends NamedColumnOwner
- implements JavaDiscriminatorColumn.Owner
- {
- public String getDefaultColumnName() {
- return this.isDescendant() ?
- this.getRootDiscriminatorColumn().getName() :
- this.discriminatorColumnIsUndefined() ? null : DiscriminatorColumn.DEFAULT_NAME;
- }
-
- public int getDefaultLength() {
- return this.isDescendant() ?
- this.getRootDiscriminatorColumn().getLength() :
- this.discriminatorColumnIsUndefined() ? 0 : DiscriminatorColumn.DEFAULT_LENGTH;
- }
-
- public DiscriminatorType getDefaultDiscriminatorType() {
- return this.isDescendant() ?
- this.getRootDiscriminatorColumn().getDiscriminatorType() :
- this.discriminatorColumnIsUndefined() ? null : DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE;
- }
-
- protected boolean isDescendant() {
- return AbstractJavaEntity.this.isDescendant();
- }
-
- protected DiscriminatorColumn getRootDiscriminatorColumn() {
- return AbstractJavaEntity.this.rootEntity.getDiscriminatorColumn();
- }
-
- protected boolean discriminatorColumnIsUndefined() {
- return AbstractJavaEntity.this.discriminatorColumnIsUndefined;
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new DiscriminatorColumnValidator(column, textRangeResolver);
- }
- }
-
-
- // ********** table owner **********
-
- protected class TableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table t, TableTextRangeResolver textRangeResolver) {
- return new TableValidator(t, textRangeResolver);
- }
- }
-
-
- // ********** secondary table owner **********
-
- protected class SecondaryTableOwner implements Table.Owner {
- public JptValidator buildTableValidator(Table t, TableTextRangeResolver textRangeResolver) {
- return new SecondaryTableValidator((SecondaryTable) t, textRangeResolver);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
deleted file mode 100644
index 51ed36d6b3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaGenerator.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.jpa.core.context.Generator;
-import org.eclipse.jpt.jpa.core.context.java.JavaGenerator;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.GeneratorAnnotation;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java sequence or table generator
- */
-public abstract class AbstractJavaGenerator<A extends GeneratorAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaGenerator
-{
- protected final A generatorAnnotation;
-
- protected String name;
-
- protected Integer specifiedInitialValue;
- protected int defaultInitialValue;
-
- protected Integer specifiedAllocationSize;
- protected int defaultAllocationSize;
-
-
- protected AbstractJavaGenerator(JavaJpaContextNode parent, A generatorAnnotation) {
- super(parent);
- this.generatorAnnotation = generatorAnnotation;
- this.name = generatorAnnotation.getName();
- this.specifiedInitialValue = generatorAnnotation.getInitialValue();
- this.specifiedAllocationSize = generatorAnnotation.getAllocationSize();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName_(this.generatorAnnotation.getName());
- this.setSpecifiedInitialValue_(this.generatorAnnotation.getInitialValue());
- this.setSpecifiedAllocationSize_(this.generatorAnnotation.getAllocationSize());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultInitialValue(this.buildDefaultInitialValue());
- this.setDefaultAllocationSize(this.buildDefaultAllocationSize());
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.generatorAnnotation.setName(name);
- this.setName_(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 value) {
- this.generatorAnnotation.setInitialValue(value);
- this.setSpecifiedInitialValue_(value);
- }
-
- protected void setSpecifiedInitialValue_(Integer value) {
- Integer old = this.specifiedInitialValue;
- this.specifiedInitialValue = value;
- this.firePropertyChanged(SPECIFIED_INITIAL_VALUE_PROPERTY, old, value);
- }
-
- public int getDefaultInitialValue() {
- return this.defaultInitialValue;
- }
-
- protected void setDefaultInitialValue(int value) {
- int old = this.defaultInitialValue;
- this.defaultInitialValue = value;
- this.firePropertyChanged(DEFAULT_INITIAL_VALUE_PROPERTY, old, value);
- }
-
- protected abstract int buildDefaultInitialValue();
-
-
- // ********** allocation size **********
-
- public int getAllocationSize() {
- return (this.specifiedAllocationSize != null) ? this.specifiedAllocationSize.intValue() : this.defaultAllocationSize;
- }
-
- public Integer getSpecifiedAllocationSize() {
- return this.specifiedAllocationSize;
- }
-
- public void setSpecifiedAllocationSize(Integer size) {
- this.generatorAnnotation.setAllocationSize(size);
- this.setSpecifiedAllocationSize_(size);
- }
-
- protected void setSpecifiedAllocationSize_(Integer size) {
- Integer old = this.specifiedAllocationSize;
- this.specifiedAllocationSize = size;
- this.firePropertyChanged(SPECIFIED_ALLOCATION_SIZE_PROPERTY, old, size);
- }
-
- public int getDefaultAllocationSize() {
- return this.defaultAllocationSize;
- }
-
- protected void setDefaultAllocationSize(int size) {
- int old = this.defaultAllocationSize;
- this.defaultAllocationSize = size;
- this.firePropertyChanged(DEFAULT_ALLOCATION_SIZE_PROPERTY, old, size);
- }
-
- protected int buildDefaultAllocationSize() {
- return DEFAULT_ALLOCATION_SIZE;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- if (StringTools.stringIsEmpty(this.name)){
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_NAME_UNDEFINED,
- EMPTY_STRING_ARRAY,
- this,
- this.getNameTextRange(astRoot)
- )
- );
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.generatorAnnotation.getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.generatorAnnotation.getNameTextRange(astRoot), astRoot);
- }
-
-
- // ********** 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.resolveDbCatalog(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.resolveDbCatalog(catalog);
- }
-
- protected abstract String getCatalog();
-
-
- // ********** JpaNamedContextNode implementation **********
-
- public boolean overrides(Generator other) {
- return MappingTools.nodeOverrides(this, other, PRECEDENCE_TYPE_LIST);
- }
-
- public boolean duplicates(Generator other) {
- return MappingTools.nodesAreDuplicates(this, other);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- public A getGeneratorAnnotation() {
- return this.generatorAnnotation;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java
deleted file mode 100644
index c504200023..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaIdMapping.java
+++ /dev/null
@@ -1,486 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.Association;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.SimpleAssociation;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Converter;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
-import org.eclipse.jpt.jpa.core.context.java.JavaGeneratedValue;
-import org.eclipse.jpt.jpa.core.context.java.JavaGeneratorContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaTemporalConverter;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.NullJavaConverter;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.IdMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java ID mapping
- */
-public abstract class AbstractJavaIdMapping
- extends AbstractJavaAttributeMapping<IdAnnotation>
- implements JavaIdMapping, IdMapping2_0
-{
- protected final JavaColumn column;
-
- protected final JavaGeneratorContainer generatorContainer;
-
- protected JavaGeneratedValue generatedValue;
-
- protected JavaConverter converter; // never null
-
- /* 2.0 feature - a relationship may map this id */
- protected boolean mappedByRelationship;
-
-
- protected static final JavaConverter.Adapter[] CONVERTER_ADAPTER_ARRAY = new JavaConverter.Adapter[] {
- JavaTemporalConverter.Adapter.instance(),
- };
- protected static final Iterable<JavaConverter.Adapter> CONVERTER_ADAPTERS = new ArrayIterable<JavaConverter.Adapter>(CONVERTER_ADAPTER_ARRAY);
-
-
- protected AbstractJavaIdMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = this.buildColumn();
- this.generatorContainer = this.buildGeneratorContainer();
- this.generatedValue = this.buildGeneratedValue();
- this.converter = this.buildConverter();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.column.synchronizeWithResourceModel();
- this.generatorContainer.synchronizeWithResourceModel();
- this.syncGeneratedValue();
- this.syncConverter();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update();
- this.generatorContainer.update();
- if (this.generatedValue != null) {
- this.generatedValue.update();
- }
- this.converter.update();
- this.setMappedByRelationship(this.buildMappedByRelationship());
- }
-
-
- // ********** column **********
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- protected JavaColumn buildColumn() {
- return this.getJpaFactory().buildJavaColumn(this, this);
- }
-
-
- // ********** generator container **********
-
- public JavaGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- protected JavaGeneratorContainer buildGeneratorContainer() {
- return this.getJpaFactory().buildJavaGeneratorContainer(this, this);
- }
-
-
- // ********** generated value **********
-
- public JavaGeneratedValue getGeneratedValue() {
- return this.generatedValue;
- }
-
- public JavaGeneratedValue addGeneratedValue() {
- if (this.generatedValue != null) {
- throw new IllegalStateException("generated value already exists: " + this.generatedValue); //$NON-NLS-1$
- }
- GeneratedValueAnnotation annotation = this.buildGeneratedValueAnnotation();
- JavaGeneratedValue value = this.buildGeneratedValue(annotation);
- this.setGeneratedValue(value);
- return value;
- }
-
- protected GeneratedValueAnnotation buildGeneratedValueAnnotation() {
- return (GeneratedValueAnnotation) this.getResourcePersistentAttribute().addAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- }
-
- public void removeGeneratedValue() {
- if (this.generatedValue == null) {
- throw new IllegalStateException("generated value does not exist"); //$NON-NLS-1$
- }
- this.getResourcePersistentAttribute().removeAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- this.setGeneratedValue(null);
- }
-
- protected JavaGeneratedValue buildGeneratedValue() {
- GeneratedValueAnnotation annotation = this.getGeneratedValueAnnotation();
- return (annotation == null) ? null : this.buildGeneratedValue(annotation);
- }
-
- protected GeneratedValueAnnotation getGeneratedValueAnnotation() {
- return (GeneratedValueAnnotation) this.getResourcePersistentAttribute().getAnnotation(GeneratedValueAnnotation.ANNOTATION_NAME);
- }
-
- protected JavaGeneratedValue buildGeneratedValue(GeneratedValueAnnotation generatedValueAnnotation) {
- return this.getJpaFactory().buildJavaGeneratedValue(this, generatedValueAnnotation);
- }
-
- protected void syncGeneratedValue() {
- GeneratedValueAnnotation annotation = this.getGeneratedValueAnnotation();
- if (annotation == null) {
- if (this.generatedValue != null) {
- this.setGeneratedValue(null);
- }
- }
- else {
- if ((this.generatedValue != null) && (this.generatedValue.getGeneratedValueAnnotation() == annotation)) {
- this.generatedValue.synchronizeWithResourceModel();
- } else {
- this.setGeneratedValue(this.buildGeneratedValue(annotation));
- }
- }
- }
-
- protected void setGeneratedValue(JavaGeneratedValue value) {
- JavaGeneratedValue old = this.generatedValue;
- this.generatedValue = value;
- this.firePropertyChanged(GENERATED_VALUE_PROPERTY, old, value);
- }
-
-
- // ********** converter **********
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- public void setConverter(Class<? extends Converter> converterType) {
- if (this.converter.getType() != converterType) {
- this.converter.dispose();
- JavaConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.retainConverterAnnotation(converterAdapter);
- this.setConverter_(this.buildConverter(converterAdapter));
- }
- }
-
- protected JavaConverter buildConverter(JavaConverter.Adapter converterAdapter) {
- return (converterAdapter != null) ?
- converterAdapter.buildNewConverter(this, this.getJpaFactory()) :
- this.buildNullConverter();
- }
-
- protected void setConverter_(JavaConverter converter) {
- Converter old = this.converter;
- this.converter = converter;
- this.firePropertyChanged(CONVERTER_PROPERTY, old, converter);
- }
-
- /**
- * Clear all the converter annotations <em>except</em> for the annotation
- * corresponding to the specified adapter. If the specified adapter is
- * <code>null</code>, remove <em>all</em> the converter annotations.
- */
- protected void retainConverterAnnotation(JavaConverter.Adapter converterAdapter) {
- JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter != converterAdapter) {
- adapter.removeConverterAnnotation(resourceAttribute);
- }
- }
- }
-
- protected JavaConverter buildConverter() {
- JpaFactory jpaFactory = this.getJpaFactory();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- JavaConverter javaConverter = adapter.buildConverter(this, jpaFactory);
- if (javaConverter != null) {
- return javaConverter;
- }
- }
- return this.buildNullConverter();
- }
-
- protected void syncConverter() {
- Association<JavaConverter.Adapter, Annotation> assoc = this.getConverterAnnotation();
- if (assoc == null) {
- if (this.converter.getType() != null) {
- this.setConverter_(this.buildNullConverter());
- }
- } else {
- JavaConverter.Adapter adapter = assoc.getKey();
- Annotation annotation = assoc.getValue();
- if ((this.converter.getType() == adapter.getConverterType()) &&
- (this.converter.getConverterAnnotation() == annotation)) {
- this.converter.synchronizeWithResourceModel();
- } else {
- this.setConverter_(adapter.buildConverter(annotation, this, this.getJpaFactory()));
- }
- }
- }
-
- /**
- * Return the first converter annotation we find along with its corresponding
- * adapter. Return <code>null</code> if there are no converter annotations.
- */
- protected Association<JavaConverter.Adapter, Annotation> getConverterAnnotation() {
- JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- Annotation annotation = adapter.getConverterAnnotation(resourceAttribute);
- if (annotation != null) {
- return new SimpleAssociation<JavaConverter.Adapter, Annotation>(adapter, annotation);
- }
- }
- return null;
- }
-
- protected JavaConverter buildNullConverter() {
- return new NullJavaConverter(this);
- }
-
-
- // ********** converter adapters **********
-
- /**
- * Return the converter adapter for the specified converter type.
- */
- protected JavaConverter.Adapter getConverterAdapter(Class<? extends Converter> converterType) {
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.getConverterType() == converterType) {
- return adapter;
- }
- }
- return null;
- }
-
- protected Iterable<JavaConverter.Adapter> getConverterAdapters() {
- return CONVERTER_ADAPTERS;
- }
-
-
- // ********** mapped by relationship **********
-
- public boolean isMappedByRelationship() {
- return this.mappedByRelationship;
- }
-
- protected void setMappedByRelationship(boolean mappedByRelationship) {
- boolean old = this.mappedByRelationship;
- this.mappedByRelationship = mappedByRelationship;
- this.firePropertyChanged(MAPPED_BY_RELATIONSHIP_PROPERTY, old, mappedByRelationship);
- }
-
- protected boolean buildMappedByRelationship() {
- return this.isJpa2_0Compatible() && this.buildMappedByRelationship_();
- }
-
- protected boolean buildMappedByRelationship_() {
- return CollectionTools.contains(this.getMappedByRelationshipAttributeNames(), this.getName());
- }
-
- protected Iterable<String> getMappedByRelationshipAttributeNames() {
- return TypeMappingTools.getMappedByRelationshipAttributeNames(this.getTypeMapping());
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return IdAnnotation.ANNOTATION_NAME;
- }
-
- @Override
- public String getPrimaryKeyColumnName() {
- return this.column.getName();
- }
-
- protected boolean columnIsSpecified() {
- return this.getResourcePersistentAttribute().getAnnotation(ColumnAnnotation.ANNOTATION_NAME) != null;
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
-
- // ********** JavaGeneratorContainer implementation **********
-
- public JavaResourcePersistentMember getResourceAnnotatedElement() {
- return this.getResourcePersistentAttribute();
- }
-
-
- // ********** JavaColumn.Owner implementation **********
-
- public ColumnAnnotation getColumnAnnotation() {
- return (ColumnAnnotation) this.getResourcePersistentAttribute().getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- public void removeColumnAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- public String getDefaultColumnName() {
- return (this.mappedByRelationship && ! this.columnIsSpecified()) ? null : this.getName();
- }
-
- public String getDefaultTableName() {
- return (this.mappedByRelationship && ! this.columnIsSpecified()) ? null : this.getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
-
- // ********** 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.column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- result = this.generatorContainer.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- if (this.generatedValue != null) {
- result = this.generatedValue.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- }
-
- result = this.converter.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);
-
- // JPA 2.0: If the column is specified or if the ID is not mapped by a relationship,
- // the column is validated.
- // JPA 1.0: The column is always be validated, since the ID is never mapped by a
- // relationship.
- if (this.columnIsSpecified() || ! this.mappedByRelationship) {
- this.column.validate(messages, reporter, astRoot);
- }
-
- // JPA 2.0: If the column is specified and the ID is mapped by a relationship,
- // we have an error.
- // JPA 1.0: The ID cannot be mapped by a relationship.
- if (this.columnIsSpecified() && this.mappedByRelationship) {
- messages.add(this.buildMappedByRelationshipAndColumnSpecifiedMessage(astRoot));
- }
-
- this.generatorContainer.validate(messages, reporter, astRoot);
- if (this.generatedValue != null) {
- this.generatedValue.validate(messages, reporter, astRoot);
- }
- this.converter.validate(messages, reporter, astRoot);
- }
-
- protected IMessage buildMappedByRelationshipAndColumnSpecifiedMessage(CompilationUnit astRoot) {
- return this.buildMessage(
- JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
- EMPTY_STRING_ARRAY,
- this.column.getValidationTextRange(astRoot)
- );
- }
-
- protected IMessage buildMessage(String msgID, String[] parms, TextRange textRange) {
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- ArrayTools.add(parms, 0, this.buildAttributeDescription()),
- this,
- textRange
- );
- }
-
- protected String buildAttributeDescription() {
- return NLS.bind(this.getAttributeDescriptionTemplate(), this.getPersistentAttribute().getName());
- }
-
- protected String getAttributeDescriptionTemplate() {
- return this.getPersistentAttribute().isVirtual() ?
- JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC :
- JpaValidationDescriptionMessages.ATTRIBUTE_DESC;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java
deleted file mode 100644
index b133a319f7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJoinColumnRelationshipStrategy
- extends AbstractJavaJpaContextNode
- implements JavaJoinColumnRelationshipStrategy
-{
- protected final Vector<JavaJoinColumn> specifiedJoinColumns = new Vector<JavaJoinColumn>();
- protected final SpecifiedJoinColumnContainerAdapter specifiedJoinColumnContainerAdapter;
- protected final JavaJoinColumn.Owner joinColumnOwner;
-
- protected JavaJoinColumn defaultJoinColumn;
-
-
- protected AbstractJavaJoinColumnRelationshipStrategy(JavaJoinColumnRelationship parent) {
- super(parent);
- this.specifiedJoinColumnContainerAdapter = this.buildSpecifiedJoinColumnContainerAdapter();
- this.joinColumnOwner = this.buildJoinColumnOwner();
- this.initializeSpecifiedJoinColumns();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncSpecifiedJoinColumns();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getSpecifiedJoinColumns());
- this.updateDefaultJoinColumn();
- }
-
-
- // ********** join columns **********
-
- public ListIterator<JavaJoinColumn> joinColumns() {
- return this.getJoinColumns().iterator();
- }
-
- protected ListIterable<JavaJoinColumn> getJoinColumns() {
- return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ? this.specifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize();
- }
-
-
- // ********** specified join columns **********
-
- public ListIterator<JavaJoinColumn> specifiedJoinColumns() {
- return this.getSpecifiedJoinColumns().iterator();
- }
-
- protected ListIterable<JavaJoinColumn> getSpecifiedJoinColumns() {
- return new LiveCloneListIterable<JavaJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return this.specifiedJoinColumns.size() != 0;
- }
-
- public JavaJoinColumn getSpecifiedJoinColumn(int index) {
- return this.specifiedJoinColumns.get(index);
- }
-
- public JavaJoinColumn addSpecifiedJoinColumn() {
- return this.addSpecifiedJoinColumn(this.specifiedJoinColumns.size());
- }
-
- public JavaJoinColumn addSpecifiedJoinColumn(int index) {
- JoinColumnAnnotation annotation = this.addJoinColumnAnnotation(index);
- return this.addSpecifiedJoinColumn_(index, annotation);
- }
-
- public void removeSpecifiedJoinColumn(JoinColumn joinColumn) {
- this.removeSpecifiedJoinColumn(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- public void removeSpecifiedJoinColumn(int index) {
- this.removeJoinColumnAnnotation(index);
- this.removeSpecifiedJoinColumn_(index);
- }
-
- protected void removeSpecifiedJoinColumn_(int index) {
- this.removeItemFromList(index, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) {
- this.moveJoinColumnAnnotation(targetIndex, sourceIndex);
- this.moveItemInList(targetIndex, sourceIndex, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected void initializeSpecifiedJoinColumns() {
- for (JoinColumnAnnotation joinColumnAnnotation : this.getJoinColumnAnnotations()) {
- this.specifiedJoinColumns.add(this.buildJoinColumn(joinColumnAnnotation));
- }
- }
-
- protected void syncSpecifiedJoinColumns() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedJoinColumnContainerAdapter);
- }
-
- protected Iterable<JoinColumnAnnotation> getJoinColumnAnnotations() {
- return CollectionTools.iterable(this.joinColumnAnnotations());
- }
-
- protected void moveSpecifiedJoinColumn_(int index, JavaJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected JavaJoinColumn addSpecifiedJoinColumn_(int index, JoinColumnAnnotation joinColumnAnnotation) {
- JavaJoinColumn joinColumn = this.buildJoinColumn(joinColumnAnnotation);
- this.addItemToList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- return joinColumn;
- }
-
- protected void removeSpecifiedJoinColumn_(JavaJoinColumn joinColumn) {
- this.removeSpecifiedJoinColumn_(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- protected SpecifiedJoinColumnContainerAdapter buildSpecifiedJoinColumnContainerAdapter() {
- return new SpecifiedJoinColumnContainerAdapter();
- }
-
- /**
- * specified join column container adapter
- */
- protected class SpecifiedJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<JavaJoinColumn, JoinColumnAnnotation>
- {
- public Iterable<JavaJoinColumn> getContextElements() {
- return AbstractJavaJoinColumnRelationshipStrategy.this.getSpecifiedJoinColumns();
- }
- public Iterable<JoinColumnAnnotation> getResourceElements() {
- return AbstractJavaJoinColumnRelationshipStrategy.this.getJoinColumnAnnotations();
- }
- public JoinColumnAnnotation getResourceElement(JavaJoinColumn contextElement) {
- return contextElement.getColumnAnnotation();
- }
- public void moveContextElement(int index, JavaJoinColumn element) {
- AbstractJavaJoinColumnRelationshipStrategy.this.moveSpecifiedJoinColumn_(index, element);
- }
- public void addContextElement(int index, JoinColumnAnnotation resourceElement) {
- AbstractJavaJoinColumnRelationshipStrategy.this.addSpecifiedJoinColumn_(index, resourceElement);
- }
- public void removeContextElement(JavaJoinColumn element) {
- AbstractJavaJoinColumnRelationshipStrategy.this.removeSpecifiedJoinColumn_(element);
- }
- }
-
- protected abstract JavaJoinColumn.Owner buildJoinColumnOwner();
-
-
- // ********** default join column **********
-
- public JavaJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(JavaJoinColumn joinColumn) {
- JavaJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn);
- }
-
- protected ListIterable<JavaJoinColumn> getDefaultJoinColumns() {
- return (this.defaultJoinColumn != null) ?
- new SingleElementListIterable<JavaJoinColumn>(this.defaultJoinColumn) :
- EmptyListIterable.<JavaJoinColumn>instance();
- }
-
- protected int getDefaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultJoinColumn() {
- if (this.buildsDefaultJoinColumn()) {
- if (this.defaultJoinColumn == null) {
- this.setDefaultJoinColumn(this.buildJoinColumn(this.buildNullJoinColumnAnnotation()));
- } else {
- this.defaultJoinColumn.update();
- }
- } else {
- this.setDefaultJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultJoinColumn() {
- return ! this.hasSpecifiedJoinColumns() &&
- this.getRelationship().mayHaveDefaultJoinColumn();
- }
-
-
- // ********** join column annotations **********
-
- protected abstract Iterator<JoinColumnAnnotation> joinColumnAnnotations();
-
- protected abstract JoinColumnAnnotation addJoinColumnAnnotation(int index);
-
- protected abstract void removeJoinColumnAnnotation(int index);
-
- protected abstract void moveJoinColumnAnnotation(int targetIndex, int sourceIndex);
-
- protected abstract JoinColumnAnnotation buildNullJoinColumnAnnotation();
-
-
- // ********** misc **********
-
- @Override
- public JavaJoinColumnRelationship getParent() {
- return (JavaJoinColumnRelationship) super.getParent();
- }
-
- public JavaJoinColumnRelationship getRelationship() {
- return this.getParent();
- }
-
- protected JavaJoinColumn buildJoinColumn(JoinColumnAnnotation joinColumnAnnotation) {
- return this.getJpaFactory().buildJavaJoinColumn(this, this.joinColumnOwner, joinColumnAnnotation);
- }
-
- public void initializeFrom(ReadOnlyJoinColumnRelationshipStrategy oldStrategy) {
- for (ReadOnlyJoinColumn joinColumn : CollectionTools.iterable(oldStrategy.specifiedJoinColumns())) {
- this.addSpecifiedJoinColumn().initializeFrom(joinColumn);
- }
- }
-
- public void initializeFromVirtual(ReadOnlyJoinColumnRelationshipStrategy virtualStrategy) {
- for (ReadOnlyJoinColumn joinColumn : CollectionTools.iterable(virtualStrategy.joinColumns())) {
- this.addSpecifiedJoinColumn().initializeFromVirtual(joinColumn);
- }
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- public String getTableName() {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping == null) ? null : typeMapping.getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping == null) ? null : typeMapping.resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping != null) && typeMapping.tableNameIsInvalid(tableName);
- }
-
- // subclasses like this to be public
- public Table getReferencedColumnDbTable() {
- TypeMapping relationshipTarget = this.getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
- protected Iterator<String> candidateTableNames() {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping != null) ? typeMapping.allAssociatedTableNames() : EmptyIterator.<String>instance();
- }
-
- public void addStrategy() {
- if (this.specifiedJoinColumnsSize() == 0) {
- this.addSpecifiedJoinColumn();
- }
- }
-
- public void removeStrategy() {
- for (int i = this.specifiedJoinColumns.size(); i-- > 0; ) {
- this.removeSpecifiedJoinColumn(i);
- }
- }
-
-
- // ********** 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 joinColumn : this.getJoinColumns()) {
- result = joinColumn.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 (JavaJoinColumn joinColumn : this.getJoinColumns()) {
- joinColumn.validate(messages, reporter, astRoot);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinTableRelationshipStrategy.java
deleted file mode 100644
index 6eafead62c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJoinTableRelationshipStrategy.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractJavaJoinTableRelationshipStrategy
- extends AbstractJavaJpaContextNode
- implements JavaJoinTableRelationshipStrategy, Table.Owner
-{
- protected JavaJoinTable joinTable;
-
-
- protected AbstractJavaJoinTableRelationshipStrategy(JavaJoinTableRelationship parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- if (this.joinTable != null) {
- this.joinTable.synchronizeWithResourceModel();
- }
- }
-
- @Override
- public void update() {
- super.update();
- this.updateJoinTable();
- }
-
-
- // ********** join table **********
-
- public JavaJoinTable getJoinTable() {
- return this.joinTable;
- }
-
- protected void setJoinTable(JavaJoinTable joinTable) {
- JavaJoinTable old = this.joinTable;
- this.joinTable = joinTable;
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, old, joinTable);
- }
-
- protected void updateJoinTable() {
- if (this.buildsJoinTable()) {
- if (this.joinTable == null) {
- this.setJoinTable(this.buildJoinTable());
- } else {
- this.joinTable.update();
- }
- } else {
- if (this.joinTable != null) {
- this.setJoinTable(null);
- }
- }
- }
-
- /**
- * The strategy can have a join table if either the table annotation is present
- * or the [mapping] relationship supports a default join table.
- */
- protected boolean buildsJoinTable() {
- return this.getJoinTableAnnotation().isSpecified()
- || this.getRelationship().mayHaveDefaultJoinTable();
- }
-
- protected JavaJoinTable buildJoinTable() {
- return this.getJpaFactory().buildJavaJoinTable(this, this);
- }
-
-
- // ********** join table annotation **********
-
- protected abstract JoinTableAnnotation addJoinTableAnnotation();
-
- protected abstract void removeJoinTableAnnotation();
-
-
- // ********** misc **********
-
- @Override
- public JavaJoinTableRelationship getParent() {
- return (JavaJoinTableRelationship) super.getParent();
- }
-
- public JavaJoinTableRelationship getRelationship() {
- return this.getParent();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- public void initializeFrom(ReadOnlyJoinTableRelationshipStrategy oldStrategy) {
- ReadOnlyJoinTable oldJoinTable = oldStrategy.getJoinTable();
- if (oldJoinTable != null) {
- this.addStrategy();
- this.joinTable.initializeFrom(oldJoinTable);
- }
- }
-
- public void initializeFromVirtual(ReadOnlyJoinTableRelationshipStrategy virtualStrategy) {
- ReadOnlyJoinTable oldJoinTable = virtualStrategy.getJoinTable();
- if (oldJoinTable != null) {
- this.addStrategy();
- this.joinTable.initializeFromVirtual(oldJoinTable);
- }
- }
-
- public String getTableName() {
- return (this.joinTable == null) ? null : this.joinTable.getName();
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return (this.joinTable == null) ? null : this.joinTable.getDbTable();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return Tools.valuesAreDifferent(this.getTableName(), tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.DOES_NOT_MATCH_JOIN_TABLE;
- }
-
- public String getJoinTableDefaultName() {
- return MappingTools.buildJoinTableDefaultName(this.getRelationship());
- }
-
- public void addStrategy() {
- if (this.joinTable == null) {
- this.addJoinTableAnnotation();
- this.setJoinTable(this.buildJoinTable());
- }
- }
-
- public void removeStrategy() {
- if (this.joinTable != null) {
- this.removeJoinTableAnnotation();
- this.setJoinTable(null);
- }
- }
-
-
- // ********** Java completion proposals **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- if (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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJpaContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJpaContextNode.java
deleted file mode 100644
index 8026c69af9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJpaContextNode.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.JptCommonCorePlugin;
-import org.eclipse.jpt.common.core.JptResourceType;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.internal.context.AbstractJpaContextNode;
-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
-{
- protected AbstractJavaJpaContextNode(JpaContextNode parent) {
- super(parent);
- }
-
- @Override
- public JptResourceType getResourceType() {
- return JptCommonCorePlugin.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 <em>not</em> be cascaded to "child" objects; it should
- * only return candidates for the current object. The cascading is
- * handled by {@link #javaCompletionProposals(int, Filter, CompilationUnit)}.
- */
- @SuppressWarnings("unused")
- protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- return null;
- }
-
- // ********** validation **********
-
- /**
- * All subclass implementations
- * 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();
- }
- }
-
- /**
- * Return the specified text range if it is not <code>null</code>; if it is
- * <code>null</code>, return the node's validation text range.
- */
- protected TextRange getValidationTextRange(TextRange textRange, CompilationUnit astRoot) {
- return (textRange != null) ? textRange : this.getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToManyMapping.java
deleted file mode 100644
index 22c5d8c9e3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToManyMapping.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
-
-public abstract class AbstractJavaManyToManyMapping
- extends AbstractJavaMultiRelationshipMapping<ManyToManyAnnotation>
- implements JavaManyToManyMapping2_0
-{
- protected AbstractJavaManyToManyMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
-
- // ********** relationship **********
-
- @Override
- public JavaManyToManyRelationship getRelationship() {
- return (JavaManyToManyRelationship) super.getRelationship();
- }
-
- @Override
- protected JavaMappingRelationship buildRelationship() {
- return new GenericJavaManyToManyRelationship(this);
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return ManyToManyAnnotation.ANNOTATION_NAME;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToOneMapping.java
deleted file mode 100644
index 42a93b9b37..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaManyToOneMapping.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
-
-public abstract class AbstractJavaManyToOneMapping
- extends AbstractJavaSingleRelationshipMapping<ManyToOneAnnotation>
- implements JavaManyToOneMapping2_0
-{
- protected AbstractJavaManyToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- }
-
-
- // ********** relationship **********
-
- @Override
- public JavaManyToOneRelationship getRelationship() {
- return (JavaManyToOneRelationship) super.getRelationship();
- }
-
- @Override
- protected JavaManyToOneRelationship buildRelationship() {
- return new GenericJavaManyToOneRelationship(this);
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return ManyToOneAnnotation.ANNOTATION_NAME;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappedSuperclass.java
deleted file mode 100644
index d51f3017e1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappedSuperclass.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericMappedSuperclassPrimaryKeyValidator;
-import org.eclipse.jpt.jpa.core.resource.java.MappedSuperclassAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java mapped superclass
- */
-public abstract class AbstractJavaMappedSuperclass
- extends AbstractJavaTypeMapping<MappedSuperclassAnnotation>
- implements JavaMappedSuperclass
-{
- protected final JavaIdClassReference idClassReference;
-
-
- protected AbstractJavaMappedSuperclass(JavaPersistentType parent, MappedSuperclassAnnotation mappingAnnotation) {
- super(parent, mappingAnnotation);
- this.idClassReference = this.buildIdClassReference();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.idClassReference.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.idClassReference.update();
- }
-
-
- // ********** id class **********
-
- public JavaIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
- protected JavaIdClassReference buildIdClassReference() {
- return new GenericJavaIdClassReference(this);
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
- public boolean isMapped() {
- return true;
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validatePrimaryKey(messages, reporter, astRoot);
- this.idClassReference.validate(messages, reporter, astRoot);
- }
-
- @Override
- public boolean validatesAgainstDatabase() {
- return false;
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- this.buildPrimaryKeyValidator(astRoot).validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) {
- return new GenericMappedSuperclassPrimaryKeyValidator(this, 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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappingRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappingRelationship.java
deleted file mode 100644
index 852474ce29..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMappingRelationship.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-
-/**
- * <strong>NB:</strong> Subclasses may want to set the {@link #strategy} at the
- * end of their constructors; otherwise, it will be <code>null</code> until it
- * is set during {@link #update()}.
- */
-public abstract class AbstractJavaMappingRelationship<M extends JavaRelationshipMapping>
- extends AbstractJavaJpaContextNode
- implements JavaMappingRelationship
-{
- protected JavaRelationshipStrategy strategy;
-
-
- public AbstractJavaMappingRelationship(M parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateStrategy();
- }
-
-
- // ********** strategy **********
-
- public JavaRelationshipStrategy getStrategy() {
- return this.strategy;
- }
-
- protected void setStrategy(JavaRelationshipStrategy strategy) {
- RelationshipStrategy old = this.strategy;
- this.strategy = strategy;
- this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy);
- }
-
- protected abstract JavaRelationshipStrategy buildStrategy();
-
- /**
- * This is called by subclasses when the various supported strategies are
- * added or removed; allowing the strategy to be set synchronously. (?)
- */
- protected void updateStrategy() {
- this.setStrategy(this.buildStrategy());
- }
-
-
- // ********** conversions **********
-
- public void initializeFrom(ReadOnlyRelationship oldRelationship) {
- oldRelationship.initializeOn(this);
- }
-
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- // NOP
- }
-
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- // NOP
- }
-
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- // NOP
- }
-
-
- // ********** misc **********
-
- @Override
- @SuppressWarnings("unchecked")
- public M getParent() {
- return (M) super.getParent();
- }
-
- public JavaRelationshipMapping getMapping() {
- return this.getParent();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getMapping().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = this.getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isOverridable() {
- return this.strategy.isOverridable();
- }
-
- public boolean isVirtual() {
- return this.getMapping().getPersistentAttribute().isVirtual();
- }
-
- public boolean isTargetForeignKey() {
- return false;
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getMapping().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
deleted file mode 100644
index d452d2e0af..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaMultiRelationshipMapping.java
+++ /dev/null
@@ -1,784 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.OverrideContainer;
-import org.eclipse.jpt.jpa.core.context.Override_;
-import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaMultiRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaOrderable;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MapKeyAttributeOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MapKeyColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.RelationshipStrategyTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.NullJavaMapKeyColumn2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyClass2_0Annotation;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.MapKeyColumn2_0Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.RelationshipMappingAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java multi-relationship (m:m, 1:m) mapping
- */
-public abstract class AbstractJavaMultiRelationshipMapping<A extends RelationshipMappingAnnotation>
- extends AbstractJavaRelationshipMapping<A>
- implements JavaMultiRelationshipMapping, JavaCollectionMapping2_0
-{
- protected final JavaOrderable orderable;
-
- 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 Type valueType;
- protected Type keyType;
-
- protected final JavaColumn mapKeyColumn;
-
- protected final JavaAttributeOverrideContainer mapKeyAttributeOverrideContainer;
-
-
- protected AbstractJavaMultiRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orderable = this.buildOrderable();
-
- this.specifiedMapKey = this.buildSpecifiedMapKey();
- this.noMapKey = this.buildNoMapKey();
- this.pkMapKey = this.buildPkMapKey();
- this.customMapKey = this.buildCustomMapKey();
-
- this.specifiedMapKeyClass = this.buildSpecifiedMapKeyClass();
-
- this.mapKeyColumn = this.buildMapKeyColumn();
- this.mapKeyAttributeOverrideContainer = this.buildMapKeyAttributeOverrideContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.orderable.synchronizeWithResourceModel();
-
- this.setSpecifiedMapKey_(this.buildSpecifiedMapKey());
- this.setNoMapKey_(this.buildNoMapKey());
- this.setPkMapKey_(this.buildPkMapKey());
- this.setCustomMapKey_(this.buildCustomMapKey());
-
- this.setSpecifiedMapKeyClass_(this.buildSpecifiedMapKeyClass());
-
- this.mapKeyColumn.synchronizeWithResourceModel();
-
- this.mapKeyAttributeOverrideContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
-
- this.orderable.update();
-
- this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
- this.setFullyQualifiedMapKeyClass(this.buildFullyQualifiedMapKeyClass());
-
- this.setValueType(this.buildValueType());
- this.setKeyType(this.buildKeyType());
-
- this.mapKeyColumn.update();
-
- this.mapKeyAttributeOverrideContainer.update();
- }
-
-
- // ********** orderable **********
-
- public JavaOrderable getOrderable() {
- return this.orderable;
- }
-
- protected JavaOrderable buildOrderable() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory2_0().buildJavaOrderable(this, this.buildOrderableOwner()) :
- this.getJpaFactory().buildJavaOrderable(this);
- }
-
- protected Orderable2_0.Owner buildOrderableOwner() {
- return new OrderableOwner();
- }
-
- protected class OrderableOwner
- implements Orderable2_0.Owner
- {
- public String getTableName() {
- return this.getRelationshipStrategy().getTableName();
- }
- public Table resolveDbTable(String tableName) {
- return this.getRelationshipStrategy().resolveDbTable(tableName);
- }
- protected JavaRelationshipStrategy getRelationshipStrategy() {
- return AbstractJavaMultiRelationshipMapping.this.getRelationship().getStrategy();
- }
- }
-
-
- // ********** 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$
- }
-
-
- // ********** specified map key **********
-
- public String getSpecifiedMapKey() {
- return this.specifiedMapKey;
- }
-
- public void setSpecifiedMapKey(String mapKey) {
- if (mapKey != null) {
- this.getMapKeyAnnotationForUpdate().setName(mapKey);
-
- this.setSpecifiedMapKey_(mapKey);
- this.setNoMapKey_(false);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(true);
- } else {
- this.setPkMapKey(true); // hmmm...
- }
- }
-
- protected void setSpecifiedMapKey_(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected String buildSpecifiedMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation == null) ? null : mapKeyAnnotation.getName();
- }
-
-
- // ********** no map key **********
-
- public boolean isNoMapKey() {
- return this.noMapKey;
- }
-
- public void setNoMapKey(boolean noMapKey) {
- if (noMapKey) {
- if (this.getMapKeyAnnotation() != null) {
- this.removeMapKeyAnnotation();
- }
-
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(true);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(false);
- } else {
- this.setPkMapKey(true); // hmmm...
- }
- }
-
- protected void setNoMapKey_(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
- protected boolean buildNoMapKey() {
- return this.getMapKeyAnnotation() == null;
- }
-
-
- // ********** pk map key **********
-
- public boolean isPkMapKey() {
- return this.pkMapKey;
- }
-
- public void setPkMapKey(boolean pkMapKey) {
- if (pkMapKey) {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- if (mapKeyAnnotation == null) {
- mapKeyAnnotation = this.addMapKeyAnnotation();
- } else {
- mapKeyAnnotation.setName(null);
- }
-
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(false);
- this.setPkMapKey_(true);
- this.setCustomMapKey_(false);
- } else {
- this.setNoMapKey(true); // hmmm...
- }
- }
-
- protected void setPkMapKey_(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
- protected boolean buildPkMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation != null) && (mapKeyAnnotation.getName() == null);
- }
-
-
- // ********** custom map key **********
-
- public boolean isCustomMapKey() {
- return this.customMapKey;
- }
-
- public void setCustomMapKey(boolean customMapKey) {
- if (customMapKey) {
- this.setSpecifiedMapKey(""); //$NON-NLS-1$
- } else {
- this.setNoMapKey(true); // hmmm...
- }
- }
-
- protected void setCustomMapKey_(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
- protected boolean buildCustomMapKey() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation != null) && (mapKeyAnnotation.getName() != null);
- }
-
-
- // ********** map key annotation **********
-
- protected MapKeyAnnotation getMapKeyAnnotation() {
- return (MapKeyAnnotation) this.getResourcePersistentAttribute().getAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected MapKeyAnnotation getMapKeyAnnotationForUpdate() {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation != null) ? mapKeyAnnotation : this.addMapKeyAnnotation();
- }
-
- protected MapKeyAnnotation addMapKeyAnnotation() {
- return (MapKeyAnnotation) this.getResourcePersistentAttribute().addAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
- protected void removeMapKeyAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(MapKeyAnnotation.ANNOTATION_NAME);
- }
-
-
- // ********** 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) {
- if (this.valuesAreDifferent(mapKeyClass, this.specifiedMapKeyClass)) {
- MapKeyClass2_0Annotation annotation = this.getMapKeyClassAnnotation();
- if (mapKeyClass == null) {
- if (annotation != null) {
- this.removeMapKeyClassAnnotation();
- }
- } else {
- if (annotation == null) {
- annotation = this.addMapKeyClassAnnotation();
- }
- annotation.setValue(mapKeyClass);
- }
-
- this.setSpecifiedMapKeyClass_(mapKeyClass);
- }
- }
-
- protected void setSpecifiedMapKeyClass_(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected String buildSpecifiedMapKeyClass() {
- MapKeyClass2_0Annotation annotation = this.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.isJpa2_0Compatible() ? this.getPersistentAttribute().getMultiReferenceMapKeyTypeName() : null;
- }
-
- 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.isJpa2_0Compatible() ? this.buildFullyQualifiedMapKeyClass_() : null;
- }
-
- protected String buildFullyQualifiedMapKeyClass_() {
- return (this.specifiedMapKeyClass == null) ?
- this.defaultMapKeyClass :
- this.getMapKeyClassAnnotation().getFullyQualifiedClassName();
- }
-
- public char getMapKeyClassEnclosingTypeSeparator() {
- return '.';
- }
-
-
- // ********** resolved map key embeddable/entity **********
-
- protected Embeddable getResolvedMapKeyEmbeddable() {
- return this.getPersistenceUnit().getEmbeddable(this.fullyQualifiedMapKeyClass);
- }
-
- protected Entity getResolvedMapKeyEntity() {
- return this.getPersistenceUnit().getEntity(this.fullyQualifiedMapKeyClass);
- }
-
-
- // ********** map key class annotation **********
-
- protected MapKeyClass2_0Annotation getMapKeyClassAnnotation() {
- return this.isJpa2_0Compatible() ? this.getMapKeyClassAnnotation_() : null;
- }
-
- 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);
- }
-
-
- // ********** value type **********
-
- public Type getValueType() {
- return this.valueType;
- }
-
- protected void setValueType(Type valueType) {
- Type old = this.valueType;
- this.valueType = valueType;
- this.firePropertyChanged(VALUE_TYPE_PROPERTY, old, valueType);
- }
-
- protected Type buildValueType() {
- if (this.getResolvedTargetEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- if (this.getResolvedTargetEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (this.getTargetEntity() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- protected Embeddable getResolvedTargetEmbeddable() {
- return this.getPersistenceUnit().getEmbeddable(this.fullyQualifiedTargetEntity);
- }
-
-
- // ********** key type **********
-
- public Type getKeyType() {
- return this.keyType;
- }
-
- protected void setKeyType(Type keyType) {
- Type old = this.keyType;
- this.keyType = keyType;
- this.firePropertyChanged(KEY_TYPE_PROPERTY, old, keyType);
- }
-
- protected Type buildKeyType() {
- if (this.getResolvedMapKeyEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (this.getResolvedMapKeyEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- if (this.getMapKeyClass() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
-
- // ********** map key column **********
-
- public JavaColumn getMapKeyColumn() {
- return this.mapKeyColumn;
- }
-
- protected JavaColumn buildMapKeyColumn() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory2_0().buildJavaMapKeyColumn(this, this.buildMapKeyColumnOwner()) :
- new NullJavaMapKeyColumn2_0(this);
- }
-
- protected JavaColumn.Owner buildMapKeyColumnOwner() {
- return new MapKeyColumnOwner();
- }
-
- protected MapKeyColumn2_0Annotation getMapKeyColumnAnnotation() {
- return this.isJpa2_0Compatible() ? this.getMapKeyColumnAnnotation_() : null;
- }
-
- protected MapKeyColumn2_0Annotation getMapKeyColumnAnnotation_() {
- return (MapKeyColumn2_0Annotation) this.getResourcePersistentAttribute().getNonNullAnnotation(MapKeyColumn2_0Annotation.ANNOTATION_NAME);
- }
-
- protected void removeMapKeyColumnAnnotation() {
- if (this.isJpa2_0Compatible()) {
- this.removeMapKeyColumnAnnotation_();
- } else {
- throw new IllegalStateException();
- }
- }
-
- protected void removeMapKeyColumnAnnotation_() {
- this.getResourcePersistentAttribute().removeAnnotation(MapKeyColumn2_0Annotation.ANNOTATION_NAME);
- }
-
-
- // ********** map key attribute override container **********
-
- public JavaAttributeOverrideContainer getMapKeyAttributeOverrideContainer() {
- return this.mapKeyAttributeOverrideContainer;
- }
-
- public JavaAttributeOverrideContainer buildMapKeyAttributeOverrideContainer() {
- return this.getJpaFactory().buildJavaAttributeOverrideContainer(this, this.buildMapKeyAttributeOverrideContainerOwner());
- }
-
- protected JavaAttributeOverrideContainer.Owner buildMapKeyAttributeOverrideContainerOwner() {
- return new MapKeyAttributeOverrideContainerOwner();
- }
-
-
- // ********** misc **********
-
- @Override
- protected String buildDefaultTargetEntity() {
- return this.getPersistentAttribute().getMultiReferenceTargetTypeName();
- }
-
- @Override
- protected FetchType buildDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- // ********** 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.orderable.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- if (this.mapKeyNameTouches(pos, astRoot)) {
- return this.javaCandidateMapKeyNames(filter);
- }
-
- result = this.mapKeyColumn.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- result = this.mapKeyAttributeOverrideContainer.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return null;
- }
-
- protected boolean mapKeyNameTouches(int pos, CompilationUnit astRoot) {
- MapKeyAnnotation mapKeyAnnotation = this.getMapKeyAnnotation();
- return (mapKeyAnnotation != null) && mapKeyAnnotation.nameTouches(pos, astRoot);
- }
-
- 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 (this.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 (this.getKeyType() == Type.BASIC_TYPE) {
- this.mapKeyColumn.validate(messages, reporter, astRoot);
- //validate map key converter
- }
- else if (this.getKeyType() == Type.ENTITY_TYPE) {
- //validate map key join columns
- }
- else if (this.getKeyType() == Type.EMBEDDABLE_TYPE) {
- this.mapKeyAttributeOverrideContainer.validate(messages, reporter, astRoot);
- //validate map key association overrides - for eclipselink
- }
- }
-
-
- // ********** abstract owner **********
-
- /**
- * some common behavior
- */
- protected abstract class AbstractOwner
- {
- public TypeMapping getTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getTypeMapping();
- }
-
- public String getDefaultTableName() {
- return this.getRelationshipStrategy().getTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getRelationshipStrategy().resolveDbTable(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return AbstractJavaMultiRelationshipMapping.this.getValidationTextRange(astRoot);
- }
-
- protected RelationshipStrategy getRelationshipStrategy() {
- return AbstractJavaMultiRelationshipMapping.this.getRelationship().getStrategy();
- }
-
- protected JavaPersistentAttribute getPersistentAttribute() {
- return AbstractJavaMultiRelationshipMapping.this.getPersistentAttribute();
- }
- }
-
-
- // ********** map key column owner **********
-
- protected class MapKeyColumnOwner
- extends AbstractOwner
- implements JavaColumn.Owner
- {
- public MapKeyColumn2_0Annotation getColumnAnnotation() {
- return AbstractJavaMultiRelationshipMapping.this.getMapKeyColumnAnnotation();
- }
-
- public void removeColumnAnnotation() {
- AbstractJavaMultiRelationshipMapping.this.removeMapKeyColumnAnnotation();
- }
-
- public String getDefaultColumnName() {
- return AbstractJavaMultiRelationshipMapping.this.getName() + "_KEY"; //$NON-NLS-1$
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getRelationshipStrategy().tableNameIsInvalid(tableName);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new MapKeyColumnValidator(this.getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new RelationshipStrategyTableDescriptionProvider(this.getRelationshipStrategy()));
- }
- }
-
-
- // ********** map key attribute override owner **********
-
- protected class MapKeyAttributeOverrideContainerOwner
- extends AbstractOwner
- implements JavaAttributeOverrideContainer.Owner
- {
- public JavaResourcePersistentMember getResourcePersistentMember() {
- return AbstractJavaMultiRelationshipMapping.this.getResourcePersistentAttribute();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractJavaMultiRelationshipMapping.this.getResolvedMapKeyEmbeddable();
- }
-
- /**
- * 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 Tools.valuesAreDifferent(this.getDefaultTableName(), tableName);
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = this.getOverridableTypeMapping();
- return (typeMapping != null) ? typeMapping.allOverridableAttributeNames() : EmptyIterator.<String>instance();
- }
-
- protected static final String POSSIBLE_PREFIX = "key"; //$NON-NLS-1$
- public String getPossiblePrefix() {
- return POSSIBLE_PREFIX;
- }
-
- public String getWritePrefix() {
- return this.getPossiblePrefix();
- }
-
- // since only a map's 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 attributeName) {
- return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName);
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideValidator(this.getPersistentAttribute(), (AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideColumnValidator(this.getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new RelationshipStrategyTableDescriptionProvider(this.getRelationshipStrategy()));
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java
deleted file mode 100644
index 44615c5f91..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.java.NamedColumnAnnotation;
-import org.eclipse.jpt.jpa.db.Column;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java<ul>
- * <li>column
- * <li>join column
- * <li>discriminator column
- * <li>order column
- * <li>primary key join column
- * </ul>
- * <strong>NB:</strong> any subclass that directly holds its column annotation
- * must:<ul>
- * <li>call the "super" constructor that takes a column annotation
- * {@link #AbstractJavaNamedColumn(JavaJpaContextNode, JavaNamedColumn.Owner, NamedColumnAnnotation)}
- * <li>override {@link #setColumnAnnotation(NamedColumnAnnotation)} to set the column annotation
- * so it is in place before the column's state (e.g. {@link #specifiedName})
- * is initialized
- * </ul>
- */
-public abstract class AbstractJavaNamedColumn<A extends NamedColumnAnnotation, O extends JavaNamedColumn.Owner>
- extends AbstractJavaJpaContextNode
- implements JavaNamedColumn
-{
- protected final O owner;
-
- protected String specifiedName;
- protected String defaultName;
-
- protected String columnDefinition;
-
-
- protected AbstractJavaNamedColumn(JavaJpaContextNode parent, O owner) {
- this(parent, owner, null);
- }
-
- protected AbstractJavaNamedColumn(JavaJpaContextNode parent, O owner, A columnAnnotation) {
- super(parent);
- this.owner = owner;
- this.setColumnAnnotation(columnAnnotation);
- this.specifiedName = this.buildSpecifiedName();
- this.columnDefinition = this.buildColumnDefinition();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedName_(this.buildSpecifiedName());
- this.setColumnDefinition_(this.buildColumnDefinition());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultName(this.buildDefaultName());
- }
-
-
- // ********** column annotation **********
-
- /**
- * Return the Java column annotation. Do not return <code>null</code> if the
- * Java annotation does not exist; return a <em>null</em> column annotation
- * instead.
- */
- public abstract A getColumnAnnotation();
-
- /**
- * see class comment... ({@link AbstractJavaNamedColumn})
- */
- protected void setColumnAnnotation(A columnAnnotation) {
- if (columnAnnotation != null) {
- throw new IllegalArgumentException("this method must be overridden if the column annotation is not null: " + columnAnnotation); //$NON-NLS-1$
- }
- }
-
- protected void removeColumnAnnotationIfUnset() {
- if (this.getColumnAnnotation().isUnset()) {
- this.removeColumnAnnotation();
- }
- }
-
- protected abstract void removeColumnAnnotation();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- if (this.valuesAreDifferent(this.specifiedName, name)) {
- this.getColumnAnnotation().setName(name);
- this.removeColumnAnnotationIfUnset();
- this.setSpecifiedName_(name);
- }
- }
-
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- return this.getColumnAnnotation().getName();
- }
-
- 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);
- }
-
- protected String buildDefaultName() {
- return this.owner.getDefaultColumnName();
- }
-
-
- // ********** column definition **********
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- public void setColumnDefinition(String columnDefinition) {
- if (this.valuesAreDifferent(this.columnDefinition, columnDefinition)) {
- this.getColumnAnnotation().setColumnDefinition(columnDefinition);
- this.removeColumnAnnotationIfUnset();
- this.setColumnDefinition_(columnDefinition);
- }
- }
-
- protected void setColumnDefinition_(String columnDefinition) {
- String old = this.columnDefinition;
- this.columnDefinition = columnDefinition;
- this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition);
- }
-
- public String buildColumnDefinition() {
- return this.getColumnAnnotation().getColumnDefinition();
- }
-
-
- // ********** database stuff **********
-
- protected Column getDbColumn() {
- Table table = this.getDbTable();
- return (table == null) ? null : table.getColumnForIdentifier(this.getName());
- }
-
- public Table getDbTable() {
- return this.owner.resolveDbTable(this.getTable());
- }
-
- /**
- * Return the name of the column's table. This is overridden
- * in {@link AbstractJavaBaseColumn} where a table can be defined.
- */
- public String getTable() {
- return this.owner.getTypeMapping().getPrimaryTableName();
- }
-
- public boolean isResolved() {
- return this.getDbColumn() != null;
- }
-
-
- // ********** Java completion proposals **********
-
- @Override
- protected 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;
- }
-
- protected boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getColumnAnnotation().nameTouches(pos, astRoot);
- }
-
- 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() {
- Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers() : EmptyIterable.<String> instance();
- }
-
-
- // ********** validation **********
-
- @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.owner.buildColumnValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected NamedColumnTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaNamedColumnTextRangeResolver(this, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getColumnAnnotation().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.owner.getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.getColumnAnnotation().getNameTextRange(astRoot), astRoot);
- }
-
-
- // ********** misc **********
-
- /**
- * This is used by the subclasses that implement {@link BaseJoinColumn}.
- */
- public boolean isVirtual() {
- return false;
- }
-
- protected void initializeFrom(ReadOnlyNamedColumn oldColumn) {
- this.setSpecifiedName(oldColumn.getSpecifiedName());
- this.setColumnDefinition(oldColumn.getColumnDefinition());
- }
-
- protected void initializeFromVirtual(ReadOnlyNamedColumn virtualColumn) {
- this.setSpecifiedName(virtualColumn.getName());
- this.setColumnDefinition(virtualColumn.getColumnDefinition());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- String table = this.getTable();
- if (table != null) {
- sb.append(table);
- sb.append('.');
- }
- sb.append(this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToManyMapping.java
deleted file mode 100644
index a7614b8d84..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToManyMapping.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.NullJavaOrphanRemoval2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-
-public abstract class AbstractJavaOneToManyMapping
- extends AbstractJavaMultiRelationshipMapping<OneToManyAnnotation>
- implements JavaOneToManyMapping2_0, JavaOrphanRemovalHolder2_0
-{
- protected final JavaOrphanRemovable2_0 orphanRemoval;
-
-
- protected AbstractJavaOneToManyMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.orphanRemoval.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.orphanRemoval.update();
- }
-
-
- // ********** relationship **********
-
- @Override
- public JavaOneToManyRelationship getRelationship() {
- return (JavaOneToManyRelationship) super.getRelationship();
- }
-
- @Override
- protected JavaMappingRelationship buildRelationship() {
- return new GenericJavaOneToManyRelationship(this, this.isJpa2_0Compatible());
- }
-
-
- // ********** orphan removal **********
-
- public JavaOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-
- protected JavaOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory2_0().buildJavaOrphanRemoval(this) :
- new NullJavaOrphanRemoval2_0(this);
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return OneToManyAnnotation.ANNOTATION_NAME;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToOneMapping.java
deleted file mode 100644
index 1fca5e88aa..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOneToOneMapping.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.NullJavaOrphanRemoval2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
-
-
-public abstract class AbstractJavaOneToOneMapping
- extends AbstractJavaSingleRelationshipMapping<OneToOneAnnotation>
- implements JavaOneToOneMapping2_0, JavaOrphanRemovalHolder2_0
-{
- protected final JavaOrphanRemovable2_0 orphanRemoval;
-
-
- protected AbstractJavaOneToOneMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.orphanRemoval.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.orphanRemoval.update();
- }
-
-
- // ********** relationship **********
-
- @Override
- public JavaOneToOneRelationship getRelationship() {
- return (JavaOneToOneRelationship) super.getRelationship();
- }
-
- @Override
- protected JavaOneToOneRelationship buildRelationship() {
- return new GenericJavaOneToOneRelationship(this);
- }
-
-
- // ********** orphan removal **********
-
- public JavaOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-
- protected JavaOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory2_0().buildJavaOrphanRemoval(this) :
- new NullJavaOrphanRemoval2_0(this);
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return OneToOneAnnotation.ANNOTATION_NAME;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java
deleted file mode 100644
index cf70a08a2b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaOverride.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualOverride;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.java.OverrideAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Specified Java override
- */
-public abstract class AbstractJavaOverride<C extends JavaOverrideContainer, A extends OverrideAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaOverride
-{
- protected final A overrideAnnotation;
-
- protected String name;
-
-
- protected AbstractJavaOverride(C parent, A overrideAnnotation) {
- super(parent);
- this.overrideAnnotation = overrideAnnotation;
- this.name = this.buildName();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName_(this.buildName());
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- /**
- * Strip the prefix (if necessary) before storing the name in the context
- * model. Pass the unchanged name to the annotation.
- */
- public void setName(String name) {
- this.overrideAnnotation.setName(name);
- this.setName_(this.stripPrefix(name));
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
- /**
- * Strip the prefix (if necessary) from the name taken from the annotation
- * before storing it in the context model.
- */
- protected String buildName() {
- return this.stripPrefix(this.overrideAnnotation.getName());
- }
-
- protected String stripPrefix(String rawName) {
- if (rawName == null) {
- return null;
- }
- String prefix = this.getPossiblePrefix();
- if (prefix == null) {
- return rawName;
- }
- int prefixLength = prefix.length();
- if ((rawName.length() > prefixLength) &&
- (rawName.charAt(prefixLength) == '.') &&
- rawName.startsWith(prefix)) {
- return rawName.substring(prefixLength + 1);
- }
- return rawName;
- }
-
- protected String getPossiblePrefix() {
- return this.getContainer().getPossiblePrefix();
- }
-
-
- // ********** specified/virtual **********
-
- public boolean isVirtual() {
- return false;
- }
-
- public JavaVirtualOverride convertToVirtual() {
- return this.getContainer().convertOverrideToVirtual(this);
- }
-
-
- // ********** misc **********
-
- @Override
- @SuppressWarnings("unchecked")
- public C getParent() {
- return (C) super.getParent();
- }
-
- public C getContainer() {
- return this.getParent();
- }
-
- public A getOverrideAnnotation() {
- return this.overrideAnnotation;
- }
-
- protected void initializeFrom(ReadOnlyOverride oldOverride) {
- this.setName(this.prefix(oldOverride.getName()));
- }
-
- protected void initializeFromVirtual(ReadOnlyOverride virtualOverride) {
- this.setName(this.prefix(virtualOverride.getName()));
- }
-
- protected String prefix(String oldName) {
- if (oldName == null) {
- return null;
- }
- String prefix = this.getWritePrefix();
- return (prefix == null) ? oldName : (prefix + '.' + oldName);
- }
-
- protected String getWritePrefix() {
- return this.getContainer().getWritePrefix();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-
- // ********** 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;
- }
- if (this.nameTouches(pos, astRoot)) {
- return this.javaCandidateNames(filter);
- }
- return null;
- }
-
- protected boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.overrideAnnotation.nameTouches(pos, astRoot);
- }
-
- protected Iterator<String> javaCandidateNames(Filter<String> filter) {
- return StringTools.convertToJavaStringLiterals(this.candidateNames(filter));
- }
-
- private Iterator<String> candidateNames(Filter<String> filter) {
- return new FilteringIterator<String>(this.candidateNames(), filter);
- }
-
- protected abstract Iterator<String> candidateNames();
-
-
- // ********** 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.getContainer().buildValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected OverrideTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaOverrideTextRangeResolver(this, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.overrideAnnotation.getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getContainer().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.overrideAnnotation.getNameTextRange(astRoot), astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
deleted file mode 100644
index 55053350af..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentAttribute.java
+++ /dev/null
@@ -1,787 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jdt.core.dom.Modifier;
-import org.eclipse.jpt.common.core.internal.utility.JDTTools;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.CollectionMapping;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.orm.VirtualOrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java persistent attributes
- */
-public abstract class AbstractJavaPersistentAttribute
- extends AbstractJavaJpaContextNode
- implements JavaPersistentAttribute2_0
-{
- protected final JavaResourcePersistentAttribute resourcePersistentAttribute;
-
- protected String name;
-
- protected AccessType defaultAccess;
-
- protected JavaAttributeMapping mapping; // never null
- protected String defaultMappingKey;
-
-
- protected AbstractJavaPersistentAttribute(PersistentType parent, JavaResourcePersistentAttribute resourcePersistentAttribute) {
- super(parent);
- this.resourcePersistentAttribute = resourcePersistentAttribute;
- this.name = resourcePersistentAttribute.getName();
-
- // this is determined directly from the resource model
- this.defaultAccess = this.buildDefaultAccess();
-
- // keep non-null at all times
- this.mapping = this.buildMapping();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName(this.resourcePersistentAttribute.getName());
- // this is determined directly from the resource model
- this.setDefaultAccess(this.buildDefaultAccess());
- this.syncMapping();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateMapping();
- }
-
-
- // ********** 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);
- }
-
-
- // ********** access **********
-
- /**
- * Subclasses determine the specified access.
- */
- public AccessType getAccess() {
- AccessType access = this.getSpecifiedAccess();
- return (access != null) ? access : this.defaultAccess;
- }
-
- public abstract AccessType getSpecifiedAccess();
-
- 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);
- }
-
- protected AccessType buildDefaultAccess() {
- return this.resourcePersistentAttribute.isField() ? AccessType.FIELD : AccessType.PROPERTY;
- }
-
-
- // ********** mapping **********
-
- public JavaAttributeMapping getMapping() {
- return this.mapping;
- }
-
- /**
- * Clients do not set the mapping directly.
- * @see #setMappingKey(String)
- */
- protected void setMapping(JavaAttributeMapping mapping) {
- JavaAttributeMapping old = this.mapping;
- this.mapping = mapping;
- this.firePropertyChanged(MAPPING_PROPERTY, old, mapping);
- }
-
- public String getMappingKey() {
- return this.mapping.getKey();
- }
-
- /**
- * Possible transitions:
- * <table border>
- * <th>
- * <th>null mapping/default<br>
- * <code>key = null</code>
- * <th>specified mapping A<br>
- * <code>key = "A"</code>
- * <th>specified mapping B<br>
- * <code>key = "B"</code>
- * <tr>
- * <th>[default] null mapping
- * <td>do nothing
- * <td>add annotation A<br>
- * set new mapping A
- * <td>add annotation B<br>
- * set new mapping B
- * <tr>
- * <th>default mapping A
- * <td>do nothing
- * <td>add annotation A<br>
- * <em>re-use</em> default mapping A
- * <td>add annotation B<br>
- * set new mapping B
- * <tr>
- * <th>specified mapping A
- * <td>remove annotation A<br>
- * set new default or null mapping
- * <td>do nothing
- * <td>remove annotation A<br>
- * add annotation B<br>
- * set new mapping B
- * </table>
- * The "do nothing" transitions are handled in this method.
- */
- public JavaAttributeMapping setMappingKey(String key) {
- if (this.mapping.isDefault()) {
- if (key == null) {
- // leave the default mapping unchanged
- } else {
- this.setMappingKey_(key); // replace the default mapping
- }
- } else {
- if (this.valuesAreEqual(key, this.mapping.getKey())) {
- // leave the specified mapping unchanged
- } else {
- this.setMappingKey_(key); // replace the specified mapping
- }
- }
- return this.mapping;
- }
-
- /**
- * We have either:<ul>
- * <li>a <em>default</em> mapping and a non-<code>null</code> key
- * </ul>or<ul>
- * <li>a <em>specified</em> mapping and a different (possibly
- * <code>null</code>) key
- * </ul>
- */
- protected void setMappingKey_(String key) {
- JavaAttributeMappingDefinition definition = this.getSpecifiedMappingDefinition(key);
- if (definition == null) {
- // our mapping is "specified" and the key is null;
- // check for a default definition
- definition = this.getDefaultMappingDefinition();
- Iterable<String> supportingAnnotationNames = (definition != null) ? definition.getSupportingAnnotationNames() : EmptyIterable.<String>instance();
- // clear any mapping annotation(s);
- // leave the "default" mapping's supporting annotations;
- // if there is no "default" mapping, clear all supporting annotations too(?)
- this.setMappingAnnotation(null, supportingAnnotationNames);
- } else {
- this.setMappingAnnotation(definition);
- }
- // note: 'definition' can still be null (if the key is null and there is no "default" mapping)
- this.setMapping(this.buildMapping(definition));
- }
-
- /**
- * pre-condition: definition is not <code>null</code>
- */
- protected void setMappingAnnotation(JavaAttributeMappingDefinition definition) {
- this.setMappingAnnotation(definition.getAnnotationName(), definition.getSupportingAnnotationNames());
- }
-
- protected void setMappingAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) {
- this.resourcePersistentAttribute.setPrimaryAnnotation(primaryAnnotationName, supportingAnnotationNames);
- }
-
- protected JavaAttributeMapping buildMapping(JavaAttributeMappingDefinition definition) {
- return (definition == null) ? this.buildNullMapping() : this.buildMapping_(definition);
- }
-
- protected JavaAttributeMapping buildNullMapping() {
- return this.getJpaFactory().buildJavaNullAttributeMapping(this);
- }
-
- /**
- * pre-condition: definition is not null
- * <p>
- * If we are converting a <em>default</em> mapping to its <em>specified</em>
- * manifestation, we just keep the same mapping and create its annotation.
- * We do <em>not</em> do the same thing when converting a <em>specified</em>
- * mapping to its <em>default</em> manifestation. We rebuild the
- * entire mapping, simplifying the clearing of all its state. We do this
- * because we allow clients to modify a <em>default</em> mapping (or any of
- * its components) directly,
- * modifying its state and triggering a conversion to a <em>specified</em>
- * mapping. The only way to convert a <em>specified</em> mapping to a
- * <em>default</em> mapping is by {@link #setMappingKey(String) setting the
- * mapping key} to <code>null</code>.
- */
- protected JavaAttributeMapping buildMapping_(JavaAttributeMappingDefinition definition) {
- // 'mapping' is null during construction
- if ((this.mapping != null) && this.mapping.isDefault() && Tools.valuesAreEqual(this.mapping.getKey(), definition.getKey())) {
- this.mapping.updateDefault(); // since nothing here changes, we need to update the mapping's flag
- return this.mapping;
- }
- return definition.buildMapping(this, this.getJpaFactory());
- }
-
- /**
- * We only look for a <em>specified</em> mapping here.
- * We look for a default mapping during <em>update</em>.
- */
- protected JavaAttributeMapping buildMapping() {
- return this.buildMapping(this.getSpecifiedMappingDefinition());
- }
-
- /**
- * Look for a <em>specified</em> mapping and sync our mapping.
- */
- protected void syncMapping() {
- JavaAttributeMappingDefinition definition = this.getSpecifiedMappingDefinition();
- if (definition == null) {
- if (this.mapping.isDefault()) {
- // null/default => null/default
- this.mapping.synchronizeWithResourceModel();
- } else {
- // specified => null/default
- definition = this.getDefaultMappingDefinition();
- this.setMapping(this.buildMapping(definition));
- }
- } else {
- if (this.mapping.isDefault()) {
- // null/default => specified
- this.setMapping(this.buildMapping(definition));
- } else {
- // specified => specified
- if (this.valuesAreEqual(definition.getKey(), this.mapping.getKey())) {
- this.mapping.synchronizeWithResourceModel();
- } else {
- this.setMapping(this.buildMapping(definition));
- }
- }
- }
- }
-
- /**
- * Return the "specified" mapping definition for the specified key.
- */
- protected JavaAttributeMappingDefinition getSpecifiedMappingDefinition(String key) {
- if (key == null) {
- return null;
- }
- for (JavaAttributeMappingDefinition definition : this.getSpecifiedMappingDefinitions()) {
- if (Tools.valuesAreEqual(definition.getKey(), key)) {
- return definition;
- }
- }
- throw new IllegalArgumentException("invalid mapping key: " + key); //$NON-NLS-1$
- }
-
- /**
- * Return the mapping definition for the mapping currently specified in the
- * source code.
- */
- protected JavaAttributeMappingDefinition getSpecifiedMappingDefinition() {
- for (JavaAttributeMappingDefinition definition : this.getSpecifiedMappingDefinitions()) {
- if (definition.isSpecified(this)) {
- return definition;
- }
- }
- return null;
- }
-
- protected Iterable<JavaAttributeMappingDefinition> getSpecifiedMappingDefinitions() {
- return this.getJpaPlatform().getSpecifiedJavaAttributeMappingDefinitions();
- }
-
-
- // ********** default mapping **********
-
- public String getDefaultMappingKey() {
- return this.defaultMappingKey;
- }
-
- protected void setDefaultMappingKey(String mappingKey) {
- String old = this.defaultMappingKey;
- this.defaultMappingKey = mappingKey;
- this.firePropertyChanged(DEFAULT_MAPPING_KEY_PROPERTY, old, mappingKey);
- }
-
- /**
- * If a mapping annotation is specified, we would have already set a
- * <em>specified</em> mapping in {@link #syncMapping()}. We need only check
- * for changes to the <em>default</em> mapping.
- */
- protected void updateMapping() {
- JavaAttributeMappingDefinition definition = this.getDefaultMappingDefinition();
- String newDefaultKey = (definition == null) ? null : definition.getKey();
- if (this.mapping.isDefault() && Tools.valuesAreDifferent(this.mapping.getKey(), newDefaultKey)) {
- this.setMapping(this.buildMapping(definition)); // the default mapping has changed
- } else {
- this.mapping.update();
- }
- this.setDefaultMappingKey(newDefaultKey);
- }
-
- protected JavaAttributeMappingDefinition getDefaultMappingDefinition() {
- for (DefaultJavaAttributeMappingDefinition definition : this.getDefaultMappingDefinitions()) {
- if (definition.isDefault(this)) {
- return definition;
- }
- }
- return null;
- }
-
- protected Iterable<DefaultJavaAttributeMappingDefinition> getDefaultMappingDefinitions() {
- return this.getJpaPlatform().getDefaultJavaAttributeMappingDefinitions();
- }
-
-
- // ********** 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
- }
-
-
- // ********** type **********
-
- /**
- * From the JPA spec, when the basic mapping applies:<br>
- * If the type of the attribute (field or property) is one of the following
- * it must be mapped as <code>@javax.persistence.Basic</code>:<ul>
- * <li><code>byte[]</code>
- * <li><code>java.lang.Byte[]</code>
- * <li><code>char[]</code>
- * <li><code>java.lang.Character[]</code>
- * <li>primitive types (except <code>void</code>)
- * <li>primitive wrappers (except <code>java.lang.Void</code>)
- * <li><code>java.lang.String</code>
- * <li><code>java.math.BigInteger</code>
- * <li><code>java.math.BigDecimal</code>
- * <li><code>java.util.Date</code>
- * <li><code>java.util.Calendar</code>
- * <li><code>java.sql.Date</code>
- * <li><code>java.sql.Time</code>
- * <li><code>java.sql.Timestamp</code>
- * <li><code>enum</code>s
- * <li>any other type that implements <code>java.io.Serializable</code>
- * </ul>
- */
- public boolean typeIsBasic() {
- // 'typeName' may include array brackets but not generic type arguments
- String typeName = this.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 JDTTools.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 (JDTTools.typeIsOtherValidBasicType(typeName)) {
- return true;
- }
- if (this.resourcePersistentAttribute.typeIsEnum()) {
- return true;
- }
- if (this.resourcePersistentAttribute.typeIsSubTypeOf(SERIALIZABLE_TYPE_NAME)) {
- return true;
- }
- return false;
- }
-
- protected static final String SERIALIZABLE_TYPE_NAME = java.io.Serializable.class.getName();
-
- public String getSingleReferenceTargetTypeName() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- String typeName = this.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.getJpaContainerDefinition().getMultiReferenceTargetTypeName(this.resourcePersistentAttribute);
- }
-
- public String getMultiReferenceMapKeyTypeName() {
- return this.getJpaContainerDefinition().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.getJpaContainerDefinition(typeName).isContainer();
- }
-
-
- // ********** misc **********
-
- @Override
- public PersistentType getParent() {
- return (PersistentType) super.getParent();
- }
-
- public PersistentType getOwningPersistentType() {
- return this.getParent();
- }
-
- public TypeMapping getOwningTypeMapping() {
- return this.getOwningPersistentType().getMapping();
- }
-
- public JavaPersistentAttribute getJavaPersistentAttribute() {
- return this;
- }
-
- public JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.resourcePersistentAttribute;
- }
-
- public String getPrimaryKeyColumnName() {
- return this.mapping.getPrimaryKeyColumnName();
- }
-
- public String getTypeName() {
- return this.resourcePersistentAttribute.getTypeName();
- }
-
- public boolean contains(int offset, CompilationUnit astRoot) {
- TextRange fullTextRange = this.resourcePersistentAttribute.getTextRange(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);
- }
-
- public Embeddable getEmbeddable() {
- String typeName = this.getTypeName();
- return (typeName == null) ? null : this.getPersistenceUnit().getEmbeddable(typeName);
- }
-
- 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());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.isVirtual() ?
- this.getOwningPersistentType().getValidationTextRange() :
- this.getSelectionTextRange(astRoot);
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateAttribute(messages, reporter, astRoot);
- this.mapping.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);
- }
-
- /**
- * If the attribute's owning type is an <code>orm.xml</code> persistent
- * type, the attribute must be one of the type's default attributes.
- * (Actually, the Java attribute is held by a <em>virtual</em>
- * <code>orm.xml</code> attribute
- * (see {@link VirtualOrmPersistentAttribute})
- * that is held by the <code>orm.xml</code> type.
- * The <em>virtual</em> attribute returns the Java attribute's mapping
- * as its own.)
- */
- public boolean isVirtual() {
- return this.declaringPersistentTypeIs(JptJpaCorePlugin.ORM_XML_CONTENT_TYPE);
- }
-
- protected boolean declaringPersistentTypeIs(IContentType contentType) {
- return this.getOwningPersistentType().getResourceType().getContentType().equals(contentType);
- }
-
-
- // ********** 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.mapping.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainerDefinition().getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainerDefinition().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.mapping);
- }
-
- public String getMetamodelTypeName() {
- String typeName = this.getTypeName();
- if (typeName == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- if (ClassName.isPrimitive(typeName)) {
- return ClassName.getWrapperClassName(typeName); // ???
- }
- return typeName;
- }
-
-
- // ********** JPA container definition **********
-
- public JpaContainerDefinition getJpaContainerDefinition() {
- // 'typeName' may include array brackets ("[]")
- // but not generic type arguments (e.g. "<java.lang.String>")
- return this.getJpaContainerDefinition(this.resourcePersistentAttribute.getTypeName());
- }
-
- /**
- * Return the JPA container definition corresponding to the specified type;
- * return a "null" definition if the specified type is not one of the
- * container types allowed by the JPA spec.
- */
- protected JpaContainerDefinition getJpaContainerDefinition(String typeName) {
- for (JpaContainerDefinition definition : this.getJpaContainerDefinitions()) {
- if (definition.getTypeName().equals(typeName)) {
- return definition;
- }
- }
- return JpaContainerDefinition.Null.instance();
- }
-
- protected Iterable<JpaContainerDefinition> getJpaContainerDefinitions() {
- return JPA_CONTAINER_DEFINITIONS;
- }
-
- protected static final JpaContainerDefinition[] JPA_CONTAINER_DEFINITION_ARRAY = new JpaContainerDefinition[] {
- new CollectionJpaContainerDefinition(java.util.Collection.class, JPA2_0.COLLECTION_ATTRIBUTE),
- new CollectionJpaContainerDefinition(java.util.Set.class, JPA2_0.SET_ATTRIBUTE),
- new CollectionJpaContainerDefinition(java.util.List.class, JPA2_0.LIST_ATTRIBUTE),
- new MapJpaContainerDefinition(java.util.Map.class, JPA2_0.MAP_ATTRIBUTE)
- };
-
- protected static final Iterable<JpaContainerDefinition> JPA_CONTAINER_DEFINITIONS = new ArrayIterable<JpaContainerDefinition>(JPA_CONTAINER_DEFINITION_ARRAY);
-
-
- /**
- * Abstract JPA container definition
- */
- protected abstract static class AbstractJpaContainerDefinition
- implements JpaContainerDefinition
- {
- protected final String typeName;
- protected final String metamodelContainerFieldTypeName;
-
- protected AbstractJpaContainerDefinition(Class<?> containerClass, String metamodelContainerFieldTypeName) {
- this(containerClass.getName(), metamodelContainerFieldTypeName);
- }
-
- protected AbstractJpaContainerDefinition(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 definition
- */
- protected static class CollectionJpaContainerDefinition
- extends AbstractJpaContainerDefinition
- {
- protected CollectionJpaContainerDefinition(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 definition
- */
- protected static class MapJpaContainerDefinition
- extends AbstractJpaContainerDefinition
- {
- protected MapJpaContainerDefinition(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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
deleted file mode 100644
index 6ec801509b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java
+++ /dev/null
@@ -1,722 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.ChainIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.JpaFile;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaStructureNodes;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceNode;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-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 final JavaResourcePersistentType resourcePersistentType;
-
- protected String name;
-
- protected PersistentType superPersistentType;
-
- protected AccessType specifiedAccess;
- protected AccessType defaultAccess; // never null
-
- protected JavaTypeMapping mapping; // never null
-
- protected final Vector<JavaPersistentAttribute> attributes = new Vector<JavaPersistentAttribute>();
- protected final AttributeContainerAdapter attributeContainerAdapter = new AttributeContainerAdapter();
-
-
- protected AbstractJavaPersistentType(PersistentType.Owner parent, JavaResourcePersistentType resourcePersistentType) {
- super(parent);
- this.resourcePersistentType = resourcePersistentType;
- this.name = resourcePersistentType.getQualifiedName();
- this.specifiedAccess = this.buildSpecifiedAccess();
-
- // keep this non-null
- this.defaultAccess = AccessType.FIELD;
-
- this.mapping = this.buildMapping();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName(this.resourcePersistentType.getQualifiedName());
- this.setSpecifiedAccess_(this.buildSpecifiedAccess());
- this.syncMapping();
- this.synchronizeNodesWithResourceModel(this.getAttributes());
- }
-
- @Override
- public void update() {
- super.update();
- this.setSuperPersistentType(this.buildSuperPersistentType());
- this.setDefaultAccess(this.buildDefaultAccess());
- this.mapping.update();
- this.updateAttributes();
- this.registerRootStructureNode();
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public String getSimpleName(){
- return ClassName.getSimpleName(this.name);
- }
-
- protected void setName(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
-
- // ********** 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.resolveSuperPersistentType(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 <em>its</em> super type.
- * <p>
- * The <code>visited</code> collection is used to detect a cycle in the
- * <em>resource</em> type inheritance hierarchy and prevent the resulting
- * stack overflow. Any cycles in the <em>context</em> type inheritance
- * hierarchy are handled in {@link #buildSuperPersistentType()}.
- */
- protected PersistentType resolveSuperPersistentType(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.resolvePersistentType(typeName);
- return (spt != null) ? spt : this.resolveSuperPersistentType(resourceType.getSuperclassQualifiedName(), visited); // recurse
- }
-
- protected PersistentType resolvePersistentType(String typeName) {
- return this.getPersistenceUnit().getPersistentType(typeName);
- }
-
-
- // ********** access **********
-
- public AccessType getAccess() {
- return (this.specifiedAccess != null) ? this.specifiedAccess : this.defaultAccess;
- }
-
- public AccessType getSpecifiedAccess() {
- return this.specifiedAccess;
- }
-
- protected void setSpecifiedAccess_(AccessType access) {
- AccessType old = this.specifiedAccess;
- this.specifiedAccess = access;
- this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, access);
- }
-
- /**
- * Build an access type based on annotations from the resource model.
- * (This is JPA platform-dependent.)
- */
- protected abstract AccessType buildSpecifiedAccess();
-
- 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);
- }
-
- /**
- * 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 {@link AccessType#FIELD FIELD} if all else fails.
- * </ul>
- */
- protected AccessType buildDefaultAccess() {
- AccessType accessType = AccessType.fromJavaResourceModel(JavaResourcePersistentType.Tools.buildAccess(this.resourcePersistentType));
- 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;
- }
-
-
- // ********** mapping **********
-
- public JavaTypeMapping getMapping() {
- return this.mapping;
- }
-
- public String getMappingKey() {
- return this.mapping.getKey();
- }
-
- public void setMappingKey(String key) {
- if (this.valuesAreDifferent(key, this.getMappingKey())) {
- this.setMapping(this.buildMapping(key));
- }
- }
-
- protected JavaTypeMapping buildMapping(String key) {
- for (JavaTypeMappingDefinition definition : this.getMappingDefinitions()) {
- if (Tools.valuesAreEqual(definition.getKey(), key)) {
- Annotation annotation = this.resourcePersistentType.setPrimaryAnnotation(definition.getAnnotationName(), definition.getSupportingAnnotationNames());
- return definition.buildMapping(this, annotation, this.getJpaFactory());
- }
- }
- this.resourcePersistentType.setPrimaryAnnotation(null, EmptyIterable.<String>instance());
- return this.buildNullMapping();
- }
-
- /**
- * Clients do not set the mapping directly.
- * @see #setMappingKey(String)
- */
- protected void setMapping(JavaTypeMapping mapping) {
- JavaTypeMapping old = this.mapping;
- this.mapping = mapping;
- this.firePropertyChanged(MAPPING_PROPERTY, old, mapping);
- }
-
- protected JavaTypeMapping buildMapping() {
- for (JavaTypeMappingDefinition definition : this.getMappingDefinitions()) {
- Annotation annotation = this.resourcePersistentType.getAnnotation(definition.getAnnotationName());
- if (annotation != null) {
- return definition.buildMapping(this, annotation, this.getJpaFactory());
- }
- }
- return this.buildNullMapping();
- }
-
- protected void syncMapping() {
- JavaTypeMappingDefinition definition = null;
- Annotation annotation = null;
- for (Iterator<JavaTypeMappingDefinition> stream = this.mappingDefinitions(); stream.hasNext(); ) {
- definition = stream.next();
- annotation = this.resourcePersistentType.getAnnotation(definition.getAnnotationName());
- if (annotation != null) {
- break;
- }
- }
- // 'annotation' can still be null when we get here
- if (this.mapping.getMappingAnnotation() == annotation) {
- this.mapping.synchronizeWithResourceModel();
- } else {
- this.setMapping(this.buildMapping(annotation, definition));
- }
- }
-
- protected JavaTypeMapping buildMapping(Annotation annotation, JavaTypeMappingDefinition definition) {
- return (annotation != null) ?
- definition.buildMapping(this, annotation, this.getJpaFactory()) :
- this.buildNullMapping();
- }
-
- protected Iterator<JavaTypeMappingDefinition> mappingDefinitions() {
- return this.getMappingDefinitions().iterator();
- }
-
- protected Iterable<JavaTypeMappingDefinition> getMappingDefinitions() {
- return this.getJpaPlatform().getJavaTypeMappingDefinitions();
- }
-
- protected JavaTypeMapping buildNullMapping() {
- return this.getJpaFactory().buildJavaNullTypeMapping(this);
- }
-
- public boolean isMapped() {
- return this.mapping.isMapped();
- }
-
-
- // ********** attributes **********
-
- public ListIterator<JavaPersistentAttribute> attributes() {
- return this.getAttributes().iterator();
- }
-
- protected ListIterable<JavaPersistentAttribute> getAttributes() {
- return new LiveCloneListIterable<JavaPersistentAttribute>(this.attributes);
- }
-
- public int attributesSize() {
- return this.attributes.size();
- }
-
- public Iterator<String> attributeNames() {
- return this.getAttributeNames().iterator();
- }
-
- protected Iterable<String> getAttributeNames() {
- return this.convertToNames(this.getAttributes());
- }
-
- public JavaPersistentAttribute getAttributeNamed(String attributeName) {
- Iterator<JavaPersistentAttribute> stream = this.getAttributesNamed(attributeName).iterator();
- return stream.hasNext() ? stream.next() : null;
- }
-
- public JavaPersistentAttribute getAttributeFor(JavaResourcePersistentAttribute javaResourceAttribute) {
- for (JavaPersistentAttribute javaAttribute : this.getAttributes()) {
- if (javaAttribute.getResourcePersistentAttribute() == javaResourceAttribute) {
- return javaAttribute;
- }
- }
- return null;
- }
-
- public Iterator<ReadOnlyPersistentAttribute> allAttributes() {
- return this.getAllAttributes().iterator();
- }
-
- protected Iterable<ReadOnlyPersistentAttribute> getAllAttributes() {
- return new CompositeIterable<ReadOnlyPersistentAttribute>(
- new TransformationIterable<PersistentType, Iterable<ReadOnlyPersistentAttribute>>(this.getInheritanceHierarchy()) {
- @Override
- protected Iterable<ReadOnlyPersistentAttribute> transform(PersistentType pt) {
- return new SnapshotCloneIterable<ReadOnlyPersistentAttribute>(pt.attributes());
- }
- }
- );
- }
-
- public Iterator<String> allAttributeNames() {
- return this.getAllAttributeNames().iterator();
- }
-
- protected Iterable<String> getAllAttributeNames() {
- return this.convertToNames(this.getAllAttributes());
- }
-
- protected Iterable<JavaPersistentAttribute> getAttributesNamed(final String attributeName) {
- return new FilteringIterable<JavaPersistentAttribute>(this.getAttributes()) {
- @Override
- protected boolean accept(JavaPersistentAttribute attribute) {
- return Tools.valuesAreEqual(attributeName, attribute.getName());
- }
- };
- }
-
- public ReadOnlyPersistentAttribute resolveAttribute(String attributeName) {
- Iterator<JavaPersistentAttribute> stream = this.getAttributesNamed(attributeName).iterator();
- if (stream.hasNext()) {
- JavaPersistentAttribute attribute = stream.next();
- // return null if we have more than one
- return stream.hasNext() ? null : attribute;
- }
- // recurse
- return (this.superPersistentType == null) ? null : this.superPersistentType.resolveAttribute(attributeName);
- }
-
- protected Iterable<String> convertToNames(Iterable<? extends ReadOnlyPersistentAttribute> attrs) {
- return new TransformationIterable<ReadOnlyPersistentAttribute, String>(attrs) {
- @Override
- protected String transform(ReadOnlyPersistentAttribute attribute) {
- return attribute.getName();
- }
- };
- }
-
- protected Iterator<JavaResourcePersistentAttribute> resourceAttributes() {
- return (this.getAccess() == AccessType.PROPERTY) ?
- this.resourcePersistentType.persistableProperties() :
- this.resourcePersistentType.persistableFields();
- }
-
- protected Iterable<JavaResourcePersistentAttribute> getResourceAttributes() {
- return CollectionTools.iterable(this.resourceAttributes());
- }
-
- protected JavaPersistentAttribute buildAttribute(JavaResourcePersistentAttribute resourceAttribute) {
- return this.getJpaFactory().buildJavaPersistentAttribute(this, resourceAttribute);
- }
-
- public boolean hasAnyAnnotatedAttributes() {
- return this.resourcePersistentType.hasAnyAnnotatedAttributes();
- }
-
- /**
- * The attributes are synchronized during the <em>update</em> because
- * the list of resource attributes is determined by the access type
- * which can be controlled in a number of different places....
- */
- protected void updateAttributes() {
- ContextContainerTools.update(this.attributeContainerAdapter);
- }
-
- protected void moveAttribute(int index, JavaPersistentAttribute attribute) {
- this.moveItemInList(index, attribute, this.attributes, ATTRIBUTES_LIST);
- }
-
- protected void addAttribute(int index, JavaResourcePersistentAttribute resourceAttribute) {
- this.addItemToList(index, this.buildAttribute(resourceAttribute), this.attributes, ATTRIBUTES_LIST);
- }
-
- protected void removeAttribute(JavaPersistentAttribute attribute) {
- this.removeItemFromList(attribute, this.attributes, ATTRIBUTES_LIST);
- }
-
- /**
- * attribute container adapter
- */
- protected class AttributeContainerAdapter
- implements ContextContainerTools.Adapter<JavaPersistentAttribute, JavaResourcePersistentAttribute>
- {
- public Iterable<JavaPersistentAttribute> getContextElements() {
- return AbstractJavaPersistentType.this.getAttributes();
- }
- public Iterable<JavaResourcePersistentAttribute> getResourceElements() {
- return AbstractJavaPersistentType.this.getResourceAttributes();
- }
- public JavaResourcePersistentAttribute getResourceElement(JavaPersistentAttribute contextElement) {
- return contextElement.getResourcePersistentAttribute();
- }
- public void moveContextElement(int index, JavaPersistentAttribute element) {
- AbstractJavaPersistentType.this.moveAttribute(index, element);
- }
- public void addContextElement(int index, JavaResourcePersistentAttribute resourceElement) {
- AbstractJavaPersistentType.this.addAttribute(index, resourceElement);
- }
- public void removeContextElement(JavaPersistentAttribute element) {
- AbstractJavaPersistentType.this.removeAttribute(element);
- }
- }
-
-
- // ********** inheritance **********
-
- public Iterator<PersistentType> inheritanceHierarchy() {
- return this.getInheritanceHierarchy().iterator();
- }
-
- public Iterable<PersistentType> getInheritanceHierarchy() {
- return this.getInheritanceHierarchyOf(this);
- }
-
- public Iterator<PersistentType> ancestors() {
- return this.getAncestors().iterator();
- }
-
- public Iterable<PersistentType> getAncestors() {
- return this.getInheritanceHierarchyOf(this.superPersistentType);
- }
-
- protected Iterable<PersistentType> getInheritanceHierarchyOf(PersistentType start) {
- // using a chain iterable to traverse up the inheritance tree
- return new ChainIterable<PersistentType>(start) {
- @Override
- protected PersistentType nextLink(PersistentType persistentType) {
- return persistentType.getSuperPersistentType();
- }
- };
- }
-
-
- // ********** 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.resourcePersistentType.getTextRange(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);
- }
-
- public TextRange getSelectionTextRange() {
- return this.getSelectionTextRange(this.buildASTRoot());
- }
-
- protected TextRange getSelectionTextRange(CompilationUnit astRoot) {
- return this.resourcePersistentType.getNameTextRange(astRoot);
- }
-
- public void dispose() {
- this.unregisterRootStructureNode();
- }
-
- protected void registerRootStructureNode() {
- JpaFile jpaFile = this.getJpaFile();
- // the JPA file can be null if the resource type is "external"
- if (jpaFile != null) {
- jpaFile.addRootStructureNode(this.name, this);
- }
- }
-
- protected void unregisterRootStructureNode() {
- JpaFile jpaFile = this.getJpaFile();
- // the JPA file can be null if the .java file was deleted
- // or the resource type is "external"
- if (jpaFile != null) {
- jpaFile.removeRootStructureNode(this.name, 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) {
- 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) {
- JptJpaCorePlugin.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) {
- JptJpaCorePlugin.log(t);
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getSelectionTextRange(astRoot);
- }
-
- public TextRange getValidationTextRange() {
- return this.getSelectionTextRange();
- }
-
-
- // ********** misc **********
-
- @Override
- public PersistentType.Owner getParent() {
- return (PersistentType.Owner) super.getParent();
- }
-
- @Override
- public IResource getResource() {
- return this.resourcePersistentType.getFile();
- }
-
- public JavaResourcePersistentType getResourcePersistentType() {
- return this.resourcePersistentType;
- }
-
- public AccessType getOwnerOverrideAccess() {
- return this.getParent().getOverridePersistentTypeAccess();
- }
-
- public AccessType getOwnerDefaultAccess() {
- return this.getParent().getDefaultPersistentTypeAccess();
- }
-
- protected CompilationUnit buildASTRoot() {
- return this.resourcePersistentType.getJavaResourceCompilationUnit().buildASTRoot();
- }
-
- protected JpaFile getJpaFile() {
- return this.getJpaFile(this.resourcePersistentType.getFile());
- }
-
- public boolean isFor(String typeName) {
- return Tools.valuesAreEqual(typeName, this.getName());
- }
-
- public boolean isIn(IPackageFragment packageFragment) {
- return Tools.valuesAreEqual(packageFragment.getElementName(), this.getPackageName());
- }
-
- protected String getPackageName() {
- return this.getResourcePersistentType().getPackageName();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
deleted file mode 100644
index 47fbf2d288..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaQuery.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.Query;
-import org.eclipse.jpt.jpa.core.context.QueryHint;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
-import org.eclipse.jpt.jpa.core.context.java.JavaQueryHint;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.QueryAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.QueryHintAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java query
- */
-public abstract class AbstractJavaQuery<A extends QueryAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaQuery
-{
- protected final A queryAnnotation;
-
- protected String name;
-
- protected String query;
-
- protected final Vector<JavaQueryHint> hints = new Vector<JavaQueryHint>();
- protected final HintContainerAdapter hintContainerAdapter = new HintContainerAdapter();
-
-
- protected AbstractJavaQuery(JavaJpaContextNode parent, A queryAnnotation) {
- super(parent);
- this.queryAnnotation = queryAnnotation;
- this.name = queryAnnotation.getName();
- this.query = queryAnnotation.getQuery();
- this.initializeHints();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName_(this.queryAnnotation.getName());
- this.setQuery_(this.queryAnnotation.getQuery());
- this.syncHints();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getHints());
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.queryAnnotation.setName(name);
- this.setName_(name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
-
- // ********** query **********
-
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- this.queryAnnotation.setQuery(query);
- this.setQuery_(query);
- }
-
- protected void setQuery_(String query) {
- String old = this.query;
- this.query = query;
- this.firePropertyChanged(QUERY_PROPERTY, old, query);
- }
-
-
- // ********** hints **********
-
- public ListIterable<JavaQueryHint> getHints() {
- return new LiveCloneListIterable<JavaQueryHint>(this.hints);
- }
-
- public int getHintsSize() {
- return this.hints.size();
- }
-
- public JavaQueryHint addHint() {
- return this.addHint(this.hints.size());
- }
-
- public JavaQueryHint addHint(int index) {
- QueryHintAnnotation annotation = this.queryAnnotation.addHint(index);
- return this.addHint_(index, annotation);
- }
-
- public void removeHint(QueryHint hint) {
- this.removeHint(this.hints.indexOf(hint));
- }
-
- public void removeHint(int index) {
- this.queryAnnotation.removeHint(index);
- this.removeHint_(index);
- }
-
- protected void removeHint_(int index) {
- this.removeItemFromList(index, this.hints, HINTS_LIST);
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- this.queryAnnotation.moveHint(targetIndex, sourceIndex);
- this.moveItemInList(targetIndex, sourceIndex, this.hints, HINTS_LIST);
- }
-
- protected void initializeHints() {
- for (Iterator<QueryHintAnnotation> stream = this.queryAnnotation.hints(); stream.hasNext(); ) {
- this.hints.add(this.buildHint(stream.next()));
- }
- }
-
- protected JavaQueryHint buildHint(QueryHintAnnotation hintAnnotation) {
- return this.getJpaFactory().buildJavaQueryHint(this, hintAnnotation);
- }
-
- protected void syncHints() {
- ContextContainerTools.synchronizeWithResourceModel(this.hintContainerAdapter);
- }
-
- protected Iterable<QueryHintAnnotation> getHintAnnotations() {
- return CollectionTools.iterable(this.queryAnnotation.hints());
- }
-
- protected void moveHint_(int index, JavaQueryHint hint) {
- this.moveItemInList(index, hint, this.hints, HINTS_LIST);
- }
-
- protected JavaQueryHint addHint_(int index, QueryHintAnnotation hintAnnotation) {
- JavaQueryHint hint = this.buildHint(hintAnnotation);
- this.addItemToList(index, hint, this.hints, HINTS_LIST);
- return hint;
- }
-
- protected void removeHint_(JavaQueryHint hint) {
- this.removeHint_(this.hints.indexOf(hint));
- }
-
- /**
- * hint container adapter
- */
- protected class HintContainerAdapter
- implements ContextContainerTools.Adapter<JavaQueryHint, QueryHintAnnotation>
- {
- public Iterable<JavaQueryHint> getContextElements() {
- return AbstractJavaQuery.this.getHints();
- }
- public Iterable<QueryHintAnnotation> getResourceElements() {
- return AbstractJavaQuery.this.getHintAnnotations();
- }
- public QueryHintAnnotation getResourceElement(JavaQueryHint contextElement) {
- return contextElement.getQueryHintAnnotation();
- }
- public void moveContextElement(int index, JavaQueryHint element) {
- AbstractJavaQuery.this.moveHint_(index, element);
- }
- public void addContextElement(int index, QueryHintAnnotation resourceElement) {
- AbstractJavaQuery.this.addHint_(index, resourceElement);
- }
- public void removeContextElement(JavaQueryHint element) {
- AbstractJavaQuery.this.removeHint_(element);
- }
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateName(messages, astRoot);
- this.validateQuery(messages, reporter, astRoot);
- }
-
- protected void validateName(List<IMessage> messages, CompilationUnit astRoot) {
- if (StringTools.stringIsEmpty(this.name)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_NAME_UNDEFINED,
- EMPTY_STRING_ARRAY,
- this,
- this.getNameTextRange(astRoot)
- )
- );
- }
- }
-
- protected void validateQuery(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (StringTools.stringIsEmpty(this.query)){
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_STATEMENT_UNDEFINED,
- new String[] {this.name},
- this,
- this.getNameTextRange(astRoot)
- )
- );
- } else {
- this.validateQuery_(messages, reporter, astRoot);
- }
- }
-
- protected abstract void validateQuery_(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot);
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.queryAnnotation.getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.queryAnnotation.getNameTextRange(astRoot), astRoot);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- public A getQueryAnnotation() {
- return this.queryAnnotation;
- }
-
- public boolean overrides(Query other) {
- return MappingTools.nodeOverrides(this, other, PRECEDENCE_TYPE_LIST);
- }
-
- public boolean duplicates(Query other) {
- return MappingTools.nodesAreDuplicates(this, other);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaReadOnlyUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaReadOnlyUniqueConstraint.java
deleted file mode 100644
index 0760a1be4c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaReadOnlyUniqueConstraint.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyUniqueConstraint;
-
-public abstract class AbstractJavaReadOnlyUniqueConstraint
- extends AbstractJavaJpaContextNode
- implements JavaReadOnlyUniqueConstraint
-{
- protected final Vector<String> columnNames = new Vector<String>();
-
-
- public AbstractJavaReadOnlyUniqueConstraint(JavaJpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** column names **********
-
- public Iterable<String> getColumnNames() {
- return new LiveCloneIterable<String>(this.columnNames);
- }
-
- public int getColumnNamesSize() {
- return this.columnNames.size();
- }
-
- public String getColumnName(int index) {
- return this.columnNames.get(index);
- }
-
- protected void syncColumnNames() {
- this.synchronizeList(this.getResourceColumnNames(), this.columnNames, COLUMN_NAMES_LIST);
- }
-
- protected abstract Iterable<String> getResourceColumnNames();
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.columnNames);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java
deleted file mode 100644
index 77afa0ebf6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaRelationshipMapping.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaCascade;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaCascade;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.core.resource.java.RelationshipMappingAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java relationship mapping (1:1, 1:m, m:1, m:m)
- */
-public abstract class AbstractJavaRelationshipMapping<A extends RelationshipMappingAnnotation>
- extends AbstractJavaAttributeMapping<A>
- implements JavaRelationshipMapping
-{
- protected String specifiedTargetEntity;
- protected String defaultTargetEntity;
- protected String fullyQualifiedTargetEntity;
-
- protected final JavaMappingRelationship relationship;
-
- protected final JavaCascade cascade;
-
- protected FetchType specifiedFetch;
- protected FetchType defaultFetch;
-
-
- protected AbstractJavaRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.specifiedTargetEntity = this.buildSpecifiedTargetEntity();
- this.relationship = this.buildRelationship();
- this.cascade = this.buildCascade();
- this.specifiedFetch = this.buildSpecifiedFetch();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedTargetEntity_(this.buildSpecifiedTargetEntity());
- this.relationship.synchronizeWithResourceModel();
- this.cascade.synchronizeWithResourceModel();
- this.setSpecifiedFetch_(this.buildSpecifiedFetch());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultTargetEntity(this.buildDefaultTargetEntity());
- this.setFullyQualifiedTargetEntity(this.buildFullyQualifiedTargetEntity());
- this.relationship.update();
- this.cascade.update();
- this.setDefaultFetch(this.buildDefaultFetch());
- }
-
-
- // ********** target entity **********
-
- public String getTargetEntity() {
- return (this.specifiedTargetEntity != null) ? this.specifiedTargetEntity : this.defaultTargetEntity;
- }
-
- public String getSpecifiedTargetEntity() {
- return this.specifiedTargetEntity;
- }
-
- public void setSpecifiedTargetEntity(String entity) {
- if (this.valuesAreDifferent(entity, this.specifiedTargetEntity)) {
- this.getAnnotationForUpdate().setTargetEntity(entity);
- this.setSpecifiedTargetEntity_(entity);
- }
- }
-
- protected void setSpecifiedTargetEntity_(String entity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = entity;
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- protected String buildSpecifiedTargetEntity() {
- A annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getTargetEntity();
- }
-
- public String getDefaultTargetEntity() {
- return this.defaultTargetEntity;
- }
-
- protected void setDefaultTargetEntity(String entity) {
- String old = this.defaultTargetEntity;
- this.defaultTargetEntity = entity;
- this.firePropertyChanged(DEFAULT_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- protected abstract String buildDefaultTargetEntity();
-
- public String getFullyQualifiedTargetEntity() {
- return this.fullyQualifiedTargetEntity;
- }
-
- protected void setFullyQualifiedTargetEntity(String entity) {
- String old = this.fullyQualifiedTargetEntity;
- this.fullyQualifiedTargetEntity = entity;
- this.firePropertyChanged(FULLY_QUALIFIED_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- protected String buildFullyQualifiedTargetEntity() {
- return (this.specifiedTargetEntity == null) ?
- this.defaultTargetEntity :
- this.getMappingAnnotation().getFullyQualifiedTargetEntityClassName();
- }
-
- public Entity getResolvedTargetEntity() {
- return (this.fullyQualifiedTargetEntity == null) ? null : this.getPersistenceUnit().getEntity(this.fullyQualifiedTargetEntity);
- }
-
- // sub-classes like this to be public
- public PersistentType getResolvedTargetType() {
- return (this.fullyQualifiedTargetEntity == null) ? null : this.getPersistenceUnit().getPersistentType(this.fullyQualifiedTargetEntity);
- }
-
- public char getTargetEntityEnclosingTypeSeparator() {
- return '.';
- }
-
-
- // ********** relationship reference **********
-
- public JavaMappingRelationship getRelationship() {
- return this.relationship;
- }
-
- protected abstract JavaMappingRelationship buildRelationship();
-
-
- // ********** cascade **********
-
- public JavaCascade getCascade() {
- return this.cascade;
- }
-
- protected JavaCascade buildCascade() {
- // NB: we don't use the platform
- return new GenericJavaCascade(this);
- }
-
-
- // ********** fetch **********
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.defaultFetch;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- if (this.valuesAreDifferent(fetch, this.specifiedFetch)) {
- this.getAnnotationForUpdate().setFetch(FetchType.toJavaResourceModel(fetch));
- this.setSpecifiedFetch_(fetch);
- }
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType buildSpecifiedFetch() {
- A annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : FetchType.fromJavaResourceModel(annotation.getFetch());
- }
-
- public FetchType getDefaultFetch() {
- return this.defaultFetch;
- }
-
- protected void setDefaultFetch(FetchType fetch) {
- FetchType old = this.defaultFetch;
- this.defaultFetch = fetch;
- this.firePropertyChanged(DEFAULT_FETCH_PROPERTY, old, fetch);
- }
-
- protected abstract FetchType buildDefaultFetch();
-
-
- // ********** misc **********
-
- @Override
- public boolean isRelationshipOwner() {
- return this.relationship.isOwner();
- }
-
- @Override
- public boolean isOwnedBy(AttributeMapping mapping) {
- return mapping.isRelationshipOwner() &&
- this.relationship.isOwnedBy((RelationshipMapping) mapping);
- }
-
- public RelationshipMapping getRelationshipOwner() {
- Entity entity = this.getResolvedTargetEntity();
- if (entity == null) {
- return null;
- }
- for (ReadOnlyPersistentAttribute attribute : CollectionTools.iterable(entity.getPersistentType().allAttributes())) {
- AttributeMapping mapping = attribute.getMapping();
- if (this.isOwnedBy(mapping)) {
- return (RelationshipMapping) mapping;
- }
- }
- return null;
- }
-
- @Override
- public boolean isOverridableAssociationMapping() {
- return this.relationship.isOverridable();
- }
-
- public Iterator<String> allTargetEntityAttributeNames() {
- return new CompositeIterator<String>(this.allTargetEntityAttributeNamesLists());
- }
-
- protected Iterator<Iterator<String>> allTargetEntityAttributeNamesLists() {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEntityAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
- }
-
- protected Iterator<AttributeMapping> allTargetEntityAttributeMappings() {
- Entity entity = this.getResolvedTargetEntity();
- return (entity != null) ? entity.allAttributeMappings() : EmptyIterator.<AttributeMapping> instance();
- }
-
- protected String getTargetEntityIdAttributeName() {
- PersistentAttribute attribute = this.getTargetEntityIdAttribute();
- return (attribute == null) ? null : attribute.getName();
- }
-
- protected PersistentAttribute getTargetEntityIdAttribute() {
- Entity entity = this.getResolvedTargetEntity();
- return (entity == null) ? null : entity.getIdAttribute();
- }
-
-
- // ********** 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.relationship.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return null;
- }
-
-
- // ********** metamodel **********
-
- @Override
- public String getMetamodelTypeName() {
- return (this.fullyQualifiedTargetEntity != null) ? this.fullyQualifiedTargetEntity : MetamodelField.DEFAULT_TYPE_NAME;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateTargetEntity(messages, astRoot);
- this.relationship.validate(messages, reporter, astRoot);
- }
-
- protected void validateTargetEntity(List<IMessage> messages, CompilationUnit astRoot) {
- if (this.getTargetEntity() == null) {
- String msg = this.getPersistentAttribute().isVirtual() ?
- JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED :
- JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED;
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msg,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- return;
- }
- if (this.getResolvedTargetEntity() == null) {
- if (this.getPersistentAttribute().isVirtual()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY,
- new String[] {this.getName(), this.getTargetEntity()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- } else {
- 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.getValidationTextRange(this.getAnnotationTargetEntityTextRange(astRoot), astRoot);
- }
-
- protected TextRange getAnnotationTargetEntityTextRange(CompilationUnit astRoot) {
- A annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getTargetEntityTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
deleted file mode 100644
index 0400ace268..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSequenceGenerator.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaSequenceGenerator;
-import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.jpa.db.Schema;
-
-/**
- * Java sequence generator
- */
-public abstract class AbstractJavaSequenceGenerator<A extends SequenceGeneratorAnnotation>
- extends AbstractJavaGenerator<A>
- implements JavaSequenceGenerator
-{
- protected String specifiedSequenceName;
- protected String defaultSequenceName;
-
-
- protected AbstractJavaSequenceGenerator(JavaJpaContextNode parent, A generatorAnnotation) {
- super(parent, generatorAnnotation);
- this.specifiedSequenceName = generatorAnnotation.getSequenceName();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedSequenceName_(this.generatorAnnotation.getSequenceName());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultSequenceName(this.buildDefaultSequenceName());
- }
-
-
- // ********** initial value **********
-
- @Override
- protected int buildDefaultInitialValue() {
- return 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 name) {
- this.generatorAnnotation.setSequenceName(name);
- this.setSpecifiedSequenceName_(name);
- }
-
- protected void setSpecifiedSequenceName_(String name) {
- String old = this.specifiedSequenceName;
- this.specifiedSequenceName = name;
- this.firePropertyChanged(SPECIFIED_SEQUENCE_NAME_PROPERTY, old, name);
- }
-
- public String getDefaultSequenceName() {
- return this.defaultSequenceName;
- }
-
- protected void setDefaultSequenceName(String name) {
- String old = this.defaultSequenceName;
- this.defaultSequenceName = name;
- this.firePropertyChanged(DEFAULT_SEQUENCE_NAME_PROPERTY, old, name);
- }
-
- protected String buildDefaultSequenceName() {
- return null; // TODO the default sequence name is determined by the runtime provider...
- }
-
-
- // ********** Java completion proposals **********
-
- /**
- * called if the database is connected:
- * sequenceName
- */
- @Override
- protected 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.generatorAnnotation.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();
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java
deleted file mode 100644
index 38ee6dc2c2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaSingleRelationshipMapping.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.java.NullJavaDerivedIdentity2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaDerivedIdentity2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaSingleRelationshipMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.java.SingleRelationshipMappingAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java single relationship mapping (1:1, m:1)
- */
-public abstract class AbstractJavaSingleRelationshipMapping<A extends SingleRelationshipMappingAnnotation>
- extends AbstractJavaRelationshipMapping<A>
- implements JavaSingleRelationshipMapping2_0
-{
- protected Boolean specifiedOptional;
- protected boolean defaultOptional;
-
- protected final JavaDerivedIdentity2_0 derivedIdentity;
-
-
- protected AbstractJavaSingleRelationshipMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.specifiedOptional = this.buildSpecifiedOptional();
- this.derivedIdentity = this.buildDerivedIdentity();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedOptional_(this.buildSpecifiedOptional());
- this.derivedIdentity.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultOptional(this.buildDefaultOptional());
- this.derivedIdentity.update();
- }
-
-
- // ********** optional **********
-
- public boolean isOptional() {
- return (this.specifiedOptional != null) ? this.specifiedOptional.booleanValue() : this.defaultOptional;
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean optional) {
- if (this.valuesAreDifferent(optional, this.specifiedOptional)) {
- this.getAnnotationForUpdate().setOptional(optional);
- this.setSpecifiedOptional_(optional);
- }
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected Boolean buildSpecifiedOptional() {
- A annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getOptional();
- }
-
- public boolean isDefaultOptional() {
- return this.defaultOptional;
- }
-
- protected void setDefaultOptional(boolean optional) {
- boolean old = this.defaultOptional;
- this.defaultOptional = optional;
- this.firePropertyChanged(DEFAULT_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected boolean buildDefaultOptional() {
- return DEFAULT_OPTIONAL;
- }
-
-
- // ********** derived identity **********
-
- public JavaDerivedIdentity2_0 getDerivedIdentity() {
- return this.derivedIdentity;
- }
-
- protected JavaDerivedIdentity2_0 buildDerivedIdentity() {
- return this.isJpa2_0Compatible() ?
- this.getJpaFactory2_0().buildJavaDerivedIdentity(this) :
- new NullJavaDerivedIdentity2_0(this);
- }
-
-
- // ********** misc **********
-
- @Override
- protected FetchType buildDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
- @Override
- protected String buildDefaultTargetEntity() {
- return this.getPersistentAttribute().getSingleReferenceTargetTypeName();
- }
-
-
- // ********** 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.derivedIdentity.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.derivedIdentity.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java
deleted file mode 100644
index ced9446238..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTable.java
+++ /dev/null
@@ -1,581 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyUniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaUniqueConstraint;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.java.BaseTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.UniqueConstraintAnnotation;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Database;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java table, secondary table, join table, or collection table
- * <p>
- * <strong>NB:</strong> any subclass that directly holds its table
- * annotation must:<ul>
- * <li>call the "super" constructor that takes a table annotation
- * {@link #AbstractJavaTable(JavaJpaContextNode, org.eclipse.jpt.jpa.core.context.Table.Owner, BaseTableAnnotation)}
- * <li>override {@link #setTableAnnotation(BaseTableAnnotation)} to set the table
- * annotation so it is in place before the table's state
- * (e.g. {@link #specifiedName}) is initialized
- * </ul>
- */
-public abstract class AbstractJavaTable<A extends BaseTableAnnotation>
- extends AbstractJavaJpaContextNode
- implements JavaTable, UniqueConstraint.Owner
-{
- protected final Owner 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 UniqueConstraintContainerAdapter uniqueConstraintContainerAdapter = new UniqueConstraintContainerAdapter();
-
-
- protected AbstractJavaTable(JavaJpaContextNode parent, Owner owner) {
- this(parent, owner, null);
- }
-
- protected AbstractJavaTable(JavaJpaContextNode parent, Owner owner, A tableAnnotation) {
- super(parent);
- this.owner = owner;
- this.setTableAnnotation(tableAnnotation);
- this.specifiedName = this.buildSpecifiedName();
- this.specifiedSchema = this.buildSpecifiedSchema();
- this.specifiedCatalog = this.buildSpecifiedCatalog();
- this.initializeUniqueConstraints();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedName_(this.buildSpecifiedName());
- this.setSpecifiedSchema_(this.buildSpecifiedSchema());
- this.setSpecifiedCatalog_(this.buildSpecifiedCatalog());
- this.syncUniqueConstraints();
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultName(this.buildDefaultName());
- this.setDefaultSchema(this.buildDefaultSchema());
- this.setDefaultCatalog(this.buildDefaultCatalog());
- this.updateNodes(this.getUniqueConstraints());
- }
-
-
- // ********** table annotation **********
-
- /**
- * Return the Java table annotation. Do not return <code>null</code> if the
- * Java annotation does not exist; return a <em>null</em> table annotation
- * instead.
- */
- public abstract A getTableAnnotation();
-
- /**
- * see class comment... ({@link AbstractJavaTable})
- */
- protected void setTableAnnotation(A tableAnnotation) {
- if (tableAnnotation != null) {
- throw new IllegalArgumentException("this method must be overridden if the table annotation is not null: " + tableAnnotation); //$NON-NLS-1$
- }
- }
-
- protected void removeTableAnnotationIfUnset() {
- if (this.getTableAnnotation().isUnset()) {
- this.removeTableAnnotation();
- }
- }
-
- protected abstract void removeTableAnnotation();
-
- public boolean isSpecifiedInResource() {
- return this.getTableAnnotation().isSpecified();
- }
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- if (this.valuesAreDifferent(this.specifiedName, name)) {
- this.getTableAnnotation().setName(name);
- this.removeTableAnnotationIfUnset();
- this.setSpecifiedName_(name);
- }
- }
-
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- return this.getTableAnnotation().getName();
- }
-
- 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);
- }
-
- protected abstract String buildDefaultName();
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- if (this.valuesAreDifferent(this.specifiedSchema, schema)) {
- this.getTableAnnotation().setSchema(schema);
- this.removeTableAnnotationIfUnset();
- this.setSpecifiedSchema_(schema);
- }
- }
-
- protected void setSpecifiedSchema_(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- protected String buildSpecifiedSchema() {
- return this.getTableAnnotation().getSchema();
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- protected abstract String buildDefaultSchema();
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- if (this.valuesAreDifferent(this.specifiedCatalog, catalog)) {
- this.getTableAnnotation().setCatalog(catalog);
- this.removeTableAnnotationIfUnset();
- this.setSpecifiedCatalog_(catalog);
- }
- }
-
- protected void setSpecifiedCatalog_(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- protected String buildSpecifiedCatalog() {
- return this.getTableAnnotation().getCatalog();
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- protected abstract String buildDefaultCatalog();
-
-
- // ********** unique constraints **********
-
- public ListIterator<JavaUniqueConstraint> uniqueConstraints() {
- return this.getUniqueConstraints().iterator();
- }
-
- protected ListIterable<JavaUniqueConstraint> getUniqueConstraints() {
- return new LiveCloneListIterable<JavaUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public JavaUniqueConstraint getUniqueConstraint(int index) {
- return this.uniqueConstraints.get(index);
- }
-
- public JavaUniqueConstraint addUniqueConstraint() {
- return this.addUniqueConstraint(this.uniqueConstraints.size());
- }
-
- public JavaUniqueConstraint addUniqueConstraint(int index) {
- UniqueConstraintAnnotation annotation = this.getTableAnnotation().addUniqueConstraint(index);
- return this.addUniqueConstraint_(index, annotation);
- }
-
- public void removeUniqueConstraint(UniqueConstraint constraint) {
- this.removeUniqueConstraint(this.uniqueConstraints.indexOf(constraint));
- }
-
- public void removeUniqueConstraint(int index) {
- this.getTableAnnotation().removeUniqueConstraint(index);
- this.removeTableAnnotationIfUnset();
- this.removeUniqueConstraint_(index);
- }
-
- protected void removeUniqueConstraint_(int index) {
- this.removeItemFromList(index, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- public void moveUniqueConstraint(int targetIndex, int sourceIndex) {
- this.getTableAnnotation().moveUniqueConstraint(targetIndex, sourceIndex);
- this.moveItemInList(targetIndex, sourceIndex, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected void initializeUniqueConstraints() {
- for (Iterator<UniqueConstraintAnnotation> stream = this.getTableAnnotation().uniqueConstraints(); stream.hasNext(); ) {
- this.uniqueConstraints.add(this.buildUniqueConstraint(stream.next()));
- }
- }
-
- protected JavaUniqueConstraint buildUniqueConstraint(UniqueConstraintAnnotation constraintAnnotation) {
- return this.getJpaFactory().buildJavaUniqueConstraint(this, this, constraintAnnotation);
- }
-
- protected void syncUniqueConstraints() {
- ContextContainerTools.synchronizeWithResourceModel(this.uniqueConstraintContainerAdapter);
- }
-
- protected Iterable<UniqueConstraintAnnotation> getUniqueConstraintAnnotations() {
- return CollectionTools.iterable(this.getTableAnnotation().uniqueConstraints());
- }
-
- protected void moveUniqueConstraint_(int index, JavaUniqueConstraint constraint) {
- this.moveItemInList(index, constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected JavaUniqueConstraint addUniqueConstraint_(int index, UniqueConstraintAnnotation constraintAnnotation) {
- JavaUniqueConstraint constraint = this.buildUniqueConstraint(constraintAnnotation);
- this.addItemToList(index, constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- return constraint;
- }
-
- protected void removeUniqueConstraint_(JavaUniqueConstraint constraint) {
- this.removeUniqueConstraint_(this.uniqueConstraints.indexOf(constraint));
- }
-
- /**
- * unique constraint container adapter
- */
- protected class UniqueConstraintContainerAdapter
- implements ContextContainerTools.Adapter<JavaUniqueConstraint, UniqueConstraintAnnotation>
- {
- public Iterable<JavaUniqueConstraint> getContextElements() {
- return AbstractJavaTable.this.getUniqueConstraints();
- }
- public Iterable<UniqueConstraintAnnotation> getResourceElements() {
- return AbstractJavaTable.this.getUniqueConstraintAnnotations();
- }
- public UniqueConstraintAnnotation getResourceElement(JavaUniqueConstraint contextElement) {
- return contextElement.getUniqueConstraintAnnotation();
- }
- public void moveContextElement(int index, JavaUniqueConstraint element) {
- AbstractJavaTable.this.moveUniqueConstraint_(index, element);
- }
- public void addContextElement(int index, UniqueConstraintAnnotation resourceElement) {
- AbstractJavaTable.this.addUniqueConstraint_(index, resourceElement);
- }
- public void removeContextElement(JavaUniqueConstraint element) {
- AbstractJavaTable.this.removeUniqueConstraint_(element);
- }
- }
-
-
- // ********** database stuff **********
-
- public org.eclipse.jpt.jpa.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.resolveDbCatalog(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.resolveDbCatalog(catalog);
- }
-
- public boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- public boolean schemaIsResolved() {
- 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 catalogIsResolved() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.resolveDbCatalog(catalog) != null);
- }
-
-
- // ********** UniqueConstraint.Owner implementation **********
-
- public Iterator<String> candidateUniqueConstraintColumnNames() {
- org.eclipse.jpt.jpa.db.Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers().iterator() : EmptyIterator.<String>instance();
- }
-
-
- // ********** 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
- protected 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 boolean nameTouches(int pos, CompilationUnit astRoot) {
- return this.getTableAnnotation().nameTouches(pos, astRoot);
- }
-
- 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 boolean schemaTouches(int pos, CompilationUnit astRoot) {
- return this.getTableAnnotation().schemaTouches(pos, astRoot);
- }
-
- 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 boolean catalogTouches(int pos, CompilationUnit astRoot) {
- return this.getTableAnnotation().catalogTouches(pos, astRoot);
- }
-
- 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();
- }
-
-
- // ********** validation **********
-
- @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.owner.buildTableValidator(this, buildTextRangeResolver(astRoot));
- }
-
- protected TableTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaTableTextRangeResolver(this, astRoot);
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getTableAnnotation().getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.getTableAnnotation().getNameTextRange(astRoot), astRoot);
- }
-
- public TextRange getSchemaTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.getTableAnnotation().getSchemaTextRange(astRoot), astRoot);
- }
-
- public TextRange getCatalogTextRange(CompilationUnit astRoot) {
- return this.getValidationTextRange(this.getTableAnnotation().getCatalogTextRange(astRoot), astRoot);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- protected void initializeFrom(ReadOnlyTable oldTable) {
- this.setSpecifiedName(oldTable.getSpecifiedName());
- this.setSpecifiedCatalog(oldTable.getSpecifiedCatalog());
- this.setSpecifiedSchema(oldTable.getSpecifiedSchema());
- for (ReadOnlyUniqueConstraint constraint : CollectionTools.iterable(oldTable.uniqueConstraints())) {
- this.addUniqueConstraint().initializeFrom(constraint);
- }
- }
-
- protected void initializeFromVirtual(ReadOnlyTable virtualTable) {
- this.setSpecifiedName(virtualTable.getName());
- // ignore other settings?
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.buildQualifiedName());
- }
-
- protected String buildQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
deleted file mode 100644
index 7aeada737c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaTypeMapping.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericTypeMappingValidator;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java type mapping
- */
-public abstract class AbstractJavaTypeMapping<A extends Annotation>
- extends AbstractJavaJpaContextNode
- implements JavaTypeMapping
-{
- // this can be null for a "null" type mapping
- protected final A mappingAnnotation;
-
-
- protected AbstractJavaTypeMapping(JavaPersistentType parent, A mappingAnnotation) {
- super(parent);
- this.mappingAnnotation = mappingAnnotation;
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaPersistentType getParent() {
- return (JavaPersistentType) super.getParent();
- }
-
- public JavaPersistentType getPersistentType() {
- return this.getParent();
- }
-
- public JavaResourcePersistentType getResourcePersistentType() {
- return this.getPersistentType().getResourcePersistentType();
- }
-
- public String getName() {
- return this.getPersistentType().getName();
- }
-
- public A getMappingAnnotation() {
- return this.mappingAnnotation;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getPersistentType().getName());
- }
-
-
- // ********** tables **********
-
- public String getPrimaryTableName() {
- return null;
- }
-
- public org.eclipse.jpt.jpa.db.Table getPrimaryDbTable() {
- return null;
- }
-
- public Schema getDbSchema() {
- return null;
- }
-
- public Iterator<ReadOnlyTable> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<ReadOnlyTable> allAssociatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<String> allAssociatedTableNames() {
- return EmptyIterator.instance();
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return null;
- }
-
-
- // ********** inheritance **********
-
- public TypeMapping getSuperTypeMapping() {
- PersistentType superPersistentType = this.getPersistentType().getSuperPersistentType();
- return (superPersistentType == null) ? null : superPersistentType.getMapping();
- }
-
- public Iterator<TypeMapping> inheritanceHierarchy() {
- return this.convertToMappings(this.getPersistentType().inheritanceHierarchy());
- }
-
- protected Iterable<TypeMapping> getInheritanceHierarchy() {
- return CollectionTools.iterable(this.inheritanceHierarchy());
- }
-
- /**
- * Return the type mapping's "persistence" ancestors,
- * <em>excluding</em> the type mapping itself.
- * The returned iterator will return elements infinitely if the hierarchy
- * has a loop.
- */
- protected Iterator<TypeMapping> ancestors() {
- return this.convertToMappings(this.getPersistentType().ancestors());
- }
-
- protected Iterable<TypeMapping> getAncestors() {
- return CollectionTools.iterable(this.ancestors());
- }
-
- protected Iterator<TypeMapping> convertToMappings(Iterator<PersistentType> types) {
- return new TransformationIterator<PersistentType, TypeMapping>(types) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
-
- // ********** attribute mappings **********
-
- public Iterator<JavaAttributeMapping> attributeMappings() {
- return new TransformationIterator<JavaPersistentAttribute, JavaAttributeMapping>(this.getPersistentType().attributes()) {
- @Override
- protected JavaAttributeMapping transform(JavaPersistentAttribute attribute) {
- return attribute.getMapping();
- }
- };
- }
-
- public Iterable<JavaAttributeMapping> getAttributeMappings(final String mappingKey) {
- return new FilteringIterable<JavaAttributeMapping>(CollectionTools.collection(this.attributeMappings())) {
- @Override
- protected boolean accept(JavaAttributeMapping o) {
- return Tools.valuesAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterator<AttributeMapping> allAttributeMappings() {
- return new CompositeIterator<AttributeMapping>(this.allAttributeMappingsLists());
- }
-
- protected Iterator<Iterator<AttributeMapping>> allAttributeMappingsLists() {
- return new TransformationIterator<TypeMapping, Iterator<AttributeMapping>>(this.nonNullInheritanceHierarchy(), TypeMappingTools.ATTRIBUTE_MAPPINGS_TRANSFORMER);
- }
-
- protected Iterator<TypeMapping> nonNullInheritanceHierarchy() {
- return new FilteringIterator<TypeMapping>(this.inheritanceHierarchy(), NotNullFilter.<TypeMapping>instance());
- }
-
- public Iterable<AttributeMapping> getAllAttributeMappings(final String mappingKey) {
- return new FilteringIterable<AttributeMapping>(CollectionTools.collection(this.allAttributeMappings())) {
- @Override
- protected boolean accept(AttributeMapping o) {
- return Tools.valuesAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public boolean attributeMappingKeyAllowed(String attributeMappingKey) {
- return true;
- }
-
-
- // ********** attribute overrides **********
-
- public Iterator<String> overridableAttributeNames() {
- return new CompositeIterator<String>(this.overridableAttributeNamesLists());
- }
-
- protected Iterator<Iterator<String>> overridableAttributeNamesLists() {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings(), AttributeMappingTools.ALL_OVERRIDABLE_ATTRIBUTE_MAPPING_NAMES_TRANSFORMER);
- }
-
- public Iterator<String> allOverridableAttributeNames() {
- return new CompositeIterator<String>(this.allOverridableAttributeNamesLists());
- }
-
- protected Iterator<Iterator<String>> allOverridableAttributeNamesLists() {
- return new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy(), TypeMappingTools.OVERRIDABLE_ATTRIBUTE_NAMES_TRANSFORMER);
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.attributeMappings())) {
- Column column = attributeMapping.resolveOverriddenColumn(attributeName);
- if (column != null) {
- return column;
- }
- }
- return null;
- }
-
-
- // ********** association overrides **********
-
- public Iterator<String> overridableAssociationNames() {
- return new CompositeIterator<String>(this.overridableAssociationNamesLists());
- }
-
- protected Iterator<Iterator<String>> overridableAssociationNamesLists() {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings(), AttributeMappingTools.ALL_OVERRIDABLE_ASSOCIATION_MAPPING_NAMES_TRANSFORMER);
- }
-
- public Iterator<String> allOverridableAssociationNames() {
- return new CompositeIterator<String>(this.allOverridableAssociationNamesLists());
- }
-
- protected Iterator<Iterator<String>> allOverridableAssociationNamesLists() {
- return new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy(), TypeMappingTools.OVERRIDABLE_ASSOCIATION_NAMES_TRANSFORMER);
- }
-
- public Relationship resolveOverriddenRelationship(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.attributeMappings())) {
- Relationship relationship = attributeMapping.resolveOverriddenRelationship(attributeName);
- if (relationship != null) {
- return relationship;
- }
- }
- return null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.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.getResourcePersistentType(), buildTextRangeResolver(astRoot));
- }
-
- protected TypeMappingTextRangeResolver buildTextRangeResolver(CompilationUnit astRoot) {
- return new JavaTypeMappingTextRangeResolver(this, astRoot);
- }
-
- public boolean validatesAgainstDatabase() {
- return this.getPersistenceUnit().validatesAgainstDatabase();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.mappingAnnotation.getTextRange(astRoot);
- return (textRange != null) ? textRange : this.getPersistentType().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java
deleted file mode 100644
index 0a74da1dde..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.Association;
-import org.eclipse.jpt.common.utility.internal.SimpleAssociation;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Converter;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaConverter;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaTemporalConverter;
-import org.eclipse.jpt.jpa.core.context.java.JavaVersionMapping;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.NullJavaConverter;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java version mapping
- */
-public abstract class AbstractJavaVersionMapping
- extends AbstractJavaAttributeMapping<VersionAnnotation>
- implements JavaVersionMapping
-{
- protected final JavaColumn column;
-
- protected JavaConverter converter; // never null
-
-
- // the spec does not list Temporal explicitly,
- // but it is included in the orm.xml schema...
- protected static final JavaConverter.Adapter[] CONVERTER_ADAPTER_ARRAY = new JavaConverter.Adapter[] {
- JavaTemporalConverter.Adapter.instance(),
- };
- protected static final Iterable<JavaConverter.Adapter> CONVERTER_ADAPTERS = new ArrayIterable<JavaConverter.Adapter>(CONVERTER_ADAPTER_ARRAY);
-
-
- protected AbstractJavaVersionMapping(JavaPersistentAttribute parent) {
- super(parent);
- this.column = this.buildColumn();
- this.converter = this.buildConverter();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.column.synchronizeWithResourceModel();
- this.syncConverter();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update();
- this.converter.update();
- }
-
-
- // ********** column **********
-
- public JavaColumn getColumn() {
- return this.column;
- }
-
- protected JavaColumn buildColumn() {
- return this.getJpaFactory().buildJavaColumn(this, this);
- }
-
-
- // ********** converter **********
-
- public JavaConverter getConverter() {
- return this.converter;
- }
-
- public void setConverter(Class<? extends Converter> converterType) {
- if (this.converter.getType() != converterType) {
- this.converter.dispose();
- JavaConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.retainConverterAnnotation(converterAdapter);
- this.setConverter_(this.buildConverter(converterAdapter));
- }
- }
-
- protected JavaConverter buildConverter(JavaConverter.Adapter converterAdapter) {
- return (converterAdapter != null) ?
- converterAdapter.buildNewConverter(this, this.getJpaFactory()) :
- this.buildNullConverter();
- }
-
- protected void setConverter_(JavaConverter converter) {
- Converter old = this.converter;
- this.converter = converter;
- this.firePropertyChanged(CONVERTER_PROPERTY, old, converter);
- }
-
- /**
- * Clear all the converter annotations <em>except</em> for the annotation
- * corresponding to the specified adapter. If the specified adapter is
- * <code>null</code>, remove <em>all</em> the converter annotations.
- */
- protected void retainConverterAnnotation(JavaConverter.Adapter converterAdapter) {
- JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter != converterAdapter) {
- adapter.removeConverterAnnotation(resourceAttribute);
- }
- }
- }
-
- protected JavaConverter buildConverter() {
- JpaFactory jpaFactory = this.getJpaFactory();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- JavaConverter javaConverter = adapter.buildConverter(this, jpaFactory);
- if (javaConverter != null) {
- return javaConverter;
- }
- }
- return this.buildNullConverter();
- }
-
- protected void syncConverter() {
- Association<JavaConverter.Adapter, Annotation> assoc = this.getConverterAnnotation();
- if (assoc == null) {
- if (this.converter.getType() != null) {
- this.setConverter_(this.buildNullConverter());
- }
- } else {
- JavaConverter.Adapter adapter = assoc.getKey();
- Annotation annotation = assoc.getValue();
- if ((this.converter.getType() == adapter.getConverterType()) &&
- (this.converter.getConverterAnnotation() == annotation)) {
- this.converter.synchronizeWithResourceModel();
- } else {
- this.setConverter_(adapter.buildConverter(annotation, this, this.getJpaFactory()));
- }
- }
- }
-
- /**
- * Return the first converter annotation we find along with its corresponding
- * adapter. Return <code>null</code> if there are no converter annotations.
- */
- protected Association<JavaConverter.Adapter, Annotation> getConverterAnnotation() {
- JavaResourcePersistentAttribute resourceAttribute = this.getResourcePersistentAttribute();
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- Annotation annotation = adapter.getConverterAnnotation(resourceAttribute);
- if (annotation != null) {
- return new SimpleAssociation<JavaConverter.Adapter, Annotation>(adapter, annotation);
- }
- }
- return null;
- }
-
- protected JavaConverter buildNullConverter() {
- return new NullJavaConverter(this);
- }
-
-
- // ********** converter adapters **********
-
- /**
- * Return the converter adapter for the specified converter type.
- */
- protected JavaConverter.Adapter getConverterAdapter(Class<? extends Converter> converterType) {
- for (JavaConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.getConverterType() == converterType) {
- return adapter;
- }
- }
- return null;
- }
-
- protected Iterable<JavaConverter.Adapter> getConverterAdapters() {
- return CONVERTER_ADAPTERS;
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- @Override
- protected String getAnnotationName() {
- return VersionAnnotation.ANNOTATION_NAME;
- }
-
-
- // ********** JavaColumn.Owner implementation **********
-
- public ColumnAnnotation getColumnAnnotation() {
- return (ColumnAnnotation) this.getResourcePersistentAttribute().getNonNullAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- public void removeColumnAnnotation() {
- this.getResourcePersistentAttribute().removeAnnotation(ColumnAnnotation.ANNOTATION_NAME);
- }
-
- public String getDefaultColumnName() {
- return this.getName();
- }
-
- public String getDefaultTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-
-
- // ********** 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.column.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- result = this.converter.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.column.validate(messages, reporter, astRoot);
- this.converter.validate(messages, reporter, astRoot);
- this.validateAttributeType(messages, astRoot);
- }
-
- protected void validateAttributeType(List<IMessage> messages, CompilationUnit astRoot) {
- if (!ArrayTools.contains(VERSION_MAPPING_SUPPORTED_TYPES, this.getPersistentAttribute().getTypeName())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE,
- new String[] {this.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualBaseColumn.java
deleted file mode 100644
index a28099d901..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualBaseColumn.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
-import org.eclipse.jpt.jpa.core.context.VirtualBaseColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-
-public abstract class AbstractJavaVirtualBaseColumn<O extends ReadOnlyNamedColumn.Owner, C extends BaseColumn>
- extends AbstractJavaVirtualNamedColumn<O, C>
- implements VirtualBaseColumn
-{
- protected String specifiedTable;
- protected String defaultTable;
-
- protected Boolean specifiedUnique;
- protected boolean defaultUnique;
-
- protected Boolean specifiedNullable;
- protected boolean defaultNullable;
-
- protected Boolean specifiedInsertable;
- protected boolean defaultInsertable;
-
- protected Boolean specifiedUpdatable;
- protected boolean defaultUpdatable;
-
-
- protected AbstractJavaVirtualBaseColumn(JavaJpaContextNode parent, O owner) {
- super(parent, owner);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
-
- this.setSpecifiedTable(this.buildSpecifiedTable());
- this.setDefaultTable(this.buildDefaultTable());
-
- this.setSpecifiedUnique(this.buildSpecifiedUnique());
- this.setDefaultUnique(this.buildDefaultUnique());
-
- this.setSpecifiedNullable(this.buildSpecifiedNullable());
- this.setDefaultNullable(this.buildDefaultNullable());
-
- this.setSpecifiedInsertable(this.buildSpecifiedInsertable());
- this.setDefaultInsertable(this.buildDefaultInsertable());
-
- this.setSpecifiedUpdatable(this.buildSpecifiedUpdatable());
- this.setDefaultUpdatable(this.buildDefaultUpdatable());
- }
-
-
- // ********** table **********
-
- public String getTable() {
- return (this.specifiedTable != null) ? this.specifiedTable : this.defaultTable;
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- protected void setSpecifiedTable(String table) {
- String old = this.specifiedTable;
- this.specifiedTable = table;
- this.firePropertyChanged(SPECIFIED_TABLE_PROPERTY, old, table);
- }
-
- protected String buildSpecifiedTable() {
- return this.getOverriddenColumn().getSpecifiedTable();
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String table) {
- String old = this.defaultTable;
- this.defaultTable = table;
- this.firePropertyChanged(DEFAULT_TABLE_PROPERTY, old, table);
- }
-
- protected String buildDefaultTable() {
- return this.owner.getDefaultTableName();
- }
-
-
- // ********** unique **********
-
- public boolean isUnique() {
- return (this.specifiedUnique != null) ? this.specifiedUnique.booleanValue() : this.isDefaultUnique();
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- protected void setSpecifiedUnique(Boolean unique) {
- Boolean old = this.specifiedUnique;
- this.specifiedUnique = unique;
- this.firePropertyChanged(SPECIFIED_UNIQUE_PROPERTY, old, unique);
- }
-
- protected Boolean buildSpecifiedUnique() {
- return this.getOverriddenColumn().getSpecifiedUnique();
- }
-
- public boolean isDefaultUnique() {
- return this.defaultUnique;
- }
-
- protected void setDefaultUnique(boolean unique) {
- boolean old = this.defaultUnique;
- this.defaultUnique = unique;
- this.firePropertyChanged(DEFAULT_UNIQUE_PROPERTY, old, unique);
- }
-
- protected boolean buildDefaultUnique() {
- return DEFAULT_UNIQUE;
- }
-
-
- // ********** nullable **********
-
- public boolean isNullable() {
- return (this.specifiedNullable != null) ? this.specifiedNullable.booleanValue() : this.isDefaultNullable();
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- protected void setSpecifiedNullable(Boolean nullable) {
- Boolean old = this.specifiedNullable;
- this.specifiedNullable = nullable;
- this.firePropertyChanged(SPECIFIED_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected Boolean buildSpecifiedNullable() {
- return this.getOverriddenColumn().getSpecifiedNullable();
- }
-
- public boolean isDefaultNullable() {
- return this.defaultNullable;
- }
-
- protected void setDefaultNullable(boolean nullable) {
- boolean old = this.defaultNullable;
- this.defaultNullable = nullable;
- this.firePropertyChanged(DEFAULT_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected boolean buildDefaultNullable() {
- return DEFAULT_NULLABLE;
- }
-
-
- // ********** insertable **********
-
- public boolean isInsertable() {
- return (this.specifiedInsertable != null) ? this.specifiedInsertable.booleanValue() : this.isDefaultInsertable();
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- protected void setSpecifiedInsertable(Boolean insertable) {
- Boolean old = this.specifiedInsertable;
- this.specifiedInsertable = insertable;
- this.firePropertyChanged(SPECIFIED_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected Boolean buildSpecifiedInsertable() {
- return this.getOverriddenColumn().getSpecifiedInsertable();
- }
-
- public boolean isDefaultInsertable() {
- return this.defaultInsertable;
- }
-
- protected void setDefaultInsertable(boolean insertable) {
- boolean old = this.defaultInsertable;
- this.defaultInsertable = insertable;
- this.firePropertyChanged(DEFAULT_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected boolean buildDefaultInsertable() {
- return DEFAULT_INSERTABLE;
- }
-
-
- // ********** updatable **********
-
- public boolean isUpdatable() {
- return (this.specifiedUpdatable != null) ? this.specifiedUpdatable.booleanValue() : this.isDefaultUpdatable();
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- protected void setSpecifiedUpdatable(Boolean updatable) {
- Boolean old = this.specifiedUpdatable;
- this.specifiedUpdatable = updatable;
- this.firePropertyChanged(SPECIFIED_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected Boolean buildSpecifiedUpdatable() {
- return this.getOverriddenColumn().getSpecifiedUpdatable();
- }
-
- public boolean isDefaultUpdatable() {
- return this.defaultUpdatable;
- }
-
- protected void setDefaultUpdatable(boolean updatable) {
- boolean old = this.defaultUpdatable;
- this.defaultUpdatable = updatable;
- this.firePropertyChanged(DEFAULT_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected boolean buildDefaultUpdatable() {
- return DEFAULT_UPDATABLE;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualNamedColumn.java
deleted file mode 100644
index cb72435abd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualNamedColumn.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
-import org.eclipse.jpt.jpa.core.context.VirtualNamedColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-
-/**
- * Java virtual<ul>
- * <li>column
- * <li>join column
- * </ul>
- * <strong>NB:</strong> all state is sync'ed/updated in {@link #update()}
- * because <em>all</em> of it is derived from the context model (i.e. none of it
- * is derived from the resource model).
- */
-public abstract class AbstractJavaVirtualNamedColumn<O extends ReadOnlyNamedColumn.Owner, C extends NamedColumn>
- extends AbstractJavaJpaContextNode
- implements VirtualNamedColumn
-{
- protected final O owner;
-
- protected String specifiedName;
- protected String defaultName;
-
- protected String columnDefinition;
-
-
- protected AbstractJavaVirtualNamedColumn(JavaJpaContextNode parent, O owner) {
- super(parent);
- this.owner = owner;
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
-
- this.setSpecifiedName(this.buildSpecifiedName());
- this.setDefaultName(this.buildDefaultName());
-
- this.setColumnDefinition(this.buildColumnDefinition());
- }
-
-
- // ********** column **********
-
- /**
- * This should never return <code>null</code>.
- */
- public abstract C getOverriddenColumn();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- protected void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- return this.getOverriddenColumn().getSpecifiedName();
- }
-
- 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);
- }
-
- protected String buildDefaultName() {
- return this.owner.getDefaultColumnName();
- }
-
-
- // ********** column definition **********
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- protected void setColumnDefinition(String columnDefinition) {
- String old = this.columnDefinition;
- this.columnDefinition = columnDefinition;
- this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition);
- }
-
- protected String buildColumnDefinition() {
- return this.getOverriddenColumn().getColumnDefinition();
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getParent().getValidationTextRange(astRoot);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- String table = this.getTable();
- if (table != null) {
- sb.append(table);
- sb.append('.');
- }
- sb.append(this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualOverride.java
deleted file mode 100644
index ca34875b28..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualOverride.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualOverride;
-
-/**
- * Virtual Java override
- */
-public abstract class AbstractJavaVirtualOverride<C extends JavaOverrideContainer>
- extends AbstractJavaJpaContextNode
- implements JavaVirtualOverride
-{
- protected final String name; // never null
-
-
- protected AbstractJavaVirtualOverride(C parent, String name) {
- super(parent);
- this.name = name;
- }
-
- public String getName() {
- return this.name;
- }
-
- public boolean isVirtual() {
- return true;
- }
-
- public JavaOverride convertToSpecified() {
- return this.getContainer().convertOverrideToSpecified(this);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public C getParent() {
- return (C) super.getParent();
- }
-
- public C getContainer() {
- return this.getParent();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getContainer().getValidationTextRange(astRoot);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualReferenceTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualReferenceTable.java
deleted file mode 100644
index ec4d5b507f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualReferenceTable.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReferenceTable;
-import org.eclipse.jpt.jpa.core.context.VirtualReferenceTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-
-public abstract class AbstractJavaVirtualReferenceTable<T extends ReferenceTable>
- extends AbstractJavaVirtualTable<T>
- implements VirtualReferenceTable
-{
- protected final Vector<JavaVirtualJoinColumn> specifiedJoinColumns = new Vector<JavaVirtualJoinColumn>();
- protected final SpecifiedJoinColumnContainerAdapter specifiedJoinColumnContainerAdapter = new SpecifiedJoinColumnContainerAdapter();
- protected final ReadOnlyJoinColumn.Owner joinColumnOwner;
-
- protected JavaVirtualJoinColumn defaultJoinColumn;
-
-
- protected AbstractJavaVirtualReferenceTable(JavaJpaContextNode parent) {
- super(parent);
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateSpecifiedJoinColumns();
- this.updateDefaultJoinColumn();
- }
-
-
- // ********** join columns **********
-
- public ListIterator<JavaVirtualJoinColumn> joinColumns() {
- return this.getJoinColumns().iterator();
- }
-
- protected ListIterable<JavaVirtualJoinColumn> getJoinColumns() {
- return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ? this.specifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize();
- }
-
-
- // ********** specified join columns **********
-
- public ListIterator<JavaVirtualJoinColumn> specifiedJoinColumns() {
- return this.getSpecifiedJoinColumns().iterator();
- }
-
- protected ListIterable<JavaVirtualJoinColumn> getSpecifiedJoinColumns() {
- return new LiveCloneListIterable<JavaVirtualJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return this.specifiedJoinColumns.size() != 0;
- }
-
- public JavaVirtualJoinColumn getSpecifiedJoinColumn(int index) {
- return this.specifiedJoinColumns.get(index);
- }
-
- protected void updateSpecifiedJoinColumns() {
- ContextContainerTools.update(this.specifiedJoinColumnContainerAdapter);
- }
-
- protected Iterable<JoinColumn> getOverriddenJoinColumns() {
- return CollectionTools.iterable(this.getOverriddenTable().specifiedJoinColumns());
- }
-
- protected void moveSpecifiedJoinColumn(int index, JavaVirtualJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected JavaVirtualJoinColumn addSpecifiedJoinColumn(int index, JoinColumn joinColumn) {
- JavaVirtualJoinColumn virtualJoinColumn = this.buildJoinColumn(joinColumn);
- this.addItemToList(index, virtualJoinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- return virtualJoinColumn;
- }
-
- protected void removeSpecifiedJoinColumn(JavaVirtualJoinColumn joinColumn) {
- this.removeItemFromList(joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- /**
- * specified join column container adapter
- */
- protected class SpecifiedJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<JavaVirtualJoinColumn, JoinColumn>
- {
- public Iterable<JavaVirtualJoinColumn> getContextElements() {
- return AbstractJavaVirtualReferenceTable.this.getSpecifiedJoinColumns();
- }
- public Iterable<JoinColumn> getResourceElements() {
- return AbstractJavaVirtualReferenceTable.this.getOverriddenJoinColumns();
- }
- public JoinColumn getResourceElement(JavaVirtualJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, JavaVirtualJoinColumn element) {
- AbstractJavaVirtualReferenceTable.this.moveSpecifiedJoinColumn(index, element);
- }
- public void addContextElement(int index, JoinColumn element) {
- AbstractJavaVirtualReferenceTable.this.addSpecifiedJoinColumn(index, element);
- }
- public void removeContextElement(JavaVirtualJoinColumn element) {
- AbstractJavaVirtualReferenceTable.this.removeSpecifiedJoinColumn(element);
- }
- }
-
-
- // ********** default join column **********
-
- public JavaVirtualJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(JavaVirtualJoinColumn joinColumn) {
- JavaVirtualJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn);
- }
-
- protected ListIterable<JavaVirtualJoinColumn> getDefaultJoinColumns() {
- return (this.defaultJoinColumn != null) ?
- new SingleElementListIterable<JavaVirtualJoinColumn>(this.defaultJoinColumn) :
- EmptyListIterable.<JavaVirtualJoinColumn>instance();
- }
-
- protected int getDefaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultJoinColumn() {
- if (this.buildsDefaultJoinColumn()) {
- if (this.defaultJoinColumn == null) {
- this.setDefaultJoinColumn(this.buildJoinColumn(this.getOverriddenTable().getDefaultJoinColumn()));
- } else {
- this.defaultJoinColumn.update();
- }
- } else {
- this.setDefaultJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultJoinColumn() {
- return ! this.hasSpecifiedJoinColumns();
- }
-
-
- // ********** misc **********
-
- protected JavaVirtualJoinColumn buildJoinColumn(JoinColumn joinColumn) {
- return this.buildJoinColumn(this.joinColumnOwner, joinColumn);
- }
-
- protected JavaVirtualJoinColumn buildJoinColumn(ReadOnlyJoinColumn.Owner owner, JoinColumn joinColumn) {
- return this.getJpaFactory().buildJavaVirtualJoinColumn(this, owner, joinColumn);
- }
-
- protected abstract ReadOnlyJoinColumn.Owner buildJoinColumnOwner();
-
- @Override
- protected String buildDefaultSchema() {
- return this.getContextDefaultSchema();
- }
-
- @Override
- protected String buildDefaultCatalog() {
- return this.getContextDefaultCatalog();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualTable.java
deleted file mode 100644
index fad37786bd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVirtualTable.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.VirtualTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualUniqueConstraint;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-
-public abstract class AbstractJavaVirtualTable<T extends Table>
- extends AbstractJavaJpaContextNode
- implements VirtualTable
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected final Vector<JavaVirtualUniqueConstraint> uniqueConstraints = new Vector<JavaVirtualUniqueConstraint>();
- protected final UniqueConstraintContainerAdapter uniqueConstraintContainerAdapter = new UniqueConstraintContainerAdapter();
-
-
- protected AbstractJavaVirtualTable(JavaJpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
-
- this.setSpecifiedName(this.buildSpecifiedName());
- this.setDefaultName(this.buildDefaultName());
-
- this.setSpecifiedSchema(this.buildSpecifiedSchema());
- this.setDefaultSchema(this.buildDefaultSchema());
-
- this.setSpecifiedCatalog(this.buildSpecifiedCatalog());
- this.setDefaultCatalog(this.buildDefaultCatalog());
-
- this.updateUniqueConstraints();
- }
-
-
- // ********** table **********
-
- /**
- * This should never return <code>null</code>.
- */
- public abstract T getOverriddenTable();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- protected void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- return this.getOverriddenTable().getSpecifiedName();
- }
-
- 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);
- }
-
- protected abstract String buildDefaultName();
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- protected void setSpecifiedSchema(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- protected String buildSpecifiedSchema() {
- return this.getOverriddenTable().getSchema();
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- protected abstract String buildDefaultSchema();
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- protected void setSpecifiedCatalog(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- protected String buildSpecifiedCatalog() {
- return this.getOverriddenTable().getCatalog();
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- protected abstract String buildDefaultCatalog();
-
-
- // ********** unique constraints **********
-
- public ListIterator<JavaVirtualUniqueConstraint> uniqueConstraints() {
- return this.getUniqueConstraints().iterator();
- }
-
- protected ListIterable<JavaVirtualUniqueConstraint> getUniqueConstraints() {
- return new LiveCloneListIterable<JavaVirtualUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public JavaVirtualUniqueConstraint getUniqueConstraint(int index) {
- return this.uniqueConstraints.get(index);
- }
-
- protected void updateUniqueConstraints() {
- ContextContainerTools.update(this.uniqueConstraintContainerAdapter);
- }
-
- protected Iterable<UniqueConstraint> getOverriddenUniqueConstraints() {
- return CollectionTools.iterable(this.getOverriddenTable().uniqueConstraints());
- }
-
- protected void moveUniqueConstraint(int index, JavaVirtualUniqueConstraint constraint) {
- this.moveItemInList(index, constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected JavaVirtualUniqueConstraint addUniqueConstraint(int index, UniqueConstraint uniqueConstraint) {
- JavaVirtualUniqueConstraint virtualConstraint = this.buildUniqueConstraint(uniqueConstraint);
- this.addItemToList(index, virtualConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- return virtualConstraint;
- }
-
- protected JavaVirtualUniqueConstraint buildUniqueConstraint(UniqueConstraint uniqueConstraint) {
- return this.getJpaFactory().buildJavaVirtualUniqueConstraint(this, uniqueConstraint);
- }
-
- protected void removeUniqueConstraint(JavaVirtualUniqueConstraint constraint) {
- this.removeItemFromList(constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- /**
- * unique constraint container adapter
- */
- protected class UniqueConstraintContainerAdapter
- implements ContextContainerTools.Adapter<JavaVirtualUniqueConstraint, UniqueConstraint>
- {
- public Iterable<JavaVirtualUniqueConstraint> getContextElements() {
- return AbstractJavaVirtualTable.this.getUniqueConstraints();
- }
- public Iterable<UniqueConstraint> getResourceElements() {
- return AbstractJavaVirtualTable.this.getOverriddenUniqueConstraints();
- }
- public UniqueConstraint getResourceElement(JavaVirtualUniqueConstraint contextElement) {
- return contextElement.getOverriddenUniqueConstraint();
- }
- public void moveContextElement(int index, JavaVirtualUniqueConstraint element) {
- AbstractJavaVirtualTable.this.moveUniqueConstraint(index, element);
- }
- public void addContextElement(int index, UniqueConstraint resourceElement) {
- AbstractJavaVirtualTable.this.addUniqueConstraint(index, resourceElement);
- }
- public void removeContextElement(JavaVirtualUniqueConstraint element) {
- AbstractJavaVirtualTable.this.removeUniqueConstraint(element);
- }
- }
-
-
- // ********** database stuff **********
-
- public org.eclipse.jpt.jpa.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.resolveDbCatalog(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.resolveDbCatalog(catalog);
- }
-
- protected boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- protected 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.
- */
- protected boolean hasResolvedCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.resolveDbCatalog(catalog) != null);
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getParent().getValidationTextRange(astRoot);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaJpaContextNode getParent() {
- return (JavaJpaContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.buildQualifiedName());
- }
-
- protected String buildQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/DefaultJavaAttributeMappingDefinitionWrapper.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/DefaultJavaAttributeMappingDefinitionWrapper.java
deleted file mode 100644
index 5c23c36ade..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/DefaultJavaAttributeMappingDefinitionWrapper.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-
-public abstract class DefaultJavaAttributeMappingDefinitionWrapper
- extends JavaAttributeMappingDefinitionWrapper
- implements DefaultJavaAttributeMappingDefinition
-{
- protected DefaultJavaAttributeMappingDefinitionWrapper() {
- super();
- }
-
- @Override
- protected abstract DefaultJavaAttributeMappingDefinition getDelegate();
-
- public boolean isDefault(JavaPersistentAttribute persistentAttribute) {
- return this.getDelegate().isDefault(persistentAttribute);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaIdClassReference.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaIdClassReference.java
deleted file mode 100644
index 840e0bc0dd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaIdClassReference.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java ID class reference
- */
-public class GenericJavaIdClassReference
- extends AbstractJavaJpaContextNode
- implements JavaIdClassReference
-{
- protected String idClassName;
- protected String fullyQualifiedIdClassName;
- // the ref holds the type directly because the ref is the type's parent
- protected JavaPersistentType idClass;
-
-
- public GenericJavaIdClassReference(JavaTypeMapping parent) {
- super(parent);
- this.idClassName = this.buildIdClassName();
- // 'idClass' is resolved in the update
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setIdClassName_(this.buildIdClassName());
- if (this.idClass != null) {
- this.idClass.synchronizeWithResourceModel();
- }
- }
-
- @Override
- public void update() {
- super.update();
- this.setFullyQualifiedIdClassName(this.buildFullyQualifiedIdClassName());
- this.updateIdClass();
- }
-
-
- // ********** id class name **********
-
- public String getIdClassName() {
- return this.getSpecifiedIdClassName();
- }
-
- public String getSpecifiedIdClassName() {
- return this.idClassName;
- }
-
- public void setSpecifiedIdClassName(String name) {
- if (this.valuesAreDifferent(name, this.idClassName)) {
- this.getIdClassAnnotationForUpdate().setValue(name);
- this.removeIdClassAnnotationIfUnset();
- this.setIdClassName_(name);
- }
- }
-
- protected void setIdClassName_(String name) {
- String old = this.idClassName;
- this.idClassName = name;
- this.firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, old, name);
- }
-
- protected String buildIdClassName() {
- IdClassAnnotation annotation = this.getIdClassAnnotation();
- return (annotation == null) ? null : annotation.getValue();
- }
-
- public String getDefaultIdClassName() {
- return null;
- }
-
- public boolean isSpecified() {
- return this.idClassName != null;
- }
-
-
- // ********** id class annotation **********
-
- /**
- * Return <code>null</code> if the annotation does not exists.
- */
- protected IdClassAnnotation getIdClassAnnotation() {
- return (IdClassAnnotation) this.getResourcePersistentType().getAnnotation(this.getIdClassAnnotationName());
- }
-
- /**
- * Build the annotation if it does not exist.
- */
- protected IdClassAnnotation getIdClassAnnotationForUpdate() {
- IdClassAnnotation annotation = this.getIdClassAnnotation();
- return (annotation != null) ? annotation : this.buildIdClassAnnotation();
- }
-
- protected IdClassAnnotation buildIdClassAnnotation() {
- return (IdClassAnnotation) this.getResourcePersistentType().addAnnotation(this.getIdClassAnnotationName());
- }
-
- protected void removeIdClassAnnotationIfUnset() {
- if (this.getIdClassAnnotation().isUnset()) {
- this.removeIdClassAnnotation();
- }
- }
-
- protected void removeIdClassAnnotation() {
- this.getResourcePersistentType().removeAnnotation(this.getIdClassAnnotationName());
- }
-
- protected String getIdClassAnnotationName() {
- return IdClassAnnotation.ANNOTATION_NAME;
- }
-
-
- // ********** fully-qualified id class name **********
-
- public String getFullyQualifiedIdClassName() {
- return this.fullyQualifiedIdClassName;
- }
-
- protected void setFullyQualifiedIdClassName(String name) {
- String old = this.fullyQualifiedIdClassName;
- this.fullyQualifiedIdClassName = name;
- this.firePropertyChanged(FULLY_QUALIFIED_ID_CLASS_PROPERTY, old, name);
- }
-
- protected String buildFullyQualifiedIdClassName() {
- IdClassAnnotation annotation = this.getIdClassAnnotation();
- return (annotation == null) ? null : annotation.getFullyQualifiedClassName();
- }
-
-
- // ********** id class **********
-
- public JavaPersistentType getIdClass() {
- return this.idClass;
- }
-
- protected void setIdClass(JavaPersistentType idClass) {
- JavaPersistentType old = this.idClass;
- this.idClass = idClass;
- this.firePropertyChanged(ID_CLASS_PROPERTY, old, idClass);
- }
-
- protected void updateIdClass() {
- JavaResourcePersistentType resourceIdClass = this.resolveResourceIdClass();
- if (resourceIdClass == null) {
- if (this.idClass != null) {
- this.idClass.dispose();
- this.setIdClass(null);
- }
- } else {
- if (this.idClass == null) {
- this.setIdClass(this.buildIdClass(resourceIdClass));
- } else {
- if (this.idClass.getResourcePersistentType() == resourceIdClass) {
- this.idClass.update();
- } else {
- this.idClass.dispose();
- this.setIdClass(this.buildIdClass(resourceIdClass));
- }
- }
- }
- }
-
- protected JavaResourcePersistentType resolveResourceIdClass() {
- if (this.fullyQualifiedIdClassName == null) {
- return null;
- }
- JavaResourcePersistentType jrpt = this.getJpaProject().getJavaResourcePersistentType(this.fullyQualifiedIdClassName);
- return (jrpt == null) ? null : (jrpt.isMapped() ? null : jrpt);
- }
-
- protected JavaPersistentType buildIdClass(JavaResourcePersistentType resourceClass) {
- return this.getJpaFactory().buildJavaPersistentType(this, resourceClass);
- }
-
- public char getIdClassEnclosingTypeSeparator() {
- return '.';
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaTypeMapping getParent() {
- return (JavaTypeMapping) super.getParent();
- }
-
- protected JavaTypeMapping getTypeMapping() {
- return this.getParent();
- }
-
- protected JavaPersistentType getPersistentType() {
- return this.getTypeMapping().getPersistentType();
- }
-
- protected JavaResourcePersistentType getResourcePersistentType() {
- return this.getPersistentType().getResourcePersistentType();
- }
-
-
- // ********** PersistentType.Owner implementation **********
-
- public AccessType getOverridePersistentTypeAccess() {
- return this.getPersistentType().getAccess();
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- // this shouldn't be needed, since we've specified an override access, but just to be safe ...
- return this.getPersistentType().getAccess();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.validateIdClass(messages, reporter, astRoot);
- }
-
- protected void validateIdClass(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- if (this.isSpecified()) {
- JavaResourcePersistentType jrpt = this.getJpaProject().getJavaResourcePersistentType(this.getFullyQualifiedIdClassName());
- if ((jrpt != null) && (jrpt.isMapped())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TYPE_MAPPING_ID_CLASS_NOT_VALID,
- new String[] {jrpt.getName()},
- this,
- this.getValidationTextRange(astRoot)
- )
- );
- }
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getAnnotationTextRange(astRoot);
- return (textRange != null) ? textRange : this.getTypeMapping().getValidationTextRange(astRoot);
- }
-
- protected TextRange getAnnotationTextRange(CompilationUnit astRoot) {
- IdClassAnnotation annotation = this.getIdClassAnnotation();
- return (annotation == null) ? null : annotation.getTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToManyRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToManyRelationship.java
deleted file mode 100644
index acbd82eeb9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToManyRelationship.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToManyRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaMappingJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaManyToManyRelationship
- extends AbstractJavaMappingRelationship<JavaManyToManyMapping>
- implements JavaManyToManyRelationship
-{
- protected final JavaMappedByRelationshipStrategy mappedByStrategy;
-
- protected final JavaJoinTableRelationshipStrategy joinTableStrategy;
-
-
- public GenericJavaManyToManyRelationship(JavaManyToManyMapping parent) {
- super(parent);
- this.mappedByStrategy = this.buildMappedByStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mappedByStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.mappedByStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected JavaRelationshipStrategy buildStrategy() {
- if (this.mappedByStrategy.getMappedByAttribute() != null) {
- return this.mappedByStrategy;
- }
- return this.joinTableStrategy;
- }
-
-
- // ********** mapped by strategy **********
-
- public JavaMappedByRelationshipStrategy getMappedByStrategy() {
- return this.mappedByStrategy;
- }
-
- public boolean strategyIsMappedBy() {
- return this.strategy == this.mappedByStrategy;
- }
-
- public void setStrategyToMappedBy() {
- this.mappedByStrategy.addStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mapping) {
- return mapping.getKey() == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- protected JavaMappedByRelationshipStrategy buildMappedByStrategy() {
- return new GenericJavaMappedByRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public JavaJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public void setStrategyToJoinTable() {
- // join table is default option, so no need to add to resource
- this.mappedByStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return this.getMappedByStrategy().getMappedByAttribute() == null;
- }
-
- protected JavaJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return new GenericJavaMappingJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromMappedByRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- }
-
- @Override
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- super.initializeFromMappedByRelationship(oldRelationship);
- this.mappedByStrategy.initializeFrom(oldRelationship.getMappedByStrategy());
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaManyToManyMapping getMapping() {
- return this.getParent();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return this.getMapping().getMappingAnnotation();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotationForUpdate() {
- return this.getMapping().getAnnotationForUpdate();
- }
-
- public boolean isOwner() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByStrategy.relationshipIsOwnedBy(mapping);
- }
-
-
- // ********** 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.mappedByStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return this.joinTableStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByStrategy.validate(messages, reporter, astRoot);
- this.joinTableStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToOneRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToOneRelationship.java
deleted file mode 100644
index c0ad6c945b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaManyToOneRelationship.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaMappingJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.NullJavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaManyToOneRelationship2_0;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaManyToOneRelationship
- extends AbstractJavaMappingRelationship<JavaManyToOneMapping>
- implements JavaManyToOneRelationship2_0
-{
- protected final JavaJoinColumnRelationshipStrategy joinColumnStrategy;
-
- // JPA 2.0
- protected final JavaJoinTableRelationshipStrategy joinTableStrategy;
-
-
- public GenericJavaManyToOneRelationship(JavaManyToOneMapping parent) {
- super(parent);
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.joinColumnStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected JavaRelationshipStrategy buildStrategy() {
- if (this.isJpa2_0Compatible()) {
- if (this.joinTableStrategy.getJoinTable() != null) {
- return this.joinTableStrategy;
- }
- }
- return this.joinColumnStrategy;
- }
-
-
- // ********** join table strategy **********
-
- public JavaJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public final void setStrategyToJoinTable() {
- this.joinTableStrategy.addStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- protected JavaJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return this.isJpa2_0Compatible() ?
- new GenericJavaMappingJoinTableRelationshipStrategy(this) :
- new NullJavaJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** join column strategy **********
-
- public JavaJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- // join column strategy is the default; so no need to add stuff,
- // just remove all the others
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.joinTableStrategy.getJoinTable() == null;
- }
-
- protected JavaJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return new GenericJavaMappingJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromJoinColumnRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- @Override
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- super.initializeFromJoinColumnRelationship(oldRelationship);
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaManyToOneMapping getMapping() {
- return this.getParent();
- }
-
- public boolean isOwner() {
- return true;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return false;
- }
-
-
- // ********** 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.joinColumnStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return this.joinTableStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.joinColumnStrategy.validate(messages, reporter, astRoot);
- this.joinTableStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
deleted file mode 100644
index 592466b523..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-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 GenericJavaMappedByRelationshipStrategy
- extends AbstractJavaJpaContextNode
- implements JavaMappedByRelationshipStrategy
-{
- protected String mappedByAttribute;
-
-
- public GenericJavaMappedByRelationshipStrategy(JavaMappedByRelationship parent) {
- super(parent);
- this.mappedByAttribute = this.buildMappedByAttribute();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setMappedByAttribute_(this.buildMappedByAttribute());
- }
-
-
- // ********** mapped by attribute **********
-
- public String getMappedByAttribute() {
- return this.mappedByAttribute;
- }
-
- public void setMappedByAttribute(String mappedByAttribute) {
- if (this.valuesAreDifferent(mappedByAttribute, this.mappedByAttribute)) {
- this.getMappingAnnotationForUpdate().setMappedBy(mappedByAttribute);
- this.setMappedByAttribute_(mappedByAttribute);
- }
- }
-
- protected void setMappedByAttribute_(String mappedByAttribute) {
- String old = this.mappedByAttribute;
- this.mappedByAttribute = mappedByAttribute;
- this.firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, old, mappedByAttribute);
- }
-
- protected String buildMappedByAttribute() {
- OwnableRelationshipMappingAnnotation annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getMappedBy();
- }
-
-
- // ********** misc **********
-
- protected OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return this.getRelationship().getMappingAnnotation();
- }
-
- protected OwnableRelationshipMappingAnnotation getMappingAnnotationForUpdate() {
- return this.getRelationship().getMappingAnnotationForUpdate();
- }
-
- @Override
- public JavaMappedByRelationship getParent() {
- return (JavaMappedByRelationship) super.getParent();
- }
-
- public JavaMappedByRelationship getRelationship() {
- return this.getParent();
- }
-
- public void initializeFrom(MappedByRelationshipStrategy oldStrategy) {
- this.setMappedByAttribute(oldStrategy.getMappedByAttribute());
- }
-
- public String getTableName() {
- RelationshipMapping owner = this.getRelationshipOwner();
- return (owner == null) ? null : owner.getRelationship().getStrategy().getTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- RelationshipMapping owner = this.getRelationshipOwner();
- return (owner == null) ? null : owner.getRelationship().getStrategy().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- RelationshipMapping owner = this.getRelationshipOwner();
- return (owner != null) && owner.getRelationship().getStrategy().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- //this will not be called if getRelationshipOwner() is null
- return this.getRelationshipOwner().getRelationship().getStrategy().getColumnTableNotValidDescription();
- }
-
- protected RelationshipMapping getRelationshipOwner() {
- return this.getRelationshipMapping().getRelationshipOwner();
- }
-
- public boolean isOverridable() {
- return false;
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- public boolean relationshipIsOwnedBy(RelationshipMapping otherMapping) {
- String thisEntityName = this.getEntityName();
- Entity otherEntity = otherMapping.getResolvedTargetEntity();
- String otherEntityName = (otherEntity == null) ? null : otherEntity.getName();
- return Tools.valuesAreEqual(thisEntityName, otherEntityName) &&
- Tools.valuesAreEqual(this.mappedByAttribute, otherMapping.getName());
- }
-
- protected String getEntityName() {
- Entity entity = this.getRelationship().getEntity();
- return (entity == null) ? null : entity.getName();
- }
-
- public void addStrategy() {
- if (this.mappedByAttribute == null) {
- this.setMappedByAttribute(""); //$NON-NLS-1$
- }
- }
-
- public void removeStrategy() {
- if (this.mappedByAttribute != null) {
- this.setMappedByAttribute(null);
- }
- }
-
-
- // ********** java completion proposals **********
-
- @Override
- public Iterator<String> javaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) {
- Iterator<String> result = super.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
- OwnableRelationshipMappingAnnotation annotation = this.getMappingAnnotation();
- if ((annotation != null) && annotation.mappedByTouches(pos, astRoot)) {
- result = this.javaCandidateMappedByAttributeNames(filter);
- }
- return result;
- }
-
- public Iterator<String> candidateMappedByAttributeNames() {
- return this.getRelationshipMapping().allTargetEntityAttributeNames();
- }
-
- protected 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 **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
-
- if (this.mappedByAttribute == 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(
- this.buildMessage(
- JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
- new String[] {this.mappedByAttribute},
- astRoot
- )
- );
- return;
- }
-
- if ( ! this.getRelationship().mayBeMappedBy(mappedByMapping)) {
- messages.add(
- this.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(
- this.buildMessage(
- JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
- new String[] {this.mappedByAttribute},
- astRoot
- )
- );
- }
- }
-
- protected IMessage buildMessage(String msgID, String[] parms, CompilationUnit astRoot) {
- PersistentAttribute attribute = this.getRelationshipMapping().getPersistentAttribute();
- String attributeDescription = attribute.isVirtual() ?
- JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC :
- JpaValidationDescriptionMessages.ATTRIBUTE_DESC;
- attributeDescription = NLS.bind(attributeDescription, attribute.getName());
- parms = ArrayTools.add(parms, 0, attributeDescription);
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- parms,
- this,
- this.getValidationTextRange(astRoot)
- );
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- TextRange textRange = this.getAnnotationMappedByTextRange(astRoot);
- return (textRange != null) ? textRange : this.getRelationship().getValidationTextRange(astRoot);
- }
-
- protected TextRange getAnnotationMappedByTextRange(CompilationUnit astRoot) {
- OwnableRelationshipMappingAnnotation annotation = this.getMappingAnnotation();
- return (annotation == null) ? null : annotation.getMappedByTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappingJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappingJoinColumnRelationshipStrategy.java
deleted file mode 100644
index 5e703d851b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappingJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.iterators.SubIteratorWrapper;
-import org.eclipse.jpt.common.utility.internal.iterators.SuperIteratorWrapper;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappingJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.resource.java.NullJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestableJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-
-public class GenericJavaMappingJoinColumnRelationshipStrategy
- extends AbstractJavaJoinColumnRelationshipStrategy
-{
- protected final boolean targetForeignKey;
-
-
- /**
- * The default strategy is for a "source" foreign key.
- */
- public GenericJavaMappingJoinColumnRelationshipStrategy(JavaMappingJoinColumnRelationship parent) {
- this(parent, false);
- }
-
- public GenericJavaMappingJoinColumnRelationshipStrategy(JavaMappingJoinColumnRelationship parent, boolean targetForeignKey) {
- super(parent);
- this.targetForeignKey = targetForeignKey;
- }
-
-
- // ********** join column annotations **********
-
- @Override
- protected Iterator<JoinColumnAnnotation> joinColumnAnnotations() {
- return new SuperIteratorWrapper<JoinColumnAnnotation>(this.nestableJoinColumnAnnotations());
- }
-
- protected Iterator<NestableJoinColumnAnnotation> nestableJoinColumnAnnotations() {
- return new SubIteratorWrapper<NestableAnnotation, NestableJoinColumnAnnotation>(this.nestableJoinColumnAnnotations_());
- }
-
- protected Iterator<NestableAnnotation> nestableJoinColumnAnnotations_() {
- return this.getResourcePersistentAttribute().annotations(JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected JoinColumnAnnotation addJoinColumnAnnotation(int index) {
- return (JoinColumnAnnotation) this.getResourcePersistentAttribute().addAnnotation(index, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void removeJoinColumnAnnotation(int index) {
- this.getResourcePersistentAttribute().removeAnnotation(index, JoinColumnAnnotation.ANNOTATION_NAME, JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected void moveJoinColumnAnnotation(int targetIndex, int sourceIndex) {
- this.getResourcePersistentAttribute().moveAnnotation(targetIndex, sourceIndex, JoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- @Override
- protected JoinColumnAnnotation buildNullJoinColumnAnnotation() {
- return new NullJoinColumnAnnotation(this.getResourcePersistentAttribute());
- }
-
-
- // ********** misc **********
-
- protected JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.getRelationship().getMapping().getResourcePersistentAttribute();
- }
-
- @Override
- public JavaMappingJoinColumnRelationship getRelationship() {
- return (JavaMappingJoinColumnRelationship) super.getRelationship();
- }
-
- @Override
- protected JavaJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isOverridable() {
- return true;
- }
-
- public TypeMapping getRelationshipSource() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return this.targetForeignKey ?
- mapping.getResolvedTargetEntity() :
- mapping.getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return this.targetForeignKey ?
- mapping.getTypeMapping() :
- mapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping target = this.getRelationshipTarget();
- return (target instanceof Entity) ? (Entity) target : null;
- }
-
- public boolean isTargetForeignKey() {
- return this.targetForeignKey;
- }
-
-
- // ********** validation **********
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationship().getValidationTextRange(astRoot);
- }
-
-
- // ********** join column owner **********
-
- 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 GenericJavaMappingJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.getRelationshipMapping().getName();
- }
-
- protected PersistentAttribute getPersistentAttribute() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.getRelationshipMapping().getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public Iterator<String> candidateTableNames() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.candidateTableNames();
- }
-
- public Table resolveDbTable(String tableName) {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.resolveDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaMappingJoinColumnRelationshipStrategy.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator(this.getPersistentAttribute(), (JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToManyRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToManyRelationship.java
deleted file mode 100644
index 318babfe30..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToManyRelationship.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaMappingJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.NullJavaJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToManyRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaOneToManyRelationship
- extends AbstractJavaMappingRelationship<JavaOneToManyMapping>
- implements JavaOneToManyRelationship2_0
-{
- protected final JavaMappedByRelationshipStrategy mappedByStrategy;
-
- protected final JavaJoinTableRelationshipStrategy joinTableStrategy;
-
- // JPA 2.0 or EclipseLink
- protected final boolean supportsJoinColumnStrategy;
- protected final JavaJoinColumnRelationshipStrategy joinColumnStrategy;
-
-
- public GenericJavaOneToManyRelationship(JavaOneToManyMapping parent, boolean supportsJoinColumnStrategy) {
- super(parent);
- this.mappedByStrategy = this.buildMappedByStrategy();
- this.supportsJoinColumnStrategy = supportsJoinColumnStrategy;
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
-
- // build join table strategy last since it's dependent on the other strategies
- this.joinTableStrategy = this.buildJoinTableStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mappedByStrategy.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.mappedByStrategy.update();
- this.joinColumnStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected JavaRelationshipStrategy buildStrategy() {
- if (this.mappedByStrategy.getMappedByAttribute() != null) {
- return this.mappedByStrategy;
- }
- if (this.supportsJoinColumnStrategy) {
- if (this.joinColumnStrategy.hasSpecifiedJoinColumns()) {
- return this.joinColumnStrategy;
- }
- }
- return this.joinTableStrategy;
- }
-
-
- // ********** mapped by strategy **********
-
- public JavaMappedByRelationshipStrategy getMappedByStrategy() {
- return this.mappedByStrategy;
- }
-
- public boolean strategyIsMappedBy() {
- return this.strategy == this.mappedByStrategy;
- }
-
- public final void setStrategyToMappedBy() {
- this.mappedByStrategy.addStrategy();
- this.joinTableStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mapping) {
- String key = mapping.getKey();
- if (key == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY) {
- return true;
- }
- if (this.supportsJoinColumnStrategy) {
- return key == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
- return false;
- }
-
- protected JavaMappedByRelationshipStrategy buildMappedByStrategy() {
- return new GenericJavaMappedByRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public JavaJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public final void setStrategyToJoinTable() {
- // join table is default, so no need to add annotation
- this.mappedByStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return (this.mappedByStrategy.getMappedByAttribute() == null) &&
- ! this.joinColumnStrategy.hasSpecifiedJoinColumns();
- }
-
- protected JavaJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return new GenericJavaMappingJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** join column strategy **********
-
- public JavaJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- this.joinColumnStrategy.addStrategy();
- this.mappedByStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
- protected JavaJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return this.supportsJoinColumnStrategy ?
- new GenericJavaMappingJoinColumnRelationshipStrategy(this, true) : // true = target foreign key
- new NullJavaJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromMappedByRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- newRelationship.initializeFromJoinColumnRelationship(this);
- }
-
- @Override
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- super.initializeFromMappedByRelationship(oldRelationship);
- this.mappedByStrategy.initializeFrom(oldRelationship.getMappedByStrategy());
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- @Override
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- super.initializeFromJoinColumnRelationship(oldRelationship);
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaOneToManyMapping getMapping() {
- return this.getParent();
- }
-
- public OneToManyAnnotation getMappingAnnotation() {
- return this.getMapping().getMappingAnnotation();
- }
-
- public OneToManyAnnotation getMappingAnnotationForUpdate() {
- return this.getMapping().getAnnotationForUpdate();
- }
-
- public boolean isOwner() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public boolean isTargetForeignKey() {
- return this.joinColumnStrategy.isTargetForeignKey();
- }
-
-
- // ********** 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.mappedByStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- result = this.joinTableStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return this.joinColumnStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByStrategy.validate(messages, reporter, astRoot);
- this.joinTableStrategy.validate(messages, reporter, astRoot);
- this.joinColumnStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToOneRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToOneRelationship.java
deleted file mode 100644
index 8ea6e4ef66..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOneToOneRelationship.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaMappingJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.NullJavaJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaOneToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.java.OwnableRelationshipMappingAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaOneToOneRelationship
- extends AbstractJavaMappingRelationship<JavaOneToOneMapping>
- implements JavaOneToOneRelationship2_0
-{
- protected final JavaMappedByRelationshipStrategy mappedByStrategy;
-
- protected final JavaPrimaryKeyJoinColumnRelationshipStrategy primaryKeyJoinColumnStrategy;
-
- // JPA 2.0
- protected final JavaJoinTableRelationshipStrategy joinTableStrategy;
-
- protected final JavaJoinColumnRelationshipStrategy joinColumnStrategy;
-
-
- public GenericJavaOneToOneRelationship(JavaOneToOneMapping parent) {
- super(parent);
- this.mappedByStrategy = this.buildMappedByStrategy();
- this.primaryKeyJoinColumnStrategy = this.buildPrimaryKeyJoinColumnStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mappedByStrategy.synchronizeWithResourceModel();
- this.primaryKeyJoinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.mappedByStrategy.update();
- this.primaryKeyJoinColumnStrategy.update();
- this.joinTableStrategy.update();
- this.joinColumnStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected JavaRelationshipStrategy buildStrategy() {
- if (this.mappedByStrategy.getMappedByAttribute() != null) {
- return this.mappedByStrategy;
- }
- if (this.primaryKeyJoinColumnStrategy.hasPrimaryKeyJoinColumns()) {
- return this.primaryKeyJoinColumnStrategy;
- }
- if (this.isJpa2_0Compatible()) {
- if (this.joinTableStrategy.getJoinTable() != null) {
- return this.joinTableStrategy;
- }
- }
- return this.joinColumnStrategy;
- }
-
-
- // ********** mapped by strategy **********
-
- public JavaMappedByRelationshipStrategy getMappedByStrategy() {
- return this.mappedByStrategy;
- }
-
- public boolean strategyIsMappedBy() {
- return this.strategy == this.mappedByStrategy;
- }
-
- public void setStrategyToMappedBy() {
- this.mappedByStrategy.addStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.primaryKeyJoinColumnStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mapping) {
- return mapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- protected JavaMappedByRelationshipStrategy buildMappedByStrategy() {
- return new GenericJavaMappedByRelationshipStrategy(this);
- }
-
-
- // ********** primary key join column strategy **********
-
- public JavaPrimaryKeyJoinColumnRelationshipStrategy getPrimaryKeyJoinColumnStrategy() {
- return this.primaryKeyJoinColumnStrategy;
- }
-
- public boolean strategyIsPrimaryKeyJoinColumn() {
- return this.strategy == this.primaryKeyJoinColumnStrategy;
- }
-
- public void setStrategyToPrimaryKeyJoinColumn() {
- this.primaryKeyJoinColumnStrategy.addStrategy();
- this.mappedByStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- protected JavaPrimaryKeyJoinColumnRelationshipStrategy buildPrimaryKeyJoinColumnStrategy() {
- return new GenericJavaPrimaryKeyJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public JavaJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public final void setStrategyToJoinTable() {
- this.joinTableStrategy.addStrategy();
- this.mappedByStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.primaryKeyJoinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- protected JavaJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return this.isJpa2_0Compatible() ?
- new GenericJavaMappingJoinTableRelationshipStrategy(this) :
- new NullJavaJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** join column strategy **********
-
- public JavaJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- // join column strategy is the default; so no need to add stuff,
- // just remove all the others
- this.mappedByStrategy.removeStrategy();
- this.primaryKeyJoinColumnStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return (this.mappedByStrategy.getMappedByAttribute() == null) &&
- (this.primaryKeyJoinColumnStrategy.primaryKeyJoinColumnsSize() == 0) &&
- (this.joinTableStrategy.getJoinTable() == null);
- }
-
- protected JavaJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return new GenericJavaMappingJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromMappedByRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- newRelationship.initializeFromJoinColumnRelationship(this);
- // no other pk join column relationships yet
- }
-
- @Override
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- super.initializeFromMappedByRelationship(oldRelationship);
- this.mappedByStrategy.initializeFrom(oldRelationship.getMappedByStrategy());
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- @Override
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- super.initializeFromJoinColumnRelationship(oldRelationship);
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaOneToOneMapping getMapping() {
- return this.getParent();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotation() {
- return this.getMapping().getMappingAnnotation();
- }
-
- public OwnableRelationshipMappingAnnotation getMappingAnnotationForUpdate() {
- return this.getMapping().getAnnotationForUpdate();
- }
-
- public boolean isOwner() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByStrategy.relationshipIsOwnedBy(mapping);
- }
-
-
- // ********** 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.mappedByStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- result = this.primaryKeyJoinColumnStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- result = this.joinTableStrategy.javaCompletionProposals(pos, filter, astRoot);
- if (result != null) {
- return result;
- }
-
- return this.joinColumnStrategy.javaCompletionProposals(pos, filter, astRoot);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) {
- super.validate(messages, reporter, astRoot);
- this.mappedByStrategy.validate(messages, reporter, astRoot);
- this.primaryKeyJoinColumnStrategy.validate(messages, reporter, astRoot);
- this.joinColumnStrategy.validate(messages, reporter, astRoot);
- this.joinTableStrategy.validate(messages, reporter, astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOverrideJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOverrideJoinColumnRelationshipStrategy.java
deleted file mode 100644
index 9190e16939..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaOverrideJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverrideRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn.Owner;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.resource.java.NullJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-
-public class GenericJavaOverrideJoinColumnRelationshipStrategy
- extends AbstractJavaJoinColumnRelationshipStrategy
-{
- public GenericJavaOverrideJoinColumnRelationshipStrategy(JavaOverrideRelationship parent) {
- super(parent);
- }
-
-
- // ********** join column annotations **********
-
- @Override
- protected ListIterator<JoinColumnAnnotation> joinColumnAnnotations() {
- return this.getOverrideAnnotation().joinColumns();
- }
-
- @Override
- protected JoinColumnAnnotation addJoinColumnAnnotation(int index) {
- return this.getOverrideAnnotation().addJoinColumn(index);
- }
-
- @Override
- protected void removeJoinColumnAnnotation(int index) {
- this.getOverrideAnnotation().removeJoinColumn(index);
- }
-
- @Override
- protected void moveJoinColumnAnnotation(int targetIndex, int sourceIndex) {
- this.getOverrideAnnotation().moveJoinColumn(targetIndex, sourceIndex);
- }
-
- @Override
- protected JoinColumnAnnotation buildNullJoinColumnAnnotation() {
- return new NullJoinColumnAnnotation(this.getOverrideAnnotation());
- }
-
- protected AssociationOverrideAnnotation getOverrideAnnotation() {
- return this.getAssociationOverride().getOverrideAnnotation();
- }
-
-
- // ********** misc **********
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isTargetForeignKey() {
- RelationshipMapping relationshipMapping = this.getRelationshipMapping();
- return (relationshipMapping != null) &&
- relationshipMapping.getRelationship().isTargetForeignKey();
- }
-
- public TypeMapping getRelationshipSource() {
- return this.isTargetForeignKey() ?
- this.getRelationshipMapping().getResolvedTargetEntity() :
- this.getAssociationOverrideContainer().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- return this.isTargetForeignKey() ?
- this.getAssociationOverrideContainer().getTypeMapping() :
- this.getRelationshipMappingTargetEntity();
- }
-
- protected TypeMapping getRelationshipMappingTargetEntity() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return (mapping == null) ? null : mapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping target = this.getRelationshipTarget();
- return (target instanceof Entity) ? (Entity) target : null;
- }
-
- @Override
- public RelationshipMapping getRelationshipMapping() {
- return this.getAssociationOverride().getMapping();
- }
-
- protected String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- @Override
- public String getTableName() {
- return this.isTargetForeignKey() ?
- super.getTableName() :
- this.getAssociationOverrideContainer().getDefaultTableName();
- }
-
- @Override
- public Table resolveDbTable(String tableName) {
- return this.isTargetForeignKey() ?
- super.resolveDbTable(tableName) :
- this.getAssociationOverrideContainer().resolveDbTable(tableName);
- }
-
- @Override
- public boolean tableNameIsInvalid(String tableName) {
- return this.isTargetForeignKey() ?
- super.tableNameIsInvalid(tableName) :
- this.getAssociationOverrideContainer().tableNameIsInvalid(tableName);
- }
-
- @Override
- public Iterator<String> candidateTableNames() {
- return this.isTargetForeignKey() ?
- super.candidateTableNames() :
- this.getAssociationOverrideContainer().candidateTableNames();
- }
-
- public String getColumnTableNotValidDescription() {
- return null;
- }
-
- public boolean isOverridable() {
- return false;
- }
-
- protected JavaAssociationOverride getAssociationOverride() {
- return this.getRelationship().getAssociationOverride();
- }
-
- protected JavaAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.getAssociationOverride().getContainer();
- }
-
- @Override
- public JavaOverrideRelationship getRelationship() {
- return (JavaOverrideRelationship) super.getRelationship();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationship().getValidationTextRange(astRoot);
- }
-
-
- // ********** join column owner adapter **********
-
- protected class JoinColumnOwner
- implements JavaJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- public String getDefaultTableName() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getAttributeName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- RelationshipMapping relationshipMapping = GenericJavaOverrideJoinColumnRelationshipStrategy.this.getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.candidateTableNames();
- }
-
- public Table resolveDbTable(String tableName) {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.resolveDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return false;
- }
-
- public int joinColumnsSize() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getValidationTextRange(astRoot);
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return this.getAssociationOverrideContainer().buildColumnValidator(this.getAssociationOverride(), (BaseColumn) column, this, (BaseColumnTextRangeResolver) textRangeResolver);
- }
-
- protected JavaAssociationOverride getAssociationOverride() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getAssociationOverride();
- }
-
- protected JavaAssociationOverrideContainer getAssociationOverrideContainer() {
- return GenericJavaOverrideJoinColumnRelationshipStrategy.this.getAssociationOverrideContainer();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.java
deleted file mode 100644
index a55f54f9b7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.Filter;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.SubIteratorWrapper;
-import org.eclipse.jpt.common.utility.internal.iterators.SuperIteratorWrapper;
-import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaRelationshipMapping;
-import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.OneToOnePrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NestablePrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericJavaPrimaryKeyJoinColumnRelationshipStrategy
- extends AbstractJavaJpaContextNode
- implements JavaPrimaryKeyJoinColumnRelationshipStrategy
-{
- protected final Vector<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns = new Vector<JavaPrimaryKeyJoinColumn>();
- protected final PrimaryKeyJoinColumnContainerAdapter primaryKeyJoinColumnContainerAdapter;
- protected final JavaJoinColumn.Owner primaryKeyJoinColumnOwner;
-
-
- public GenericJavaPrimaryKeyJoinColumnRelationshipStrategy(JavaPrimaryKeyJoinColumnRelationship parent) {
- super(parent);
- this.primaryKeyJoinColumnContainerAdapter = this.buildPrimaryKeyJoinColumnContainerAdapter();
- this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner();
- this.initializePrimaryKeyJoinColumns();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncPrimaryKeyJoinColumns();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getPrimaryKeyJoinColumns());
- }
-
-
- // ********** primary key join columns **********
-
- public ListIterator<JavaPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.getPrimaryKeyJoinColumns().iterator();
- }
-
- public ListIterable<JavaPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<JavaPrimaryKeyJoinColumn>(this.primaryKeyJoinColumns);
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.primaryKeyJoinColumns.size();
- }
-
- public boolean hasPrimaryKeyJoinColumns() {
- return this.primaryKeyJoinColumns.size() != 0;
- }
-
- public JavaPrimaryKeyJoinColumn getPrimaryKeyJoinColumn(int index) {
- return this.primaryKeyJoinColumns.get(index);
- }
-
- public JavaPrimaryKeyJoinColumn addPrimaryKeyJoinColumn() {
- return this.addPrimaryKeyJoinColumn(this.primaryKeyJoinColumns.size());
- }
-
- public JavaPrimaryKeyJoinColumn addPrimaryKeyJoinColumn(int index) {
- PrimaryKeyJoinColumnAnnotation annotation = this.addPrimaryKeyJoinColumnAnnotation(index);
- return this.addPrimaryKeyJoinColumn_(index, annotation);
- }
-
- public void removePrimaryKeyJoinColumn(PrimaryKeyJoinColumn joinColumn) {
- this.removePrimaryKeyJoinColumn(this.primaryKeyJoinColumns.indexOf(joinColumn));
- }
-
- public void removePrimaryKeyJoinColumn(int index) {
- this.removePrimaryKeyJoinColumnAnnotation(index);
- this.removePrimaryKeyJoinColumn_(index);
- }
-
- protected void removePrimaryKeyJoinColumn_(int index) {
- this.removeItemFromList(index, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void movePrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- this.movePrimaryKeyJoinColumnAnnotation(targetIndex, sourceIndex);
- this.moveItemInList(targetIndex, sourceIndex, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- for (PrimaryKeyJoinColumnAnnotation annotation : this.getPrimaryKeyJoinColumnAnnotations()) {
- this.primaryKeyJoinColumns.add(this.buildPrimaryKeyJoinColumn(annotation));
- }
- }
-
- protected void syncPrimaryKeyJoinColumns() {
- ContextContainerTools.synchronizeWithResourceModel(this.primaryKeyJoinColumnContainerAdapter);
- }
-
- protected Iterable<PrimaryKeyJoinColumnAnnotation> getPrimaryKeyJoinColumnAnnotations() {
- return CollectionTools.iterable(this.primaryKeyJoinColumnAnnotations());
- }
-
- protected void movePrimaryKeyJoinColumn_(int index, JavaPrimaryKeyJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected JavaPrimaryKeyJoinColumn addPrimaryKeyJoinColumn_(int index, PrimaryKeyJoinColumnAnnotation pkJoinColumnAnnotation) {
- JavaPrimaryKeyJoinColumn joinColumn = this.buildPrimaryKeyJoinColumn(pkJoinColumnAnnotation);
- this.addItemToList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- return joinColumn;
- }
-
- protected void removePrimaryKeyJoinColumn_(JavaPrimaryKeyJoinColumn joinColumn) {
- this.removePrimaryKeyJoinColumn_(this.primaryKeyJoinColumns.indexOf(joinColumn));
- }
-
- protected PrimaryKeyJoinColumnContainerAdapter buildPrimaryKeyJoinColumnContainerAdapter() {
- return new PrimaryKeyJoinColumnContainerAdapter();
- }
-
- /**
- * primary key join column container adapter
- */
- protected class PrimaryKeyJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<JavaPrimaryKeyJoinColumn, PrimaryKeyJoinColumnAnnotation>
- {
- public Iterable<JavaPrimaryKeyJoinColumn> getContextElements() {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.getPrimaryKeyJoinColumns();
- }
- public Iterable<PrimaryKeyJoinColumnAnnotation> getResourceElements() {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.getPrimaryKeyJoinColumnAnnotations();
- }
- public PrimaryKeyJoinColumnAnnotation getResourceElement(JavaPrimaryKeyJoinColumn contextElement) {
- return contextElement.getColumnAnnotation();
- }
- public void moveContextElement(int index, JavaPrimaryKeyJoinColumn element) {
- GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.movePrimaryKeyJoinColumn_(index, element);
- }
- public void addContextElement(int index, PrimaryKeyJoinColumnAnnotation resourceElement) {
- GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.addPrimaryKeyJoinColumn_(index, resourceElement);
- }
- public void removeContextElement(JavaPrimaryKeyJoinColumn element) {
- GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.removePrimaryKeyJoinColumn_(element);
- }
- }
-
- protected JavaJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected JavaPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(PrimaryKeyJoinColumnAnnotation annotation) {
- return this.getJpaFactory().buildJavaPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, annotation);
- }
-
-
- // ********** primary key join column annotations **********
-
- protected Iterator<PrimaryKeyJoinColumnAnnotation> primaryKeyJoinColumnAnnotations() {
- return new SuperIteratorWrapper<PrimaryKeyJoinColumnAnnotation>(this.nestablePrimaryKeyJoinColumnAnnotations());
- }
-
- protected Iterator<NestablePrimaryKeyJoinColumnAnnotation> nestablePrimaryKeyJoinColumnAnnotations() {
- return new SubIteratorWrapper<NestableAnnotation, NestablePrimaryKeyJoinColumnAnnotation>(this.nestablePrimaryKeyJoinColumnAnnotations_());
- }
-
- protected Iterator<NestableAnnotation> nestablePrimaryKeyJoinColumnAnnotations_() {
- return this.getResourcePersistentAttribute().annotations(PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected PrimaryKeyJoinColumnAnnotation addPrimaryKeyJoinColumnAnnotation(int index) {
- return (PrimaryKeyJoinColumnAnnotation) this.getResourcePersistentAttribute().addAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void removePrimaryKeyJoinColumnAnnotation(int index) {
- this.getResourcePersistentAttribute().removeAnnotation(index, PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
- protected void movePrimaryKeyJoinColumnAnnotation(int targetIndex, int sourceIndex) {
- this.getResourcePersistentAttribute().moveAnnotation(targetIndex, sourceIndex, PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME);
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaPrimaryKeyJoinColumnRelationship getParent() {
- return (JavaPrimaryKeyJoinColumnRelationship) super.getParent();
- }
-
- public JavaPrimaryKeyJoinColumnRelationship getRelationship() {
- return this.getParent();
- }
-
- protected JavaRelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- protected JavaResourcePersistentAttribute getResourcePersistentAttribute() {
- return this.getRelationship().getMapping().getResourcePersistentAttribute();
- }
-
- public String getTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public boolean isOverridable() {
- return false;
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- protected TypeMapping getTypeMapping() {
- return this.getRelationshipMapping().getTypeMapping();
- }
-
- public void addStrategy() {
- if (this.primaryKeyJoinColumns.size() == 0) {
- this.addPrimaryKeyJoinColumn();
- }
- }
-
- public void removeStrategy() {
- for (int i = this.primaryKeyJoinColumns.size(); i-- > 0; ) {
- this.removePrimaryKeyJoinColumn(i);
- }
- }
-
-
- // ********** 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 : this.getPrimaryKeyJoinColumns()) {
- 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 (JavaPrimaryKeyJoinColumn pkJoinColumn : this.getPrimaryKeyJoinColumns()) {
- pkJoinColumn.validate(messages, reporter, astRoot);
- }
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getRelationship().getValidationTextRange(astRoot);
- }
-
-
- // ********** join column owner **********
-
- protected class PrimaryKeyJoinColumnOwner
- implements JavaJoinColumn.Owner
- {
- protected PrimaryKeyJoinColumnOwner() {
- super();
- }
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public Entity getRelationshipTarget() {
- return this.getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- return this.getRelationshipMapping().getName();
- }
-
- protected PersistentAttribute getPersistentAttribute() {
- return this.getRelationshipMapping().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- /**
- * the join column can be on a secondary table
- */
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.getTypeMapping();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- Entity targetEntity = this.getRelationshipTarget();
- return (targetEntity == null) ? null : targetEntity.getPrimaryDbTable();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return false;
- }
-
- public String getDefaultColumnName() {
- return null;
- }
-
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.getValidationTextRange(astRoot);
- }
-
- public int joinColumnsSize() {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.primaryKeyJoinColumnsSize();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new OneToOnePrimaryKeyJoinColumnValidator(this.getPersistentAttribute(), (BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
-
- protected JavaRelationshipMapping getRelationshipMapping() {
- return GenericJavaPrimaryKeyJoinColumnRelationshipStrategy.this.getRelationshipMapping();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaVirtualJoinTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaVirtualJoinTable.java
deleted file mode 100644
index f27ca4df39..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaVirtualJoinTable.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.java.JavaVirtualRelationship;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-
-/**
- * Java virtual join table
- */
-public class GenericJavaVirtualJoinTable
- extends AbstractJavaVirtualReferenceTable<JoinTable>
- implements JavaVirtualJoinTable
-{
- protected final JoinTable overriddenTable;
-
- protected final Vector<JavaVirtualJoinColumn> specifiedInverseJoinColumns = new Vector<JavaVirtualJoinColumn>();
- protected final SpecifiedInverseJoinColumnContainerAdapter specifiedInverseJoinColumnContainerAdapter = new SpecifiedInverseJoinColumnContainerAdapter();
- protected final ReadOnlyJoinColumn.Owner inverseJoinColumnOwner;
-
- protected JavaVirtualJoinColumn defaultInverseJoinColumn;
-
-
- public GenericJavaVirtualJoinTable(JavaVirtualJoinTableRelationshipStrategy parent, JoinTable overriddenTable) {
- super(parent);
- this.overriddenTable = overriddenTable;
- this.inverseJoinColumnOwner = this.buildInverseJoinColumnOwner();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateSpecifiedInverseJoinColumns();
- this.updateDefaultInverseJoinColumn();
- }
-
-
- // ********** table **********
-
- @Override
- public JoinTable getOverriddenTable() {
- return this.overriddenTable;
- }
-
-
- // ********** inverse join columns **********
-
- public ListIterator<JavaVirtualJoinColumn> inverseJoinColumns() {
- return this.getInverseJoinColumns().iterator();
- }
-
- protected ListIterable<JavaVirtualJoinColumn> getInverseJoinColumns() {
- return this.hasSpecifiedInverseJoinColumns() ? this.getSpecifiedInverseJoinColumns() : this.getDefaultInverseJoinColumns();
- }
-
- public int inverseJoinColumnsSize() {
- return this.hasSpecifiedInverseJoinColumns() ? this.specifiedInverseJoinColumnsSize() : this.getDefaultInverseJoinColumnsSize();
- }
-
-
- // ********** inverse specified join columns **********
-
- public ListIterator<JavaVirtualJoinColumn> specifiedInverseJoinColumns() {
- return this.getSpecifiedInverseJoinColumns().iterator();
- }
-
- protected ListIterable<JavaVirtualJoinColumn> getSpecifiedInverseJoinColumns() {
- return new LiveCloneListIterable<JavaVirtualJoinColumn>(this.specifiedInverseJoinColumns);
- }
-
- public int specifiedInverseJoinColumnsSize() {
- return this.specifiedInverseJoinColumns.size();
- }
-
- public boolean hasSpecifiedInverseJoinColumns() {
- return this.specifiedInverseJoinColumns.size() != 0;
- }
-
- public JavaVirtualJoinColumn getSpecifiedInverseJoinColumn(int index) {
- return this.specifiedInverseJoinColumns.get(index);
- }
-
- protected void updateSpecifiedInverseJoinColumns() {
- ContextContainerTools.update(this.specifiedInverseJoinColumnContainerAdapter);
- }
-
- protected Iterable<JoinColumn> getOverriddenInverseJoinColumns() {
- return CollectionTools.iterable(this.getOverriddenTable().specifiedInverseJoinColumns());
- }
-
- protected void moveSpecifiedInverseJoinColumn(int index, JavaVirtualJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedInverseJoinColumns, SPECIFIED_INVERSE_JOIN_COLUMNS_LIST);
- }
-
- protected JavaVirtualJoinColumn addSpecifiedInverseJoinColumn(int index, JoinColumn joinColumn) {
- JavaVirtualJoinColumn virtualJoinColumn = this.buildInverseJoinColumn(joinColumn);
- this.addItemToList(index, virtualJoinColumn, this.specifiedInverseJoinColumns, SPECIFIED_INVERSE_JOIN_COLUMNS_LIST);
- return virtualJoinColumn;
- }
-
- protected void removeSpecifiedInverseJoinColumn(JavaVirtualJoinColumn joinColumn) {
- this.removeItemFromList(joinColumn, this.specifiedInverseJoinColumns, SPECIFIED_INVERSE_JOIN_COLUMNS_LIST);
- }
-
- /**
- * specified inverse join column container adapter
- */
- protected class SpecifiedInverseJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<JavaVirtualJoinColumn, JoinColumn>
- {
- public Iterable<JavaVirtualJoinColumn> getContextElements() {
- return GenericJavaVirtualJoinTable.this.getSpecifiedInverseJoinColumns();
- }
- public Iterable<JoinColumn> getResourceElements() {
- return GenericJavaVirtualJoinTable.this.getOverriddenInverseJoinColumns();
- }
- public JoinColumn getResourceElement(JavaVirtualJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, JavaVirtualJoinColumn element) {
- GenericJavaVirtualJoinTable.this.moveSpecifiedInverseJoinColumn(index, element);
- }
- public void addContextElement(int index, JoinColumn element) {
- GenericJavaVirtualJoinTable.this.addSpecifiedInverseJoinColumn(index, element);
- }
- public void removeContextElement(JavaVirtualJoinColumn element) {
- GenericJavaVirtualJoinTable.this.removeSpecifiedInverseJoinColumn(element);
- }
- }
-
-
- // ********** default inverse join column **********
-
- public JavaVirtualJoinColumn getDefaultInverseJoinColumn() {
- return this.defaultInverseJoinColumn;
- }
-
- protected void setDefaultInverseJoinColumn(JavaVirtualJoinColumn joinColumn) {
- JavaVirtualJoinColumn old = this.defaultInverseJoinColumn;
- this.defaultInverseJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_INVERSE_JOIN_COLUMN, old, joinColumn);
- }
-
- protected ListIterable<JavaVirtualJoinColumn> getDefaultInverseJoinColumns() {
- return (this.defaultInverseJoinColumn != null) ?
- new SingleElementListIterable<JavaVirtualJoinColumn>(this.defaultInverseJoinColumn) :
- EmptyListIterable.<JavaVirtualJoinColumn>instance();
- }
-
- protected int getDefaultInverseJoinColumnsSize() {
- return (this.defaultInverseJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultInverseJoinColumn() {
- if (this.buildsDefaultInverseJoinColumn()) {
- if (this.defaultInverseJoinColumn == null) {
- this.setDefaultInverseJoinColumn(this.buildInverseJoinColumn(this.getOverriddenTable().getDefaultInverseJoinColumn()));
- } else {
- this.defaultInverseJoinColumn.update();
- }
- } else {
- this.setDefaultInverseJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultInverseJoinColumn() {
- return ! this.hasSpecifiedInverseJoinColumns();
- }
-
-
- // ********** misc **********
-
- @Override
- public JavaVirtualJoinTableRelationshipStrategy getParent() {
- return (JavaVirtualJoinTableRelationshipStrategy) super.getParent();
- }
-
- protected JavaVirtualJoinTableRelationshipStrategy getJoinStrategy() {
- return this.getParent();
- }
-
- @Override
- protected ReadOnlyJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- protected ReadOnlyJoinColumn.Owner buildInverseJoinColumnOwner() {
- return new InverseJoinColumnOwner();
- }
-
- protected JavaVirtualJoinColumn buildInverseJoinColumn(JoinColumn joinColumn) {
- return this.buildJoinColumn(this.inverseJoinColumnOwner, joinColumn);
- }
-
- @Override
- protected String buildDefaultName() {
- return this.getJoinStrategy().getJoinTableDefaultName();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getJoinStrategy().getRelationship().getMapping();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return this.getRelationshipMapping().getPersistentAttribute();
- }
-
-
- // ********** join column owners **********
-
- /**
- * just a little common behavior
- */
- protected abstract class AbstractJoinColumnOwner
- implements ReadOnlyJoinColumn.Owner
- {
- protected AbstractJoinColumnOwner() {
- super();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getRelationship().getTypeMapping();
- }
-
- /**
- * by default, the join column is, obviously, in the join table;
- * not sure whether it can be anywhere else...
- */
- public String getDefaultTableName() {
- return GenericJavaVirtualJoinTable.this.getName();
- }
-
- /**
- * @see MappingTools#buildJoinColumnDefaultName(org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn, org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn.Owner)
- */
- public String getDefaultColumnName() {
- throw new UnsupportedOperationException();
- }
-
- protected JavaVirtualRelationship getRelationship() {
- return GenericJavaVirtualJoinTable.this.getJoinStrategy().getRelationship();
- }
- }
-
-
- /**
- * owner for "back-pointer" join columns;
- * these point at the source/owning entity
- */
- protected class JoinColumnOwner
- extends AbstractJoinColumnOwner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- public Entity getRelationshipTarget() {
- return this.getRelationship().getEntity();
- }
-
- public String getAttributeName() {
- return MappingTools.getTargetAttributeName(GenericJavaVirtualJoinTable.this.getRelationshipMapping());
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericJavaVirtualJoinTable.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericJavaVirtualJoinTable.this.joinColumnsSize();
- }
- }
-
-
- /**
- * owner for "forward-pointer" join columns;
- * these point at the target/inverse entity
- */
- protected class InverseJoinColumnOwner
- extends AbstractJoinColumnOwner
- {
- protected InverseJoinColumnOwner() {
- super();
- }
-
- public Entity getRelationshipTarget() {
- RelationshipMapping relationshipMapping = GenericJavaVirtualJoinTable.this.getRelationshipMapping();
- return (relationshipMapping == null) ? null : relationshipMapping.getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- RelationshipMapping relationshipMapping = GenericJavaVirtualJoinTable.this.getRelationshipMapping();
- return (relationshipMapping == null) ? null : relationshipMapping.getName();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericJavaVirtualJoinTable.this.defaultInverseJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericJavaVirtualJoinTable.this.inverseJoinColumnsSize();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaAttributeMappingDefinitionWrapper.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaAttributeMappingDefinitionWrapper.java
deleted file mode 100644
index 7f038b7ecf..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaAttributeMappingDefinitionWrapper.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-
-/**
- * Simplify delegation to another definition.
- * A subclass need only implement {@link #getDelegate()} and override the
- * appropriate method(s).
- */
-public abstract class JavaAttributeMappingDefinitionWrapper
- implements JavaAttributeMappingDefinition
-{
- protected JavaAttributeMappingDefinitionWrapper() {
- super();
- }
-
- protected abstract JavaAttributeMappingDefinition getDelegate();
-
- public String getKey() {
- return this.getDelegate().getKey();
- }
-
- public String getAnnotationName() {
- return this.getDelegate().getAnnotationName();
- }
-
- public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return this.getDelegate().isSpecified(persistentAttribute);
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return this.getDelegate().getSupportingAnnotationNames();
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return this.getDelegate().buildMapping(persistentAttribute, factory);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBaseColumnTextRangeResolver.java
deleted file mode 100644
index 951094aed6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaBaseColumn;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBasicMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBasicMappingDefinition.java
deleted file mode 100644
index 123325a218..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaBasicMappingDefinition.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.BasicAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EnumeratedAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.LobAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
-
-public class JavaBasicMappingDefinition
- implements DefaultJavaAttributeMappingDefinition
-{
- // singleton
- private static final DefaultJavaAttributeMappingDefinition INSTANCE = new JavaBasicMappingDefinition();
-
- /**
- * Return the singleton.
- */
- public static DefaultJavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- ColumnAnnotation.ANNOTATION_NAME,
- LobAnnotation.ANNOTATION_NAME,
- TemporalAnnotation.ANNOTATION_NAME,
- EnumeratedAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaBasicMapping(persistentAttribute);
- }
-
- public boolean isDefault(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.typeIsBasic();
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddableDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddableDefinition.java
deleted file mode 100644
index db5e442034..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddableDefinition.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.EmbeddableAnnotation;
-
-public class JavaEmbeddableDefinition
- implements JavaTypeMappingDefinition
-{
- // 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 Iterable<String> getSupportingAnnotationNames() {
- return EmptyIterable.instance();
- }
-
- public JavaEmbeddable buildMapping(JavaPersistentType persistentType, Annotation mappingAnnotation, JpaFactory factory) {
- return factory.buildJavaEmbeddable(persistentType, (EmbeddableAnnotation) mappingAnnotation);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java
deleted file mode 100644
index 86d3c1100d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedIdMappingDefinition.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EmbeddedIdAnnotation;
-
-public class JavaEmbeddedIdMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- AttributeOverrideAnnotation.ANNOTATION_NAME,
- AttributeOverridesAnnotation.ANNOTATION_NAME,
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaEmbeddedIdMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedMappingDefinition.java
deleted file mode 100644
index 3a91dc7e71..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEmbeddedMappingDefinition.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.DefaultJavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EmbeddedAnnotation;
-
-public class JavaEmbeddedMappingDefinition
- implements DefaultJavaAttributeMappingDefinition
-{
- // singleton
- private static final DefaultJavaAttributeMappingDefinition INSTANCE = new JavaEmbeddedMappingDefinition();
-
- /**
- * Return the singleton.
- */
- public static DefaultJavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- AttributeOverrideAnnotation.ANNOTATION_NAME,
- AttributeOverridesAnnotation.ANNOTATION_NAME,
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaEmbeddedMapping(persistentAttribute);
- }
-
- public boolean isDefault(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getEmbeddable() != null;
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityDefinition.java
deleted file mode 100644
index 3d604b334f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityDefinition.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.AssociationOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AssociationOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverrideAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.AttributeOverridesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.DiscriminatorValueAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.EntityAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.InheritanceAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueriesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NamedNativeQueryAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NamedQueriesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.SecondaryTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.SecondaryTablesAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
-
-public class JavaEntityDefinition
- implements JavaTypeMappingDefinition
-{
- // 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 Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- TableAnnotation.ANNOTATION_NAME,
- SecondaryTableAnnotation.ANNOTATION_NAME,
- SecondaryTablesAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME,
- IdClassAnnotation.ANNOTATION_NAME,
- InheritanceAnnotation.ANNOTATION_NAME,
- DiscriminatorValueAnnotation.ANNOTATION_NAME,
- DiscriminatorColumnAnnotation.ANNOTATION_NAME,
- SequenceGeneratorAnnotation.ANNOTATION_NAME,
- TableGeneratorAnnotation.ANNOTATION_NAME,
- NamedQueryAnnotation.ANNOTATION_NAME,
- NamedQueriesAnnotation.ANNOTATION_NAME,
- NamedNativeQueryAnnotation.ANNOTATION_NAME,
- NamedNativeQueriesAnnotation.ANNOTATION_NAME,
- 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,
- AttributeOverrideAnnotation.ANNOTATION_NAME,
- AttributeOverridesAnnotation.ANNOTATION_NAME,
- AssociationOverrideAnnotation.ANNOTATION_NAME,
- AssociationOverridesAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaEntity buildMapping(JavaPersistentType persistentType, Annotation mappingAnnotation, JpaFactory factory) {
- return factory.buildJavaEntity(persistentType, (EntityAnnotation) mappingAnnotation);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaEntityTextRangeResolver.java
deleted file mode 100644
index af74224308..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.internal.context.EntityTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaIdMappingDefinition.java
deleted file mode 100644
index 6ba589476b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaIdMappingDefinition.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.GeneratedValueAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.SequenceGeneratorAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TableGeneratorAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
-
-public class JavaIdMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition INSTANCE = new JavaIdMappingDefinition();
-
- /**
- * Return the singleton.
- */
- public static JavaAttributeMappingDefinition instance() {
- return INSTANCE;
- }
-
-
- /**
- * Enforce singleton usage
- */
- private JavaIdMappingDefinition() {
- super();
- }
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public String getAnnotationName() {
- return IdAnnotation.ANNOTATION_NAME;
- }
-
- public boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- ColumnAnnotation.ANNOTATION_NAME,
- GeneratedValueAnnotation.ANNOTATION_NAME,
- TemporalAnnotation.ANNOTATION_NAME,
- TableGeneratorAnnotation.ANNOTATION_NAME,
- SequenceGeneratorAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaIdMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaJoinColumnTextRangeResolver.java
deleted file mode 100644
index e715135955..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-
-public class JavaJoinColumnTextRangeResolver
- extends JavaNamedColumnTextRangeResolver
- implements 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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToManyMappingDefinition.java
deleted file mode 100644
index 12655a9a88..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToManyMappingDefinition.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
-
-public class JavaManyToManyMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JoinTableAnnotation.ANNOTATION_NAME,
- MapKeyAnnotation.ANNOTATION_NAME,
- OrderByAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaManyToManyMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToOneMappingDefinition.java
deleted file mode 100644
index f4c48d6b44..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaManyToOneMappingDefinition.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.ManyToOneAnnotation;
-
-public class JavaManyToOneMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JoinTableAnnotation.ANNOTATION_NAME,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaManyToOneMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassDefinition.java
deleted file mode 100644
index 33ba199c08..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassDefinition.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.IdClassAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JPA;
-import org.eclipse.jpt.jpa.core.resource.java.MappedSuperclassAnnotation;
-
-public class JavaMappedSuperclassDefinition
- implements JavaTypeMappingDefinition
-{
- // 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 Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- IdClassAnnotation.ANNOTATION_NAME,
- 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
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaMappedSuperclass buildMapping(JavaPersistentType persistentType, Annotation mappingAnnotation, JpaFactory factory) {
- return factory.buildJavaMappedSuperclass(persistentType, (MappedSuperclassAnnotation) mappingAnnotation);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaMappedSuperclassTextRangeResolver.java
deleted file mode 100644
index c9319716ea..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNamedColumnTextRangeResolver.java
deleted file mode 100644
index cab6e08e67..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaNamedColumn;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNullTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNullTypeMapping.java
deleted file mode 100644
index b48a3deef0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaNullTypeMapping.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * Java null type mapping
- */
-public class JavaNullTypeMapping
- extends AbstractJavaTypeMapping<Annotation>
-{
- public JavaNullTypeMapping(JavaPersistentType parent) {
- super(parent, null);
- }
-
- public String getKey() {
- return MappingKeys.NULL_TYPE_MAPPING_KEY;
- }
-
- public JavaPersistentType getIdClass() {
- return null;
- }
-
- public boolean isMapped() {
- return false;
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
-
- // ********** validation **********
-
- /**
- * 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 boolean validatesAgainstDatabase() {
- return false;
- }
-
- @Override
- public TextRange getValidationTextRange(CompilationUnit astRoot) {
- return this.getPersistentType().getValidationTextRange(astRoot);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToManyMappingDefinition.java
deleted file mode 100644
index 4af1e38043..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToManyMappingDefinition.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.MapKeyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToManyAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OrderByAnnotation;
-
-public class JavaOneToManyMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JoinTableAnnotation.ANNOTATION_NAME,
- MapKeyAnnotation.ANNOTATION_NAME,
- OrderByAnnotation.ANNOTATION_NAME,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaOneToManyMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToOneMappingDefinition.java
deleted file mode 100644
index 727a1f3470..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOneToOneMappingDefinition.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinColumnsAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.JoinTableAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.OneToOneAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.PrimaryKeyJoinColumnsAnnotation;
-
-public class JavaOneToOneMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- JoinTableAnnotation.ANNOTATION_NAME,
- JoinColumnAnnotation.ANNOTATION_NAME,
- JoinColumnsAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnAnnotation.ANNOTATION_NAME,
- PrimaryKeyJoinColumnsAnnotation.ANNOTATION_NAME
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaOneToOneMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaOverrideTextRangeResolver.java
deleted file mode 100644
index 7dcd7ce470..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaOverride;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPersistentAttributeTextRangeResolver.java
deleted file mode 100644
index 83fe6f95ca..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.java
deleted file mode 100644
index 261f522f4a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaPrimaryKeyJoinColumnTextRangeResolver.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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTableTextRangeResolver.java
deleted file mode 100644
index 2f431635bb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaTable;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-
-public class JavaTableTextRangeResolver
- implements TableTextRangeResolver
-{
- protected final JavaTable javaTable;
-
- protected final CompilationUnit astRoot;
-
- public JavaTableTextRangeResolver(JavaTable javaTable, CompilationUnit astRoot) {
- this.javaTable = javaTable;
- this.astRoot = astRoot;
- }
-
- protected JavaTable 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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTransientMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTransientMappingDefinition.java
deleted file mode 100644
index 4618a9ec32..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTransientMappingDefinition.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.TransientAnnotation;
-
-public class JavaTransientMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return EmptyIterable.instance();
- }
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaTransientMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaTypeMappingTextRangeResolver.java
deleted file mode 100644
index 174e6b2b7a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.java;
-
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaVersionMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaVersionMappingDefinition.java
deleted file mode 100644
index 826bc5763a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/JavaVersionMappingDefinition.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.java;
-
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.jpa.core.JpaFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.ColumnAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.TemporalAnnotation;
-import org.eclipse.jpt.jpa.core.resource.java.VersionAnnotation;
-
-public class JavaVersionMappingDefinition
- implements JavaAttributeMappingDefinition
-{
- // singleton
- private static final JavaAttributeMappingDefinition 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 boolean isSpecified(JavaPersistentAttribute persistentAttribute) {
- return persistentAttribute.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()) != null;
- }
-
- public Iterable<String> getSupportingAnnotationNames() {
- return SUPPORTING_ANNOTATION_NAMES;
- }
-
- private static final String[] SUPPORTING_ANNOTATION_NAMES_ARRAY = new String[] {
- ColumnAnnotation.ANNOTATION_NAME,
- TemporalAnnotation.ANNOTATION_NAME,
- };
- private static final Iterable<String> SUPPORTING_ANNOTATION_NAMES = new ArrayIterable<String>(SUPPORTING_ANNOTATION_NAMES_ARRAY);
-
- public JavaAttributeMapping buildMapping(JavaPersistentAttribute persistentAttribute, JpaFactory factory) {
- return factory.buildJavaVersionMapping(persistentAttribute);
- }
-
- @Override
- public String toString() {
- return this.getClass().getSimpleName();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
deleted file mode 100644
index 655dffc7a2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java
+++ /dev/null
@@ -1,972 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Comparator;
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.jpa.core.context.orm.OrmStructureNodes;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-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_; // "package" is a Java keyword
-
- protected AccessType specifiedAccess;
- protected AccessType defaultAccess;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected final OrmPersistenceUnitMetadata persistenceUnitMetadata;
-
- protected final Vector<OrmPersistentType> persistentTypes = new Vector<OrmPersistentType>();
- protected final PersistentTypeContainerAdapter persistentTypeContainerAdapter = new PersistentTypeContainerAdapter();
-
- protected final Vector<OrmSequenceGenerator> sequenceGenerators = new Vector<OrmSequenceGenerator>();
- protected final SequenceGeneratorContainerAdapter sequenceGeneratorContainerAdapter = new SequenceGeneratorContainerAdapter();
-
- protected final Vector<OrmTableGenerator> tableGenerators = new Vector<OrmTableGenerator>();
- protected final TableGeneratorContainerAdapter tableGeneratorContainerAdapter = new TableGeneratorContainerAdapter();
-
- protected final OrmQueryContainer queryContainer;
-
-
- protected AbstractEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) {
- super(parent);
- this.xmlEntityMappings = xmlEntityMappings;
-
- this.description = this.xmlEntityMappings.getDescription();
- this.package_ = this.xmlEntityMappings.getPackage();
-
- this.specifiedAccess = this.buildSpecifiedAccess();
- this.specifiedCatalog = this.xmlEntityMappings.getCatalog();
- this.specifiedSchema = this.xmlEntityMappings.getSchema();
-
- this.persistenceUnitMetadata = this.buildPersistenceUnitMetadata();
-
- this.initializePersistentTypes();
- this.initializeSequenceGenerators();
- this.initializeTableGenerators();
-
- this.queryContainer = this.buildQueryContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
-
- this.setDescription_(this.xmlEntityMappings.getDescription());
- this.setPackage_(this.xmlEntityMappings.getPackage());
-
- this.setSpecifiedAccess_(this.buildSpecifiedAccess());
- this.setSpecifiedCatalog_(this.xmlEntityMappings.getCatalog());
- this.setSpecifiedSchema_(this.xmlEntityMappings.getSchema());
-
- this.persistenceUnitMetadata.synchronizeWithResourceModel();
-
- this.syncPersistentTypes();
- this.syncSequenceGenerators();
- this.syncTableGenerators();
-
- this.queryContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
-
- this.setDefaultAccess(this.buildDefaultAccess());
- this.setDefaultCatalog(this.buildDefaultCatalog());
- this.setDefaultSchema(this.buildDefaultSchema());
-
- this.persistenceUnitMetadata.update();
-
- this.updateNodes(this.getPersistentTypes());
- this.updateNodes(this.getSequenceGenerators());
- this.updateNodes(this.getTableGenerators());
-
- this.queryContainer.update();
- }
-
-
- // ********** overrides **********
-
- @Override
- public OrmXml getParent() {
- return (OrmXml) super.getParent();
- }
-
- // TODO bjv add to interface
- public OrmXml getOrmXml() {
- return this.getParent();
- }
-
- @Override
- public EntityMappings getMappingFileRoot() {
- return this;
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return OrmStructureNodes.ENTITY_MAPPINGS_ID;
- }
-
- public JpaStructureNode getStructureNode(int textOffset) {
- for (OrmPersistentType persistentType: this.getPersistentTypes()) {
- if (persistentType.contains(textOffset)) {
- return persistentType.getStructureNode(textOffset);
- }
- }
- return this;
- }
-
- public TextRange getSelectionTextRange() {
- return this.xmlEntityMappings.getSelectionTextRange();
- }
-
- public void dispose() {
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- ormPersistentType.dispose();
- }
- }
-
-
- // ********** PersistentType.Owner implementation **********
-
- public AccessType getOverridePersistentTypeAccess() {
- return this.isXmlMappingMetadataComplete() ? this.specifiedAccess : null;
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- return this.getAccess();
- }
-
- public String getDefaultPersistentTypePackage() {
- return this.getPackage();
- }
-
- protected boolean isXmlMappingMetadataComplete() {
- return this.getPersistenceUnit().isXmlMappingMetadataComplete();
- }
-
-
- // ********** persistence unit metadata **********
-
- public OrmPersistenceUnitMetadata getPersistenceUnitMetadata() {
- return this.persistenceUnitMetadata;
- }
-
- protected OrmPersistenceUnitMetadata buildPersistenceUnitMetadata() {
- return this.getContextNodeFactory().buildOrmPersistenceUnitMetadata(this);
- }
-
-
- // ********** misc **********
-
- public XmlEntityMappings getXmlEntityMappings() {
- return this.xmlEntityMappings;
- }
-
- public String getVersion() {
- return this.xmlEntityMappings.getVersion();
- }
-
- public void changeMapping(OrmPersistentType ormPersistentType, OrmTypeMapping oldMapping, OrmTypeMapping newMapping) {
- AccessType savedAccess = ormPersistentType.getSpecifiedAccess();
- int sourceIndex = this.persistentTypes.indexOf(ormPersistentType);
- this.persistentTypes.remove(sourceIndex);
- oldMapping.removeXmlTypeMappingFrom(this.xmlEntityMappings);
- int targetIndex = this.calculateInsertionIndex(ormPersistentType);
- this.persistentTypes.add(targetIndex, ormPersistentType);
- newMapping.addXmlTypeMappingTo(this.xmlEntityMappings);
-
- newMapping.initializeFrom(oldMapping);
- //not sure where else to put this, need to set the access on the resource model
- ormPersistentType.setSpecifiedAccess(savedAccess);
- this.fireItemMoved(PERSISTENT_TYPES_LIST, targetIndex, sourceIndex);
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.xmlEntityMappings.getValidationTextRange();
- return (textRange != null) ? textRange : this.getOrmXml().getValidationTextRange();
- }
-
- public boolean containsOffset(int textOffset) {
- return (this.xmlEntityMappings != null) && this.xmlEntityMappings.containsOffset(textOffset);
- }
-
-
- // ********** description **********
-
- public String getDescription() {
- return this.description;
- }
-
- public void setDescription(String description) {
- this.setDescription_(description);
- this.xmlEntityMappings.setDescription(description);
- }
-
- protected void setDescription_(String description) {
- String old = this.description;
- this.description = description;
- this.firePropertyChanged(DESCRIPTION_PROPERTY, old, description);
- }
-
-
- // ********** package **********
-
- public String getPackage() {
- return this.package_;
- }
-
- public void setPackage(String package_) {
- this.setPackage_(package_);
- this.xmlEntityMappings.setPackage(package_);
- }
-
- /**
- * TODO If the package changes, we should probably clear out all resolved
- * references to persistent types:<ul>
- * <li>{@link OrmIdClassReference#getIdClass()}
- * <li>{@link OrmPersistentType#getJavaPersistentType()}
- * </ul>
- */
- protected void setPackage_(String package_) {
- String old = this.package_;
- this.package_ = package_;
- this.firePropertyChanged(PACKAGE_PROPERTY, old, package_);
- }
-
-
- // ********** access **********
-
- public AccessType getAccess() {
- return (this.specifiedAccess != null) ? this.specifiedAccess : this.defaultAccess;
- }
-
- public AccessType getSpecifiedAccess() {
- return this.specifiedAccess;
- }
-
- public void setSpecifiedAccess(AccessType access) {
- this.setSpecifiedAccess_(access);
- this.xmlEntityMappings.setAccess(AccessType.toOrmResourceModel(access));
- }
-
- protected void setSpecifiedAccess_(AccessType access) {
- AccessType old = this.specifiedAccess;
- this.specifiedAccess = access;
- this.firePropertyChanged(SPECIFIED_ACCESS_PROPERTY, old, access);
- }
-
- protected AccessType buildSpecifiedAccess() {
- return AccessType.fromOrmResourceModel(this.xmlEntityMappings.getAccess());
- }
-
- 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);
- }
-
- protected AccessType buildDefaultAccess() {
- return this.getPersistenceUnit().getDefaultAccess();
- }
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- this.setSpecifiedCatalog_(catalog);
- this.xmlEntityMappings.setCatalog(catalog);
- }
-
- protected void setSpecifiedCatalog_(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- protected String buildDefaultCatalog() {
- return this.getPersistenceUnit().getDefaultCatalog();
- }
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em>
- * catalog), then the database probably does not support catalogs.
- */
- public Catalog getDbCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) ? null : this.resolveDbCatalog(catalog);
- }
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- this.setSpecifiedSchema_(schema);
- this.xmlEntityMappings.setSchema(schema);
- }
-
- protected void setSpecifiedSchema_(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- protected String buildDefaultSchema() {
- return this.getPersistenceUnit().getDefaultSchema();
- }
-
- public Schema getDbSchema() {
- SchemaContainer dbSchemaContainer = this.getDbSchemaContainer();
- return (dbSchemaContainer == null) ? null : dbSchemaContainer.getSchemaForIdentifier(this.getSchema());
- }
-
-
- // ********** schema container **********
-
- /**
- * If we don't have a catalog (i.e. we don't even have a <em>default</em> catalog),
- * then the database probably does not support catalogs; and we need to
- * get the schema directly from the database.
- */
- public SchemaContainer getDbSchemaContainer() {
- String catalog = this.getCatalog();
- return (catalog != null) ? this.resolveDbCatalog(catalog) : this.getDatabase();
- }
-
-
- // ********** persistent types **********
-
- public ListIterable<OrmPersistentType> getPersistentTypes() {
- return new LiveCloneListIterable<OrmPersistentType>(this.persistentTypes);
- }
-
- public int getPersistentTypesSize() {
- return this.persistentTypes.size();
- }
-
- public OrmPersistentType getPersistentType(String className) {
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- if (ormPersistentType.isFor(className)) {
- return ormPersistentType;
- }
- }
- return null;
- }
-
- public boolean containsPersistentType(String className) {
- return this.getPersistentType(className) != null;
- }
-
- public PersistentType resolvePersistentType(String className) {
- return (PersistentType) this.resolvePersistentType(PERSISTENT_TYPE_LOOKUP_ADAPTER, className);
- }
-
- public JavaResourcePersistentType resolveJavaResourcePersistentType(String className) {
- return (JavaResourcePersistentType) this.resolvePersistentType(RESOURCE_PERSISTENT_TYPE_LOOKUP_ADAPTER, className);
- }
-
- protected Object resolvePersistentType(PersistentTypeLookupAdapter adapter, 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...
- Object persistentType = adapter.resolvePersistentType(this, className);
- if (persistentType != null) {
- return persistentType;
- }
-
- // ...then try to resolve by prepending the global package name
- if (this.getPackage() == null) {
- return null;
- }
- return adapter.resolvePersistentType(this, this.getPackage() + '.' + className);
- }
-
- protected interface PersistentTypeLookupAdapter {
- Object resolvePersistentType(EntityMappings entityMappings, String className);
- }
-
- protected static final PersistentTypeLookupAdapter PERSISTENT_TYPE_LOOKUP_ADAPTER =
- new PersistentTypeLookupAdapter() {
- public Object resolvePersistentType(EntityMappings entityMappings, String className) {
- return entityMappings.getPersistenceUnit().getPersistentType(className);
- }
- };
-
- protected static final PersistentTypeLookupAdapter RESOURCE_PERSISTENT_TYPE_LOOKUP_ADAPTER =
- new PersistentTypeLookupAdapter() {
- public Object resolvePersistentType(EntityMappings entityMappings, String className) {
- return entityMappings.getJpaProject().getJavaResourcePersistentType(className);
- }
- };
-
- /**
- * We have to calculate the new persistent type's index.
- * We will use the type's short name if the entity mappings's
- * package is the same as the type's package.
- */
- public OrmPersistentType addPersistentType(String mappingKey, String className) {
- OrmTypeMappingDefinition md = this.getMappingFileDefinition().getTypeMappingDefinition(mappingKey);
- XmlTypeMapping xmlTypeMapping = md.buildResourceMapping(this.getResourceNodeFactory());
- OrmPersistentType persistentType = this.buildPersistentType(xmlTypeMapping);
- int index = this.calculateInsertionIndex(persistentType);
- this.addItemToList(index, persistentType, this.persistentTypes, PERSISTENT_TYPES_LIST);
-
- persistentType.getMapping().addXmlTypeMappingTo(this.xmlEntityMappings);
-
- // adds short name if package name is relevant
- className = this.normalizeClassName(className);
- persistentType.getMapping().setClass(className);
-
- return persistentType;
- }
-
- /**
- * Shorten the specified class name if it is in the entity mappings's package.
- */
- protected String normalizeClassName(String className) {
- return ((this.package_ != null) &&
- className.startsWith(this.package_) &&
- (className.charAt(this.package_.length()) == '.')) ?
- className.substring(this.package_.length() + 1) :
- className;
- }
-
- protected OrmPersistentType buildPersistentType(XmlTypeMapping xmlTypeMapping) {
- return this.getContextNodeFactory().buildOrmPersistentType(this, xmlTypeMapping);
- }
-
- protected int calculateInsertionIndex(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.removePersistentType_(index);
- persistentType.getMapping().removeXmlTypeMappingFrom(this.xmlEntityMappings);
- }
-
- /**
- * dispose and return the persistent type
- */
- protected OrmPersistentType removePersistentType_(int index) {
- OrmPersistentType persistentType = this.removeItemFromList(index, this.persistentTypes, PERSISTENT_TYPES_LIST);
- persistentType.dispose();
- return persistentType;
- }
-
- public void removePersistentType(OrmPersistentType persistentType) {
- this.removePersistentType(this.persistentTypes.indexOf(persistentType));
- }
-
- protected void initializePersistentTypes() {
- for (XmlTypeMapping xmlTypeMapping : this.getXmlTypeMappings()) {
- this.persistentTypes.add(this.buildPersistentType(xmlTypeMapping));
- }
- }
-
- protected void syncPersistentTypes() {
- ContextContainerTools.synchronizeWithResourceModel(this.persistentTypeContainerAdapter);
- }
-
- protected Iterable<XmlTypeMapping> getXmlTypeMappings() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlTypeMapping>(this.xmlEntityMappings.getTypeMappings());
- }
-
- protected void movePersistentType_(int index, OrmPersistentType persistentType) {
- this.moveItemInList(index, persistentType, this.persistentTypes, PERSISTENT_TYPES_LIST);
- }
-
- protected void addPersistentType_(int index, XmlTypeMapping xmlTypeMapping) {
- this.addItemToList(index, this.buildPersistentType(xmlTypeMapping), this.persistentTypes, PERSISTENT_TYPES_LIST);
- }
-
- protected void removePersistentType_(OrmPersistentType persistentType) {
- this.removePersistentType_(this.persistentTypes.indexOf(persistentType));
- }
-
- /**
- * persistent type container adapter
- */
- protected class PersistentTypeContainerAdapter
- implements ContextContainerTools.Adapter<OrmPersistentType, XmlTypeMapping>
- {
- public Iterable<OrmPersistentType> getContextElements() {
- return AbstractEntityMappings.this.getPersistentTypes();
- }
- public Iterable<XmlTypeMapping> getResourceElements() {
- return AbstractEntityMappings.this.getXmlTypeMappings();
- }
- public XmlTypeMapping getResourceElement(OrmPersistentType contextElement) {
- return contextElement.getMapping().getXmlTypeMapping();
- }
- public void moveContextElement(int index, OrmPersistentType element) {
- AbstractEntityMappings.this.movePersistentType_(index, element);
- }
- public void addContextElement(int index, XmlTypeMapping resourceElement) {
- AbstractEntityMappings.this.addPersistentType_(index, resourceElement);
- }
- public void removeContextElement(OrmPersistentType element) {
- AbstractEntityMappings.this.removePersistentType_(element);
- }
- }
-
-
- // ********** sequence generators **********
-
- public ListIterable<OrmSequenceGenerator> getSequenceGenerators() {
- return new LiveCloneListIterable<OrmSequenceGenerator>(this.sequenceGenerators);
- }
-
- public int getSequenceGeneratorsSize() {
- return this.sequenceGenerators.size();
- }
-
- public OrmSequenceGenerator addSequenceGenerator() {
- return this.addSequenceGenerator(this.sequenceGenerators.size());
- }
-
- public OrmSequenceGenerator addSequenceGenerator(int index) {
- XmlSequenceGenerator xmlGenerator = this.buildXmlSequenceGenerator();
- OrmSequenceGenerator sequenceGenerator = this.addSequenceGenerator_(index, xmlGenerator);
- this.xmlEntityMappings.getSequenceGenerators().add(index, xmlGenerator);
- return sequenceGenerator;
- }
-
- protected XmlSequenceGenerator buildXmlSequenceGenerator() {
- return OrmFactory.eINSTANCE.createXmlSequenceGenerator();
- }
-
- protected OrmSequenceGenerator buildSequenceGenerator(XmlSequenceGenerator xmlSequenceGenerator) {
- return this.getContextNodeFactory().buildOrmSequenceGenerator(this, xmlSequenceGenerator);
- }
-
- public void removeSequenceGenerator(OrmSequenceGenerator sequenceGenerator) {
- this.removeSequenceGenerator(this.sequenceGenerators.indexOf(sequenceGenerator));
- }
-
- public void removeSequenceGenerator(int index) {
- this.removeSequenceGenerator_(index);
- this.xmlEntityMappings.getSequenceGenerators().remove(index);
- }
-
- protected void removeSequenceGenerator_(int index) {
- this.removeItemFromList(index, this.sequenceGenerators, SEQUENCE_GENERATORS_LIST);
- }
-
- public void moveSequenceGenerator(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.sequenceGenerators, SEQUENCE_GENERATORS_LIST);
- this.xmlEntityMappings.getSequenceGenerators().move(targetIndex, sourceIndex);
- }
-
- protected void initializeSequenceGenerators() {
- for (XmlSequenceGenerator sequenceGenerator : this.getXmlSequenceGenerators()) {
- this.sequenceGenerators.add(this.buildSequenceGenerator(sequenceGenerator));
- }
- }
-
- protected void syncSequenceGenerators() {
- ContextContainerTools.synchronizeWithResourceModel(this.sequenceGeneratorContainerAdapter);
- }
-
- protected Iterable<XmlSequenceGenerator> getXmlSequenceGenerators() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlSequenceGenerator>(this.xmlEntityMappings.getSequenceGenerators());
- }
-
- protected void moveSequenceGenerator_(int index, OrmSequenceGenerator sequenceGenerator) {
- this.moveItemInList(index, sequenceGenerator, this.sequenceGenerators, SEQUENCE_GENERATORS_LIST);
- }
-
- protected OrmSequenceGenerator addSequenceGenerator_(int index, XmlSequenceGenerator xmlSequenceGenerator) {
- OrmSequenceGenerator sequenceGenerator = this.buildSequenceGenerator(xmlSequenceGenerator);
- this.addItemToList(index, sequenceGenerator, this.sequenceGenerators, SEQUENCE_GENERATORS_LIST);
- return sequenceGenerator;
- }
-
- protected void removeSequenceGenerator_(OrmSequenceGenerator sequenceGenerator) {
- this.removeSequenceGenerator_(this.sequenceGenerators.indexOf(sequenceGenerator));
- }
-
- /**
- * sequence generator container adapter
- */
- protected class SequenceGeneratorContainerAdapter
- implements ContextContainerTools.Adapter<OrmSequenceGenerator, XmlSequenceGenerator>
- {
- public Iterable<OrmSequenceGenerator> getContextElements() {
- return AbstractEntityMappings.this.getSequenceGenerators();
- }
- public Iterable<XmlSequenceGenerator> getResourceElements() {
- return AbstractEntityMappings.this.getXmlSequenceGenerators();
- }
- public XmlSequenceGenerator getResourceElement(OrmSequenceGenerator contextElement) {
- return contextElement.getXmlGenerator();
- }
- public void moveContextElement(int index, OrmSequenceGenerator element) {
- AbstractEntityMappings.this.moveSequenceGenerator_(index, element);
- }
- public void addContextElement(int index, XmlSequenceGenerator resourceElement) {
- AbstractEntityMappings.this.addSequenceGenerator_(index, resourceElement);
- }
- public void removeContextElement(OrmSequenceGenerator element) {
- AbstractEntityMappings.this.removeSequenceGenerator_(element);
- }
- }
-
-
- // ********** table generators **********
-
- public ListIterable<OrmTableGenerator> getTableGenerators() {
- return new LiveCloneListIterable<OrmTableGenerator>(this.tableGenerators);
- }
-
- public int getTableGeneratorsSize() {
- return this.tableGenerators.size();
- }
-
- public OrmTableGenerator addTableGenerator() {
- return this.addTableGenerator(this.tableGenerators.size());
- }
-
- public OrmTableGenerator addTableGenerator(int index) {
- XmlTableGenerator xmlTableGenerator = this.buildXmlTableGenerator();
- OrmTableGenerator tableGenerator = this.addTableGenerator_(index, xmlTableGenerator);
- this.xmlEntityMappings.getTableGenerators().add(index, xmlTableGenerator);
- return tableGenerator;
- }
-
- protected XmlTableGenerator buildXmlTableGenerator() {
- return OrmFactory.eINSTANCE.createXmlTableGenerator();
- }
-
- protected OrmTableGenerator buildTableGenerator(XmlTableGenerator xmlTableGenerator) {
- return this.getContextNodeFactory().buildOrmTableGenerator(this, xmlTableGenerator);
- }
-
- public void removeTableGenerator(OrmTableGenerator tableGenerator) {
- this.removeTableGenerator(this.tableGenerators.indexOf(tableGenerator));
- }
-
- public void removeTableGenerator(int index) {
- this.removeTableGenerator_(index);
- this.xmlEntityMappings.getTableGenerators().remove(index);
- }
-
- protected void removeTableGenerator_(int index) {
- this.removeItemFromList(index, this.tableGenerators, TABLE_GENERATORS_LIST);
- }
-
- public void moveTableGenerator(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.tableGenerators, TABLE_GENERATORS_LIST);
- this.xmlEntityMappings.getTableGenerators().move(targetIndex, sourceIndex);
- }
-
- protected void initializeTableGenerators() {
- for (XmlTableGenerator tableGenerator : this.getXmlTableGenerators()) {
- this.tableGenerators.add(this.buildTableGenerator(tableGenerator));
- }
- }
-
- protected void syncTableGenerators() {
- ContextContainerTools.synchronizeWithResourceModel(this.tableGeneratorContainerAdapter);
- }
-
- protected Iterable<XmlTableGenerator> getXmlTableGenerators() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlTableGenerator>(this.xmlEntityMappings.getTableGenerators());
- }
-
- protected void moveTableGenerator_(int index, OrmTableGenerator tableGenerator) {
- this.moveItemInList(index, tableGenerator, this.tableGenerators, TABLE_GENERATORS_LIST);
- }
-
- protected OrmTableGenerator addTableGenerator_(int index, XmlTableGenerator xmlTableGenerator) {
- OrmTableGenerator tableGenerator = this.buildTableGenerator(xmlTableGenerator);
- this.addItemToList(index, tableGenerator, this.tableGenerators, TABLE_GENERATORS_LIST);
- return tableGenerator;
- }
-
- protected void removeTableGenerator_(OrmTableGenerator tableGenerator) {
- this.removeTableGenerator_(this.tableGenerators.indexOf(tableGenerator));
- }
-
- /**
- * table generator container adapter
- */
- protected class TableGeneratorContainerAdapter
- implements ContextContainerTools.Adapter<OrmTableGenerator, XmlTableGenerator>
- {
- public Iterable<OrmTableGenerator> getContextElements() {
- return AbstractEntityMappings.this.getTableGenerators();
- }
- public Iterable<XmlTableGenerator> getResourceElements() {
- return AbstractEntityMappings.this.getXmlTableGenerators();
- }
- public XmlTableGenerator getResourceElement(OrmTableGenerator contextElement) {
- return contextElement.getXmlGenerator();
- }
- public void moveContextElement(int index, OrmTableGenerator element) {
- AbstractEntityMappings.this.moveTableGenerator_(index, element);
- }
- public void addContextElement(int index, XmlTableGenerator resourceElement) {
- AbstractEntityMappings.this.addTableGenerator_(index, resourceElement);
- }
- public void removeContextElement(OrmTableGenerator element) {
- AbstractEntityMappings.this.removeTableGenerator_(element);
- }
- }
-
-
- // ********** query container **********
-
- public OrmQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
- protected OrmQueryContainer buildQueryContainer() {
- return this.getContextNodeFactory().buildOrmQueryContainer(this, this.xmlEntityMappings);
- }
-
-
- // ********** validation **********
-
- /**
- * The generators are validated in the persistence unit.
- * @see org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit#validateGenerators(List, IReporter)
- */
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateVersion(messages);
- // generators are validated in the persistence unit
- this.queryContainer.validate(messages, reporter);
- for (OrmPersistentType ormPersistentType : this.getPersistentTypes()) {
- this.validatePersistentType(ormPersistentType, messages, reporter);
- }
- }
-
- protected void validateVersion(List<IMessage> messages) {
- if (! this.getLatestDocumentVersion().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 String getLatestDocumentVersion() {
- return this.getJpaPlatform().getMostRecentSupportedResourceType(this.getContentType()).getVersion();
- }
-
- protected IContentType getContentType() {
- return JptJpaCorePlugin.ORM_XML_CONTENT_TYPE;
- }
-
- protected void validatePersistentType(OrmPersistentType persistentType, List<IMessage> messages, IReporter reporter) {
- try {
- persistentType.validate(messages, reporter);
- } catch (Throwable exception) {
- JptJpaCorePlugin.log(exception);
- }
- }
-
-
- // ********** refactoring **********
-
- public Iterable<DeleteEdit> createDeleteTypeEdits(final IType type) {
- return new CompositeIterable<DeleteEdit>(
- new TransformationIterable<OrmPersistentType, Iterable<DeleteEdit>>(this.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>>(this.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>>(this.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>>(this.getPersistentTypes()) {
- @Override
- protected Iterable<ReplaceEdit> transform(OrmPersistentType persistentType) {
- return persistentType.createRenamePackageEdits(originalPackage, newName);
- }
- }
- );
- }
-
- protected Iterable<ReplaceEdit> createRenamePackageEdit(final IPackageFragment originalPackage, final String newName) {
- return Tools.valuesAreEqual(this.package_, originalPackage.getElementName()) ?
- new SingleElementIterable<ReplaceEdit>(this.xmlEntityMappings.createRenamePackageEdit(newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
deleted file mode 100644
index e59a7af66c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmAttributeMapping.java
+++ /dev/null
@@ -1,416 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.SingleElementIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.ColumnMapping;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBaseEmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMultiRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSingleRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.SimpleMetamodelField;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.AttributeMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JPA2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-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<X extends XmlAttributeMapping>
- extends AbstractOrmXmlContextNode
- implements OrmAttributeMapping, AttributeMapping2_0
-{
- // never null
- protected final X xmlAttributeMapping;
-
- protected String name;
-
-
- protected AbstractOrmAttributeMapping(OrmPersistentAttribute parent, X xmlAttributeMapping) {
- super(parent);
- this.xmlAttributeMapping = xmlAttributeMapping;
- this.name = xmlAttributeMapping.getName();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName_(this.xmlAttributeMapping.getName());
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.setName_(name);
- this.xmlAttributeMapping.setName(name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- if (this.firePropertyChanged(NAME_PROPERTY, old, name)) {
- // tell our attribute its name has, effectively, changed
- this.getPersistentAttribute().nameChanged(old, name);
- }
- }
-
-
- // ********** morphing mappings **********
-
- public void initializeFromOrmAttributeMapping(OrmAttributeMapping oldMapping) {
- this.setName(oldMapping.getName());
- }
-
- protected void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- this.initializeFromOrmAttributeMapping(oldMapping);
- }
-
- public void initializeFromOrmBasicMapping(OrmBasicMapping oldMapping) {
- this.initializeFromOrmColumnMapping(oldMapping);
- }
-
- public void initializeFromOrmIdMapping(OrmIdMapping oldMapping) {
- this.initializeFromOrmColumnMapping(oldMapping);
- }
-
- public void initializeFromOrmTransientMapping(OrmTransientMapping oldMapping) {
- this.initializeFromOrmAttributeMapping(oldMapping);
- }
-
- protected void initializeFromOrmBaseEmbeddedMapping(OrmBaseEmbeddedMapping oldMapping) {
- this.initializeFromOrmAttributeMapping(oldMapping);
- }
-
- public void initializeFromOrmEmbeddedMapping(OrmEmbeddedMapping oldMapping) {
- this.initializeFromOrmBaseEmbeddedMapping(oldMapping);
- }
-
- public void initializeFromOrmEmbeddedIdMapping(OrmEmbeddedIdMapping oldMapping) {
- this.initializeFromOrmBaseEmbeddedMapping(oldMapping);
- }
-
- public void initializeFromOrmVersionMapping(OrmVersionMapping oldMapping) {
- this.initializeFromOrmColumnMapping(oldMapping);
- }
-
- protected void initializeFromOrmRelationshipMapping(OrmRelationshipMapping oldMapping) {
- this.initializeFromOrmAttributeMapping(oldMapping);
- }
-
- protected void initializeFromOrmMultiRelationshipMapping(OrmMultiRelationshipMapping oldMapping) {
- this.initializeFromOrmRelationshipMapping(oldMapping);
- }
-
- protected void initializeFromOrmSingleRelationshipMapping(OrmSingleRelationshipMapping oldMapping) {
- this.initializeFromOrmRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmOneToManyMapping(OrmOneToManyMapping oldMapping) {
- this.initializeFromOrmMultiRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmManyToOneMapping(OrmManyToOneMapping oldMapping) {
- this.initializeFromOrmSingleRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmOneToOneMapping(OrmOneToOneMapping oldMapping) {
- this.initializeFromOrmSingleRelationshipMapping(oldMapping);
- }
-
- public void initializeFromOrmManyToManyMapping(OrmManyToManyMapping oldMapping) {
- this.initializeFromOrmMultiRelationshipMapping(oldMapping);
- }
-
-
- // ********** misc **********
-
- public X getXmlAttributeMapping() {
- return this.xmlAttributeMapping;
- }
-
- @Override
- public OrmPersistentAttribute getParent() {
- return (OrmPersistentAttribute) super.getParent();
- }
-
- public OrmPersistentAttribute getPersistentAttribute() {
- return this.getParent();
- }
-
- public OrmTypeMapping getTypeMapping() {
- return this.getPersistentAttribute().getOwningTypeMapping();
- }
-
- protected JavaPersistentAttribute getJavaPersistentAttribute() {
- return this.getPersistentAttribute().getJavaPersistentAttribute();
- }
-
- protected EntityMappings getEntityMappings() {
- return this.getPersistentAttribute().getOwningPersistentType().getParent();
- }
-
- protected PersistentType resolvePersistentType(String className) {
- return this.getEntityMappings().resolvePersistentType(className);
- }
-
- public boolean isDefault() {
- return false;
- }
-
- 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 boolean validatesAgainstDatabase() {
- return this.getTypeMapping().validatesAgainstDatabase();
- }
-
- public boolean contains(int textOffset) {
- return this.xmlAttributeMapping.containsOffset(textOffset);
- }
-
- public TextRange getSelectionTextRange() {
- return this.xmlAttributeMapping.getSelectionTextRange();
- }
-
- public TextRange getValidationTextRange() {
- // this should never be null; also, the persistent attribute delegates
- // to here, so don't delegate back to it (or we will get a stack overflow)
- return this.xmlAttributeMapping.getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.xmlAttributeMapping.getNameTextRange());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-
- // ********** embedded mappings **********
-
- public Iterator<String> allMappingNames() {
- return (this.name != null) ?
- new SingleElementIterator<String>(this.name) :
- EmptyIterator.<String>instance();
- }
-
- public Iterator<String> allOverridableAttributeMappingNames() {
- return ((this.name != null) && this.isOverridableAttributeMapping()) ?
- new SingleElementIterator<String>(this.name) :
- EmptyIterator.<String>instance();
- }
-
- public Iterator<String> allOverridableAssociationMappingNames() {
- return ((this.name != null) && this.isOverridableAssociationMapping()) ?
- new SingleElementIterator<String>(this.name) :
- EmptyIterator.<String>instance();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- ColumnMapping mapping = this.resolveColumnMapping(attributeName);
- return (mapping == null) ? null : mapping.getColumn();
- }
-
- protected ColumnMapping resolveColumnMapping(String attributeName) {
- AttributeMapping mapping = this.resolveAttributeMapping(attributeName);
- return ((mapping != null) && mapping.isOverridableAttributeMapping()) ? (ColumnMapping) mapping : null;
- }
-
- public Relationship resolveOverriddenRelationship(String attributeName) {
- RelationshipMapping mapping = this.resolveRelationshipMapping(attributeName);
- return (mapping == null) ? null : mapping.getRelationship();
- }
-
- protected RelationshipMapping resolveRelationshipMapping(String attributeName) {
- AttributeMapping mapping = this.resolveAttributeMapping(attributeName);
- return ((mapping != null) && mapping.isOverridableAssociationMapping()) ?
- (RelationshipMapping) mapping :
- null;
- }
-
- public AttributeMapping resolveAttributeMapping(String attributeName) {
- return Tools.valuesAreEqual(attributeName, this.name) ? this : null;
- }
-
- protected Transformer<String, String> buildQualifierTransformer() {
- return new MappingTools.QualifierTransformer(this.name);
- }
-
- protected String unqualify(String attributeName) {
- return MappingTools.unqualify(this.name, attributeName);
- }
-
-
- // ********** 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.name;
- }
-
-
- // ********** 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()
- )
- );
- }
- }
-
- //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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java
deleted file mode 100644
index f6aa8a2149..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseColumn.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBaseColumn;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlColumn;
-
-/**
- * <code>orm.xml</code> column or join column
- */
-public abstract class AbstractOrmBaseColumn<X extends AbstractXmlColumn, O extends OrmBaseColumn.Owner>
- extends AbstractOrmNamedColumn<X, O>
- implements OrmBaseColumn
-{
- protected String specifiedTable;
- protected String defaultTable;
-
- // TODO defaults from java for all of these settings
- protected Boolean specifiedUnique;
-
- protected Boolean specifiedNullable;
-
- protected Boolean specifiedInsertable;
-
- protected Boolean specifiedUpdatable;
-
-
- // ********** constructor/initialization **********
-
- protected AbstractOrmBaseColumn(XmlContextNode parent, O owner) {
- this(parent, owner, null);
- }
-
- protected AbstractOrmBaseColumn(XmlContextNode parent, O owner, X xmlColumn) {
- super(parent, owner, xmlColumn);
- this.specifiedTable = this.buildSpecifiedTable();
- this.specifiedUnique = this.buildSpecifiedUnique();
- this.specifiedNullable = this.buildSpecifiedNullable();
- this.specifiedInsertable = this.buildSpecifiedInsertable();
- this.specifiedUpdatable = this.buildSpecifiedUpdatable();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedTable_(this.buildSpecifiedTable());
- this.setSpecifiedUnique_(this.buildSpecifiedUnique());
- this.setSpecifiedNullable_(this.buildSpecifiedNullable());
- this.setSpecifiedInsertable_(this.buildSpecifiedInsertable());
- this.setSpecifiedUpdatable_(this.buildSpecifiedUpdatable());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultTable(this.buildDefaultTable());
- }
-
-
- // ********** table **********
-
- @Override
- public String getTable() {
- return (this.specifiedTable != null) ? this.specifiedTable : this.defaultTable;
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- public void setSpecifiedTable(String table) {
- if (this.valuesAreDifferent(this.specifiedTable, table)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setSpecifiedTable_(table);
- xmlColumn.setTable(table);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setSpecifiedTable_(String table) {
- String old = this.specifiedTable;
- this.specifiedTable = table;
- this.firePropertyChanged(SPECIFIED_TABLE_PROPERTY, old, table);
- }
-
- protected String buildSpecifiedTable() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getTable();
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String table) {
- String old = this.defaultTable;
- this.defaultTable = table;
- this.firePropertyChanged(DEFAULT_TABLE_PROPERTY, old, table);
- }
-
- protected String buildDefaultTable() {
- return this.owner.getDefaultTableName();
- }
-
-
- // ********** unique **********
-
- public boolean isUnique() {
- return (this.specifiedUnique != null) ? this.specifiedUnique.booleanValue() : this.isDefaultUnique();
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- public void setSpecifiedUnique(Boolean unique) {
- if (this.valuesAreDifferent(this.specifiedUnique, unique)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setSpecifiedUnique_(unique);
- xmlColumn.setUnique(unique);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setSpecifiedUnique_(Boolean unique) {
- Boolean old = this.specifiedUnique;
- this.specifiedUnique = unique;
- this.firePropertyChanged(SPECIFIED_UNIQUE_PROPERTY, old, unique);
- }
-
- protected Boolean buildSpecifiedUnique() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getUnique();
- }
-
- public boolean isDefaultUnique() {
- return DEFAULT_UNIQUE;
- }
-
-
- // ********** nullable **********
-
- public boolean isNullable() {
- return (this.specifiedNullable != null) ? this.specifiedNullable.booleanValue() : this.isDefaultNullable();
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- public void setSpecifiedNullable(Boolean nullable) {
- if (this.valuesAreDifferent(this.specifiedNullable, nullable)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setSpecifiedNullable_(nullable);
- xmlColumn.setNullable(nullable);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setSpecifiedNullable_(Boolean nullable) {
- Boolean old = this.specifiedNullable;
- this.specifiedNullable = nullable;
- this.firePropertyChanged(SPECIFIED_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected Boolean buildSpecifiedNullable() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getNullable();
- }
-
- public boolean isDefaultNullable() {
- return DEFAULT_NULLABLE;
- }
-
-
- // ********** insertable **********
-
- public boolean isInsertable() {
- return (this.specifiedInsertable != null) ? this.specifiedInsertable.booleanValue() : this.isDefaultInsertable();
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- public void setSpecifiedInsertable(Boolean insertable) {
- if (this.valuesAreDifferent(this.specifiedInsertable, insertable)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setSpecifiedInsertable_(insertable);
- xmlColumn.setInsertable(insertable);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setSpecifiedInsertable_(Boolean insertable) {
- Boolean old = this.specifiedInsertable;
- this.specifiedInsertable = insertable;
- this.firePropertyChanged(SPECIFIED_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected Boolean buildSpecifiedInsertable() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getInsertable();
- }
-
- public boolean isDefaultInsertable() {
- return DEFAULT_INSERTABLE;
- }
-
-
- // ********** updatable **********
-
- public boolean isUpdatable() {
- return (this.specifiedUpdatable != null) ? this.specifiedUpdatable.booleanValue() : this.isDefaultUpdatable();
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- public void setSpecifiedUpdatable(Boolean updatable) {
- if (this.valuesAreDifferent(this.specifiedUpdatable, updatable)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setSpecifiedUpdatable_(updatable);
- xmlColumn.setUpdatable(updatable);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setSpecifiedUpdatable_(Boolean updatable) {
- Boolean old = this.specifiedUpdatable;
- this.specifiedUpdatable = updatable;
- this.firePropertyChanged(SPECIFIED_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected Boolean buildSpecifiedUpdatable() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getUpdatable();
- }
-
- public boolean isDefaultUpdatable() {
- return DEFAULT_UPDATABLE;
- }
-
-
- // ********** misc **********
-
- protected void initializeFrom(ReadOnlyBaseColumn oldColumn) {
- super.initializeFrom(oldColumn);
- this.setSpecifiedTable(oldColumn.getSpecifiedTable());
- this.setSpecifiedUnique(oldColumn.getSpecifiedUnique());
- this.setSpecifiedNullable(oldColumn.getSpecifiedNullable());
- this.setSpecifiedInsertable(oldColumn.getSpecifiedInsertable());
- this.setSpecifiedUpdatable(oldColumn.getSpecifiedUpdatable());
- }
-
- protected void initializeFromVirtual(ReadOnlyBaseColumn virtualColumn) {
- super.initializeFromVirtual(virtualColumn);
- this.setSpecifiedTable(virtualColumn.getTable());
- // ignore other settings?
- }
-
- public boolean tableNameIsInvalid() {
- return this.owner.tableNameIsInvalid(this.getTable());
- }
-
- public Iterator<String> candidateTableNames() {
- return this.owner.candidateTableNames();
- }
-
-
- // ********** validation **********
-
- public TextRange getTableTextRange() {
- return this.getValidationTextRange(this.getXmlColumnTableTextRange());
- }
-
- protected TextRange getXmlColumnTableTextRange() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getTableTextRange();
- }
-
- @Override
- protected NamedColumnTextRangeResolver buildTextRangeResolver() {
- return new OrmBaseColumnTextRangeResolver(this);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
deleted file mode 100644
index 9334507a51..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBaseEmbeddedMapping.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.Transformer;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.OverrideContainer;
-import org.eclipse.jpt.jpa.core.context.Override_;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBaseEmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlEmbedded;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> embedded or embedded ID mapping
- */
-public abstract class AbstractOrmBaseEmbeddedMapping<X extends AbstractXmlEmbedded>
- extends AbstractOrmAttributeMapping<X>
- implements OrmBaseEmbeddedMapping
-{
- protected final OrmAttributeOverrideContainer attributeOverrideContainer;
-
- protected Embeddable targetEmbeddable;
-
-
- protected AbstractOrmBaseEmbeddedMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.attributeOverrideContainer = this.buildAttributeOverrideContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.attributeOverrideContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.attributeOverrideContainer.update();
- this.setTargetEmbeddable(this.buildTargetEmbeddable());
- }
-
-
- // ********** attribute override container **********
-
- public OrmAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- protected OrmAttributeOverrideContainer buildAttributeOverrideContainer() {
- return this.getContextNodeFactory().buildOrmAttributeOverrideContainer(this, this.buildAttributeOverrideContainerOwner());
- }
-
- protected OrmAttributeOverrideContainer.Owner buildAttributeOverrideContainerOwner() {
- return new AttributeOverrideContainerOwner();
- }
-
-
- // ********** target embeddable **********
-
- public Embeddable getTargetEmbeddable() {
- return this.targetEmbeddable;
- }
-
- protected void setTargetEmbeddable(Embeddable embeddable) {
- Embeddable old = this.targetEmbeddable;
- this.targetEmbeddable = embeddable;
- this.firePropertyChanged(TARGET_EMBEDDABLE_PROPERTY, old, embeddable);
- }
-
- protected Embeddable buildTargetEmbeddable() {
- JavaPersistentAttribute javaAttribute = this.getJavaPersistentAttribute();
- return (javaAttribute == null) ? null : javaAttribute.getEmbeddable();
- }
-
-
- // ********** embedded mappings **********
-
- @Override
- public Iterator<String> allOverridableAttributeMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverridableAttributeMappingNames() :
- super.allOverridableAttributeMappingNames();
- }
-
- protected Iterator<String> embeddableOverridableAttributeMappingNames() {
- return this.qualifiedEmbeddableOverridableMappingNames(AttributeMappingTools.ALL_OVERRIDABLE_ATTRIBUTE_MAPPING_NAMES_TRANSFORMER);
- }
-
- @Override
- public Iterator<String> allOverridableAssociationMappingNames() {
- return this.isJpa2_0Compatible() ?
- this.embeddableOverridableAssociationMappingNames() :
- super.allOverridableAssociationMappingNames();
- }
-
- protected Iterator<String> embeddableOverridableAssociationMappingNames() {
- return this.qualifiedEmbeddableOverridableMappingNames(AttributeMappingTools.ALL_OVERRIDABLE_ASSOCIATION_MAPPING_NAMES_TRANSFORMER);
- }
-
- protected Iterator<String> qualifiedEmbeddableOverridableMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<String, String>(this.embeddableAttributeMappingNames(transformer), this.buildQualifierTransformer());
- }
-
- protected Iterator<String> embeddableAttributeMappingNames(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new CompositeIterator<String>(this.embeddableAttributeMappingNamesLists(transformer));
- }
-
- /**
- * Return a list of lists; each nested list holds the names for one of the
- * embedded mapping's target embeddable type mapping's attribute mappings
- * (attribute or association mappings, depending on the specified transformer).
- */
- protected Iterator<Iterator<String>> embeddableAttributeMappingNamesLists(Transformer<AttributeMapping, Iterator<String>> transformer) {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.embeddableAttributeMappings(), transformer);
- }
-
- /**
- * Return the target embeddable's attribute mappings.
- */
- protected Iterator<AttributeMapping> embeddableAttributeMappings() {
- return ((this.targetEmbeddable != null) && (this.targetEmbeddable != this.getTypeMapping())) ?
- this.targetEmbeddable.attributeMappings() :
- EmptyIterator.<AttributeMapping>instance();
- }
-
-
- // ********** misc **********
-
- @Override
- protected void initializeFromOrmBaseEmbeddedMapping(OrmBaseEmbeddedMapping oldMapping) {
- super.initializeFromOrmBaseEmbeddedMapping(oldMapping);
- this.attributeOverrideContainer.initializeFrom(oldMapping.getAttributeOverrideContainer());
- }
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- return this.isJpa2_0Compatible() ? this.resolveOverriddenColumn_(attributeName) : null;
- }
-
- protected Column resolveOverriddenColumn_(String attributeName) {
- attributeName = this.unqualify(attributeName);
- if (attributeName == null) {
- return null;
- }
- AttributeOverride override = this.attributeOverrideContainer.getSpecifiedOverrideNamed(attributeName);
- // recurse into the target embeddable if necessary
- return (override != null) ? override.getColumn() : this.resolveOverriddenColumnInTargetEmbeddable(attributeName);
- }
-
- protected Column resolveOverriddenColumnInTargetEmbeddable(String attributeName) {
- return (this.targetEmbeddable == null) ? null : this.targetEmbeddable.resolveOverriddenColumn(attributeName);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- if (this.validateTargetEmbeddable(messages)) {
- this.validateOverrides(messages, reporter);
- }
- }
-
- protected boolean validateTargetEmbeddable(List<IMessage> messages) {
- if (this.targetEmbeddable == null) {
- String targetEmbeddableTypeName = this.getPersistentAttribute().getTypeName();
- // if the type isn't resolvable, 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) {
- this.attributeOverrideContainer.validate(messages, reporter);
- }
-
-
- // ********** attribute override container owner *********
-
- 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 = this.getOverridableTypeMapping();
- return (typeMapping != null) ? this.allOverridableAttributeNames_(typeMapping) : EmptyIterator.<String>instance();
- }
-
- /**
- * pre-condition: type mapping is not <code>null</code>
- * <p>
- * NB: Overridden in {@link GenericOrmEmbeddedIdMapping.AttributeOverrideContainerOwner}
- */
- protected Iterator<String> allOverridableAttributeNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAttributeNames();
- }
-
- public EList<XmlAttributeOverride> getXmlOverrides() {
- return AbstractOrmBaseEmbeddedMapping.this.getXmlAttributeMapping().getAttributeOverrides();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public String getDefaultTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator(this.getPersistentAttribute(), (AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator(this.getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmBaseEmbeddedMapping.this.getValidationTextRange();
- }
-
- protected OrmPersistentAttribute getPersistentAttribute() {
- return AbstractOrmBaseEmbeddedMapping.this.getPersistentAttribute();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java
deleted file mode 100644
index 60ab3a1f63..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmBasicMapping.java
+++ /dev/null
@@ -1,425 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Converter;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEnumeratedConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmLobConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmConverter;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.jpa.db.Table;
-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> basic mapping
- */
-public abstract class AbstractOrmBasicMapping<X extends XmlBasic>
- extends AbstractOrmAttributeMapping<X>
- implements OrmBasicMapping
-{
- protected final OrmColumn column;
-
- protected FetchType specifiedFetch;
- protected FetchType defaultFetch;
-
- protected Boolean specifiedOptional;
- protected boolean defaultOptional;
-
- protected OrmConverter converter; // never null
-
-
- protected static final OrmConverter.Adapter[] CONVERTER_ADAPTER_ARRAY = new OrmConverter.Adapter[] {
- OrmEnumeratedConverter.Adapter.instance(),
- OrmTemporalConverter.Adapter.instance(),
- OrmLobConverter.Adapter.instance()
- };
- protected static final Iterable<OrmConverter.Adapter> CONVERTER_ADAPTERS = new ArrayIterable<OrmConverter.Adapter>(CONVERTER_ADAPTER_ARRAY);
-
-
- protected AbstractOrmBasicMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.column = this.buildColumn();
- this.specifiedFetch = this.buildSpecifiedFetch();
- this.specifiedOptional = this.buildSpecifiedOptional();
- this.converter = this.buildConverter();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.column.synchronizeWithResourceModel();
- this.setSpecifiedFetch_(this.buildSpecifiedFetch());
- this.setSpecifiedOptional_(this.buildSpecifiedOptional());
- this.syncConverter();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update();
- this.setDefaultFetch(this.buildDefaultFetch());
- this.setDefaultOptional(this.buildDefaultOptional());
- this.converter.update();
- }
-
-
- // ********** column **********
-
- public OrmColumn getColumn() {
- return this.column;
- }
-
- protected OrmColumn buildColumn() {
- return this.getContextNodeFactory().buildOrmColumn(this, this);
- }
-
-
- // ********** fetch **********
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.defaultFetch;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- this.setSpecifiedFetch_(fetch);
- this.xmlAttributeMapping.setFetch(FetchType.toOrmResourceModel(fetch));
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType buildSpecifiedFetch() {
- return FetchType.fromOrmResourceModel(this.xmlAttributeMapping.getFetch());
- }
-
- public FetchType getDefaultFetch() {
- return this.defaultFetch;
- }
-
- protected void setDefaultFetch(FetchType fetch) {
- FetchType old = this.defaultFetch;
- this.defaultFetch = fetch;
- this.firePropertyChanged(DEFAULT_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType buildDefaultFetch() {
- 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) {
- this.setSpecifiedOptional_(optional);
- this.xmlAttributeMapping.setOptional(optional);
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected Boolean buildSpecifiedOptional() {
- return this.xmlAttributeMapping.getOptional();
- }
-
- public boolean isDefaultOptional() {
- return this.defaultOptional;
- }
-
- protected void setDefaultOptional(boolean optional) {
- boolean old = this.defaultOptional;
- this.defaultOptional = optional;
- this.firePropertyChanged(DEFAULT_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected boolean buildDefaultOptional() {
- return DEFAULT_OPTIONAL;
- }
-
-
- // ********** converter **********
-
- public OrmConverter getConverter() {
- return this.converter;
- }
-
- public void setConverter(Class<? extends Converter> converterType) {
- if (this.converter.getType() != converterType) {
- // note: we may also clear the XML value we want;
- // but if we leave it, the resulting sync will screw things up...
- this.clearXmlConverterValues();
- OrmConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.setConverter_(this.buildConverter(converterAdapter));
- this.converter.initialize();
- }
- }
-
- protected OrmConverter buildConverter(OrmConverter.Adapter converterAdapter) {
- return (converterAdapter != null) ?
- converterAdapter.buildNewConverter(this, this.getContextNodeFactory()) :
- this.buildNullConverter();
- }
-
- protected void setConverter_(OrmConverter converter) {
- Converter old = this.converter;
- this.converter = converter;
- this.firePropertyChanged(CONVERTER_PROPERTY, old, converter);
- }
-
- protected void clearXmlConverterValues() {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- adapter.clearXmlValue(this.xmlAttributeMapping);
- }
- }
-
- protected OrmConverter buildConverter() {
- OrmXmlContextNodeFactory factory = this.getContextNodeFactory();
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- OrmConverter ormConverter = adapter.buildConverter(this, factory);
- if (ormConverter != null) {
- return ormConverter;
- }
- }
- return this.buildNullConverter();
- }
-
- protected void syncConverter() {
- OrmConverter.Adapter adapter = this.getXmlConverterAdapter();
- if (adapter == null) {
- if (this.converter.getType() != null) {
- this.setConverter_(this.buildNullConverter());
- }
- } else {
- if (this.converter.getType() == adapter.getConverterType()) {
- this.converter.synchronizeWithResourceModel();
- } else {
- this.setConverter_(adapter.buildNewConverter(this, this.getContextNodeFactory()));
- }
- }
- }
-
- /**
- * Return the first adapter whose converter value is set in the XML mapping.
- * Return <code>null</code> if there are no converter values in the XML.
- */
- protected OrmConverter.Adapter getXmlConverterAdapter() {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.isActive(this.xmlAttributeMapping)) {
- return adapter;
- }
- }
- return null;
- }
-
- protected OrmConverter buildNullConverter() {
- return new NullOrmConverter(this);
- }
-
-
- // ********** converter adapters **********
-
- /**
- * Return the converter adapter for the specified converter type.
- */
- protected OrmConverter.Adapter getConverterAdapter(Class<? extends Converter> converterType) {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.getConverterType() == converterType) {
- return adapter;
- }
- }
- return null;
- }
-
- protected Iterable<OrmConverter.Adapter> getConverterAdapters() {
- return CONVERTER_ADAPTERS;
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmBasicMapping(this);
- }
-
- @Override
- protected void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- super.initializeFromOrmColumnMapping(oldMapping);
- this.column.initializeFrom(oldMapping.getColumn());
- }
-
- public int getXmlSequence() {
- return 20;
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
- public void addXmlAttributeMappingTo(Attributes xmlAttributes) {
- xmlAttributes.getBasics().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes xmlAttributes) {
- xmlAttributes.getBasics().remove(this.xmlAttributeMapping);
- }
-
-
- // ********** OrmColumn.Owner implementation **********
-
- public String getDefaultColumnName() {
- return this.name;
- }
-
- public String getDefaultTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public XmlColumn getXmlColumn() {
- return this.xmlAttributeMapping.getColumn();
- }
-
- public XmlColumn buildXmlColumn() {
- XmlColumn xmlColumn = OrmFactory.eINSTANCE.createXmlColumn();
- this.xmlAttributeMapping.setColumn(xmlColumn);
- return xmlColumn;
- }
-
- public void removeXmlColumn() {
- this.xmlAttributeMapping.setColumn(null);
- }
-
-
- //************ refactoring ************
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createRenameTypeEdits(originalType, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createMoveTypeEdits(originalType, newPackage) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createRenamePackageEdits(originalPackage, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.column.validate(messages, reporter);
- this.converter.validate(messages, reporter);
- }
-
- public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEmbeddable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEmbeddable.java
deleted file mode 100644
index e2883a2d88..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEmbeddable.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaEmbeddable;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
-
-/**
- * <code>orm.xml</code> embeddable type mapping
- */
-public abstract class AbstractOrmEmbeddable<X extends XmlEmbeddable>
- extends AbstractOrmTypeMapping<X>
- implements OrmEmbeddable
-{
- protected AbstractOrmEmbeddable(OrmPersistentType parent, X resourceMapping) {
- super(parent, resourceMapping);
- }
-
-
- // ********** key **********
-
- public String getKey() {
- return MappingKeys.EMBEDDABLE_TYPE_MAPPING_KEY;
- }
-
-
- // ********** id class **********
-
- public JavaPersistentType getIdClass() {
- return null;
- }
-
-
- // ********** tables **********
-
- public Iterator<ReadOnlyTable> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<ReadOnlyTable> allAssociatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<String> allAssociatedTableNames() {
- return EmptyIterator.instance();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
-
- // ********** Java **********
-
- @Override
- public JavaEmbeddable getJavaTypeMapping() {
- return (JavaEmbeddable) super.getJavaTypeMapping();
- }
-
- @Override
- public JavaEmbeddable getJavaTypeMappingForDefaults() {
- return (JavaEmbeddable) super.getJavaTypeMappingForDefaults();
- }
-
-
- // ********** entity mappings **********
-
- public int getXmlSequence() {
- return 2;
- }
-
- public void addXmlTypeMappingTo(XmlEntityMappings entityMappings) {
- entityMappings.getEmbeddables().add(this.xmlTypeMapping);
- }
-
- public void removeXmlTypeMappingFrom(XmlEntityMappings entityMappings) {
- entityMappings.getEmbeddables().remove(this.xmlTypeMapping);
- }
-
-
- // ********** validation **********
-
- @Override
- public boolean validatesAgainstDatabase() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
deleted file mode 100644
index 127d74b7d3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java
+++ /dev/null
@@ -1,2293 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Collection;
-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.emf.common.util.EList;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.ClassName;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SnapshotCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.JpaPlatformVariation.Supported;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AssociationOverride;
-import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.DiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.context.DiscriminatorType;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.InheritanceType;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinColumn.Owner;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.OverrideContainer;
-import org.eclipse.jpt.jpa.core.context.Override_;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlySecondaryTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.SecondaryTable;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaEntity;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaReadOnlyAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmDiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.jpa.core.context.orm.OrmNamedColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualSecondaryTable;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.EntityTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideInverseJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideJoinTableValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.AttributeOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.DiscriminatorColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityPrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericEntityPrimaryKeyValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MappedSuperclassOverrideDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.SecondaryTableValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.TableValidator;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.SingleRelationshipMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmCacheableHolder2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.orm.Inheritance;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlDiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlIdClassContainer;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlSecondaryTable;
-import org.eclipse.jpt.jpa.db.Schema;
-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> entity
- */
-public abstract class AbstractOrmEntity<X extends XmlEntity>
- extends AbstractOrmTypeMapping<X>
- implements OrmEntity, OrmCacheableHolder2_0, OrmIdClassReference.Owner
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected Entity rootEntity;
- protected final Vector<Entity> descendants = new Vector<Entity>();
-
- protected final OrmIdClassReference idClassReference;
-
- protected final OrmTable table;
- protected boolean specifiedTableIsAllowed;
- protected boolean tableIsUndefined;
-
- protected final Vector<OrmSecondaryTable> specifiedSecondaryTables = new Vector<OrmSecondaryTable>();
- protected final SpecifiedSecondaryTableContainerAdapter specifiedSecondaryTableContainerAdapter = new SpecifiedSecondaryTableContainerAdapter();
-
- protected final Vector<OrmVirtualSecondaryTable> virtualSecondaryTables = new Vector<OrmVirtualSecondaryTable>();
- protected final VirtualSecondaryTableContainerAdapter virtualSecondaryTableContainerAdapter = new VirtualSecondaryTableContainerAdapter();
-
- protected final PrimaryKeyJoinColumnOwner primaryKeyJoinColumnOwner;
- protected final Vector<OrmPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns = new Vector<OrmPrimaryKeyJoinColumn>();
- protected final SpecifiedPrimaryKeyJoinColumnContainerAdapter specifiedPrimaryKeyJoinColumnContainerAdapter = new SpecifiedPrimaryKeyJoinColumnContainerAdapter();
-
- // this is the default if there are Java columns
- protected final Vector<OrmVirtualPrimaryKeyJoinColumn> virtualPrimaryKeyJoinColumns = new Vector<OrmVirtualPrimaryKeyJoinColumn>();
- protected final VirtualPrimaryKeyJoinColumnContainerAdapter virtualPrimaryKeyJoinColumnContainerAdapter = new VirtualPrimaryKeyJoinColumnContainerAdapter();
-
- // this is the default if there are *no* Java columns
- protected ReadOnlyPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn;
-
- protected InheritanceType specifiedInheritanceStrategy;
- protected InheritanceType defaultInheritanceStrategy;
-
- protected String specifiedDiscriminatorValue;
- protected String defaultDiscriminatorValue;
- protected boolean specifiedDiscriminatorValueIsAllowed;
- protected boolean discriminatorValueIsUndefined;
-
- protected final OrmDiscriminatorColumn discriminatorColumn;
- protected boolean specifiedDiscriminatorColumnIsAllowed;
- protected boolean discriminatorColumnIsUndefined;
-
- protected final OrmAttributeOverrideContainer attributeOverrideContainer;
- protected final OrmAssociationOverrideContainer associationOverrideContainer;
-
- protected final OrmGeneratorContainer generatorContainer;
- protected final OrmQueryContainer queryContainer;
-
-
- // ********** construction **********
-
- protected AbstractOrmEntity(OrmPersistentType parent, X xmlEntity) {
- super(parent, xmlEntity);
- this.specifiedName = xmlEntity.getName();
- this.idClassReference = this.buildIdClassReference();
- this.table = this.buildTable();
- this.initializeSpecifiedSecondaryTables();
- this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner();
- this.initializeSpecifiedPrimaryKeyJoinColumns();
- this.specifiedInheritanceStrategy = this.buildSpecifiedInheritanceStrategy();
- this.specifiedDiscriminatorValue = xmlEntity.getDiscriminatorValue();
- this.discriminatorColumn = this.buildDiscriminatorColumn();
- // start with the entity as the root - it will be recalculated in update()
- this.rootEntity = this;
- this.attributeOverrideContainer = this.buildAttributeOverrideContainer();
- this.associationOverrideContainer = this.buildAssociationOverrideContainer();
- this.generatorContainer = this.buildGeneratorContainer();
- this.queryContainer = this.buildQueryContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
-
- this.setSpecifiedName_(this.xmlTypeMapping.getName());
-
- this.idClassReference.synchronizeWithResourceModel();
-
- this.table.synchronizeWithResourceModel();
-
- this.syncSpecifiedSecondaryTables();
-
- this.syncSpecifiedPrimaryKeyJoinColumns();
-
- this.setSpecifiedInheritanceStrategy_(this.buildSpecifiedInheritanceStrategy());
- this.setSpecifiedDiscriminatorValue_(this.xmlTypeMapping.getDiscriminatorValue());
- this.discriminatorColumn.synchronizeWithResourceModel();
-
- this.attributeOverrideContainer.synchronizeWithResourceModel();
- this.associationOverrideContainer.synchronizeWithResourceModel();
-
- this.generatorContainer.synchronizeWithResourceModel();
- this.queryContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
-
- this.setDefaultName(this.buildDefaultName());
-
- // calculate root entity early - other things depend on it
- this.setRootEntity(this.buildRootEntity());
- this.updateDescendants();
-
- this.idClassReference.update();
-
- this.table.update();
- this.setSpecifiedTableIsAllowed(this.buildSpecifiedTableIsAllowed());
- this.setTableIsUndefined(this.buildTableIsUndefined());
-
- this.updateVirtualSecondaryTables();
- this.updateNodes(this.getSecondaryTables());
-
- this.updateDefaultPrimaryKeyJoinColumns();
- this.updateNodes(this.getPrimaryKeyJoinColumns());
-
- this.setDefaultInheritanceStrategy(this.buildDefaultInheritanceStrategy());
-
- this.setDefaultDiscriminatorValue(this.buildDefaultDiscriminatorValue());
- this.setSpecifiedDiscriminatorValueIsAllowed(this.buildSpecifiedDiscriminatorValueIsAllowed());
- this.setDiscriminatorValueIsUndefined(this.buildDiscriminatorValueIsUndefined());
-
- this.discriminatorColumn.update();
- this.setSpecifiedDiscriminatorColumnIsAllowed(this.buildSpecifiedDiscriminatorColumnIsAllowed());
- this.setDiscriminatorColumnIsUndefined(this.buildDiscriminatorColumnIsUndefined());
-
- this.attributeOverrideContainer.update();
- this.associationOverrideContainer.update();
-
- this.generatorContainer.update();
- this.queryContainer.update();
- }
-
-
- // ********** name **********
-
- @Override
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- this.setSpecifiedName_(name);
- this.xmlTypeMapping.setName(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);
- }
-
- protected String buildDefaultName() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- if (javaEntity != null) {
- return javaEntity.getName();
- }
- String className = this.getClass_();
- return StringTools.stringIsEmpty(className) ? null : ClassName.getSimpleName(className);
- }
-
-
- // ********** root entity **********
-
- public Entity getRootEntity() {
- return this.rootEntity;
- }
-
- protected void setRootEntity(Entity entity) {
- Entity old = this.rootEntity;
- this.rootEntity = entity;
- this.firePropertyChanged(ROOT_ENTITY_PROPERTY, old, entity);
- }
-
- protected Entity buildRootEntity() {
- Entity result = this;
- for (TypeMapping typeMapping : this.getAncestors()) {
- if (typeMapping instanceof Entity) {
- result = (Entity) typeMapping;
- }
- }
- return result;
- }
-
-
- // ********** descendants **********
-
- public Iterable<Entity> getDescendants() {
- return new LiveCloneListIterable<Entity>(this.descendants);
- }
-
- protected void updateDescendants() {
- this.synchronizeCollection(this.buildDescendants(), this.descendants, DESCENDANTS_COLLECTION);
- }
-
- protected Iterable<Entity> buildDescendants() {
- return new FilteringIterable<Entity>(this.getPersistenceUnit().getEntities()) {
- @Override
- protected boolean accept(Entity entity) {
- return AbstractOrmEntity.this.entityIsDescendant(entity);
- }
- };
- }
-
- /**
- * Return whether specified entity is a descendant of the entity.
- */
- protected boolean entityIsDescendant(Entity entity) {
- String typeName = this.getPersistentType().getName();
- String entityTypeName = entity.getPersistentType().getName();
- String rootEntityTypeName = entity.getRootEntity().getPersistentType().getName();
- return Tools.valuesAreDifferent(typeName, entityTypeName) &&
- Tools.valuesAreEqual(typeName, rootEntityTypeName);
- }
-
-
- // ********** id class **********
-
- public OrmIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
- protected OrmIdClassReference buildIdClassReference() {
- return new GenericOrmIdClassReference(this, this);
- }
-
- public XmlIdClassContainer getXmlIdClassContainer() {
- return this.getXmlTypeMapping();
- }
-
- public JavaIdClassReference getJavaIdClassReferenceForDefaults() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- return (javaEntity == null) ? null : javaEntity.getIdClassReference();
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
-
- // ********** table **********
-
- public OrmTable getTable() {
- return this.table;
- }
-
- protected OrmTable buildTable() {
- return this.getContextNodeFactory().buildOrmTable(this, this.buildTableOwner());
- }
-
- protected Table.Owner buildTableOwner() {
- return new TableOwner();
- }
-
- public boolean specifiedTableIsAllowed() {
- return this.specifiedTableIsAllowed;
- }
-
- protected void setSpecifiedTableIsAllowed(boolean specifiedTableIsAllowed) {
- boolean old = this.specifiedTableIsAllowed;
- this.specifiedTableIsAllowed = specifiedTableIsAllowed;
- this.firePropertyChanged(SPECIFIED_TABLE_IS_ALLOWED_PROPERTY, old, specifiedTableIsAllowed);
- }
-
- protected boolean buildSpecifiedTableIsAllowed() {
- return ! this.isAbstractTablePerClass() && ! this.isSingleTableDescendant();
- }
-
- public boolean tableIsUndefined() {
- return this.tableIsUndefined;
- }
-
- protected void setTableIsUndefined(boolean tableIsUndefined) {
- boolean old = this.tableIsUndefined;
- this.tableIsUndefined = tableIsUndefined;
- this.firePropertyChanged(TABLE_IS_UNDEFINED_PROPERTY, old, tableIsUndefined);
- }
-
- protected boolean buildTableIsUndefined() {
- return this.isAbstractTablePerClass();
- }
-
- public String getDefaultTableName() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- if (javaEntity != null) {
- String javaName = javaEntity.getTable().getSpecifiedName();
- if ((javaName != null) && ! this.table.isSpecifiedInResource()) {
- return javaName;
- }
- }
- return this.isSingleTableDescendant() ?
- this.rootEntity.getTable().getName() :
- this.isAbstractTablePerClass() ?
- null :
- this.getName();
- }
-
- public String getDefaultSchema() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- if (javaEntity != null) {
- String javaSchema = javaEntity.getTable().getSpecifiedSchema();
- if ((javaSchema != null) && ! this.table.isSpecifiedInResource()) {
- return javaSchema;
- }
- }
- return this.isSingleTableDescendant() ?
- this.rootEntity.getTable().getSchema() :
- this.isAbstractTablePerClass() ?
- null :
- this.getContextDefaultSchema();
- }
-
- public String getDefaultCatalog() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- if (javaEntity != null) {
- String javaCatalog = javaEntity.getTable().getSpecifiedCatalog();
- if ((javaCatalog != null) && ! this.table.isSpecifiedInResource()) {
- return javaCatalog;
- }
- }
- return this.isSingleTableDescendant() ?
- this.rootEntity.getTable().getCatalog() :
- this.isAbstractTablePerClass() ?
- null :
- this.getContextDefaultCatalog();
- }
-
- protected static class TableOwner
- implements Table.Owner
- {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new TableValidator(table, textRangeResolver);
- }
- }
-
-
- // ********** secondary tables **********
-
- public ListIterator<ReadOnlySecondaryTable> secondaryTables() {
- return this.getSecondaryTables().iterator();
- }
-
- protected ListIterable<ReadOnlySecondaryTable> getSecondaryTables() {
- return this.specifiedSecondaryTables.isEmpty() ?
- this.getReadOnlyVirtualSecondaryTables() :
- this.getReadOnlySpecifiedSecondaryTables();
- }
-
- public int secondaryTablesSize() {
- return this.specifiedSecondaryTables.isEmpty() ?
- this.virtualSecondaryTables.size() :
- this.specifiedSecondaryTables.size();
- }
-
-
- // ********** specified secondary tables **********
-
- public ListIterator<OrmSecondaryTable> specifiedSecondaryTables() {
- return this.getSpecifiedSecondaryTables().iterator();
- }
-
- protected ListIterable<OrmSecondaryTable> getSpecifiedSecondaryTables() {
- return new LiveCloneListIterable<OrmSecondaryTable>(this.specifiedSecondaryTables);
- }
-
- protected ListIterable<ReadOnlySecondaryTable> getReadOnlySpecifiedSecondaryTables() {
- return new LiveCloneListIterable<ReadOnlySecondaryTable>(this.specifiedSecondaryTables);
- }
-
- public int specifiedSecondaryTablesSize() {
- return this.specifiedSecondaryTables.size();
- }
-
- public OrmSecondaryTable addSpecifiedSecondaryTable() {
- return this.addSpecifiedSecondaryTable(this.specifiedSecondaryTables.size());
- }
-
- /**
- * no state check
- */
- protected OrmSecondaryTable addSpecifiedSecondaryTable_() {
- return this.addSpecifiedSecondaryTable_(this.specifiedSecondaryTables.size());
- }
-
- /**
- * @see #setSecondaryTablesAreDefinedInXml(boolean)
- */
- public OrmSecondaryTable addSpecifiedSecondaryTable(int index) {
- if ( ! this.secondaryTablesAreDefinedInXml()) {
- throw new IllegalStateException("virtual secondary tables exist - call OrmEntity.setSecondaryTablesAreDefinedInXml(true) first"); //$NON-NLS-1$
- }
- return this.addSpecifiedSecondaryTable_(index);
- }
-
- /**
- * no state check
- */
- protected OrmSecondaryTable addSpecifiedSecondaryTable_(int index) {
- XmlSecondaryTable xmlSecondaryTable = this.buildXmlSecondaryTable();
- OrmSecondaryTable secondaryTable = this.addSpecifiedSecondaryTable_(index, xmlSecondaryTable);
- this.xmlTypeMapping.getSecondaryTables().add(index, xmlSecondaryTable);
- return secondaryTable;
- }
-
- protected XmlSecondaryTable buildXmlSecondaryTable() {
- return OrmFactory.eINSTANCE.createXmlSecondaryTable();
- }
-
- public void removeSpecifiedSecondaryTable(SecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- public void removeSpecifiedSecondaryTable(int index) {
- this.removeSpecifiedSecondaryTable_(index);
- this.xmlTypeMapping.getSecondaryTables().remove(index);
- }
-
- protected void removeSpecifiedSecondaryTable_(int index) {
- this.removeItemFromList(index, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- public void moveSpecifiedSecondaryTable(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- this.xmlTypeMapping.getSecondaryTables().move(targetIndex, sourceIndex);
- }
-
- protected void initializeSpecifiedSecondaryTables() {
- for (XmlSecondaryTable xmlTable : this.getXmlSecondaryTables()) {
- this.specifiedSecondaryTables.add(this.buildSecondaryTable(xmlTable));
- }
- }
-
- protected OrmSecondaryTable buildSecondaryTable(XmlSecondaryTable xmlSecondaryTable) {
- return this.getContextNodeFactory().buildOrmSecondaryTable(this, this.buildSecondaryTableOwner(), xmlSecondaryTable);
- }
-
- protected Table.Owner buildSecondaryTableOwner() {
- return new SecondaryTableOwner();
- }
-
- protected void clearSpecifiedSecondaryTables() {
- this.clearList(this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- this.xmlTypeMapping.getSecondaryTables().clear();
- }
-
- protected void syncSpecifiedSecondaryTables() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedSecondaryTableContainerAdapter);
- }
-
- protected Iterable<XmlSecondaryTable> getXmlSecondaryTables() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlSecondaryTable>(this.xmlTypeMapping.getSecondaryTables());
- }
-
- protected void moveSpecifiedSecondaryTable_(int index, OrmSecondaryTable secondaryTable) {
- this.moveItemInList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- }
-
- protected OrmSecondaryTable addSpecifiedSecondaryTable_(int index, XmlSecondaryTable xmlSecondaryTable) {
- OrmSecondaryTable secondaryTable = this.buildSecondaryTable(xmlSecondaryTable);
- this.addItemToList(index, secondaryTable, this.specifiedSecondaryTables, SPECIFIED_SECONDARY_TABLES_LIST);
- return secondaryTable;
- }
-
- protected void removeSpecifiedSecondaryTable_(OrmSecondaryTable secondaryTable) {
- this.removeSpecifiedSecondaryTable_(this.specifiedSecondaryTables.indexOf(secondaryTable));
- }
-
- /**
- * specified secondary table container adapter
- */
- protected class SpecifiedSecondaryTableContainerAdapter
- implements ContextContainerTools.Adapter<OrmSecondaryTable, XmlSecondaryTable>
- {
- public Iterable<OrmSecondaryTable> getContextElements() {
- return AbstractOrmEntity.this.getSpecifiedSecondaryTables();
- }
- public Iterable<XmlSecondaryTable> getResourceElements() {
- return AbstractOrmEntity.this.getXmlSecondaryTables();
- }
- public XmlSecondaryTable getResourceElement(OrmSecondaryTable contextElement) {
- return contextElement.getXmlTable();
- }
- public void moveContextElement(int index, OrmSecondaryTable element) {
- AbstractOrmEntity.this.moveSpecifiedSecondaryTable_(index, element);
- }
- public void addContextElement(int index, XmlSecondaryTable resourceElement) {
- AbstractOrmEntity.this.addSpecifiedSecondaryTable_(index, resourceElement);
- }
- public void removeContextElement(OrmSecondaryTable element) {
- AbstractOrmEntity.this.removeSpecifiedSecondaryTable_(element);
- }
- }
-
- protected static class SecondaryTableOwner
- implements Table.Owner
- {
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new SecondaryTableValidator((SecondaryTable) table, textRangeResolver);
- }
- }
-
-
- // ********** virtual secondary tables **********
-
- public ListIterator<OrmVirtualSecondaryTable> virtualSecondaryTables() {
- return this.getVirtualSecondaryTables().iterator();
- }
-
- protected ListIterable<OrmVirtualSecondaryTable> getVirtualSecondaryTables() {
- return new LiveCloneListIterable<OrmVirtualSecondaryTable>(this.virtualSecondaryTables);
- }
-
- protected ListIterable<ReadOnlySecondaryTable> getReadOnlyVirtualSecondaryTables() {
- return new LiveCloneListIterable<ReadOnlySecondaryTable>(this.virtualSecondaryTables);
- }
-
- public int virtualSecondaryTablesSize() {
- return this.virtualSecondaryTables.size();
- }
-
- protected void clearVirtualSecondaryTables() {
- this.clearList(this.virtualSecondaryTables, VIRTUAL_SECONDARY_TABLES_LIST);
- }
-
- /**
- * If there are any specified secondary tables, then there are no virtual
- * secondary tables.
- * If there are Java specified secondary tables, then those are the virtual
- * secondary tables.
- * @see #getJavaSecondaryTablesForVirtuals()
- */
- protected void updateVirtualSecondaryTables() {
- ContextContainerTools.update(this.virtualSecondaryTableContainerAdapter);
- }
-
- protected Iterable<JavaSecondaryTable> getJavaSecondaryTablesForVirtuals() {
- if (this.specifiedSecondaryTables.size() > 0) {
- return EmptyIterable.instance();
- }
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- return (javaEntity == null) ?
- EmptyIterable.<JavaSecondaryTable>instance() :
- CollectionTools.iterable(javaEntity.secondaryTables());
- }
-
- protected void moveVirtualSecondaryTable(int index, OrmVirtualSecondaryTable secondaryTable) {
- this.moveItemInList(index, secondaryTable, this.virtualSecondaryTables, VIRTUAL_SECONDARY_TABLES_LIST);
- }
-
- protected OrmVirtualSecondaryTable addVirtualSecondaryTable(int index, JavaSecondaryTable javaSecondaryTable) {
- OrmVirtualSecondaryTable secondaryTable = this.buildVirtualSecondaryTable(javaSecondaryTable);
- this.addItemToList(index, secondaryTable, this.virtualSecondaryTables, VIRTUAL_SECONDARY_TABLES_LIST);
- return secondaryTable;
- }
-
- protected OrmVirtualSecondaryTable buildVirtualSecondaryTable(JavaSecondaryTable javaSecondaryTable) {
- return this.getContextNodeFactory().buildOrmVirtualSecondaryTable(this, javaSecondaryTable);
- }
-
- protected void removeVirtualSecondaryTable(OrmVirtualSecondaryTable secondaryTable) {
- this.removeItemFromList(secondaryTable, this.virtualSecondaryTables, VIRTUAL_SECONDARY_TABLES_LIST);
- }
-
- /**
- * virtual secondary table container adapter
- */
- protected class VirtualSecondaryTableContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualSecondaryTable, JavaSecondaryTable>
- {
- public Iterable<OrmVirtualSecondaryTable> getContextElements() {
- return AbstractOrmEntity.this.getVirtualSecondaryTables();
- }
- public Iterable<JavaSecondaryTable> getResourceElements() {
- return AbstractOrmEntity.this.getJavaSecondaryTablesForVirtuals();
- }
- public JavaSecondaryTable getResourceElement(OrmVirtualSecondaryTable contextElement) {
- return contextElement.getOverriddenTable();
- }
- public void moveContextElement(int index, OrmVirtualSecondaryTable element) {
- AbstractOrmEntity.this.moveVirtualSecondaryTable(index, element);
- }
- public void addContextElement(int index, JavaSecondaryTable resourceElement) {
- AbstractOrmEntity.this.addVirtualSecondaryTable(index, resourceElement);
- }
- public void removeContextElement(OrmVirtualSecondaryTable element) {
- AbstractOrmEntity.this.removeVirtualSecondaryTable(element);
- }
- }
-
-
- // ********** secondary table transitions **********
-
- /**
- * If the list of virtual secondary tables is empty, then either the
- * secondary tables are defined in XML or there are no secondary tables at
- * all (implying they are defined in XML).
- */
- public boolean secondaryTablesAreDefinedInXml() {
- return this.virtualSecondaryTables.isEmpty();
- }
-
- public void setSecondaryTablesAreDefinedInXml(boolean defineInXml) {
- if (defineInXml != this.secondaryTablesAreDefinedInXml()) {
- this.setSecondaryTablesAreDefinedInXml_(defineInXml);
- }
- }
-
- protected void setSecondaryTablesAreDefinedInXml_(boolean defineInXml) {
- if (defineInXml) {
- this.specifySecondaryTablesInXml();
- } else {
- this.removeSecondaryTablesFromXml();
- }
- }
-
- /**
- * This is used to take all the Java secondary tables and specify them in
- * the XML. You must use {@link #setSecondaryTablesAreDefinedInXml(boolean)}
- * before calling {@link #addSpecifiedSecondaryTable()}.
- */
- protected void specifySecondaryTablesInXml() {
- Iterable<OrmVirtualSecondaryTable> oldVirtualSecondaryTables = new SnapshotCloneIterable<OrmVirtualSecondaryTable>(this.virtualSecondaryTables);
- for (OrmVirtualSecondaryTable oldVirtualSecondaryTable : oldVirtualSecondaryTables) {
- this.addSpecifiedSecondaryTable_().initializeFrom(oldVirtualSecondaryTable);
- }
- // the virtual secondary tables will be cleared during the update
- }
-
- protected void removeSecondaryTablesFromXml() {
- this.clearSpecifiedSecondaryTables();
- // the virtual secondary tables will be built during the update
- }
-
-
- // ********** primary key join columns **********
-
- public ListIterator<ReadOnlyPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.getPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<ReadOnlyPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- return this.specifiedPrimaryKeyJoinColumns.isEmpty() ?
- this.getDefaultPrimaryKeyJoinColumns() :
- this.getReadOnlySpecifiedPrimaryKeyJoinColumns();
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.isEmpty() ?
- this.defaultPrimaryKeyJoinColumnsSize() :
- this.specifiedPrimaryKeyJoinColumnsSize();
- }
-
- protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn xmlPkJoinColumn) {
- return this.getContextNodeFactory().buildOrmPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, xmlPkJoinColumn);
- }
-
-
- // ********** specified primary key join columns **********
-
- public ListIterator<OrmPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() {
- return this.getSpecifiedPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<OrmPrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<OrmPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- protected ListIterable<ReadOnlyPrimaryKeyJoinColumn> getReadOnlySpecifiedPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<ReadOnlyPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- public int specifiedPrimaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.size();
- }
-
- public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn() {
- return this.addSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.size());
- }
-
- public OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index) {
- this.clearDefaultPrimaryKeyJoinColumns(); // could leave for update?
-
- XmlPrimaryKeyJoinColumn xmlPkJoinColumn = this.buildXmlPrimaryKeyJoinColumn();
- OrmPrimaryKeyJoinColumn pkJoinColumn = this.addSpecifiedPrimaryKeyJoinColumn_(index, xmlPkJoinColumn);
- this.xmlTypeMapping.getPrimaryKeyJoinColumns().add(index, xmlPkJoinColumn);
- return pkJoinColumn;
- }
-
- protected XmlPrimaryKeyJoinColumn buildXmlPrimaryKeyJoinColumn() {
- return OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn();
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(PrimaryKeyJoinColumn primaryKeyJoinColumn) {
- this.removeSpecifiedPrimaryKeyJoinColumn(this.specifiedPrimaryKeyJoinColumns.indexOf(primaryKeyJoinColumn));
- }
-
- public void removeSpecifiedPrimaryKeyJoinColumn(int index) {
- this.removeSpecifiedPrimaryKeyJoinColumn_(index);
- this.xmlTypeMapping.getPrimaryKeyJoinColumns().remove(index);
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(int index) {
- this.removeItemFromList(index, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedPrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- this.xmlTypeMapping.getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex);
- }
-
- protected PrimaryKeyJoinColumnOwner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected void initializeSpecifiedPrimaryKeyJoinColumns() {
- for (XmlPrimaryKeyJoinColumn xmlPkJoinColumn : this.getXmlPrimaryKeyJoinColumns()) {
- this.specifiedPrimaryKeyJoinColumns.add(this.buildPrimaryKeyJoinColumn(xmlPkJoinColumn));
- }
- }
-
- protected void syncSpecifiedPrimaryKeyJoinColumns() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedPrimaryKeyJoinColumnContainerAdapter);
- }
-
- protected Iterable<XmlPrimaryKeyJoinColumn> getXmlPrimaryKeyJoinColumns() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlPrimaryKeyJoinColumn>(this.xmlTypeMapping.getPrimaryKeyJoinColumns());
- }
-
- protected void moveSpecifiedPrimaryKeyJoinColumn_(int index, OrmPrimaryKeyJoinColumn pkJoinColumn) {
- this.moveItemInList(index, pkJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected OrmPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn_(int index, XmlPrimaryKeyJoinColumn xmlPkJoinColumn) {
- OrmPrimaryKeyJoinColumn pkJoinColumn = this.buildPrimaryKeyJoinColumn(xmlPkJoinColumn);
- this.addItemToList(index, pkJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- return pkJoinColumn;
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn_(OrmPrimaryKeyJoinColumn pkJoinColumn) {
- this.removeSpecifiedPrimaryKeyJoinColumn_(this.specifiedPrimaryKeyJoinColumns.indexOf(pkJoinColumn));
- }
-
- /**
- * specified primary key join column container adapter
- */
- protected class SpecifiedPrimaryKeyJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmPrimaryKeyJoinColumn, XmlPrimaryKeyJoinColumn>
- {
- public Iterable<OrmPrimaryKeyJoinColumn> getContextElements() {
- return AbstractOrmEntity.this.getSpecifiedPrimaryKeyJoinColumns();
- }
- public Iterable<XmlPrimaryKeyJoinColumn> getResourceElements() {
- return AbstractOrmEntity.this.getXmlPrimaryKeyJoinColumns();
- }
- public XmlPrimaryKeyJoinColumn getResourceElement(OrmPrimaryKeyJoinColumn contextElement) {
- return contextElement.getXmlColumn();
- }
- public void moveContextElement(int index, OrmPrimaryKeyJoinColumn element) {
- AbstractOrmEntity.this.moveSpecifiedPrimaryKeyJoinColumn_(index, element);
- }
- public void addContextElement(int index, XmlPrimaryKeyJoinColumn resourceElement) {
- AbstractOrmEntity.this.addSpecifiedPrimaryKeyJoinColumn_(index, resourceElement);
- }
- public void removeContextElement(OrmPrimaryKeyJoinColumn element) {
- AbstractOrmEntity.this.removeSpecifiedPrimaryKeyJoinColumn_(element);
- }
- }
-
-
- // ********** default primary key join columns **********
-
- public ListIterator<ReadOnlyPrimaryKeyJoinColumn> defaultPrimaryKeyJoinColumns() {
- return this.getDefaultPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<ReadOnlyPrimaryKeyJoinColumn> getDefaultPrimaryKeyJoinColumns() {
- int virtualSize = this.virtualPrimaryKeyJoinColumns.size();
- return (virtualSize != 0) ?
- this.getReadOnlyVirtualPrimaryKeyJoinColumns() :
- this.getReadOnlyDefaultPrimaryKeyJoinColumns();
- }
-
- public int defaultPrimaryKeyJoinColumnsSize() {
- int virtualSize = this.virtualPrimaryKeyJoinColumns.size();
- return (virtualSize != 0) ?
- virtualSize :
- (this.defaultPrimaryKeyJoinColumn != null) ? 1 : 0;
- }
-
- /**
- * This is (blindly) called whenever a specified pk join column is added.
- */
- protected void clearDefaultPrimaryKeyJoinColumns() {
- int virtualSize = this.virtualPrimaryKeyJoinColumns.size();
- if (virtualSize != 0) {
- this.clearVirtualPrimaryKeyJoinColumns();
- } else {
- if (this.defaultPrimaryKeyJoinColumn != null) {
- this.removeDefaultPrimaryKeyJoinColumn();
- } else {
- // nothing to clear
- }
- }
- }
-
- /**
- * If there are any specified pk join columns, then there are no default
- * pk join columns.
- * If there are Java specified pk join columns, then those are the default
- * pk join columns.
- * Otherwise, there is a single, spec-defined, default pk join column.
- */
- protected void updateDefaultPrimaryKeyJoinColumns() {
- if (this.specifiedPrimaryKeyJoinColumns.size() > 0) {
- // specified/java/default => specified
- this.clearDefaultPrimaryKeyJoinColumns();
- } else {
- // specified
- if (this.defaultPrimaryKeyJoinColumnsSize() == 0) {
- if (this.javaPrimaryKeyJoinColumnsWillBeDefaults()) {
- // specified => java
- this.initializeVirtualPrimaryKeyJoinColumns();
- } else {
- // specified => default
- this.addDefaultPrimaryKeyJoinColumn();
- }
- } else {
- // default
- if (this.defaultPrimaryKeyJoinColumn != null) {
- if (this.javaPrimaryKeyJoinColumnsWillBeDefaults()) {
- // default => java
- this.removeDefaultPrimaryKeyJoinColumn();
- this.initializeVirtualPrimaryKeyJoinColumns();
- } else {
- // default => default (no change)
- }
- // java
- } else {
- if (this.javaPrimaryKeyJoinColumnsWillBeDefaults()) {
- // java => java ("normal" update)
- this.updateVirtualPrimaryKeyJoinColumns();
- } else {
- // java => default
- this.clearVirtualPrimaryKeyJoinColumns();
- this.addDefaultPrimaryKeyJoinColumn();
- }
- }
- }
- }
- }
-
- protected void updateVirtualPrimaryKeyJoinColumns() {
- ContextContainerTools.update(this.virtualPrimaryKeyJoinColumnContainerAdapter);
- }
-
- /**
- * Return whether we have Java pk join columns that will be used to populate
- * our virtual pk join column collection.
- */
- protected boolean javaPrimaryKeyJoinColumnsWillBeDefaults() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- return (javaEntity != null) && (javaEntity.primaryKeyJoinColumnsSize() > 0);
- }
-
-
- // ********** virtual primary key join columns **********
-
- protected ListIterable<OrmVirtualPrimaryKeyJoinColumn> getVirtualPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<OrmVirtualPrimaryKeyJoinColumn>(this.virtualPrimaryKeyJoinColumns);
- }
-
- protected ListIterable<ReadOnlyPrimaryKeyJoinColumn> getReadOnlyVirtualPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<ReadOnlyPrimaryKeyJoinColumn>(this.virtualPrimaryKeyJoinColumns);
- }
-
- protected void initializeVirtualPrimaryKeyJoinColumns() {
- for (JavaPrimaryKeyJoinColumn javaPkJoinColumn : this.getJavaPrimaryKeyJoinColumnsForVirtuals()) {
- this.addVirtualPrimaryKeyJoinColumn(this.buildVirtualPrimaryKeyJoinColumn(javaPkJoinColumn));
- }
- }
-
- protected void addVirtualPrimaryKeyJoinColumn(OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- this.addVirtualPrimaryKeyJoinColumn(this.virtualPrimaryKeyJoinColumns.size(), pkJoinColumn);
- }
-
- protected void addVirtualPrimaryKeyJoinColumn(int index, OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- this.addItemToList(index, pkJoinColumn, this.virtualPrimaryKeyJoinColumns, DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected void clearVirtualPrimaryKeyJoinColumns() {
- this.clearList(this.virtualPrimaryKeyJoinColumns, DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- /**
- * This will only be called when there are Java pk join columns to return.
- * @see #javaPrimaryKeyJoinColumnsWillBeDefaults()
- */
- protected Iterable<JavaPrimaryKeyJoinColumn> getJavaPrimaryKeyJoinColumnsForVirtuals() {
- return CollectionTools.iterable(this.getJavaTypeMappingForDefaults().primaryKeyJoinColumns());
- }
-
- protected void moveVirtualPrimaryKeyJoinColumn(int index, OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- this.moveItemInList(index, pkJoinColumn, this.virtualPrimaryKeyJoinColumns, DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected OrmVirtualPrimaryKeyJoinColumn addVirtualPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn) {
- OrmVirtualPrimaryKeyJoinColumn pkJoinColumn = this.buildVirtualPrimaryKeyJoinColumn(javaPrimaryKeyJoinColumn);
- this.addVirtualPrimaryKeyJoinColumn(index, pkJoinColumn);
- return pkJoinColumn;
- }
-
- protected OrmVirtualPrimaryKeyJoinColumn buildVirtualPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn) {
- return this.getContextNodeFactory().buildOrmVirtualPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, javaPrimaryKeyJoinColumn);
- }
-
- protected void removeVirtualPrimaryKeyJoinColumn(OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- this.removeItemFromList(pkJoinColumn, this.virtualPrimaryKeyJoinColumns, DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- /**
- * virtual primary key join column container adapter
- */
- protected class VirtualPrimaryKeyJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualPrimaryKeyJoinColumn, JavaPrimaryKeyJoinColumn>
- {
- public Iterable<OrmVirtualPrimaryKeyJoinColumn> getContextElements() {
- return AbstractOrmEntity.this.getVirtualPrimaryKeyJoinColumns();
- }
- public Iterable<JavaPrimaryKeyJoinColumn> getResourceElements() {
- return AbstractOrmEntity.this.getJavaPrimaryKeyJoinColumnsForVirtuals();
- }
- public JavaPrimaryKeyJoinColumn getResourceElement(OrmVirtualPrimaryKeyJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, OrmVirtualPrimaryKeyJoinColumn element) {
- AbstractOrmEntity.this.moveVirtualPrimaryKeyJoinColumn(index, element);
- }
- public void addContextElement(int index, JavaPrimaryKeyJoinColumn resourceElement) {
- AbstractOrmEntity.this.addVirtualPrimaryKeyJoinColumn(index, resourceElement);
- }
- public void removeContextElement(OrmVirtualPrimaryKeyJoinColumn element) {
- AbstractOrmEntity.this.removeVirtualPrimaryKeyJoinColumn(element);
- }
- }
-
-
- // ********** default primary key join column **********
-
- protected ListIterable<ReadOnlyPrimaryKeyJoinColumn> getReadOnlyDefaultPrimaryKeyJoinColumns() {
- return (this.defaultPrimaryKeyJoinColumn != null) ?
- new SingleElementListIterable<ReadOnlyPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn) :
- EmptyListIterable.<ReadOnlyPrimaryKeyJoinColumn>instance();
- }
-
- protected void addDefaultPrimaryKeyJoinColumn() {
- this.defaultPrimaryKeyJoinColumn = this.buildPrimaryKeyJoinColumn(null);
- this.fireItemAdded(DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST, 0, this.defaultPrimaryKeyJoinColumn);
- }
-
- protected void removeDefaultPrimaryKeyJoinColumn() {
- ReadOnlyPrimaryKeyJoinColumn old = this.defaultPrimaryKeyJoinColumn;
- this.defaultPrimaryKeyJoinColumn = null;
- this.fireItemRemoved(DEFAULT_PRIMARY_KEY_JOIN_COLUMNS_LIST, 0, old);
- }
-
- protected ReadOnlyPrimaryKeyJoinColumn buildDefaultPrimaryKeyJoinColumn() {
- return this.buildPrimaryKeyJoinColumn(null);
- }
-
-
- // ********** inheritance strategy **********
-
- public InheritanceType getInheritanceStrategy() {
- return (this.specifiedInheritanceStrategy != null) ? this.specifiedInheritanceStrategy : this.defaultInheritanceStrategy;
- }
-
- public InheritanceType getSpecifiedInheritanceStrategy() {
- return this.specifiedInheritanceStrategy;
- }
-
- public void setSpecifiedInheritanceStrategy(InheritanceType inheritanceType) {
- if (this.valuesAreDifferent(this.specifiedInheritanceStrategy, inheritanceType)) {
- Inheritance xmlInheritance = this.getXmlInheritanceForUpdate();
- this.setSpecifiedInheritanceStrategy_(inheritanceType);
- xmlInheritance.setStrategy(InheritanceType.toOrmResourceModel(inheritanceType));
- this.removeXmlInheritanceIfUnset();
- }
- }
-
- protected void setSpecifiedInheritanceStrategy_(InheritanceType inheritanceType) {
- InheritanceType old = this.specifiedInheritanceStrategy;
- this.specifiedInheritanceStrategy = inheritanceType;
- this.firePropertyChanged(SPECIFIED_INHERITANCE_STRATEGY_PROPERTY, old, inheritanceType);
- }
-
- protected InheritanceType buildSpecifiedInheritanceStrategy() {
- Inheritance xmlInheritance = this.xmlTypeMapping.getInheritance();
- return (xmlInheritance == null) ? null : InheritanceType.fromOrmResourceModel(xmlInheritance.getStrategy());
- }
-
- protected Inheritance getXmlInheritanceForUpdate() {
- Inheritance xmlInheritance = this.xmlTypeMapping.getInheritance();
- return (xmlInheritance != null) ? xmlInheritance : this.buildXmlInheritance();
- }
-
- protected Inheritance buildXmlInheritance() {
- Inheritance xmlInheritance = OrmFactory.eINSTANCE.createInheritance();
- this.xmlTypeMapping.setInheritance(xmlInheritance);
- return xmlInheritance;
- }
-
- protected void removeXmlInheritanceIfUnset() {
- if (this.xmlTypeMapping.getInheritance().isUnset()) {
- this.xmlTypeMapping.setInheritance(null);
- }
- }
-
- public InheritanceType getDefaultInheritanceStrategy() {
- return this.defaultInheritanceStrategy;
- }
-
- protected void setDefaultInheritanceStrategy(InheritanceType inheritanceType) {
- InheritanceType old = this.defaultInheritanceStrategy;
- this.defaultInheritanceStrategy = inheritanceType;
- this.firePropertyChanged(DEFAULT_INHERITANCE_STRATEGY_PROPERTY, old, inheritanceType);
- }
-
- protected InheritanceType buildDefaultInheritanceStrategy() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- if ((javaEntity != null) && (this.xmlTypeMapping.getInheritance() == null)) {
- return javaEntity.getInheritanceStrategy();
- }
- return this.isRoot() ?
- InheritanceType.SINGLE_TABLE :
- this.rootEntity.getInheritanceStrategy();
- }
-
-
- // ********** discriminator value **********
-
- public String getDiscriminatorValue() {
- return (this.specifiedDiscriminatorValue != null) ? this.specifiedDiscriminatorValue : this.defaultDiscriminatorValue;
- }
-
- public String getSpecifiedDiscriminatorValue() {
- return this.specifiedDiscriminatorValue;
- }
-
- public void setSpecifiedDiscriminatorValue(String discriminatorValue) {
- this.setSpecifiedDiscriminatorValue_(discriminatorValue);
- this.xmlTypeMapping.setDiscriminatorValue(discriminatorValue);
- }
-
- protected void setSpecifiedDiscriminatorValue_(String discriminatorValue) {
- String old = this.specifiedDiscriminatorValue;
- this.specifiedDiscriminatorValue = discriminatorValue;
- this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_PROPERTY, old, discriminatorValue);
- }
-
- public String getDefaultDiscriminatorValue() {
- return this.defaultDiscriminatorValue;
- }
-
- protected void setDefaultDiscriminatorValue(String discriminatorValue) {
- String old = this.defaultDiscriminatorValue;
- this.defaultDiscriminatorValue = discriminatorValue;
- this.firePropertyChanged(DEFAULT_DISCRIMINATOR_VALUE_PROPERTY, old, discriminatorValue);
- }
-
- /**
- * 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() {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- if (javaEntity != null) {
- return javaEntity.getDiscriminatorValue();
- }
- if (this.discriminatorValueIsUndefined) {
- return null;
- }
- return (this.getDiscriminatorType() == DiscriminatorType.STRING) ? this.getName() : null;
- }
-
- protected DiscriminatorType getDiscriminatorType() {
- return this.discriminatorColumn.getDiscriminatorType();
- }
-
- public boolean specifiedDiscriminatorValueIsAllowed() {
- return this.specifiedDiscriminatorValueIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorValueIsAllowed(boolean allowed) {
- boolean old = this.specifiedDiscriminatorValueIsAllowed;
- this.specifiedDiscriminatorValueIsAllowed = allowed;
- this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_VALUE_IS_ALLOWED_PROPERTY, old, allowed);
- }
-
- protected boolean buildSpecifiedDiscriminatorValueIsAllowed() {
- return ! this.isTablePerClass() && ! this.isAbstract();
- }
-
- public boolean discriminatorValueIsUndefined() {
- return this.discriminatorValueIsUndefined;
- }
-
- protected void setDiscriminatorValueIsUndefined(boolean undefined) {
- boolean old = this.discriminatorValueIsUndefined;
- this.discriminatorValueIsUndefined = undefined;
- this.firePropertyChanged(DISCRIMINATOR_VALUE_IS_UNDEFINED_PROPERTY, old, undefined);
- }
-
- protected boolean buildDiscriminatorValueIsUndefined() {
- return this.isTablePerClass() ||
- this.isAbstract() ||
- this.isRootNoDescendantsNoStrategyDefined();
- }
-
-
- // ********** discriminator column **********
-
- public OrmDiscriminatorColumn getDiscriminatorColumn() {
- return this.discriminatorColumn;
- }
-
- protected OrmDiscriminatorColumn buildDiscriminatorColumn() {
- return this.getContextNodeFactory().buildOrmDiscriminatorColumn(this, this.buildDiscriminatorColumnOwner());
- }
-
- protected OrmDiscriminatorColumn.Owner buildDiscriminatorColumnOwner() {
- return new DiscriminatorColumnOwner();
- }
-
- public boolean specifiedDiscriminatorColumnIsAllowed() {
- return this.specifiedDiscriminatorColumnIsAllowed;
- }
-
- protected void setSpecifiedDiscriminatorColumnIsAllowed(boolean allowed) {
- boolean old = this.specifiedDiscriminatorColumnIsAllowed;
- this.specifiedDiscriminatorColumnIsAllowed = allowed;
- this.firePropertyChanged(SPECIFIED_DISCRIMINATOR_COLUMN_IS_ALLOWED_PROPERTY, old, allowed);
- }
-
- protected boolean buildSpecifiedDiscriminatorColumnIsAllowed() {
- return ! this.isTablePerClass() && this.isRoot();
- }
-
- public boolean discriminatorColumnIsUndefined() {
- return this.discriminatorColumnIsUndefined;
- }
-
- protected void setDiscriminatorColumnIsUndefined(boolean undefined) {
- boolean old = this.discriminatorColumnIsUndefined;
- this.discriminatorColumnIsUndefined = undefined;
- this.firePropertyChanged(DISCRIMINATOR_COLUMN_IS_UNDEFINED_PROPERTY, old, undefined);
- }
-
- protected boolean buildDiscriminatorColumnIsUndefined() {
- return this.isTablePerClass() ||
- this.isRootNoDescendantsNoStrategyDefined();
- }
-
-
- // ********** attribute override container **********
-
- public OrmAttributeOverrideContainer getAttributeOverrideContainer() {
- return this.attributeOverrideContainer;
- }
-
- protected OrmAttributeOverrideContainer buildAttributeOverrideContainer() {
- return this.getContextNodeFactory().buildOrmAttributeOverrideContainer(this, new AttributeOverrideContainerOwner());
- }
-
- protected TypeMapping getOverridableTypeMapping() {
- PersistentType superPersistentType = this.getPersistentType().getSuperPersistentType();
- return (superPersistentType == null) ? null : superPersistentType.getMapping();
- }
-
- protected Column resolveOverriddenColumnForAttributeOverride(String attributeName) {
- if ( ! this.isMetadataComplete()) {
- JavaPersistentType javaType = this.getJavaPersistentType();
- if (javaType != null) {
- Column column = javaType.getMapping().resolveOverriddenColumn(attributeName);
- if (column != null) {
- return column;
- }
- }
- }
- return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName);
- }
-
- protected JavaReadOnlyAttributeOverride getJavaAttributeOverrideNamedForVirtual(String attributeName) {
- JavaEntity javaEntity = this.getJavaTypeMappingForDefaults();
- return (javaEntity == null) ? null : javaEntity.getAttributeOverrideContainer().getOverrideNamed(attributeName);
- }
-
-
- // ********** association override container **********
-
- public OrmAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.associationOverrideContainer;
- }
-
- protected OrmAssociationOverrideContainer buildAssociationOverrideContainer() {
- return this.getContextNodeFactory().buildOrmAssociationOverrideContainer(this, new AssociationOverrideContainerOwner());
- }
-
- @Override
- public Relationship resolveOverriddenRelationship(String attributeName) {
- if (this.isJpa2_0Compatible()) {
- // strip off the first segment
- int dotIndex = attributeName.indexOf('.');
- if (dotIndex != -1) {
- AssociationOverride override = this.associationOverrideContainer.getSpecifiedOverrideNamed(attributeName.substring(dotIndex + 1));
- if (override != null) {
- return override.getRelationship();
- }
- }
- }
- return super.resolveOverriddenRelationship(attributeName);
- }
-
- protected Relationship resolveOverriddenRelationshipForAssociationOverride(String attributeName) {
- if ( ! this.isMetadataComplete()) {
- JavaPersistentType javaType = this.getJavaPersistentType();
- if (javaType != null) {
- Relationship relationship = javaType.getMapping().resolveOverriddenRelationship(attributeName);
- if (relationship != null) {
- return relationship;
- }
- }
- }
- return MappingTools.resolveOverriddenRelationship(this.getOverridableTypeMapping(), attributeName);
- }
-
-
- // ********** generator container **********
-
- public OrmGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- protected OrmGeneratorContainer buildGeneratorContainer() {
- return this.getContextNodeFactory().buildOrmGeneratorContainer(this, this.xmlTypeMapping);
- }
-
-
- // ********** query container **********
-
- public OrmQueryContainer getQueryContainer() {
- return this.queryContainer;
- }
-
- protected OrmQueryContainer buildQueryContainer() {
- return this.getContextNodeFactory().buildOrmQueryContainer(this, this.xmlTypeMapping);
- }
-
-
- // ********** associated tables **********
-
- public Iterator<ReadOnlyTable> associatedTables() {
- return this.getAssociatedTables().iterator();
- }
-
- public Iterable<ReadOnlyTable> getAssociatedTables() {
- return new CompositeIterable<ReadOnlyTable>(this.table, this.getSecondaryTables());
- }
-
- public Iterator<ReadOnlyTable> allAssociatedTables() {
- return new CompositeIterator<ReadOnlyTable>(this.allAssociatedTablesLists());
- }
-
- public Iterable<ReadOnlyTable> getAllAssociatedTables() {
- return CollectionTools.iterable(this.allAssociatedTables());
- }
-
- // TODO eliminate duplicate tables?
- protected Iterator<Iterator<ReadOnlyTable>> allAssociatedTablesLists() {
- return new TransformationIterator<TypeMapping, Iterator<ReadOnlyTable>>(this.inheritanceHierarchy(), TypeMappingTools.ASSOCIATED_TABLES_TRANSFORMER);
- }
-
- public Iterator<String> allAssociatedTableNames() {
- return this.getAllAssociatedTableNames().iterator();
- }
-
- public Iterable<String> getAllAssociatedTableNames() {
- return this.convertToNames(this.getAllAssociatedTables());
- }
-
- /**
- * strip out <code>null</code> names
- */
- protected Iterable<String> convertToNames(Iterable<ReadOnlyTable> tables) {
- return new FilteringIterable<String>(this.convertToNames_(tables), NotNullFilter.<String>instance());
- }
-
- protected Iterable<String> convertToNames_(Iterable<ReadOnlyTable> tables) {
- return new TransformationIterable<ReadOnlyTable, String>(tables) {
- @Override
- protected String transform(ReadOnlyTable t) {
- return t.getName();
- }
- };
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return ! this.tableNameIsValid(tableName);
- }
-
- protected boolean tableNameIsValid(String tableName) {
- return this.tableIsUndefined || CollectionTools.contains(this.getAllAssociatedTableNames(), tableName);
- }
-
-
- // ********** Java **********
-
- @Override
- public JavaEntity getJavaTypeMapping() {
- return (JavaEntity) super.getJavaTypeMapping();
- }
-
- @Override
- public JavaEntity getJavaTypeMappingForDefaults() {
- return (JavaEntity) super.getJavaTypeMappingForDefaults();
- }
-
-
- // ********** database **********
-
- @Override
- public String getPrimaryTableName() {
- return this.table.getName();
- }
-
- @Override
- public org.eclipse.jpt.jpa.db.Table getPrimaryDbTable() {
- return this.table.getDbTable();
- }
-
- @Override
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- // matching database objects and identifiers is database platform-specific
- return this.getDataSource().selectTableForIdentifier(this.getAllAssociatedDbTables(), tableName);
- }
-
- /**
- * strip out null db tables
- */
- protected Iterable<org.eclipse.jpt.jpa.db.Table> getAllAssociatedDbTables() {
- return new FilteringIterable<org.eclipse.jpt.jpa.db.Table>(this.getAllAssociatedDbTables_(), NotNullFilter.<org.eclipse.jpt.jpa.db.Table>instance());
- }
-
- protected Iterable<org.eclipse.jpt.jpa.db.Table> getAllAssociatedDbTables_() {
- return new TransformationIterable<ReadOnlyTable, org.eclipse.jpt.jpa.db.Table>(this.getAllAssociatedTables()) {
- @Override
- protected org.eclipse.jpt.jpa.db.Table transform(ReadOnlyTable t) {
- return t.getDbTable();
- }
- };
- }
-
- @Override
- public Schema getDbSchema() {
- return this.table.getDbSchema();
- }
-
-
- // ********** primary key **********
-
- public String getPrimaryKeyColumnName() {
- return MappingTools.getPrimaryKeyColumnName(this);
- }
-
- public PersistentAttribute getIdAttribute() {
- Iterator<AttributeMapping> idAttributeMappings = this.getAllAttributeMappings(MappingKeys.ID_ATTRIBUTE_MAPPING_KEY).iterator();
- if (idAttributeMappings.hasNext()) {
- PersistentAttribute attribute = idAttributeMappings.next().getPersistentAttribute();
- return idAttributeMappings.hasNext() ? null /*more than one*/: attribute;
- }
- return null;
- }
-
-
- // ********** key **********
-
- public String getKey() {
- return MappingKeys.ENTITY_TYPE_MAPPING_KEY;
- }
-
-
- // ********** entity mappings **********
-
- public int getXmlSequence() {
- return 1;
- }
-
- public void addXmlTypeMappingTo(XmlEntityMappings entityMappings) {
- entityMappings.getEntities().add(this.xmlTypeMapping);
- }
-
- public void removeXmlTypeMappingFrom(XmlEntityMappings entityMappings) {
- entityMappings.getEntities().remove(this.xmlTypeMapping);
- }
-
-
- // ********** attribute mappings **********
-
- @Override
- public Column resolveOverriddenColumn(String attributeName) {
- if (this.isJpa2_0Compatible()) {
- // strip off the first segment
- int dotIndex = attributeName.indexOf('.');
- if (dotIndex != -1) {
- AttributeOverride override = this.attributeOverrideContainer.getSpecifiedOverrideNamed(attributeName.substring(dotIndex + 1));
- if (override != null) {
- return override.getColumn();
- }
- }
- }
- return super.resolveOverriddenColumn(attributeName);
- }
-
- @Override
- public Iterator<String> overridableAttributeNames() {
- return this.isTablePerClass() ?
- super.overridableAttributeNames() :
- EmptyIterator.<String>instance();
- }
-
- @Override
- public Iterator<String> overridableAssociationNames() {
- return this.isTablePerClass() ?
- super.overridableAssociationNames() :
- EmptyIterator.<String>instance();
- }
-
- public AttributeMapping resolveAttributeMapping(String name) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.allAttributeMappings())) {
- AttributeMapping resolvedMapping = attributeMapping.resolveAttributeMapping(name);
- if (resolvedMapping != null) {
- return resolvedMapping;
- }
- }
- return null;
- }
-
-
- // ********** inheritance **********
-
- public Entity getParentEntity() {
- for (TypeMapping typeMapping : this.getAncestors()) {
- if (typeMapping instanceof Entity) {
- return (Entity) typeMapping;
- }
- }
- return null;
- }
-
- /**
- * Return whether the entity is the top of an inheritance hierarchy.
- */
- public boolean isRoot() {
- return this == this.rootEntity;
- }
-
- /**
- * 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 a descendant of the root entity
- * of a "single table" inheritance hierarchy.
- */
- protected boolean isSingleTableDescendant() {
- return this.isDescendant() &&
- (this.getInheritanceStrategy() == InheritanceType.SINGLE_TABLE);
- }
-
- /**
- * 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 this.isRoot() &&
- this.descendants.isEmpty() &&
- (this.specifiedInheritanceStrategy == null);
- }
-
- /**
- * Return whether the entity is abstract and is a part of a
- * "table per class" inheritance hierarchy.
- */
- protected boolean isAbstractTablePerClass() {
- return this.isAbstract() && this.isTablePerClass();
- }
-
- protected boolean resourceTableIsSpecified() {
- return this.table.isSpecifiedInResource() || this.javaResourceTableIsSpecified();
- }
-
- protected boolean javaResourceTableIsSpecified() {
- JavaEntity javaEntity = this.getJavaTypeMapping();
- return (javaEntity != null) && javaEntity.getTable().isSpecifiedInResource();
- }
-
- /**
- * 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 jrpt = this.getJavaResourcePersistentType();
- return (jrpt != null) && jrpt.isAbstract();
- }
-
- /**
- * Return whether the entity's type is abstract.
- */
- protected boolean isFinal() {
- JavaResourcePersistentType jrpt = this.getJavaResourcePersistentType();
- return (jrpt != null) && jrpt.isFinal();
- }
-
- /**
- * Return whether the entity's type is a member of another type.
- */
- protected boolean isMember() {
- JavaResourcePersistentType jrpt = this.getJavaResourcePersistentType();
- return (jrpt != null) && jrpt.isMemberType();
- }
-
- /**
- * Return whether the entity's type is static.
- */
- protected boolean isStatic() {
- JavaResourcePersistentType jrpt = this.getJavaResourcePersistentType();
- return (jrpt != null) && jrpt.isStatic();
- }
-
-
- // ********** refactoring **********
-
- @Override
- @SuppressWarnings("unchecked")
- 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);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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);
-
- this.validatePrimaryKey(messages, reporter);
- this.validateTable(messages, reporter);
- for (OrmSecondaryTable secondaryTable : this.getSpecifiedSecondaryTables()) {
- secondaryTable.validate(messages, reporter);
- }
- this.validateInheritance(messages, reporter);
- for (OrmPrimaryKeyJoinColumn pkJoinColumn : this.getSpecifiedPrimaryKeyJoinColumns()) {
- pkJoinColumn.validate(messages, reporter);
- }
- this.attributeOverrideContainer.validate(messages, reporter);
- this.associationOverrideContainer.validate(messages, reporter);
- this.generatorContainer.validate(messages, reporter);
- this.queryContainer.validate(messages, reporter);
- this.validateEntityName(messages);
- this.validateDuplicateEntityNames(messages);
- this.idClassReference.validate(messages, reporter);
- }
-
- protected void validateEntityName(List<IMessage> messages) {
- if (StringTools.stringIsEmpty(this.getName())){
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NAME_MISSING,
- new String[] {this.getClass_()},
- this,
- this.getNameTextRange()
- )
- );
- }
- }
-
- protected void validateDuplicateEntityNames(List<IMessage> messages) {
- HashBag<String> javaEntityNamesExclOverridden = CollectionTools.bag(this.getPersistenceUnit().javaEntityNamesExclOverridden());
- Map<String, Set<String>> map = this.getPersistenceUnit().mapEntityNameToClassNames();
- Set<String> classNames = map.get(this.getName());
- // Check whether or not this entity name has duplicates among the orm entities defined with different classes
- if (((classNames != null) && (classNames.size() > 1)) ||
- // Check whether or not this entity name has duplicates among
- // the java entities that are not defined in the mapping files
- (javaEntityNamesExclOverridden.contains(this.getName()))) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NAME_DUPLICATED,
- new String[] {this.getName()},
- this,
- this.getNameTextRange()
- )
- );
- }
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter) {
- this.buildPrimaryKeyValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator() {
- return new GenericEntityPrimaryKeyValidator(this, this.buildTextRangeResolver());
- // TODO - JPA 2.0 validation
- }
-
- @Override
- protected EntityTextRangeResolver buildTextRangeResolver() {
- return new OrmEntityTextRangeResolver(this);
- }
-
- protected void validateTable(List<IMessage> messages, IReporter reporter) {
- if (this.isAbstractTablePerClass()) {
- if (this.resourceTableIsSpecified()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_TABLE_PER_CLASS_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.table.getValidationTextRange()
- )
- );
- }
- return;
- }
- if (this.isSingleTableDescendant() && this.getDataSource().connectionProfileIsActive()) {
- if (this.specifiedTableDoesNotMatchRootTable()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_SINGLE_TABLE_DESCENDANT_DEFINES_TABLE,
- new String[] {this.getName()},
- this,
- this.table.getValidationTextRange()
- )
- );
- }
- return;
- }
- this.table.validate(messages, reporter);
- }
-
- /**
- * Return whether the entity specifies a table and it is a different table
- * than the root entity's table.
- */
- protected boolean specifiedTableDoesNotMatchRootTable() {
- return this.table.isSpecifiedInResource() &&
- (this.table.getDbTable() != this.getRootEntity().getTable().getDbTable());
- }
-
- protected void validateInheritance(List<IMessage> messages, IReporter reporter) {
- this.validateInheritanceStrategy(messages);
- this.validateDiscriminatorColumn(messages, reporter);
- this.validateDiscriminatorValue(messages);
- }
-
- protected void validateDiscriminatorColumn(List<IMessage> messages, IReporter reporter) {
- if (this.specifiedDiscriminatorColumnIsAllowed && ! this.discriminatorColumnIsUndefined) {
- this.discriminatorColumn.validate(messages, reporter);
- }
- else if (this.discriminatorColumn.isResourceSpecified()) {
- if (this.isDescendant()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.ENTITY_NON_ROOT_DISCRIMINATOR_COLUMN_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorColumnTextRange()
- )
- );
- }
- else if (this.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 (this.discriminatorValueIsUndefined && (this.specifiedDiscriminatorValue != null)) {
- if (this.isAbstract()) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.ENTITY_ABSTRACT_DISCRIMINATOR_VALUE_DEFINED,
- new String[] {this.getName()},
- this,
- this.getDiscriminatorValueTextRange()
- )
- );
- }
- else if (this.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 = this.getJpaPlatformVariation().getTablePerConcreteClassInheritanceIsSupported();
- if (tablePerConcreteClassInheritanceIsSupported == Supported.YES) {
- return;
- }
- if ((this.getInheritanceStrategy() == InheritanceType.TABLE_PER_CLASS) && this.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.getValidationTextRange(this.xmlTypeMapping.getDiscriminatorValueTextRange());
- }
-
- protected TextRange getDiscriminatorColumnTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getDiscriminatorColumn().getValidationTextRange());
- }
-
- protected TextRange getInheritanceStrategyTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getInheritanceStrategyTextRange());
- }
-
-
- // ********** OrmOverrideContainer.Owner implementation **********
-
- /**
- * some common behavior
- */
- protected abstract class OverrideContainerOwner
- implements OrmOverrideContainer.Owner
- {
- public OrmTypeMapping getTypeMapping() {
- return AbstractOrmEntity.this;
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmEntity.this.getValidationTextRange();
- }
-
- public TypeMapping getOverridableTypeMapping() {
- return AbstractOrmEntity.this.getOverridableTypeMapping();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = this.getOverridableTypeMapping();
- return (typeMapping != null) ? this.allOverridableNames_(typeMapping) : EmptyIterator.<String>instance();
- }
-
- /**
- * pre-condition: <code>typeMapping</code> is not <code>null</code>
- */
- protected abstract Iterator<String> allOverridableNames_(TypeMapping typeMapping);
-
- public String getDefaultTableName() {
- return AbstractOrmEntity.this.getPrimaryTableName();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return AbstractOrmEntity.this.tableNameIsInvalid(tableName);
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return AbstractOrmEntity.this.resolveDbTable(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return AbstractOrmEntity.this.allAssociatedTableNames();
- }
- }
-
-
- // ********** OrmAttributeOverrideContainer.Owner implementation **********
-
- protected class AttributeOverrideContainerOwner
- extends OverrideContainerOwner
- implements OrmAttributeOverrideContainer.Owner
- {
- @Override
- protected Iterator<String> allOverridableNames_(TypeMapping typeMapping) {
- final Collection<String> mappedByRelationshipAttributes = CollectionTools.collection(
- new TransformationIterator<SingleRelationshipMapping2_0, String>(this.getMapsIdRelationships()) {
- @Override
- protected String transform(SingleRelationshipMapping2_0 mapping) {
- return mapping.getDerivedIdentity().getMapsIdDerivedIdentityStrategy().getValue();
- }
- });
- return new FilteringIterator<String>(typeMapping.allOverridableAttributeNames()) {
- @Override
- protected boolean accept(String name) {
- if (mappedByRelationshipAttributes.isEmpty()) {
- return true;
- }
- // overridable names are (usually?) qualified with a container mapping,
- // which may also be the one mapped by a relationship
- int index = name.indexOf('.');
- String qualifier = (index > 0) ? name.substring(0, index) : name;
- return ! mappedByRelationshipAttributes.contains(qualifier);
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getMapsIdRelationships() {
- return new FilteringIterable<SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings()) {
- @Override
- protected boolean accept(SingleRelationshipMapping2_0 mapping) {
- return mapping.getDerivedIdentity().usesMapsIdDerivedIdentityStrategy();
- }
- };
- }
-
- protected Iterable<SingleRelationshipMapping2_0> getSingleRelationshipMappings() {
- return new SubIterableWrapper<AttributeMapping, SingleRelationshipMapping2_0>(this.getSingleRelationshipMappings_());
- }
-
- @SuppressWarnings("unchecked")
- protected Iterable<AttributeMapping> getSingleRelationshipMappings_() {
- return new CompositeIterable<AttributeMapping>(
- this.getTypeMapping().getAllAttributeMappings(MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY),
- this.getTypeMapping().getAllAttributeMappings(MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY)
- );
- }
-
- public EList<XmlAttributeOverride> getXmlOverrides() {
- return AbstractOrmEntity.this.xmlTypeMapping.getAttributeOverrides();
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new EntityTableDescriptionProvider());
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- return AbstractOrmEntity.this.resolveOverriddenColumnForAttributeOverride(attributeName);
- }
- }
-
-
- // ********** OrmAssociationOverrideContainer.Owner implementation **********
-
- protected class AssociationOverrideContainerOwner
- extends OverrideContainerOwner
- implements OrmAssociationOverrideContainer.Owner
- {
- @Override
- protected Iterator<String> allOverridableNames_(TypeMapping typeMapping) {
- return typeMapping.allOverridableAssociationNames();
- }
-
- public EList<XmlAssociationOverride> getXmlOverrides() {
- return AbstractOrmEntity.this.xmlTypeMapping.getAssociationOverrides();
- }
-
- public Relationship resolveOverriddenRelationship(String attributeName) {
- return AbstractOrmEntity.this.resolveOverriddenRelationshipForAssociationOverride(attributeName);
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new AssociationOverrideValidator((AssociationOverride) override, (AssociationOverrideContainer) container, textRangeResolver, new MappedSuperclassOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ 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 t, TableTextRangeResolver textRangeResolver) {
- return new AssociationOverrideJoinTableValidator(override, (JoinTable) t, textRangeResolver);
- }
- }
-
-
- // ********** OrmNamedColumn.Owner implementation **********
-
- /**
- * some common behavior
- */
- protected abstract class NamedColumnOwner
- implements OrmNamedColumn.Owner
- {
- public TypeMapping getTypeMapping() {
- return AbstractOrmEntity.this;
- }
-
- public String getDefaultTableName() {
- return AbstractOrmEntity.this.getPrimaryTableName();
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return AbstractOrmEntity.this.resolveDbTable(tableName);
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmEntity.this.getValidationTextRange();
- }
- }
-
-
- // ********** OrmBaseJoinColumn.Owner implementation **********
-
- protected class PrimaryKeyJoinColumnOwner
- extends NamedColumnOwner
- implements OrmBaseJoinColumn.Owner
- {
- public org.eclipse.jpt.jpa.db.Table getReferencedColumnDbTable() {
- Entity parentEntity = AbstractOrmEntity.this.getParentEntity();
- return (parentEntity == null) ? null : parentEntity.getPrimaryDbTable();
- }
-
- public int joinColumnsSize() {
- return AbstractOrmEntity.this.primaryKeyJoinColumnsSize();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return CollectionTools.contains(AbstractOrmEntity.this.defaultPrimaryKeyJoinColumns(), joinColumn);
- }
-
- public String getDefaultColumnName() {
- if (this.joinColumnsSize() != 1) {
- return null;
- }
- Entity parentEntity = AbstractOrmEntity.this.getParentEntity();
- return (parentEntity == null) ? AbstractOrmEntity.this.getPrimaryKeyColumnName() : parentEntity.getPrimaryKeyColumnName();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new EntityPrimaryKeyJoinColumnValidator((BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
- }
-
-
- // ********** OrmDiscriminatorColumn.Owner implementation **********
-
- protected class DiscriminatorColumnOwner
- extends NamedColumnOwner
- implements OrmDiscriminatorColumn.Owner
- {
- public String getDefaultColumnName() {
- if (this.getXmlColumn() == null) {
- JavaEntity javaEntity = this.getJavaEntityForDefaults();
- if (javaEntity != null) {
- String name = javaEntity.getDiscriminatorColumn().getSpecifiedName();
- if (name != null) {
- return name;
- }
- }
- }
- return AbstractOrmEntity.this.isDescendant() ?
- this.getRootDiscriminatorColumn().getName() :
- this.isTablePerClass() ? null : DiscriminatorColumn.DEFAULT_NAME;
- }
-
- public int getDefaultLength() {
- if (this.getXmlColumn() == null) {
- JavaEntity javaEntity = this.getJavaEntityForDefaults();
- if (javaEntity != null) {
- Integer length = javaEntity.getDiscriminatorColumn().getSpecifiedLength();
- if (length != null) {
- return length.intValue();
- }
- }
- }
- return AbstractOrmEntity.this.isDescendant() ?
- this.getRootDiscriminatorColumn().getLength() :
- this.isTablePerClass() ? 0 : DiscriminatorColumn.DEFAULT_LENGTH;
- }
-
- public DiscriminatorType getDefaultDiscriminatorType() {
- if (this.getXmlColumn() == null) {
- JavaEntity javaEntity = this.getJavaEntityForDefaults();
- if (javaEntity != null) {
- DiscriminatorType dt = javaEntity.getDiscriminatorColumn().getSpecifiedDiscriminatorType();
- if (dt != null) {
- return dt;
- }
- }
- }
- return AbstractOrmEntity.this.isDescendant() ?
- this.getRootDiscriminatorColumn().getDiscriminatorType() :
- this.isTablePerClass() ? null : DiscriminatorColumn.DEFAULT_DISCRIMINATOR_TYPE;
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new DiscriminatorColumnValidator(column, textRangeResolver);
- }
-
- public XmlDiscriminatorColumn getXmlColumn() {
- return this.getXmlEntity().getDiscriminatorColumn();
- }
-
- public XmlDiscriminatorColumn buildXmlColumn() {
- XmlDiscriminatorColumn xmlColumn = OrmFactory.eINSTANCE.createXmlDiscriminatorColumn();
- this.getXmlEntity().setDiscriminatorColumn(xmlColumn);
- return xmlColumn;
- }
-
- public void removeXmlColumn() {
- this.getXmlEntity().setDiscriminatorColumn(null);
- }
-
- protected XmlEntity getXmlEntity() {
- return AbstractOrmEntity.this.getXmlTypeMapping();
- }
-
- protected DiscriminatorColumn getRootDiscriminatorColumn() {
- return AbstractOrmEntity.this.rootEntity.getDiscriminatorColumn();
- }
-
- protected boolean isMetadataComplete() {
- return AbstractOrmEntity.this.isMetadataComplete();
- }
-
- protected boolean isTablePerClass() {
- return AbstractOrmEntity.this.isTablePerClass();
- }
-
- protected JavaEntity getJavaEntityForDefaults() {
- return AbstractOrmEntity.this.getJavaTypeMappingForDefaults();
- }
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
deleted file mode 100644
index b6fe73f53c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmGenerator.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.jpa.core.context.Generator;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGenerator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlGenerator;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> sequence or table generator
- */
-public abstract class AbstractOrmGenerator<X extends XmlGenerator>
- extends AbstractOrmXmlContextNode
- implements OrmGenerator
-{
- protected final X xmlGenerator;
-
- protected String name;
-
- protected Integer specifiedInitialValue;
- protected int defaultInitialValue;
-
- protected Integer specifiedAllocationSize;
- protected int defaultAllocationSize;
-
-
- protected AbstractOrmGenerator(XmlContextNode parent, X xmlGenerator) {
- super(parent);
- this.xmlGenerator = xmlGenerator;
- this.name = xmlGenerator.getName();
- this.specifiedInitialValue = xmlGenerator.getInitialValue();
- this.specifiedAllocationSize = xmlGenerator.getAllocationSize();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName_(this.xmlGenerator.getName());
- this.setSpecifiedInitialValue_(this.xmlGenerator.getInitialValue());
- this.setSpecifiedAllocationSize_(this.xmlGenerator.getAllocationSize());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultInitialValue(this.buildDefaultInitialValue());
- this.setDefaultAllocationSize(this.buildDefaultAllocationSize());
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.setName_(name);
- this.xmlGenerator.setName(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) {
- this.setSpecifiedInitialValue_(specifiedInitialValue);
- this.xmlGenerator.setInitialValue(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);
- }
-
- protected abstract int buildDefaultInitialValue();
-
-
- // ********** 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) {
- this.setSpecifiedAllocationSize_(specifiedAllocationSize);
- this.xmlGenerator.setAllocationSize(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 this.defaultAllocationSize;
- }
-
- protected void setDefaultAllocationSize(int defaultAllocationSize) {
- int old = this.defaultAllocationSize;
- this.defaultAllocationSize = defaultAllocationSize;
- this.firePropertyChanged(DEFAULT_ALLOCATION_SIZE_PROPERTY, old, defaultAllocationSize);
- }
-
- protected int buildDefaultAllocationSize() {
- return DEFAULT_ALLOCATION_SIZE;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- if (StringTools.stringIsEmpty(this.name)){
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_NAME_UNDEFINED,
- EMPTY_STRING_ARRAY,
- this,
- this.getNameTextRange()
- )
- );
- }
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.xmlGenerator.getValidationTextRange();
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.xmlGenerator.getNameTextRange());
- }
-
-
- // ********** 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.resolveDbCatalog(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.resolveDbCatalog(catalog);
- }
-
- protected abstract String getCatalog();
-
-
- // ********** misc **********
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- public X getXmlGenerator() {
- return this.xmlGenerator;
- }
-
- public boolean overrides(Generator other) {
- return MappingTools.nodeOverrides(this, other, PRECEDENCE_TYPE_LIST);
- }
-
- public boolean duplicates(Generator other) {
- return MappingTools.nodesAreDuplicates(this, other);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java
deleted file mode 100644
index 3cf5ff56f6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmIdMapping.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Converter;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratedValue;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmConverter;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.IdMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlId;
-import org.eclipse.jpt.jpa.db.Table;
-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;
-
-/**
- * <code>orm.xml</code> ID mapping
- */
-public abstract class AbstractOrmIdMapping<X extends XmlId>
- extends AbstractOrmAttributeMapping<X>
- implements OrmIdMapping, IdMapping2_0
-{
- protected final OrmColumn column;
-
- protected final OrmGeneratorContainer generatorContainer;
-
- protected OrmGeneratedValue generatedValue;
-
- protected OrmConverter converter; // never null
-
- /* 2.0 feature - a relationship may map this ID */
- protected boolean mappedByRelationship;
-
-
- protected static final OrmConverter.Adapter[] CONVERTER_ADAPTER_ARRAY = new OrmConverter.Adapter[] {
- OrmTemporalConverter.Adapter.instance(),
- };
- protected static final Iterable<OrmConverter.Adapter> CONVERTER_ADAPTERS = new ArrayIterable<OrmConverter.Adapter>(CONVERTER_ADAPTER_ARRAY);
-
-
- protected AbstractOrmIdMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.column = this.buildColumn();
- this.generatorContainer = this.buildGeneratorContainer();
- this.generatedValue = this.buildGeneratedValue();
- this.converter = this.buildConverter();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.column.synchronizeWithResourceModel();
- this.generatorContainer.synchronizeWithResourceModel();
- this.syncGeneratedValue();
- this.syncConverter();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update();
- this.generatorContainer.update();
- if (this.generatedValue != null) {
- this.generatedValue.update();
- }
- this.converter.update();
- this.setMappedByRelationship(this.buildMappedByRelationship());
- }
-
-
- // ********** column **********
-
- public OrmColumn getColumn() {
- return this.column;
- }
-
- protected OrmColumn buildColumn() {
- return this.getContextNodeFactory().buildOrmColumn(this, this);
- }
-
-
- // ********** generator container **********
-
- public OrmGeneratorContainer getGeneratorContainer() {
- return this.generatorContainer;
- }
-
- protected OrmGeneratorContainer buildGeneratorContainer() {
- return this.getContextNodeFactory().buildOrmGeneratorContainer(this, this.xmlAttributeMapping);
- }
-
-
- // ********** generated value **********
-
- public OrmGeneratedValue getGeneratedValue() {
- return this.generatedValue;
- }
-
- public OrmGeneratedValue addGeneratedValue() {
- if (this.generatedValue != null) {
- throw new IllegalStateException("generated value already exists: " + this.generatedValue); //$NON-NLS-1$
- }
- XmlGeneratedValue xmlGeneratedValue = this.buildXmlGeneratedValue();
- OrmGeneratedValue value = this.buildGeneratedValue(xmlGeneratedValue);
- this.setGeneratedValue(value);
- this.xmlAttributeMapping.setGeneratedValue(xmlGeneratedValue);
- return value;
- }
-
- protected XmlGeneratedValue buildXmlGeneratedValue() {
- return OrmFactory.eINSTANCE.createXmlGeneratedValue();
- }
-
- public void removeGeneratedValue() {
- if (this.generatedValue == null) {
- throw new IllegalStateException("generated value does not exist"); //$NON-NLS-1$
- }
- this.setGeneratedValue(null);
- this.xmlAttributeMapping.setGeneratedValue(null);
- }
-
- protected void setGeneratedValue(OrmGeneratedValue value) {
- OrmGeneratedValue old = this.generatedValue;
- this.generatedValue = value;
- this.firePropertyChanged(GENERATED_VALUE_PROPERTY, old, value);
- }
-
- protected OrmGeneratedValue buildGeneratedValue() {
- XmlGeneratedValue xmlGeneratedValue = this.xmlAttributeMapping.getGeneratedValue();
- return (xmlGeneratedValue == null) ? null : this.buildGeneratedValue(xmlGeneratedValue);
- }
-
- protected OrmGeneratedValue buildGeneratedValue(XmlGeneratedValue xmlGeneratedValue) {
- return this.getContextNodeFactory().buildOrmGeneratedValue(this, xmlGeneratedValue);
- }
-
- protected void syncGeneratedValue() {
- XmlGeneratedValue xmlGeneratedValue = this.xmlAttributeMapping.getGeneratedValue();
- if (xmlGeneratedValue == null) {
- if (this.generatedValue != null) {
- this.setGeneratedValue(null);
- }
- } else {
- if ((this.generatedValue != null) && (this.generatedValue.getXmlGeneratedValue() == xmlGeneratedValue)) {
- this.generatedValue.synchronizeWithResourceModel();
- } else {
- this.setGeneratedValue(this.buildGeneratedValue(xmlGeneratedValue));
- }
- }
- }
-
-
- // ********** converter **********
-
- public OrmConverter getConverter() {
- return this.converter;
- }
-
- public void setConverter(Class<? extends Converter> converterType) {
- if (this.converter.getType() != converterType) {
- // note: we may also clear the XML value we want;
- // but if we leave it, the resulting sync will screw things up...
- this.clearXmlConverterValues();
- OrmConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.setConverter_(this.buildConverter(converterAdapter));
- this.converter.initialize();
- }
- }
-
- protected OrmConverter buildConverter(OrmConverter.Adapter converterAdapter) {
- return (converterAdapter != null) ?
- converterAdapter.buildNewConverter(this, this.getContextNodeFactory()) :
- this.buildNullConverter();
- }
-
- protected void setConverter_(OrmConverter converter) {
- Converter old = this.converter;
- this.converter = converter;
- this.firePropertyChanged(CONVERTER_PROPERTY, old, converter);
- }
-
- protected void clearXmlConverterValues() {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- adapter.clearXmlValue(this.xmlAttributeMapping);
- }
- }
-
- protected OrmConverter buildConverter() {
- OrmXmlContextNodeFactory factory = this.getContextNodeFactory();
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- OrmConverter ormConverter = adapter.buildConverter(this, factory);
- if (ormConverter != null) {
- return ormConverter;
- }
- }
- return this.buildNullConverter();
- }
-
- protected void syncConverter() {
- OrmConverter.Adapter adapter = this.getXmlConverterAdapter();
- if (adapter == null) {
- if (this.converter.getType() != null) {
- this.setConverter_(this.buildNullConverter());
- }
- } else {
- if (this.converter.getType() == adapter.getConverterType()) {
- this.converter.synchronizeWithResourceModel();
- } else {
- this.setConverter_(adapter.buildNewConverter(this, this.getContextNodeFactory()));
- }
- }
- }
-
- /**
- * Return the first adapter whose converter value is set in the XML mapping.
- * Return <code>null</code> if there are no converter values in the XML.
- */
- protected OrmConverter.Adapter getXmlConverterAdapter() {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.isActive(this.xmlAttributeMapping)) {
- return adapter;
- }
- }
- return null;
- }
-
- protected OrmConverter buildNullConverter() {
- return new NullOrmConverter(this);
- }
-
-
- // ********** converter adapters **********
-
- /**
- * Return the converter adapter for the specified converter type.
- */
- protected OrmConverter.Adapter getConverterAdapter(Class<? extends Converter> converterType) {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.getConverterType() == converterType) {
- return adapter;
- }
- }
- return null;
- }
-
- protected Iterable<OrmConverter.Adapter> getConverterAdapters() {
- return CONVERTER_ADAPTERS;
- }
-
-
- // ********** mapped by relationship **********
-
- public boolean isMappedByRelationship() {
- return this.mappedByRelationship;
- }
-
- protected void setMappedByRelationship(boolean value) {
- boolean old = this.mappedByRelationship;
- this.mappedByRelationship = value;
- this.firePropertyChanged(MAPPED_BY_RELATIONSHIP_PROPERTY, old, value);
- }
-
- protected boolean buildMappedByRelationship() {
- return this.isJpa2_0Compatible() && this.buildMappedByRelationship_();
- }
-
- protected boolean buildMappedByRelationship_() {
- return CollectionTools.contains(this.getMappedByRelationshipAttributeNames(), this.getName());
- }
-
- protected Iterable<String> getMappedByRelationshipAttributeNames() {
- return TypeMappingTools.getMappedByRelationshipAttributeNames(this.getTypeMapping());
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ID_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 0;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmIdMapping(this);
- }
-
- @Override
- protected void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- super.initializeFromOrmColumnMapping(oldMapping);
- this.column.initializeFrom(oldMapping.getColumn());
- }
-
- @Override
- public String getPrimaryKeyColumnName() {
- return this.column.getName();
- }
-
- @Override
- public boolean isOverridableAttributeMapping() {
- return true;
- }
-
- public void addXmlAttributeMappingTo(Attributes resourceAttributes) {
- resourceAttributes.getIds().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) {
- resourceAttributes.getIds().remove(this.xmlAttributeMapping);
- }
-
-
- // ********** OrmColumn.Owner implementation **********
-
- public String getDefaultColumnName() {
- return (this.mappedByRelationship && ! this.isColumnSpecified()) ? null : this.name;
- }
-
- public String getDefaultTableName() {
- return (this.mappedByRelationship && ! this.isColumnSpecified()) ? null : this.getTypeMapping().getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public XmlColumn getXmlColumn() {
- return this.xmlAttributeMapping.getColumn();
- }
-
- public XmlColumn buildXmlColumn() {
- XmlColumn xmlColumn = OrmFactory.eINSTANCE.createXmlColumn();
- this.xmlAttributeMapping.setColumn(xmlColumn);
- return xmlColumn;
- }
-
- public void removeXmlColumn() {
- this.xmlAttributeMapping.setColumn(null);
- }
-
- protected boolean isColumnSpecified() {
- return this.getXmlColumn() != null;
- }
-
-
- // ********** refactoring **********
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createRenameTypeEdits(originalType, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createMoveTypeEdits(originalType, newPackage) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createRenamePackageEdits(originalPackage, newName) :
- EmptyIterable.<ReplaceEdit>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,
- // the column is validated.
- // JPA 1.0: The column is always be validated, since the ID is never mapped by a
- // relationship.
- if (this.isColumnSpecified() || ! this.mappedByRelationship) {
- this.column.validate(messages, reporter);
- }
-
- // JPA 2.0: If the column is specified and the ID is mapped by a relationship,
- // we have an error.
- // JPA 1.0: The ID cannot be mapped by a relationship.
- if (this.isColumnSpecified() && this.mappedByRelationship) {
- messages.add(this.buildMappedByRelationshipAndColumnSpecifiedMessage());
- }
-
- if (this.generatedValue != null) {
- this.generatedValue.validate(messages, reporter);
- }
- this.generatorContainer.validate(messages, reporter);
- this.converter.validate(messages, reporter);
- }
-
- protected IMessage buildMappedByRelationshipAndColumnSpecifiedMessage() {
- return this.buildMessage(
- JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED,
- EMPTY_STRING_ARRAY,
- this.column.getValidationTextRange()
- );
- }
-
- protected IMessage buildMessage(String msgID, String[] parms, TextRange textRange) {
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- ArrayTools.add(parms, 0, this.buildAttributeDescription()),
- this,
- textRange
- );
- }
-
- protected String buildAttributeDescription() {
- return NLS.bind(this.getAttributeDescriptionTemplate(), this.getPersistentAttribute().getName());
- }
-
- protected String getAttributeDescriptionTemplate() {
- return JpaValidationDescriptionMessages.ATTRIBUTE_DESC;
- }
-
- public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
deleted file mode 100644
index 80c03483f2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinColumnContainer;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmJoinColumnRelationshipStrategy
- extends AbstractOrmXmlContextNode
- implements OrmJoinColumnRelationshipStrategy
-{
- protected final Vector<OrmJoinColumn> specifiedJoinColumns = new Vector<OrmJoinColumn>();
- protected final SpecifiedJoinColumnContainerAdapter specifiedJoinColumnContainerAdapter;
- protected final OrmJoinColumn.Owner joinColumnOwner;
-
- protected OrmJoinColumn defaultJoinColumn;
-
-
- protected AbstractOrmJoinColumnRelationshipStrategy(OrmJoinColumnRelationship parent) {
- super(parent);
- this.specifiedJoinColumnContainerAdapter = this.buildSpecifiedJoinColumnContainerAdapter();
- this.joinColumnOwner = this.buildJoinColumnOwner();
- this.initializeSpecifiedJoinColumns();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncSpecifiedJoinColumns();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getSpecifiedJoinColumns());
- this.updateDefaultJoinColumn();
- }
-
-
- // ********** XML join column container **********
-
- protected XmlJoinColumnContainer getXmlJoinColumnContainer() {
- return this.getRelationship().getXmlContainer();
- }
-
-
- // ********** join columns **********
-
- public ListIterator<OrmJoinColumn> joinColumns() {
- return this.getJoinColumns().iterator();
- }
-
- protected ListIterable<OrmJoinColumn> getJoinColumns() {
- return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ? this.specifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize();
- }
-
-
- // ********** specified join columns **********
-
- public ListIterator<OrmJoinColumn> specifiedJoinColumns() {
- return this.getSpecifiedJoinColumns().iterator();
- }
-
- protected ListIterable<OrmJoinColumn> getSpecifiedJoinColumns() {
- return new LiveCloneListIterable<OrmJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return this.specifiedJoinColumns.size() != 0;
- }
-
- public OrmJoinColumn getSpecifiedJoinColumn(int index) {
- return this.specifiedJoinColumns.get(index);
- }
-
- public OrmJoinColumn addSpecifiedJoinColumn() {
- return this.addSpecifiedJoinColumn(this.specifiedJoinColumns.size());
- }
-
- public OrmJoinColumn addSpecifiedJoinColumn(int index) {
- XmlJoinColumn xmlJoinColumn = this.buildXmlJoinColumn();
- OrmJoinColumn joinColumn = this.addSpecifiedJoinColumn_(index, xmlJoinColumn);
- this.getXmlJoinColumnContainer().getJoinColumns().add(index, xmlJoinColumn);
- return joinColumn;
- }
-
- protected XmlJoinColumn buildXmlJoinColumn() {
- return OrmFactory.eINSTANCE.createXmlJoinColumn();
- }
-
- public void removeSpecifiedJoinColumn(JoinColumn joinColumn) {
- this.removeSpecifiedJoinColumn(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- public void removeSpecifiedJoinColumn(int index) {
- this.removeSpecifiedJoinColumn_(index);
- this.getXmlJoinColumnContainer().getJoinColumns().remove(index);
- }
-
- protected void removeSpecifiedJoinColumn_(int index) {
- this.removeItemFromList(index, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- public void moveSpecifiedJoinColumn(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- this.getXmlJoinColumnContainer().getJoinColumns().move(targetIndex, sourceIndex);
- }
-
- protected void initializeSpecifiedJoinColumns() {
- for (XmlJoinColumn xmlJoinColumn : this.getXmlJoinColumns()) {
- this.specifiedJoinColumns.add(this.buildJoinColumn(xmlJoinColumn));
- }
- }
-
- protected void syncSpecifiedJoinColumns() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedJoinColumnContainerAdapter);
- }
-
- protected Iterable<XmlJoinColumn> getXmlJoinColumns() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlJoinColumn>(this.getXmlJoinColumnContainer().getJoinColumns());
- }
-
- protected void moveSpecifiedJoinColumn_(int index, OrmJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected OrmJoinColumn addSpecifiedJoinColumn_(int index, XmlJoinColumn xmlJoinColumn) {
- OrmJoinColumn joinColumn = this.buildJoinColumn(xmlJoinColumn);
- this.addItemToList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- return joinColumn;
- }
-
- protected void removeSpecifiedJoinColumn_(OrmJoinColumn joinColumn) {
- this.removeSpecifiedJoinColumn_(this.specifiedJoinColumns.indexOf(joinColumn));
- }
-
- protected SpecifiedJoinColumnContainerAdapter buildSpecifiedJoinColumnContainerAdapter() {
- return new SpecifiedJoinColumnContainerAdapter();
- }
-
- /**
- * specified join column container adapter
- */
- protected class SpecifiedJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmJoinColumn, XmlJoinColumn>
- {
- public Iterable<OrmJoinColumn> getContextElements() {
- return AbstractOrmJoinColumnRelationshipStrategy.this.getSpecifiedJoinColumns();
- }
- public Iterable<XmlJoinColumn> getResourceElements() {
- return AbstractOrmJoinColumnRelationshipStrategy.this.getXmlJoinColumns();
- }
- public XmlJoinColumn getResourceElement(OrmJoinColumn contextElement) {
- return contextElement.getXmlColumn();
- }
- public void moveContextElement(int index, OrmJoinColumn element) {
- AbstractOrmJoinColumnRelationshipStrategy.this.moveSpecifiedJoinColumn_(index, element);
- }
- public void addContextElement(int index, XmlJoinColumn resourceElement) {
- AbstractOrmJoinColumnRelationshipStrategy.this.addSpecifiedJoinColumn_(index, resourceElement);
- }
- public void removeContextElement(OrmJoinColumn element) {
- AbstractOrmJoinColumnRelationshipStrategy.this.removeSpecifiedJoinColumn_(element);
- }
- }
-
- protected abstract OrmJoinColumn.Owner buildJoinColumnOwner();
-
-
- // ********** default join column **********
-
- public OrmJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(OrmJoinColumn joinColumn) {
- OrmJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn);
- }
-
- protected ListIterable<OrmJoinColumn> getDefaultJoinColumns() {
- return (this.defaultJoinColumn != null) ?
- new SingleElementListIterable<OrmJoinColumn>(this.defaultJoinColumn) :
- EmptyListIterable.<OrmJoinColumn>instance();
- }
-
- protected int getDefaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultJoinColumn() {
- if (this.buildsDefaultJoinColumn()) {
- if (this.defaultJoinColumn == null) {
- this.setDefaultJoinColumn(this.buildJoinColumn(null));
- } else {
- this.defaultJoinColumn.update();
- }
- } else {
- this.setDefaultJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultJoinColumn() {
- return ! this.hasSpecifiedJoinColumns() &&
- this.getRelationship().mayHaveDefaultJoinColumn();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmJoinColumnRelationship getParent() {
- return (OrmJoinColumnRelationship) super.getParent();
- }
-
- public OrmJoinColumnRelationship getRelationship() {
- return this.getParent();
- }
-
- protected OrmJoinColumn buildJoinColumn(XmlJoinColumn xmlJoinColumn) {
- return this.getContextNodeFactory().buildOrmJoinColumn(this, this.joinColumnOwner, xmlJoinColumn);
- }
-
- public void initializeFrom(ReadOnlyJoinColumnRelationshipStrategy oldStrategy) {
- for (ReadOnlyJoinColumn joinColumn : CollectionTools.iterable(oldStrategy.specifiedJoinColumns())) {
- this.addSpecifiedJoinColumn().initializeFrom(joinColumn);
- }
- }
-
- public void initializeFromVirtual(ReadOnlyJoinColumnRelationshipStrategy virtualStrategy) {
- for (ReadOnlyJoinColumn joinColumn : CollectionTools.iterable(virtualStrategy.joinColumns())) {
- this.addSpecifiedJoinColumn().initializeFromVirtual(joinColumn);
- }
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- public String getTableName() {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping == null) ? null : typeMapping.getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping == null) ? null : typeMapping.resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping != null) && typeMapping.tableNameIsInvalid(tableName);
- }
-
- // subclasses like this to be public
- public Table getReferencedColumnDbTable() {
- TypeMapping relationshipTarget = this.getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
- protected Iterator<String> candidateTableNames() {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping != null) ? typeMapping.allAssociatedTableNames() : EmptyIterator.<String>instance();
- }
-
- public void addStrategy() {
- if (this.specifiedJoinColumnsSize() == 0) {
- this.addSpecifiedJoinColumn();
- }
- }
-
- public void removeStrategy() {
- for (int i = this.specifiedJoinColumns.size(); i-- > 0; ) {
- this.removeSpecifiedJoinColumn(i);
- }
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- for (OrmJoinColumn joinColumn : this.getJoinColumns()) {
- joinColumn.validate(messages, reporter);
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java
deleted file mode 100644
index 922e5bcd64..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmJoinTableRelationshipStrategy.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinTableContainer;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public abstract class AbstractOrmJoinTableRelationshipStrategy
- extends AbstractOrmXmlContextNode
- implements OrmJoinTableRelationshipStrategy, Table.Owner
-{
- protected OrmJoinTable joinTable;
-
-
- protected AbstractOrmJoinTableRelationshipStrategy(OrmJoinTableRelationship parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- if (this.joinTable != null) {
- this.joinTable.synchronizeWithResourceModel();
- }
- }
-
- @Override
- public void update() {
- super.update();
- this.updateJoinTable();
- }
-
-
- // ********** join table **********
-
- public OrmJoinTable getJoinTable() {
- return this.joinTable;
- }
-
- protected void setJoinTable(OrmJoinTable joinTable) {
- OrmJoinTable old = this.joinTable;
- this.joinTable = joinTable;
- this.firePropertyChanged(JOIN_TABLE_PROPERTY, old, joinTable);
- }
-
- protected void updateJoinTable() {
- if (this.buildsJoinTable()) {
- if (this.joinTable == null) {
- this.setJoinTable(this.buildJoinTable());
- } else {
- this.joinTable.update();
- }
- } else {
- if (this.joinTable != null) {
- this.setJoinTable(null);
- }
- }
- }
-
- /**
- * The strategy can have a join table if either the XML table is present
- * or the [mapping] relationship supports a default join table.
- */
- protected boolean buildsJoinTable() {
- return (this.getXmlJoinTable() != null) ||
- this.getRelationship().mayHaveDefaultJoinTable();
- }
-
- protected OrmJoinTable buildJoinTable() {
- return this.getContextNodeFactory().buildOrmJoinTable(this, this);
- }
-
-
- // ********** XML join table **********
-
- public XmlJoinTable getXmlJoinTable() {
- return this.getXmlJoinTableContainer().getJoinTable();
- }
-
- public XmlJoinTable buildXmlJoinTable() {
- XmlJoinTable xmlJoinTable = OrmFactory.eINSTANCE.createXmlJoinTable();
- this.getXmlJoinTableContainer().setJoinTable(xmlJoinTable);
- return xmlJoinTable;
- }
-
- public void removeXmlJoinTable() {
- this.getXmlJoinTableContainer().setJoinTable(null);
- }
-
- protected XmlJoinTableContainer getXmlJoinTableContainer() {
- return this.getRelationship().getXmlContainer();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- if (this.joinTable != null) {
- this.joinTable.validate(messages, reporter);
- }
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmJoinTableRelationship getParent() {
- return (OrmJoinTableRelationship) super.getParent();
- }
-
- public OrmJoinTableRelationship getRelationship() {
- return this.getParent();
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- public void initializeFrom(ReadOnlyJoinTableRelationshipStrategy oldStrategy) {
- ReadOnlyJoinTable oldJoinTable = oldStrategy.getJoinTable();
- if (oldJoinTable != null) {
- this.addStrategy();
- this.joinTable.initializeFrom(oldJoinTable);
- }
- }
-
- public void initializeFromVirtual(ReadOnlyJoinTableRelationshipStrategy virtualStrategy) {
- ReadOnlyJoinTable oldJoinTable = virtualStrategy.getJoinTable();
- if (oldJoinTable != null) {
- this.addStrategy();
- this.joinTable.initializeFromVirtual(oldJoinTable);
- }
- }
-
- public String getTableName() {
- return (this.joinTable == null) ? null : this.joinTable.getName();
- }
-
- public org.eclipse.jpt.jpa.db.Table resolveDbTable(String tableName) {
- return (this.joinTable == null) ? null : this.joinTable.getDbTable();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return Tools.valuesAreDifferent(this.getTableName(), tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.DOES_NOT_MATCH_JOIN_TABLE;
- }
-
- public String getJoinTableDefaultName() {
- return MappingTools.buildJoinTableDefaultName(this.getRelationship());
- }
-
- public void addStrategy() {
- if (this.joinTable == null) {
- this.setJoinTable(this.buildJoinTable());
- this.buildXmlJoinTable();
- }
- }
-
- public void removeStrategy() {
- if (this.joinTable != null) {
- this.setJoinTable(null);
- this.removeXmlJoinTable();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToManyMapping.java
deleted file mode 100644
index e131cef90a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToManyMapping.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToMany;
-
-public abstract class AbstractOrmManyToManyMapping<X extends XmlManyToMany>
- extends AbstractOrmMultiRelationshipMapping<X>
- implements OrmManyToManyMapping2_0
-{
- protected AbstractOrmManyToManyMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- }
-
-
- // ********** relationship **********
-
- @Override
- public OrmManyToManyRelationship getRelationship() {
- return (OrmManyToManyRelationship) super.getRelationship();
- }
-
- @Override
- protected OrmMappingRelationship buildRelationship() {
- return new GenericOrmManyToManyRelationship(this);
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 70;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmManyToManyMapping(this);
- }
-
- public void addXmlAttributeMappingTo(Attributes resourceAttributes) {
- resourceAttributes.getManyToManys().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) {
- resourceAttributes.getManyToManys().remove(this.xmlAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToOneMapping.java
deleted file mode 100644
index d5927bd21d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmManyToOneMapping.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne;
-
-/**
- * <code>orm.xml</code> 1:1 mapping
- */
-public abstract class AbstractOrmManyToOneMapping<X extends XmlManyToOne>
- extends AbstractOrmSingleRelationshipMapping<X>
- implements OrmManyToOneMapping2_0
-{
- protected AbstractOrmManyToOneMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- }
-
-
- // ********** relationship **********
-
- @Override
- protected OrmManyToOneRelationship2_0 buildRelationship() {
- return new GenericOrmManyToOneRelationship(this);
- }
-
- @Override
- public OrmManyToOneRelationship2_0 getRelationship() {
- return (OrmManyToOneRelationship2_0) super.getRelationship();
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 40;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmManyToOneMapping(this);
- }
-
- public void addXmlAttributeMappingTo(Attributes resourceAttributes) {
- resourceAttributes.getManyToOnes().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) {
- resourceAttributes.getManyToOnes().remove(this.xmlAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappedSuperclass.java
deleted file mode 100644
index a67569ccdb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappedSuperclass.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.jpa.core.context.java.JavaMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericMappedSuperclassPrimaryKeyValidator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlIdClassContainer;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlMappedSuperclass;
-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> mapped superclass
- */
-public abstract class AbstractOrmMappedSuperclass<X extends XmlMappedSuperclass>
- extends AbstractOrmTypeMapping<X>
- implements OrmMappedSuperclass, OrmIdClassReference.Owner
-{
- protected final OrmIdClassReference idClassReference;
-
-
- protected AbstractOrmMappedSuperclass(OrmPersistentType parent, X xmlMappedSuperclass) {
- super(parent, xmlMappedSuperclass);
- this.idClassReference = this.buildIdClassReference();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.idClassReference.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.idClassReference.update();
- }
-
-
- // ********** key **********
-
- public String getKey() {
- return MappingKeys.MAPPED_SUPERCLASS_TYPE_MAPPING_KEY;
- }
-
-
- // ********** id class **********
-
- public OrmIdClassReference getIdClassReference() {
- return this.idClassReference;
- }
-
- protected OrmIdClassReference buildIdClassReference() {
- return new GenericOrmIdClassReference(this, this);
- }
-
- public JavaPersistentType getIdClass() {
- return this.idClassReference.getIdClass();
- }
-
- public XmlIdClassContainer getXmlIdClassContainer() {
- return this.getXmlTypeMapping();
- }
-
- public JavaIdClassReference getJavaIdClassReferenceForDefaults() {
- JavaMappedSuperclass javaMappedSuperclass = this.getJavaTypeMappingForDefaults();
- return (javaMappedSuperclass == null) ? null : javaMappedSuperclass.getIdClassReference();
- }
-
-
- // ********** entity mappings **********
-
- public int getXmlSequence() {
- return 0;
- }
-
- public void addXmlTypeMappingTo(XmlEntityMappings entityMappings) {
- entityMappings.getMappedSuperclasses().add(this.xmlTypeMapping);
- }
-
- public void removeXmlTypeMappingFrom(XmlEntityMappings entityMappings) {
- entityMappings.getMappedSuperclasses().remove(this.xmlTypeMapping);
- }
-
-
- // ********** Java **********
-
- @Override
- public JavaMappedSuperclass getJavaTypeMapping() {
- return (JavaMappedSuperclass) super.getJavaTypeMapping();
- }
-
- @Override
- public JavaMappedSuperclass getJavaTypeMappingForDefaults() {
- return (JavaMappedSuperclass) super.getJavaTypeMappingForDefaults();
- }
-
-
- // ********** tables **********
-
- public Iterator<ReadOnlyTable> associatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<ReadOnlyTable> allAssociatedTables() {
- return EmptyIterator.instance();
- }
-
- public Iterator<String> allAssociatedTableNames() {
- return EmptyIterator.instance();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return false;
- }
-
-
- // ********** refactoring **********
-
- @Override
- @SuppressWarnings("unchecked")
- 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);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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);
- this.validatePrimaryKey(messages, reporter);
- this.idClassReference.validate(messages, reporter);
- }
-
- @Override
- public boolean validatesAgainstDatabase() {
- return false;
- }
-
- protected void validatePrimaryKey(List<IMessage> messages, IReporter reporter) {
- this.buildPrimaryKeyValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildPrimaryKeyValidator() {
- return new GenericMappedSuperclassPrimaryKeyValidator(this, this.buildTextRangeResolver());
- // TODO - JPA 2.0 validation
- }
-
- @Override
- protected PrimaryKeyTextRangeResolver buildTextRangeResolver() {
- return new OrmMappedSuperclassTextRangeResolver(this);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappingRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappingRelationship.java
deleted file mode 100644
index 0095c229ff..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMappingRelationship.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyRelationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlRelationshipMapping;
-
-/**
- * <strong>NB:</strong> Subclasses will want to set the {@link #strategy} at the
- * end of their constructors; otherwise, it will be <code>null</code> until it
- * is set during {@link #update()}.
- */
-public abstract class AbstractOrmMappingRelationship<M extends OrmRelationshipMapping>
- extends AbstractOrmXmlContextNode
- implements OrmMappingRelationship
-{
- protected OrmRelationshipStrategy strategy;
-
-
- protected AbstractOrmMappingRelationship(M parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateStrategy();
- }
-
-
- // ********** strategy **********
-
- public OrmRelationshipStrategy getStrategy() {
- return this.strategy;
- }
-
- protected void setStrategy(OrmRelationshipStrategy strategy) {
- RelationshipStrategy old = this.strategy;
- this.strategy = strategy;
- this.firePropertyChanged(STRATEGY_PROPERTY, old, strategy);
- }
-
- protected abstract OrmRelationshipStrategy buildStrategy();
-
- /**
- * This is called by subclasses when the various supported strategies are
- * added or removed; allowing the strategy to be set synchronously. (?)
- */
- protected void updateStrategy() {
- this.setStrategy(this.buildStrategy());
- }
-
-
- // ********** conversions **********
-
- public void initializeFrom(ReadOnlyRelationship oldRelationship) {
- oldRelationship.initializeOn(this);
- }
-
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- // NOP
- }
-
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- // NOP
- }
-
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- // NOP
- }
-
-
- // ********** misc **********
-
- @Override
- @SuppressWarnings("unchecked")
- public M getParent() {
- return (M) super.getParent();
- }
-
- public M getMapping() {
- return this.getParent();
- }
-
- protected AbstractXmlRelationshipMapping getXmlMapping() {
- return this.getMapping().getXmlAttributeMapping();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getMapping().getTypeMapping();
- }
-
- public Entity getEntity() {
- TypeMapping typeMapping = this.getTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public boolean isOverridable() {
- return this.strategy.isOverridable();
- }
-
- public boolean isVirtual() {
- return false;
- }
-
- public boolean isTargetForeignKey() {
- return false;
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange() {
- return this.getMapping().getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
deleted file mode 100644
index d16d0c7f01..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmMultiRelationshipMapping.java
+++ /dev/null
@@ -1,799 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.AttributeOverride;
-import org.eclipse.jpt.jpa.core.context.AttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.OverrideContainer;
-import org.eclipse.jpt.jpa.core.context.Override_;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMultiRelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOrderable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EmbeddableOverrideDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MapKeyAttributeOverrideColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MapKeyAttributeOverrideValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.MapKeyColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.RelationshipStrategyTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmCollectionMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlMultiRelationshipMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.MapKey;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlClassReference;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.jpa.db.Table;
-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> multi-relationship (1:m, m:m) mapping
- */
-public abstract class AbstractOrmMultiRelationshipMapping<X extends AbstractXmlMultiRelationshipMapping>
- extends AbstractOrmRelationshipMapping<X>
- 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 Type valueType;
- protected Type keyType;
-
- protected final OrmColumn mapKeyColumn;
-
- protected final OrmAttributeOverrideContainer mapKeyAttributeOverrideContainer;
-
-
- protected AbstractOrmMultiRelationshipMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.orderable = this.buildOrderable();
-
- this.specifiedMapKey = this.buildSpecifiedMapKey();
- this.noMapKey = this.buildNoMapKey();
- this.pkMapKey = this.buildPkMapKey();
- this.customMapKey = this.buildCustomMapKey();
-
- this.specifiedMapKeyClass = this.buildSpecifiedMapKeyClass();
-
- this.mapKeyColumn = this.buildMapKeyColumn();
- this.mapKeyAttributeOverrideContainer = this.buildMapKeyAttributeOverrideContainer();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.orderable.synchronizeWithResourceModel();
-
- this.setSpecifiedMapKey_(this.buildSpecifiedMapKey());
- this.setNoMapKey_(this.buildNoMapKey());
- this.setPkMapKey_(this.buildPkMapKey());
- this.setCustomMapKey_(this.buildCustomMapKey());
-
- this.setSpecifiedMapKeyClass_(this.buildSpecifiedMapKeyClass());
-
- this.mapKeyColumn.synchronizeWithResourceModel();
-
- this.mapKeyAttributeOverrideContainer.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
-
- this.orderable.update();
-
- this.setDefaultMapKeyClass(this.buildDefaultMapKeyClass());
-
- this.setValueType(this.buildValueType());
- this.setKeyType(this.buildKeyType());
-
- this.mapKeyColumn.update();
-
- this.mapKeyAttributeOverrideContainer.update();
- }
-
-
- // ********** orderable **********
-
- public OrmOrderable getOrderable() {
- return this.orderable;
- }
-
- protected OrmOrderable buildOrderable() {
- return this.isOrmXml2_0Compatible() ?
- this.getContextNodeFactory2_0().buildOrmOrderable(this, this.buildOrderableOwner()) :
- this.getContextNodeFactory().buildOrmOrderable(this);
- }
-
- protected Orderable2_0.Owner buildOrderableOwner() {
- return new OrderableOwner();
- }
-
- protected class OrderableOwner
- implements Orderable2_0.Owner
- {
- public String getTableName() {
- return this.getRelationshipStrategy().getTableName();
- }
- public Table resolveDbTable(String tableName) {
- return this.getRelationshipStrategy().resolveDbTable(tableName);
- }
- protected OrmRelationshipStrategy getRelationshipStrategy() {
- return AbstractOrmMultiRelationshipMapping.this.getRelationship().getStrategy();
- }
- }
-
-
- // ********** 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$
- }
-
-
- // ********** specified map key **********
-
- public String getSpecifiedMapKey() {
- return this.specifiedMapKey;
- }
-
- public void setSpecifiedMapKey(String mapKey) {
- if (mapKey != null) {
- this.setSpecifiedMapKey_(mapKey);
- this.setNoMapKey_(false);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(true);
-
- MapKey xmlMapKey = this.getXmlMapKey();
- if (xmlMapKey == null) {
- xmlMapKey = this.buildXmlMapKey();
- }
- xmlMapKey.setName(mapKey);
- } else {
- this.setPkMapKey(true); // hmmm...
- }
- }
-
- protected void setSpecifiedMapKey_(String mapKey) {
- String old = this.specifiedMapKey;
- this.specifiedMapKey = mapKey;
- this.firePropertyChanged(SPECIFIED_MAP_KEY_PROPERTY, old, mapKey);
- }
-
- protected String buildSpecifiedMapKey() {
- MapKey xmlMapKey = this.getXmlMapKey();
- return (xmlMapKey == null) ? null : xmlMapKey.getName();
- }
-
-
- // ********** no map key **********
-
- public boolean isNoMapKey() {
- return this.noMapKey;
- }
-
- public void setNoMapKey(boolean noMapKey) {
- if (noMapKey) {
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(true);
- this.setPkMapKey_(false);
- this.setCustomMapKey_(false);
-
- if (this.getXmlMapKey() != null) {
- this.removeXmlMapKey();
- }
- } else {
- this.setPkMapKey(true); // hmmm...
- }
- }
-
- protected void setNoMapKey_(boolean noMapKey) {
- boolean old = this.noMapKey;
- this.noMapKey = noMapKey;
- this.firePropertyChanged(NO_MAP_KEY_PROPERTY, old, noMapKey);
- }
-
- protected boolean buildNoMapKey() {
- return this.getXmlMapKey() == null;
- }
-
-
- // ********** pk map key **********
-
- public boolean isPkMapKey() {
- return this.pkMapKey;
- }
-
- public void setPkMapKey(boolean pkMapKey) {
- if (pkMapKey) {
- this.setSpecifiedMapKey_(null);
- this.setNoMapKey_(false);
- this.setPkMapKey_(true);
- this.setCustomMapKey_(false);
-
- MapKey xmlMapKey = this.getXmlMapKey();
- if (xmlMapKey == null) {
- this.buildXmlMapKey();
- } else {
- xmlMapKey.setName(null);
- }
- } else {
- this.setNoMapKey(true); // hmmm...
- }
- }
-
- protected void setPkMapKey_(boolean pkMapKey) {
- boolean old = this.pkMapKey;
- this.pkMapKey = pkMapKey;
- this.firePropertyChanged(PK_MAP_KEY_PROPERTY, old, pkMapKey);
- }
-
- protected boolean buildPkMapKey() {
- MapKey xmlMapKey = this.getXmlMapKey();
- return (xmlMapKey != null) && (xmlMapKey.getName() == null);
- }
-
-
- // ********** custom map key **********
-
- public boolean isCustomMapKey() {
- return this.customMapKey;
- }
-
- public void setCustomMapKey(boolean customMapKey) {
- if (customMapKey) {
- this.setSpecifiedMapKey(""); //$NON-NLS-1$
- } else {
- this.setNoMapKey(true); // hmmm...
- }
- }
-
- protected void setCustomMapKey_(boolean customMapKey) {
- boolean old = this.customMapKey;
- this.customMapKey = customMapKey;
- this.firePropertyChanged(CUSTOM_MAP_KEY_PROPERTY, old, customMapKey);
- }
-
- protected boolean buildCustomMapKey() {
- MapKey xmlMapKey = this.getXmlMapKey();
- return (xmlMapKey != null) && (xmlMapKey.getName() != null);
- }
-
-
- // ********** xml map key **********
-
- protected MapKey getXmlMapKey() {
- return this.xmlAttributeMapping.getMapKey();
- }
-
- protected MapKey buildXmlMapKey() {
- MapKey mapKey = OrmFactory.eINSTANCE.createMapKey();
- this.xmlAttributeMapping.setMapKey(mapKey);
- return mapKey;
- }
-
- protected void removeXmlMapKey() {
- this.xmlAttributeMapping.setMapKey(null);
- }
-
-
- // ********** 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) {
- if (this.setSpecifiedMapKeyClass_(mapKeyClass)) {
- XmlClassReference xmlClassRef = this.xmlAttributeMapping.getMapKeyClass();
- if (mapKeyClass == null) {
- if (xmlClassRef != null) {
- this.xmlAttributeMapping.setMapKeyClass(null);
- }
- } else {
- if (xmlClassRef == null) {
- xmlClassRef = this.buildXmlMapKeyClassReference();
- }
- xmlClassRef.setClassName(mapKeyClass);
- }
- }
- }
-
- protected boolean setSpecifiedMapKeyClass_(String mapKeyClass) {
- String old = this.specifiedMapKeyClass;
- this.specifiedMapKeyClass = mapKeyClass;
- return this.firePropertyChanged(SPECIFIED_MAP_KEY_CLASS_PROPERTY, old, mapKeyClass);
- }
-
- protected XmlClassReference buildXmlMapKeyClassReference() {
- XmlClassReference mapKeyClass = OrmFactory.eINSTANCE.createXmlClassReference();
- this.xmlAttributeMapping.setMapKeyClass(mapKeyClass);
- return mapKeyClass;
- }
-
- protected String buildSpecifiedMapKeyClass() {
- XmlClassReference xmlClassRef = this.xmlAttributeMapping.getMapKeyClass();
- return (xmlClassRef == null) ? null : xmlClassRef.getClassName();
- }
-
- 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() {
- JavaPersistentAttribute javaAttribute = this.getJavaPersistentAttribute();
- return (javaAttribute == null) ? null : javaAttribute.getMultiReferenceMapKeyTypeName();
- }
-
- public char getMapKeyClassEnclosingTypeSeparator() {
- return '$';
- }
-
-
- // ********** resolved map key embeddable/entity **********
-
- protected Embeddable getResolvedMapKeyEmbeddable() {
- TypeMapping typeMapping = this.getResolvedMapKeyTypeMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- protected Entity getResolvedMapKeyEntity() {
- TypeMapping typeMapping = this.getResolvedMapKeyTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- protected TypeMapping getResolvedMapKeyTypeMapping() {
- PersistentType resolvedMapKeyType = this.getResolvedMapKeyType();
- return (resolvedMapKeyType == null) ? null : resolvedMapKeyType.getMapping();
- }
-
- protected PersistentType getResolvedMapKeyType() {
- return this.resolvePersistentType(this.getMapKeyClass());
- }
-
-
- // ********** value type **********
-
- public Type getValueType() {
- return this.valueType;
- }
-
- protected void setValueType(Type valueType) {
- Type old = this.valueType;
- this.valueType = valueType;
- this.firePropertyChanged(VALUE_TYPE_PROPERTY, old, valueType);
- }
-
- protected Type buildValueType() {
- if (this.getResolvedTargetEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- if (this.getResolvedTargetEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (this.getTargetEntity() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
- protected Embeddable getResolvedTargetEmbeddable() {
- TypeMapping typeMapping = this.getResolvedTargetTypeMapping();
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
-
- // ********** key type **********
-
- public Type getKeyType() {
- return this.keyType;
- }
-
- protected void setKeyType(Type keyType) {
- Type old = this.keyType;
- this.keyType = keyType;
- this.firePropertyChanged(KEY_TYPE_PROPERTY, old, keyType);
- }
-
- protected Type buildKeyType() {
- if (this.getResolvedMapKeyEmbeddable() != null) {
- return Type.EMBEDDABLE_TYPE;
- }
- if (this.getResolvedMapKeyEntity() != null) {
- return Type.ENTITY_TYPE;
- }
- if (this.getMapKeyClass() == null) {
- return Type.NO_TYPE;
- }
- return Type.BASIC_TYPE;
- }
-
-
- // ********** map key column **********
-
- public OrmColumn getMapKeyColumn() {
- return this.mapKeyColumn;
- }
-
- protected OrmColumn buildMapKeyColumn() {
- return this.getContextNodeFactory().buildOrmColumn(this, this.buildMapKeyColumnOwner());
- }
-
- protected OrmColumn.Owner buildMapKeyColumnOwner() {
- return new MapKeyColumnOwner();
- }
-
- protected XmlColumn getXmlMapKeyColumn() {
- return this.xmlAttributeMapping.getMapKeyColumn();
- }
-
- protected XmlColumn buildXmlMapKeyColumn() {
- XmlColumn xmlColumn = OrmFactory.eINSTANCE.createXmlColumn();
- this.xmlAttributeMapping.setMapKeyColumn(xmlColumn);
- return xmlColumn;
- }
-
- protected void removeXmlMapKeyColumn() {
- this.xmlAttributeMapping.setMapKeyColumn(null);
- }
-
-
- // ********** map key attribute override container **********
-
- public OrmAttributeOverrideContainer getMapKeyAttributeOverrideContainer() {
- return this.mapKeyAttributeOverrideContainer;
- }
-
- protected OrmAttributeOverrideContainer buildMapKeyAttributeOverrideContainer() {
- return this.getContextNodeFactory().buildOrmAttributeOverrideContainer(this, this.buildMapKeyAttributeOverrideContainerOwner());
- }
-
- protected OrmAttributeOverrideContainer.Owner buildMapKeyAttributeOverrideContainerOwner() {
- return new MapKeyAttributeOverrideContainerOwner();
- }
-
- protected JavaAttributeOverride getSpecifiedJavaMapKeyAttributeOverrideNamed(String attributeName) {
- JavaCollectionMapping2_0 javaCollectionMapping = this.getJavaCollectionMapping();
- return (javaCollectionMapping == null) ? null :
- javaCollectionMapping.getMapKeyAttributeOverrideContainer().getSpecifiedOverrideNamed(attributeName);
- }
-
- protected JavaCollectionMapping2_0 getJavaCollectionMapping() {
- AttributeMapping javaAttributeMapping = this.getJavaAttributeMapping();
- return (javaAttributeMapping.getKey() == this.getKey()) ?
- (JavaCollectionMapping2_0) javaAttributeMapping :
- null;
- }
-
- protected AttributeMapping getJavaAttributeMapping() {
- JavaPersistentAttribute javaAttribute = this.getJavaPersistentAttribute();
- return (javaAttribute == null) ? null : javaAttribute.getMapping();
- }
-
-
- // ********** misc **********
-
- /**
- * pre-condition: the mapping's Java persistent attribute is not
- * <code>null</code>.
- */
- @Override
- protected String getJavaTargetType() {
- return this.getJavaPersistentAttribute().getMultiReferenceTargetTypeName();
- }
-
- @Override
- protected FetchType buildDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
- public Iterator<String> candidateMapKeyNames() {
- return this.allTargetEntityAttributeNames();
- }
-
-
- // ********** metamodel **********
-
- @Override
- protected String getMetamodelFieldTypeName() {
- return ((OrmPersistentAttribute2_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 = ((OrmPersistentAttribute2_0) this.getPersistentAttribute()).getMetamodelContainerFieldMapKeyTypeName();
- if (keyTypeName != null) {
- typeArgumentNames.add(keyTypeName);
- }
- }
-
- public String getMetamodelFieldMapKeyTypeName() {
- return MappingTools.getMetamodelFieldMapKeyTypeName(this);
- }
-
-
- //************* refactoring *************
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- PersistentType mapKeyType = this.getResolvedMapKeyType();
- if ((mapKeyType != null) && mapKeyType.isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenameTypeEdit(originalType, newName));
- }
- }
- return EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createMapKeyClassRenameTypeEdit(IType originalType, String newName) {
- return this.xmlAttributeMapping.createRenameMapKeyClassEdit(originalType, newName);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- PersistentType mapKeyType = this.getResolvedMapKeyType();
- if ((mapKeyType != null) && mapKeyType.isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenamePackageEdit(newPackage.getElementName()));
- }
- }
- return EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- PersistentType mapKeyType = this.getResolvedMapKeyType();
- if ((mapKeyType != null) && mapKeyType.isIn(originalPackage)) {
- return new SingleElementIterable<ReplaceEdit>(this.createMapKeyClassRenamePackageEdit(newName));
- }
- }
- return EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createMapKeyClassRenamePackageEdit(String newName) {
- return this.xmlAttributeMapping.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 (this.getMapKey() != null) {
- //TODO validate that the map key refers to an existing attribute
- return;
- }
- if (this.keyType == Type.BASIC_TYPE) {
- this.mapKeyColumn.validate(messages, reporter);
- //validate map key converter
- }
- else if (this.keyType == Type.ENTITY_TYPE) {
- //validate map key join columns
- }
- else if (this.keyType == Type.EMBEDDABLE_TYPE) {
- this.mapKeyAttributeOverrideContainer.validate(messages, reporter);
- //validate map key association overrides
- }
- }
-
-
- // ********** abstract owner **********
-
- /**
- * some common behavior
- */
- protected class AbstractOwner
- {
- public OrmTypeMapping getTypeMapping() {
- return AbstractOrmMultiRelationshipMapping.this.getTypeMapping();
- }
-
- public String getDefaultTableName() {
- return this.getRelationshipStrategy().getTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getRelationshipStrategy().resolveDbTable(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return EmptyIterator.instance();
- }
-
- public TextRange getValidationTextRange() {
- return AbstractOrmMultiRelationshipMapping.this.getValidationTextRange();
- }
-
- protected OrmRelationshipStrategy getRelationshipStrategy() {
- return AbstractOrmMultiRelationshipMapping.this.getRelationship().getStrategy();
- }
-
- protected OrmPersistentAttribute getPersistentAttribute() {
- return AbstractOrmMultiRelationshipMapping.this.getPersistentAttribute();
- }
- }
-
-
- // ********** map key column owner **********
-
- protected class MapKeyColumnOwner
- extends AbstractOwner
- implements OrmColumn.Owner
- {
- public String getDefaultColumnName() {
- return AbstractOrmMultiRelationshipMapping.this.getName() + "_KEY"; //$NON-NLS-1$
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getRelationshipStrategy().tableNameIsInvalid(tableName);
- }
-
- public XmlColumn getXmlColumn() {
- return AbstractOrmMultiRelationshipMapping.this.getXmlMapKeyColumn();
- }
-
- public XmlColumn buildXmlColumn() {
- return AbstractOrmMultiRelationshipMapping.this.buildXmlMapKeyColumn();
- }
-
- public void removeXmlColumn() {
- AbstractOrmMultiRelationshipMapping.this.removeXmlMapKeyColumn();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new MapKeyColumnValidator(this.getPersistentAttribute(), (BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new RelationshipStrategyTableDescriptionProvider(this.getRelationshipStrategy()));
- }
- }
-
-
- // ********** map key attribute override container owner **********
-
- protected class MapKeyAttributeOverrideContainerOwner
- extends AbstractOwner
- implements OrmAttributeOverrideContainer.Owner
- {
- public TypeMapping getOverridableTypeMapping() {
- return AbstractOrmMultiRelationshipMapping.this.getResolvedMapKeyEmbeddable();
- }
-
- public Iterator<String> allOverridableNames() {
- TypeMapping typeMapping = this.getOverridableTypeMapping();
- return (typeMapping != null) ? typeMapping.allOverridableAttributeNames() : EmptyIterator.<String>instance();
- }
-
- protected JavaAttributeOverride getSpecifiedJavaAttributeOverrideNamed(String attributeName) {
- return AbstractOrmMultiRelationshipMapping.this.getSpecifiedJavaMapKeyAttributeOverrideNamed(attributeName);
- }
-
- public EList<XmlAttributeOverride> getXmlOverrides() {
- return AbstractOrmMultiRelationshipMapping.this.xmlAttributeMapping.getMapKeyAttributeOverrides();
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName);
- }
-
- /**
- * 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 Tools.valuesAreDifferent(this.getDefaultTableName(), tableName);
- }
-
- public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideValidator(this.getPersistentAttribute(), (AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider());
- }
-
- public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner owner, BaseColumnTextRangeResolver textRangeResolver) {
- return new MapKeyAttributeOverrideColumnValidator(this.getPersistentAttribute(), (AttributeOverride) override, column, textRangeResolver, new RelationshipStrategyTableDescriptionProvider(this.getRelationshipStrategy()));
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java
deleted file mode 100644
index c400e098f3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmNamedColumn.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011s Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmNamedColumn;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlNamedColumn;
-import org.eclipse.jpt.jpa.db.Column;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code><ul>
- * <li>column
- * <li>join column
- * <li>discriminator column
- * <li>order column
- * <li>primary key join column
- * </ul>
- * <strong>NB:</strong> any subclass that directly holds its XML column must:<ul>
- * <li>call the "super" constructor that takes an XML column
- * {@link #AbstractOrmNamedColumn(XmlContextNode, OrmNamedColumn.Owner, AbstractXmlNamedColumn)}
- * <li>override {@link #setXmlColumn(AbstractXmlNamedColumn)} to set the XML column
- * so it is in place before the column's state (e.g. {@link #specifiedName})
- * is initialized
- * </ul>
- * Typically, a column belonging to a list of columns will directly hold its XML
- * column; since the context column only exists if the XML column exists.
- */
-public abstract class AbstractOrmNamedColumn<X extends AbstractXmlNamedColumn, O extends OrmNamedColumn.Owner>
- extends AbstractOrmXmlContextNode
- implements OrmNamedColumn
-{
- protected final O owner;
-
- protected String specifiedName;
- protected String defaultName;
-
- protected String columnDefinition;
-
-
- // ********** constructor/initialization **********
-
- protected AbstractOrmNamedColumn(XmlContextNode parent, O owner) {
- this(parent, owner, null);
- }
-
- protected AbstractOrmNamedColumn(XmlContextNode parent, O owner, X xmlColumn) {
- super(parent);
- this.owner = owner;
- this.setXmlColumn(xmlColumn);
- this.specifiedName = this.buildSpecifiedName();
- this.columnDefinition = this.buildColumnDefinition();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedName_(this.buildSpecifiedName());
- this.setColumnDefinition_(this.buildColumnDefinition());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultName(this.buildDefaultName());
- }
-
-
- // ********** XML column **********
-
- /**
- * Return <code>null</code> if XML column does not exists.
- */
- public abstract X getXmlColumn();
-
- /**
- * see class comment...
- */
- protected void setXmlColumn(X xmlColumn) {
- if (xmlColumn != null) {
- throw new IllegalArgumentException("this method must be overridden if the XML column is not null: " + xmlColumn); //$NON-NLS-1$
- }
- }
-
- /**
- * Build the XML column if it does not exist.
- */
- protected X getXmlColumnForUpdate() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn != null) ? xmlColumn : this.buildXmlColumn();
- }
-
- protected abstract X buildXmlColumn();
-
- protected void removeXmlColumnIfUnset() {
- if (this.getXmlColumn().isUnset()) {
- this.removeXmlColumn();
- }
- }
-
- protected abstract void removeXmlColumn();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- if (this.valuesAreDifferent(this.specifiedName, name)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setSpecifiedName_(name);
- xmlColumn.setName(name);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getName();
- }
-
- 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);
- }
-
- protected String buildDefaultName() {
- return this.owner.getDefaultColumnName();
- }
-
-
- // ********** column definition **********
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- public void setColumnDefinition(String columnDefinition) {
- if (this.valuesAreDifferent(this.columnDefinition, columnDefinition)) {
- X xmlColumn = this.getXmlColumnForUpdate();
- this.setColumnDefinition_(columnDefinition);
- xmlColumn.setColumnDefinition(columnDefinition);
- this.removeXmlColumnIfUnset();
- }
- }
-
- protected void setColumnDefinition_(String columnDefinition) {
- String old = this.columnDefinition;
- this.columnDefinition = columnDefinition;
- this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition);
- }
-
- protected String buildColumnDefinition() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getColumnDefinition();
- }
-
-
- // ********** database stuff **********
-
- protected Column getDbColumn() {
- Table table = this.getDbTable();
- return (table == null) ? null : table.getColumnForIdentifier(this.getName());
- }
-
- public Table getDbTable() {
- return this.owner.resolveDbTable(this.getTable());
- }
-
- /**
- * Return the name of the column's table. This is overridden in
- * {@link AbstractOrmBaseColumn} (and other places) where a table can be
- * defined.
- */
- public String getTable() {
- return this.owner.getTypeMapping().getPrimaryTableName();
- }
-
- public boolean isResolved() {
- return this.getDbColumn() != null;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.buildColumnValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildColumnValidator() {
- return this.owner.buildColumnValidator(this, this.buildTextRangeResolver());
- }
-
- protected NamedColumnTextRangeResolver buildTextRangeResolver() {
- return new OrmNamedColumnTextRangeResolver(this);
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.getXmlColumnTextRange();
- return (textRange != null) ? textRange : this.owner.getValidationTextRange();
- }
-
- protected TextRange getXmlColumnTextRange() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.getXmlColumnNameTextRange());
- }
-
- protected TextRange getXmlColumnNameTextRange() {
- X xmlColumn = this.getXmlColumn();
- return (xmlColumn == null) ? null : xmlColumn.getNameTextRange();
- }
-
-
- // ********** misc **********
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- /**
- * This is used by the subclasses that implement {@link BaseJoinColumn}.
- */
- public boolean isVirtual() {
- return false;
- }
-
- protected void initializeFrom(ReadOnlyNamedColumn oldColumn) {
- this.setSpecifiedName(oldColumn.getSpecifiedName());
- this.setColumnDefinition(oldColumn.getColumnDefinition());
- }
-
- protected void initializeFromVirtual(ReadOnlyNamedColumn virtualColumn) {
- this.setSpecifiedName(virtualColumn.getName());
- this.setColumnDefinition(virtualColumn.getColumnDefinition());
- }
-
- @Override
- public void toString(StringBuilder sb) {
- String table = this.getTable();
- if (table != null) {
- sb.append(table);
- sb.append('.');
- }
- sb.append(this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToManyMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToManyMapping.java
deleted file mode 100644
index f4a7c7a7c3..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToManyMapping.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.NullOrmOrphanRemoval2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToManyMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToManyRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany;
-
-
-public abstract class AbstractOrmOneToManyMapping<X extends XmlOneToMany>
- extends AbstractOrmMultiRelationshipMapping<X>
- implements OrmOneToManyMapping2_0, OrmOrphanRemovalHolder2_0
-{
- protected final OrmOrphanRemovable2_0 orphanRemoval;
-
-
- protected AbstractOrmOneToManyMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.orphanRemoval.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.orphanRemoval.update();
- }
-
-
- // ********** orphan removal **********
-
- public OrmOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-
- protected OrmOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isOrmXml2_0Compatible() ?
- this.getContextNodeFactory2_0().buildOrmOrphanRemoval(this) :
- new NullOrmOrphanRemoval2_0(this);
- }
-
-
- // ********** relationship **********
-
- @Override
- protected OrmOneToManyRelationship2_0 buildRelationship() {
- return new GenericOrmOneToManyRelationship(this, this.isJpa2_0Compatible());
- }
-
- @Override
- public OrmOneToManyRelationship2_0 getRelationship() {
- return (OrmOneToManyRelationship2_0) super.getRelationship();
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 50;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmOneToManyMapping(this);
- }
-
- public void addXmlAttributeMappingTo(Attributes resourceAttributes) {
- resourceAttributes.getOneToManys().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) {
- resourceAttributes.getOneToManys().remove(this.xmlAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToOneMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToOneMapping.java
deleted file mode 100644
index 4302119c3d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmOneToOneMapping.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.NullOrmOrphanRemoval2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToOneMapping2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovable2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrphanRemovalHolder2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne;
-
-/**
- * <code>orm.xml</code> 1:1 mapping
- */
-public abstract class AbstractOrmOneToOneMapping<X extends XmlOneToOne>
- extends AbstractOrmSingleRelationshipMapping<X>
- implements OrmOneToOneMapping2_0, OrmOrphanRemovalHolder2_0
-{
- protected final OrmOrphanRemovable2_0 orphanRemoval;
-
-
- protected AbstractOrmOneToOneMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.orphanRemoval = this.buildOrphanRemoval();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.orphanRemoval.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.orphanRemoval.update();
- }
-
-
- // ********** orphan removal **********
-
- public OrmOrphanRemovable2_0 getOrphanRemoval() {
- return this.orphanRemoval;
- }
-
- protected OrmOrphanRemovable2_0 buildOrphanRemoval() {
- return this.isOrmXml2_0Compatible() ?
- this.getContextNodeFactory2_0().buildOrmOrphanRemoval(this) :
- new NullOrmOrphanRemoval2_0(this);
- }
-
-
- // ********** relationship **********
-
- @Override
- public OrmOneToOneRelationship2_0 getRelationship() {
- return (OrmOneToOneRelationship2_0) super.getRelationship();
- }
-
- @Override
- protected OrmMappingRelationship buildRelationship() {
- return new GenericOrmOneToOneRelationship(this);
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 60;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmOneToOneMapping(this);
- }
-
- public void addXmlAttributeMappingTo(Attributes resourceAttributes) {
- resourceAttributes.getOneToOnes().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes resourceAttributes) {
- resourceAttributes.getOneToOnes().remove(this.xmlAttributeMapping);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
deleted file mode 100644
index ca77373f5a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmQuery.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import java.util.Vector;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.Query;
-import org.eclipse.jpt.jpa.core.context.QueryHint;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlQuery;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlQueryHint;
-import org.eclipse.persistence.jpa.jpql.ExpressionTools;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> query
- */
-public abstract class AbstractOrmQuery<X extends XmlQuery>
- extends AbstractOrmXmlContextNode
- implements OrmQuery
-{
- protected final X xmlQuery;
-
- protected String name;
-
- protected String query;
-
- protected final Vector<OrmQueryHint> hints = new Vector<OrmQueryHint>();
- protected final HintContainerAdapter hintContainerAdapter = new HintContainerAdapter();
-
-
- protected AbstractOrmQuery(XmlContextNode parent, X xmlQuery) {
- super(parent);
- this.xmlQuery = xmlQuery;
- this.name = xmlQuery.getName();
- this.query = this.getUnescapedQuery();
- this.initializeHints();
- }
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setName_(this.xmlQuery.getName());
- this.setQuery_(this.getUnescapedQuery());
- this.syncHints();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getHints());
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.setName_(name);
- this.xmlQuery.setName(name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = name;
- this.firePropertyChanged(NAME_PROPERTY, old, name);
- }
-
-
- // ********** query **********
-
- public String getQuery() {
- return this.query;
- }
-
- public void setQuery(String query) {
- this.setQuery_(query);
- this.xmlQuery.setQuery(this.convertToEscapeQuery(query));
- }
-
- protected void setQuery_(String query) {
- String old = this.query;
- this.query = query;
- this.firePropertyChanged(QUERY_PROPERTY, old, query);
- }
-
- protected String getUnescapedQuery() {
- String queryString = this.xmlQuery.getQuery();
- if (StringTools.stringIsNotEmpty(queryString)) {
- queryString = ExpressionTools.unescape(queryString, new int[1]);
- }
- return queryString;
- }
-
- // TODO bjv add method to ExpressionTools?
- protected String convertToEscapeQuery(String queryString) {
- if (StringTools.stringIsNotEmpty(queryString)) {
- queryString = ExpressionTools.escape(queryString, new int[1]);
- }
- return queryString;
- }
-
-
- // ********** hints **********
-
- public ListIterable<OrmQueryHint> getHints() {
- return new LiveCloneListIterable<OrmQueryHint>(this.hints);
- }
-
- public int getHintsSize() {
- return this.hints.size();
- }
-
- public OrmQueryHint addHint() {
- return this.addHint(this.hints.size());
- }
-
- public OrmQueryHint addHint(int index) {
- XmlQueryHint xmlHint = this.buildXmlQueryHint();
- OrmQueryHint hint = this.addHint_(index, xmlHint);
- this.xmlQuery.getHints().add(index, xmlHint);
- return hint;
- }
-
- protected XmlQueryHint buildXmlQueryHint() {
- return OrmFactory.eINSTANCE.createXmlQueryHint();
- }
-
- public void removeHint(QueryHint hint) {
- this.removeHint(this.hints.indexOf(hint));
- }
-
- public void removeHint(int index) {
- this.removeHint_(index);
- this.xmlQuery.getHints().remove(index);
- }
-
- protected void removeHint_(int index) {
- this.removeItemFromList(index, this.hints, HINTS_LIST);
- }
-
- public void moveHint(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.hints, HINTS_LIST);
- this.xmlQuery.getHints().move(targetIndex, sourceIndex);
- }
-
- protected void initializeHints() {
- for (XmlQueryHint xmlHint : this.getXmlHints()) {
- this.hints.add(this.buildHint(xmlHint));
- }
- }
-
- protected OrmQueryHint buildHint(XmlQueryHint xmlHint) {
- return this.getContextNodeFactory().buildOrmQueryHint(this, xmlHint);
- }
-
- protected void syncHints() {
- ContextContainerTools.synchronizeWithResourceModel(this.hintContainerAdapter);
- }
-
- protected Iterable<XmlQueryHint> getXmlHints() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlQueryHint>(this.xmlQuery.getHints());
- }
-
- protected void moveHint_(int index, OrmQueryHint hint) {
- this.moveItemInList(index, hint, this.hints, HINTS_LIST);
- }
-
- protected OrmQueryHint addHint_(int index, XmlQueryHint xmlHint) {
- OrmQueryHint hint = this.buildHint(xmlHint);
- this.addItemToList(index, hint, this.hints, HINTS_LIST);
- return hint;
- }
-
- protected void removeHint_(OrmQueryHint hint) {
- this.removeHint_(this.hints.indexOf(hint));
- }
-
- /**
- * hint container adapter
- */
- protected class HintContainerAdapter
- implements ContextContainerTools.Adapter<OrmQueryHint, XmlQueryHint>
- {
- public Iterable<OrmQueryHint> getContextElements() {
- return AbstractOrmQuery.this.getHints();
- }
- public Iterable<XmlQueryHint> getResourceElements() {
- return AbstractOrmQuery.this.getXmlHints();
- }
- public XmlQueryHint getResourceElement(OrmQueryHint contextElement) {
- return contextElement.getXmlQueryHint();
- }
- public void moveContextElement(int index, OrmQueryHint element) {
- AbstractOrmQuery.this.moveHint_(index, element);
- }
- public void addContextElement(int index, XmlQueryHint resourceElement) {
- AbstractOrmQuery.this.addHint_(index, resourceElement);
- }
- public void removeContextElement(OrmQueryHint element) {
- AbstractOrmQuery.this.removeHint_(element);
- }
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateName(messages);
- this.validateQuery(messages, reporter);
- }
-
- protected void validateName(List<IMessage> messages) {
- if (StringTools.stringIsEmpty(this.name)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_NAME_UNDEFINED,
- EMPTY_STRING_ARRAY,
- this,
- this.getNameTextRange()
- )
- );
- }
- }
-
- protected void validateQuery(List<IMessage> messages, IReporter reporter) {
- if (StringTools.stringIsEmpty(this.query)){
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_STATEMENT_UNDEFINED,
- new String[] {this.name},
- this,
- this.getNameTextRange()
- )
- );
- } else {
- this.validateQuery_(messages, reporter);
- }
- }
-
- protected abstract void validateQuery_(List<IMessage> messages, IReporter reporter);
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.xmlQuery.getValidationTextRange();
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.xmlQuery.getNameTextRange());
- }
-
- public TextRange getQueryTextRange() {
- return this.getValidationTextRange(this.xmlQuery.getQueryTextRange());
- }
-
-
- // ********** misc **********
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- public X getXmlQuery() {
- return this.xmlQuery;
- }
-
- public boolean overrides(Query other) {
- return MappingTools.nodeOverrides(this, other, PRECEDENCE_TYPE_LIST);
- }
-
- public boolean duplicates(Query other) {
- return MappingTools.nodesAreDuplicates(this, other);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.name);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmReadOnlyUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmReadOnlyUniqueConstraint.java
deleted file mode 100644
index caa97f18dc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmReadOnlyUniqueConstraint.java
+++ /dev/null
@@ -1,53 +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.jpa.core.internal.context.orm;
-
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyUniqueConstraint;
-
-public abstract class AbstractOrmReadOnlyUniqueConstraint
- extends AbstractOrmXmlContextNode
- implements OrmReadOnlyUniqueConstraint
-{
- protected final Vector<String> columnNames = new Vector<String>();
-
-
- public AbstractOrmReadOnlyUniqueConstraint(XmlContextNode parent) {
- super(parent);
- }
-
-
- // ********** column names **********
-
- public Iterable<String> getColumnNames() {
- return new LiveCloneListIterable<String>(this.columnNames);
- }
-
- public int getColumnNamesSize() {
- return this.columnNames.size();
- }
-
- public String getColumnName(int index) {
- return this.columnNames.get(index);
- }
-
- protected void syncColumnNames() {
- this.synchronizeList(this.getResourceColumnNames(), this.columnNames, COLUMN_NAMES_LIST);
- }
-
- protected abstract Iterable<String> getResourceColumnNames();
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.columnNames);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
deleted file mode 100644
index f400b4e027..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmRelationshipMapping.java
+++ /dev/null
@@ -1,400 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmCascade;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappingRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipMapping;
-import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmCascade;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlRelationshipMapping;
-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> relationship mapping (1:1, 1:m, m:1, m:m)
- */
-public abstract class AbstractOrmRelationshipMapping<X extends AbstractXmlRelationshipMapping>
- extends AbstractOrmAttributeMapping<X>
- implements OrmRelationshipMapping
-{
- protected String specifiedTargetEntity;
- protected String defaultTargetEntity;
-
- protected final OrmMappingRelationship relationship;
-
- protected final OrmCascade cascade;
-
- protected FetchType specifiedFetch;
- protected FetchType defaultFetch;
-
-
- protected AbstractOrmRelationshipMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.specifiedTargetEntity = xmlMapping.getTargetEntity();
- this.relationship = this.buildRelationship();
- this.cascade = this.buildCascade();
- this.specifiedFetch = this.buildSpecifiedFetch();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedTargetEntity_(this.xmlAttributeMapping.getTargetEntity());
- this.relationship.synchronizeWithResourceModel();
- this.cascade.synchronizeWithResourceModel();
- this.setSpecifiedFetch_(this.buildSpecifiedFetch());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultTargetEntity(this.buildDefaultTargetEntity());
- this.relationship.update();
- this.cascade.update();
- this.setDefaultFetch(this.buildDefaultFetch());
- }
-
-
- // ********** target entity **********
-
- public String getTargetEntity() {
- return (this.specifiedTargetEntity != null) ? this.specifiedTargetEntity : this.defaultTargetEntity;
- }
-
- public String getSpecifiedTargetEntity() {
- return this.specifiedTargetEntity;
- }
-
- public void setSpecifiedTargetEntity(String entity) {
- this.setSpecifiedTargetEntity_(entity);
- this.xmlAttributeMapping.setTargetEntity(entity);
- }
-
- protected void setSpecifiedTargetEntity_(String entity) {
- String old = this.specifiedTargetEntity;
- this.specifiedTargetEntity = entity;
- this.firePropertyChanged(SPECIFIED_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- public String getDefaultTargetEntity() {
- return this.defaultTargetEntity;
- }
-
- protected void setDefaultTargetEntity(String entity) {
- String old = this.defaultTargetEntity;
- this.defaultTargetEntity = entity;
- this.firePropertyChanged(DEFAULT_TARGET_ENTITY_PROPERTY, old, entity);
- }
-
- protected String buildDefaultTargetEntity() {
- return (this.getJavaPersistentAttribute() == null) ? null : this.getJavaTargetType();
- }
-
- /**
- * pre-condition: the mapping's Java persistent attribute is not
- * <code>null</code>.
- */
- protected abstract String getJavaTargetType();
-
- public Entity getResolvedTargetEntity() {
- TypeMapping typeMapping = this.getResolvedTargetTypeMapping();
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- protected TypeMapping getResolvedTargetTypeMapping() {
- PersistentType resolvedTargetType = this.getResolvedTargetType();
- return (resolvedTargetType == null) ? null : resolvedTargetType.getMapping();
- }
-
- // sub-classes like this to be public
- public PersistentType getResolvedTargetType() {
- return this.resolvePersistentType(this.getTargetEntity());
- }
-
- public char getTargetEntityEnclosingTypeSeparator() {
- return '$';
- }
-
-
- // ********** relationship reference **********
-
- public OrmMappingRelationship getRelationship() {
- return this.relationship;
- }
-
- protected abstract OrmMappingRelationship buildRelationship();
-
-
- // ********** cascade **********
-
- public OrmCascade getCascade() {
- return this.cascade;
- }
-
- protected OrmCascade buildCascade() {
- // NB: we don't use the platform
- return new GenericOrmCascade(this);
- }
-
-
- // ********** fetch **********
-
- public FetchType getFetch() {
- return (this.specifiedFetch != null) ? this.specifiedFetch : this.defaultFetch;
- }
-
- public FetchType getSpecifiedFetch() {
- return this.specifiedFetch;
- }
-
- public void setSpecifiedFetch(FetchType fetch) {
- this.setSpecifiedFetch_(fetch);
- this.xmlAttributeMapping.setFetch(FetchType.toOrmResourceModel(fetch));
- }
-
- protected void setSpecifiedFetch_(FetchType fetch) {
- FetchType old = this.specifiedFetch;
- this.specifiedFetch = fetch;
- this.firePropertyChanged(SPECIFIED_FETCH_PROPERTY, old, fetch);
- }
-
- protected FetchType buildSpecifiedFetch() {
- return FetchType.fromOrmResourceModel(this.xmlAttributeMapping.getFetch());
- }
-
- public FetchType getDefaultFetch() {
- return this.defaultFetch;
- }
-
- protected void setDefaultFetch(FetchType fetch) {
- FetchType old = this.defaultFetch;
- this.defaultFetch = fetch;
- this.firePropertyChanged(DEFAULT_FETCH_PROPERTY, old, fetch);
- }
-
- protected abstract FetchType buildDefaultFetch();
-
-
- // ********** misc **********
-
- @Override
- public boolean isRelationshipOwner() {
- return this.relationship.isOwner();
- }
-
- @Override
- public boolean isOwnedBy(AttributeMapping mapping) {
- return mapping.isRelationshipOwner() &&
- this.relationship.isOwnedBy((RelationshipMapping) mapping);
- }
-
- public RelationshipMapping getRelationshipOwner() {
- Entity entity = this.getResolvedTargetEntity();
- if (entity == null) {
- return null;
- }
- for (ReadOnlyPersistentAttribute attribute : CollectionTools.iterable(entity.getPersistentType().allAttributes())) {
- AttributeMapping mapping = attribute.getMapping();
- if (this.isOwnedBy(mapping)) {
- return (RelationshipMapping) mapping;
- }
- }
- return null;
- }
-
- @Override
- public boolean isOverridableAssociationMapping() {
- return this.relationship.isOverridable();
- }
-
- @Override
- protected void initializeFromOrmRelationshipMapping(OrmRelationshipMapping oldMapping) {
- super.initializeFromOrmRelationshipMapping(oldMapping);
- this.setSpecifiedTargetEntity(oldMapping.getSpecifiedTargetEntity());
- this.setSpecifiedFetch(oldMapping.getSpecifiedFetch());
- oldMapping.getRelationship().initializeOn(this.relationship);
- this.cascade.initializeFrom(oldMapping.getCascade());
- //TODO should we set the fetch type from a BasicMapping??
- }
-
- public Iterator<String> allTargetEntityAttributeNames() {
- return new CompositeIterator<String>(this.allTargetEntityAttributeNamesLists());
- }
-
- protected Iterator<Iterator<String>> allTargetEntityAttributeNamesLists() {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.allTargetEntityAttributeMappings(), AttributeMappingTools.ALL_MAPPING_NAMES_TRANSFORMER);
- }
-
- protected Iterator<AttributeMapping> allTargetEntityAttributeMappings() {
- Entity entity = this.getResolvedTargetEntity();
- return (entity != null) ? entity.allAttributeMappings() : EmptyIterator.<AttributeMapping>instance();
- }
-
- protected String getTargetEntityIdAttributeName() {
- PersistentAttribute attribute = this.getTargetEntityIdAttribute();
- return (attribute == null) ? null : attribute.getName();
- }
-
- protected PersistentAttribute getTargetEntityIdAttribute() {
- Entity entity = this.getResolvedTargetEntity();
- return (entity == null) ? null : entity.getIdAttribute();
- }
-
-
- //************ refactoring ************
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- PersistentType targetType = this.getResolvedTargetType();
- if ((targetType != null) && targetType.isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createTargetEntityRenameTypeEdit(originalType, newName));
- }
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createTargetEntityRenameTypeEdit(IType originalType, String newName) {
- return this.xmlAttributeMapping.createRenameTargetEntityEdit(originalType, newName);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- PersistentType targetType = this.getResolvedTargetType();
- if ((targetType != null) && targetType.isFor(originalType.getFullyQualifiedName('.'))) {
- return new SingleElementIterable<ReplaceEdit>(this.createTargetEntityRenamePackageEdit(newPackage.getElementName()));
- }
- }
- return EmptyIterable.instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- PersistentType targetType = this.getResolvedTargetType();
- if ((targetType != null) && targetType.isIn(originalPackage)) {
- return new SingleElementIterable<ReplaceEdit>(this.createTargetEntityRenamePackageEdit(newName));
- }
- }
- return EmptyIterable.instance();
- }
-
- protected ReplaceEdit createTargetEntityRenamePackageEdit(String newName) {
- return this.xmlAttributeMapping.createRenameTargetEntityPackageEdit(newName);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateTargetEntity(messages);
- this.relationship.validate(messages, reporter);
- }
-
- protected void validateTargetEntity(List<IMessage> messages) {
- if (this.getTargetEntity() == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED,
- new String[] {this.name},
- this,
- this.getValidationTextRange()
- )
- );
- return;
- }
- if (this.getResolvedTargetEntity() == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY,
- new String[] {this.getTargetEntity(), this.name},
- this,
- this.getTargetEntityTextRange()
- )
- );
- }
- }
-
- protected TextRange getTargetEntityTextRange() {
- return this.getValidationTextRange(this.xmlAttributeMapping.getTargetEntityTextRange());
- }
-
-
- // ********** metamodel **********
-
- @Override
- public String getMetamodelTypeName() {
- PersistentType resolvedTargetType = this.getResolvedTargetType();
- if (resolvedTargetType == null) {
- return MetamodelField.DEFAULT_TYPE_NAME;
- }
- String targetTypeName = resolvedTargetType.getName();
- return (targetTypeName != null) ? targetTypeName : MetamodelField.DEFAULT_TYPE_NAME;
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
deleted file mode 100644
index ee4611f4f6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSequenceGenerator.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator;
-
-/**
- * <code>orm.xml</code> sequence generator
- */
-public abstract class AbstractOrmSequenceGenerator
- extends AbstractOrmGenerator<XmlSequenceGenerator>
- implements OrmSequenceGenerator
-{
- protected String specifiedSequenceName;
- protected String defaultSequenceName;
-
-
- protected AbstractOrmSequenceGenerator(XmlContextNode parent, XmlSequenceGenerator xmlSequenceGenerator) {
- super(parent, xmlSequenceGenerator);
- this.specifiedSequenceName = xmlSequenceGenerator.getSequenceName();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedSequenceName_(this.xmlGenerator.getSequenceName());
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultSequenceName(this.buildDefaultSequenceName());
- }
-
-
- // ********** initial value **********
-
- @Override
- protected int buildDefaultInitialValue() {
- return 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) {
- this.setSpecifiedSequenceName_(specifiedSequenceName);
- this.xmlGenerator.setSequenceName(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);
- }
-
- protected String buildDefaultSequenceName() {
- return null; // TODO the default sequence name is determined by the runtime provider...
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
deleted file mode 100644
index bde41315e5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmSingleRelationshipMapping.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.jpa.core.context.FetchType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSingleRelationshipMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.orm.NullOrmDerivedIdentity2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmDerivedIdentity2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmSingleRelationshipMapping2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlSingleRelationshipMapping;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> single relationship mapping (1:1, m:1)
- */
-public abstract class AbstractOrmSingleRelationshipMapping<X extends AbstractXmlSingleRelationshipMapping>
- extends AbstractOrmRelationshipMapping<X>
- implements OrmSingleRelationshipMapping2_0
-{
- protected Boolean specifiedOptional;
- protected boolean defaultOptional;
-
- protected final OrmDerivedIdentity2_0 derivedIdentity;
-
-
- protected AbstractOrmSingleRelationshipMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.specifiedOptional = xmlMapping.getOptional();
- this.derivedIdentity = this.buildDerivedIdentity();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedOptional_(this.xmlAttributeMapping.getOptional());
- this.derivedIdentity.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultOptional(this.buildDefaultOptional());
- this.derivedIdentity.update();
- }
-
-
- // ********** optional **********
-
- public boolean isOptional() {
- return (this.specifiedOptional != null) ? this.specifiedOptional.booleanValue() : this.defaultOptional;
- }
-
- public Boolean getSpecifiedOptional() {
- return this.specifiedOptional;
- }
-
- public void setSpecifiedOptional(Boolean optional) {
- this.setSpecifiedOptional_(optional);
- this.xmlAttributeMapping.setOptional(optional);
- }
-
- protected void setSpecifiedOptional_(Boolean optional) {
- Boolean old = this.specifiedOptional;
- this.specifiedOptional = optional;
- this.firePropertyChanged(SPECIFIED_OPTIONAL_PROPERTY, old, optional);
- }
-
- public boolean isDefaultOptional() {
- return this.defaultOptional;
- }
-
- protected void setDefaultOptional(boolean optional) {
- boolean old = this.defaultOptional;
- this.defaultOptional = optional;
- this.firePropertyChanged(DEFAULT_OPTIONAL_PROPERTY, old, optional);
- }
-
- protected boolean buildDefaultOptional() {
- return DEFAULT_OPTIONAL;
- }
-
-
- // ********** derived identity **********
-
- public OrmDerivedIdentity2_0 getDerivedIdentity() {
- return this.derivedIdentity;
- }
-
- protected OrmDerivedIdentity2_0 buildDerivedIdentity() {
- return this.isOrmXml2_0Compatible() ?
- this.getContextNodeFactory2_0().buildOrmDerivedIdentity(this) :
- new NullOrmDerivedIdentity2_0(this);
- }
-
-
- // ********** misc **********
-
- @Override
- protected void initializeFromOrmSingleRelationshipMapping(OrmSingleRelationshipMapping oldMapping) {
- super.initializeFromOrmSingleRelationshipMapping(oldMapping);
- if (this.isJpa2_0Compatible()) {
- this.derivedIdentity.initializeFrom(((OrmSingleRelationshipMapping2_0) oldMapping).getDerivedIdentity());
- }
- }
-
- /**
- * pre-condition: the mapping's Java persistent attribute is not
- * <code>null</code>.
- */
- @Override
- protected String getJavaTargetType() {
- return this.getJavaPersistentAttribute().getSingleReferenceTargetTypeName();
- }
-
- @Override
- protected FetchType buildDefaultFetch() {
- return DEFAULT_FETCH_TYPE;
- }
-
-
- // ********** 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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java
deleted file mode 100644
index d7c3600bcc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTable.java
+++ /dev/null
@@ -1,538 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyUniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.jpa.core.resource.orm.AbstractXmlTable;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> table, secondary table, join table, or collection table
- * <p>
- * <strong>NB:</strong> any subclass that directly holds its XML table must:<ul>
- * <li>call the "super" constructor that takes an XML table
- * {@link #AbstractOrmTable(XmlContextNode, Owner, AbstractXmlTable)}
- * <li>override {@link #setXmlTable(AbstractXmlTable)} to set the XML table
- * so it is in place before the table's state (e.g. {@link #specifiedName})
- * is initialized
- * </ul>
- */
-public abstract class AbstractOrmTable<X extends AbstractXmlTable>
- extends AbstractOrmXmlContextNode
- implements OrmTable, UniqueConstraint.Owner
-{
- protected final Owner owner;
-
- protected String specifiedName;
- protected String defaultName;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected final Vector<OrmUniqueConstraint> uniqueConstraints = new Vector<OrmUniqueConstraint>();
- protected final UniqueConstraintContainerAdapter uniqueConstraintContainerAdapter = new UniqueConstraintContainerAdapter();
-
-
- // ********** constructor/initialization **********
-
- protected AbstractOrmTable(XmlContextNode parent, Owner owner) {
- this(parent, owner, null);
- }
-
- protected AbstractOrmTable(XmlContextNode parent, Owner owner, X xmlTable) {
- super(parent);
- this.owner = owner;
- this.setXmlTable(xmlTable);
- this.specifiedName = this.buildSpecifiedName();
- this.specifiedSchema = this.buildSpecifiedSchema();
- this.specifiedCatalog = this.buildSpecifiedCatalog();
- this.initializeUniqueContraints();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedName_(this.buildSpecifiedName());
- this.setSpecifiedSchema_(this.buildSpecifiedSchema());
- this.setSpecifiedCatalog_(this.buildSpecifiedCatalog());
- this.syncUniqueConstraints();
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultName(this.buildDefaultName());
- this.setDefaultSchema(this.buildDefaultSchema());
- this.setDefaultCatalog(this.buildDefaultCatalog());
- this.updateNodes(this.getUniqueConstraints());
- }
-
-
- // ********** XML table **********
-
- /**
- * Return null if XML table does not exists.
- */
- protected abstract X getXmlTable();
-
- /**
- * see class comment...
- */
- protected void setXmlTable(X xmlTable) {
- if (xmlTable != null) {
- throw new IllegalArgumentException("this method must be overridden if the XML table is not null: " + xmlTable); //$NON-NLS-1$
- }
- }
-
- /**
- * Build the XML table if it does not exist.
- */
- protected X getXmlTableForUpdate() {
- X xmlTable = this.getXmlTable();
- return (xmlTable != null) ? xmlTable : this.buildXmlTable();
- }
-
- protected abstract X buildXmlTable();
-
- protected void removeXmlTableIfUnset() {
- if (this.getXmlTable().isUnset()) {
- this.removeXmlTable();
- }
- }
-
- protected abstract void removeXmlTable();
-
- public boolean isSpecifiedInResource() {
- return this.getXmlTable() != null;
- }
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- public void setSpecifiedName(String name) {
- if (this.valuesAreDifferent(this.specifiedName, name)) {
- X xmlTable = this.getXmlTableForUpdate();
- this.setSpecifiedName_(name);
- xmlTable.setName(name);
- this.removeXmlTableIfUnset();
- }
- }
-
- protected void setSpecifiedName_(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getName();
- }
-
- 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);
- }
-
- protected abstract String buildDefaultName();
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- public void setSpecifiedSchema(String schema) {
- if (this.valuesAreDifferent(this.specifiedSchema, schema)) {
- X xmlTable = this.getXmlTableForUpdate();
- this.setSpecifiedSchema_(schema);
- xmlTable.setSchema(schema);
- this.removeXmlTableIfUnset();
- }
- }
-
- protected void setSpecifiedSchema_(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- protected String buildSpecifiedSchema() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getSchema();
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- protected abstract String buildDefaultSchema();
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- public void setSpecifiedCatalog(String catalog) {
- if (this.valuesAreDifferent(this.specifiedCatalog, catalog)) {
- X xmlTable = this.getXmlTableForUpdate();
- this.setSpecifiedCatalog_(catalog);
- xmlTable.setCatalog(catalog);
- this.removeXmlTableIfUnset();
- }
- }
-
- protected void setSpecifiedCatalog_(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- protected String buildSpecifiedCatalog() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getCatalog();
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- protected abstract String buildDefaultCatalog();
-
-
- // ********** unique constraints **********
-
- public ListIterator<OrmUniqueConstraint> uniqueConstraints() {
- return this.getUniqueConstraints().iterator();
- }
-
- protected ListIterable<OrmUniqueConstraint> getUniqueConstraints() {
- return new LiveCloneListIterable<OrmUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public OrmUniqueConstraint getUniqueConstraint(int index) {
- return this.uniqueConstraints.get(index);
- }
-
- public OrmUniqueConstraint addUniqueConstraint() {
- return this.addUniqueConstraint(this.uniqueConstraints.size());
- }
-
- public OrmUniqueConstraint addUniqueConstraint(int index) {
- X xmlTable = this.getXmlTableForUpdate();
- XmlUniqueConstraint xmlConstraint = this.buildXmlUniqueConstraint();
- OrmUniqueConstraint constraint = this.addUniqueConstraint_(index, xmlConstraint);
- xmlTable.getUniqueConstraints().add(index, xmlConstraint);
- return constraint;
- }
-
- protected XmlUniqueConstraint buildXmlUniqueConstraint() {
- return OrmFactory.eINSTANCE.createXmlUniqueConstraint();
- }
-
- public void removeUniqueConstraint(UniqueConstraint constraint) {
- this.removeUniqueConstraint(this.uniqueConstraints.indexOf(constraint));
- }
-
- public void removeUniqueConstraint(int index) {
- this.removeUniqueConstraint_(index);
- this.getXmlTable().getUniqueConstraints().remove(index);
- this.removeXmlTableIfUnset();
- }
-
- protected void removeUniqueConstraint_(int index) {
- this.removeItemFromList(index, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- public void moveUniqueConstraint(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- this.getXmlTable().getUniqueConstraints().move(targetIndex, sourceIndex);
- }
-
- protected void initializeUniqueContraints() {
- for (XmlUniqueConstraint xmlConstraint : this.getXmlUniqueConstraints()) {
- this.uniqueConstraints.add(this.buildUniqueConstraint(xmlConstraint));
- }
- }
-
- protected OrmUniqueConstraint buildUniqueConstraint(XmlUniqueConstraint xmlConstraint) {
- return this.getContextNodeFactory().buildOrmUniqueConstraint(this, this, xmlConstraint);
- }
-
- protected void syncUniqueConstraints() {
- ContextContainerTools.synchronizeWithResourceModel(this.uniqueConstraintContainerAdapter);
- }
-
- protected Iterable<XmlUniqueConstraint> getXmlUniqueConstraints() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ?
- EmptyIterable.<XmlUniqueConstraint>instance() :
- // clone to reduce chance of concurrency problems
- new LiveCloneIterable<XmlUniqueConstraint>(xmlTable.getUniqueConstraints());
- }
-
- protected void moveUniqueConstraint_(int index, OrmUniqueConstraint constraint) {
- this.moveItemInList(index, constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected OrmUniqueConstraint addUniqueConstraint_(int index, XmlUniqueConstraint xmlConstraint) {
- OrmUniqueConstraint constraint = this.buildUniqueConstraint(xmlConstraint);
- this.addItemToList(index, constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- return constraint;
- }
-
- protected void removeUniqueConstraint_(OrmUniqueConstraint constraint) {
- this.removeUniqueConstraint_(this.uniqueConstraints.indexOf(constraint));
- }
-
- /**
- * unique constraint container adapter
- */
- protected class UniqueConstraintContainerAdapter
- implements ContextContainerTools.Adapter<OrmUniqueConstraint, XmlUniqueConstraint>
- {
- public Iterable<OrmUniqueConstraint> getContextElements() {
- return AbstractOrmTable.this.getUniqueConstraints();
- }
- public Iterable<XmlUniqueConstraint> getResourceElements() {
- return AbstractOrmTable.this.getXmlUniqueConstraints();
- }
- public XmlUniqueConstraint getResourceElement(OrmUniqueConstraint contextElement) {
- return contextElement.getXmlUniqueConstraint();
- }
- public void moveContextElement(int index, OrmUniqueConstraint element) {
- AbstractOrmTable.this.moveUniqueConstraint_(index, element);
- }
- public void addContextElement(int index, XmlUniqueConstraint resourceElement) {
- AbstractOrmTable.this.addUniqueConstraint_(index, resourceElement);
- }
- public void removeContextElement(OrmUniqueConstraint element) {
- AbstractOrmTable.this.removeUniqueConstraint_(element);
- }
- }
-
-
- // ********** database stuff **********
-
- public org.eclipse.jpt.jpa.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.resolveDbCatalog(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.resolveDbCatalog(catalog);
- }
-
- public boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- public boolean schemaIsResolved() {
- 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 catalogIsResolved() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.resolveDbCatalog(catalog) != null);
- }
-
-
- // ********** UniqueConstraint.Owner implementation **********
-
- public Iterator<String> candidateUniqueConstraintColumnNames() {
- org.eclipse.jpt.jpa.db.Table dbTable = this.getDbTable();
- return (dbTable != null) ? dbTable.getSortedColumnIdentifiers().iterator() : EmptyIterator.<String>instance();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.buildTableValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildTableValidator() {
- return this.owner.buildTableValidator(this, this.buildTextRangeResolver());
- }
-
- protected TableTextRangeResolver buildTextRangeResolver() {
- return new OrmTableTextRangeResolver(this);
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.getXmlTableValidationTextRange();
- return (textRange != null) ? textRange : this.getParent().getValidationTextRange();
- }
-
- protected TextRange getXmlTableValidationTextRange() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getValidationTextRange();
- }
-
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.getXmlTableNameTextRange());
- }
-
- protected TextRange getXmlTableNameTextRange() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getNameTextRange();
- }
-
- public TextRange getSchemaTextRange() {
- return this.getValidationTextRange(this.getXmlTableSchemaTextRange());
- }
-
- protected TextRange getXmlTableSchemaTextRange() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getSchemaTextRange();
- }
-
- public TextRange getCatalogTextRange() {
- return this.getValidationTextRange(this.getXmlTableCatalogTextRange());
- }
-
- protected TextRange getXmlTableCatalogTextRange() {
- X xmlTable = this.getXmlTable();
- return (xmlTable == null) ? null : xmlTable.getCatalogTextRange();
- }
-
-
- // ********** misc **********
-
- /**
- * covariant override
- */
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- protected void initializeFrom(ReadOnlyTable oldTable) {
- this.setSpecifiedName(oldTable.getSpecifiedName());
- this.setSpecifiedCatalog(oldTable.getSpecifiedCatalog());
- this.setSpecifiedSchema(oldTable.getSpecifiedSchema());
- for (ReadOnlyUniqueConstraint constraint : CollectionTools.iterable(oldTable.uniqueConstraints())) {
- this.addUniqueConstraint().initializeFrom(constraint);
- }
- }
-
- protected void initializeFromVirtual(ReadOnlyTable virtualTable) {
- this.setSpecifiedName(virtualTable.getName());
- // ignore other settings?
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.buildQualifiedName());
- }
-
- protected String buildQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
deleted file mode 100644
index 124df96c1c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java
+++ /dev/null
@@ -1,499 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Column;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.AttributeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTools;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericTypeMappingValidator;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <code>orm.xml</code> type mapping
- */
-public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping>
- extends AbstractOrmXmlContextNode
- implements OrmTypeMapping
-{
- // never null
- protected final X xmlTypeMapping;
-
- protected String class_;
-
- protected Boolean specifiedMetadataComplete;
- protected boolean overrideMetadataComplete;
-
-
- protected AbstractOrmTypeMapping(OrmPersistentType parent, X xmlTypeMapping) {
- super(parent);
- this.xmlTypeMapping = xmlTypeMapping;
- this.class_ = xmlTypeMapping.getClassName();
- this.specifiedMetadataComplete = xmlTypeMapping.getMetadataComplete();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setClass_(this.xmlTypeMapping.getClassName());
- this.setSpecifiedMetadataComplete_(this.xmlTypeMapping.getMetadataComplete());
- }
-
- @Override
- public void update() {
- super.update();
- this.setOverrideMetadataComplete(this.buildOverrideMetadataComplete());
- }
-
-
- // ********** class **********
-
- public String getClass_() {
- return this.class_;
- }
-
- public void setClass(String class_) {
- this.setClass_(class_);
- this.xmlTypeMapping.setClassName(class_);
- }
-
- protected void setClass_(String class_) {
- String old = this.class_;
- this.class_ = class_;
- if (this.firePropertyChanged(CLASS_PROPERTY, old, class_)) {
- this.getPersistentType().mappingClassChanged(old, class_);
- }
- }
-
-
- // ********** metadata complete **********
-
- /**
- * If <code>entity-mappings/persistence-unit-metadata/xml-mapping-metadata-complete</code>
- * is specified, it overrides anything set here.
- */
- public boolean isMetadataComplete() {
- if (this.overrideMetadataComplete) {
- return true;
- }
- return (this.specifiedMetadataComplete != null) ? this.specifiedMetadataComplete.booleanValue() : false;
- }
-
- public Boolean getSpecifiedMetadataComplete() {
- return this.specifiedMetadataComplete;
- }
-
- public void setSpecifiedMetadataComplete(Boolean metadataComplete) {
- this.setSpecifiedMetadataComplete_(metadataComplete);
- this.xmlTypeMapping.setMetadataComplete(metadataComplete);
- }
-
- protected void setSpecifiedMetadataComplete_(Boolean metadataComplete) {
- Boolean old = this.specifiedMetadataComplete;
- this.specifiedMetadataComplete = metadataComplete;
- this.firePropertyChanged(SPECIFIED_METADATA_COMPLETE_PROPERTY, old, metadataComplete);
- }
-
- public boolean isOverrideMetadataComplete() {
- return this.overrideMetadataComplete;
- }
-
- protected void setOverrideMetadataComplete(boolean metadataComplete) {
- boolean old = this.overrideMetadataComplete;
- this.overrideMetadataComplete = metadataComplete;
- this.firePropertyChanged(OVERRIDE_METADATA_COMPLETE_PROPERTY, old, metadataComplete);
- }
-
- protected boolean buildOverrideMetadataComplete() {
- return this.getPersistenceUnit().isXmlMappingMetadataComplete();
- }
-
-
- // ********** Java type mapping **********
-
- public JavaTypeMapping getJavaTypeMapping() {
- JavaPersistentType javaType = this.getJavaPersistentType();
- if (javaType == null) {
- return null;
- }
- return (javaType.getMappingKey() == this.getKey()) ? javaType.getMapping() : null;
- }
-
- public JavaTypeMapping getJavaTypeMappingForDefaults() {
- return this.isMetadataComplete() ? null : this.getJavaTypeMapping();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmPersistentType getParent() {
- return (OrmPersistentType) super.getParent();
- }
-
- public OrmPersistentType getPersistentType() {
- return this.getParent();
- }
-
- public String getName() {
- return this.getPersistentType().getName();
- }
-
- protected JavaPersistentType getJavaPersistentType() {
- return this.getPersistentType().getJavaPersistentType();
- }
-
- protected JavaResourcePersistentType getJavaResourcePersistentType() {
- JavaPersistentType javaType = this.getJavaPersistentType();
- return (javaType == null) ? null : javaType.getResourcePersistentType();
- }
-
- public boolean isMapped() {
- return true;
- }
-
- /**
- * A type's mapping is being changed. Copy the common settings from the old
- * mapping to the new (this).
- */
- public void initializeFrom(OrmTypeMapping oldMapping) {
- this.setClass(oldMapping.getClass_());
- this.setSpecifiedMetadataComplete(oldMapping.getSpecifiedMetadataComplete());
- this.setOverrideMetadataComplete(oldMapping.isOverrideMetadataComplete());
- }
-
-
- // ********** tables **********
-
- public String getPrimaryTableName() {
- return null;
- }
-
- public Table getPrimaryDbTable() {
- return null;
- }
-
- public Table resolveDbTable(String tableName) {
- return null;
- }
-
- public Schema getDbSchema() {
- return null;
- }
-
-
- // ********** attribute mappings **********
-
- public boolean attributeMappingKeyAllowed(String attributeMappingKey) {
- return true;
- }
-
- public Iterator<AttributeMapping> attributeMappings() {
- return new TransformationIterator<OrmReadOnlyPersistentAttribute, AttributeMapping>(this.getPersistentType().attributes()) {
- @Override
- protected AttributeMapping transform(OrmReadOnlyPersistentAttribute attribute) {
- return attribute.getMapping();
- }
- };
- }
-
- public Iterator<AttributeMapping> allAttributeMappings() {
- return new CompositeIterator<AttributeMapping>(this.allAttributeMappingsLists());
- }
-
- protected Iterator<Iterator<AttributeMapping>> allAttributeMappingsLists() {
- return new TransformationIterator<TypeMapping, Iterator<AttributeMapping>>(this.inheritanceHierarchy(), TypeMappingTools.ATTRIBUTE_MAPPINGS_TRANSFORMER);
- }
-
- public Iterator<String> overridableAttributeNames() {
- return new CompositeIterator<String>(this.overridableAttributeNamesLists());
- }
-
- protected Iterator<Iterator<String>> overridableAttributeNamesLists() {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings(), AttributeMappingTools.ALL_OVERRIDABLE_ATTRIBUTE_MAPPING_NAMES_TRANSFORMER);
- }
-
- public Iterator<String> allOverridableAttributeNames() {
- return new CompositeIterator<String>(this.allOverridableAttributeNamesLists());
- }
-
- protected Iterator<Iterator<String>> allOverridableAttributeNamesLists() {
- return new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy(), TypeMappingTools.OVERRIDABLE_ATTRIBUTE_NAMES_TRANSFORMER);
- }
-
- public Iterable<AttributeMapping> getAttributeMappings(final String mappingKey) {
- return new FilteringIterable<AttributeMapping>(CollectionTools.collection(this.attributeMappings())) {
- @Override
- protected boolean accept(AttributeMapping o) {
- return Tools.valuesAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Iterable<AttributeMapping> getAllAttributeMappings(final String mappingKey) {
- return new FilteringIterable<AttributeMapping>(CollectionTools.collection(this.allAttributeMappings())) {
- @Override
- protected boolean accept(AttributeMapping o) {
- return Tools.valuesAreEqual(o.getKey(), mappingKey);
- }
- };
- }
-
- public Column resolveOverriddenColumn(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.attributeMappings())) {
- Column column = attributeMapping.resolveOverriddenColumn(attributeName);
- if (column != null) {
- return column;
- }
- }
- if ( ! this.isMetadataComplete()) {
- JavaPersistentType javaPersistentType = this.getJavaPersistentType();
- if (javaPersistentType != null) {
- return javaPersistentType.getMapping().resolveOverriddenColumn(attributeName);
- }
- }
- return null;
- }
-
- public Iterator<String> overridableAssociationNames() {
- return new CompositeIterator<String>(this.overridableAssociationNamesLists());
- }
-
- protected Iterator<Iterator<String>> overridableAssociationNamesLists() {
- return new TransformationIterator<AttributeMapping, Iterator<String>>(this.attributeMappings(), AttributeMappingTools.ALL_OVERRIDABLE_ASSOCIATION_MAPPING_NAMES_TRANSFORMER);
- }
-
- public Iterator<String> allOverridableAssociationNames() {
- return new CompositeIterator<String>(this.allOverridableAssociationNamesLists());
- }
-
- protected Iterator<Iterator<String>> allOverridableAssociationNamesLists() {
- return new TransformationIterator<TypeMapping, Iterator<String>>(this.inheritanceHierarchy(), TypeMappingTools.OVERRIDABLE_ASSOCIATION_NAMES_TRANSFORMER);
- }
-
- public Relationship resolveOverriddenRelationship(String attributeName) {
- for (AttributeMapping attributeMapping : CollectionTools.iterable(this.attributeMappings())) {
- Relationship relationship = attributeMapping.resolveOverriddenRelationship(attributeName);
- if (relationship != null) {
- return relationship;
- }
- }
- if ( ! this.isMetadataComplete()) {
- JavaPersistentType javaPersistentType = this.getJavaPersistentType();
- if (javaPersistentType != null) {
- return javaPersistentType.getMapping().resolveOverriddenRelationship(attributeName);
- }
- }
- return null;
- }
-
-
- // ********** inheritance hierarchy **********
-
- public TypeMapping getSuperTypeMapping() {
- PersistentType superPersistentType = this.getPersistentType().getSuperPersistentType();
- return (superPersistentType == null) ? null : superPersistentType.getMapping();
- }
-
- public Iterator<TypeMapping> inheritanceHierarchy() {
- return this.convertToMappings(this.getPersistentType().inheritanceHierarchy());
- }
-
- protected Iterable<TypeMapping> getInheritanceHierarchy() {
- return CollectionTools.iterable(this.inheritanceHierarchy());
- }
-
- /**
- * Return the type mapping's "persistence" ancestors,
- * <em>excluding</em> the type mapping itself.
- * The returned iterator will return elements infinitely if the hierarchy
- * has a loop.
- */
- protected Iterator<TypeMapping> ancestors() {
- return this.convertToMappings(this.getPersistentType().ancestors());
- }
-
- protected Iterable<TypeMapping> getAncestors() {
- return CollectionTools.iterable(this.ancestors());
- }
-
- protected Iterator<TypeMapping> convertToMappings(Iterator<PersistentType> types) {
- return new TransformationIterator<PersistentType, TypeMapping>(types) {
- @Override
- protected TypeMapping transform(PersistentType type) {
- return type.getMapping();
- }
- };
- }
-
-
- // ********** misc **********
-
- public X getXmlTypeMapping() {
- return this.xmlTypeMapping;
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getPersistentType().getName());
- }
-
-
- // ********** text ranges **********
-
- public JpaStructureNode getStructureNode(int offset) {
- return this.xmlTypeMapping.containsOffset(offset) ? this.getPersistentType() : null;
- }
-
- public TextRange getSelectionTextRange() {
- return this.xmlTypeMapping.getSelectionTextRange();
- }
-
- public TextRange getClassTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getClassTextRange());
- }
-
- public TextRange getAttributesTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getAttributesTextRange());
- }
-
- public TextRange getNameTextRange() {
- return this.getValidationTextRange(this.xmlTypeMapping.getNameTextRange());
- }
-
- public boolean containsOffset(int textOffset) {
- return this.xmlTypeMapping.containsOffset(textOffset);
- }
-
-
- // ********** refactoring **********
-
- public DeleteEdit createDeleteEdit() {
- return this.xmlTypeMapping.createDeleteEdit();
- }
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return this.getPersistentType().isFor(originalType.getFullyQualifiedName('.')) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenameTypeEdit(originalType, newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createRenameTypeEdit(IType originalType, String newName) {
- return this.xmlTypeMapping.createRenameTypeEdit(originalType, newName);
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.getPersistentType().isFor(originalType.getFullyQualifiedName('.')) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newPackage.getElementName())) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.getPersistentType().isIn(originalPackage) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createRenamePackageEdit(String newName) {
- return this.xmlTypeMapping.createRenamePackageEdit(newName);
- }
-
-
- // ********** 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()
- )
- );
- } else {
- HashBag<String> ormMappedClassNames = new HashBag<String>();
- CollectionTools.addAll(ormMappedClassNames, this.getPersistenceUnit().getOrmMappedClassNames());
- if (ormMappedClassNames.count(this.class_) > 1) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.PERSISTENT_TYPE_DUPLICATE_CLASS,
- new String[] {this.class_},
- this,
- this.getClassTextRange()
- )
- );
- }
- return;
- }
- this.buildTypeMappingValidator().validate(messages, reporter);
- }
-
- protected JptValidator buildTypeMappingValidator() {
- return new GenericTypeMappingValidator(this, this.getJavaResourcePersistentType(), this.buildTextRangeResolver());
- }
-
- protected TypeMappingTextRangeResolver buildTextRangeResolver() {
- return new OrmTypeMappingTextRangeResolver(this);
- }
-
- public boolean validatesAgainstDatabase() {
- return this.getPersistenceUnit().validatesAgainstDatabase();
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.xmlTypeMapping.getValidationTextRange();
- return (textRange != null) ? textRange : this.getPersistentType().getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java
deleted file mode 100644
index 3ec67591c0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVersionMapping.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Converter;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumnMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTemporalConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.NamedColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmConverter;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.Attributes;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.jpa.db.Table;
-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> version mapping
- */
-public abstract class AbstractOrmVersionMapping<X extends XmlVersion>
- extends AbstractOrmAttributeMapping<X>
- implements OrmVersionMapping
-{
- protected final OrmColumn column;
-
- protected OrmConverter converter; // never null
-
-
- // the spec does not list Temporal explicitly,
- // but it is included in the orm.xml schema...
- protected static final OrmConverter.Adapter[] CONVERTER_ADAPTER_ARRAY = new OrmConverter.Adapter[] {
- OrmTemporalConverter.Adapter.instance(),
- };
- protected static final Iterable<OrmConverter.Adapter> CONVERTER_ADAPTERS = new ArrayIterable<OrmConverter.Adapter>(CONVERTER_ADAPTER_ARRAY);
-
-
- protected AbstractOrmVersionMapping(OrmPersistentAttribute parent, X xmlMapping) {
- super(parent, xmlMapping);
- this.column = this.buildColumn();
- this.converter = this.buildConverter();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.column.synchronizeWithResourceModel();
- this.syncConverter();
- }
-
- @Override
- public void update() {
- super.update();
- this.column.update();
- this.converter.update();
- }
-
-
- // ********** column **********
-
- public OrmColumn getColumn() {
- return this.column;
- }
-
- protected OrmColumn buildColumn() {
- return this.getContextNodeFactory().buildOrmColumn(this, this);
- }
-
-
- // ********** converter **********
-
- public OrmConverter getConverter() {
- return this.converter;
- }
-
- public void setConverter(Class<? extends Converter> converterType) {
- if (this.converter.getType() != converterType) {
- // note: we may also clear the XML value we want;
- // but if we leave it, the resulting sync will screw things up...
- this.clearXmlConverterValues();
- OrmConverter.Adapter converterAdapter = this.getConverterAdapter(converterType);
- this.setConverter_(this.buildConverter(converterAdapter));
- this.converter.initialize();
- }
- }
-
- protected OrmConverter buildConverter(OrmConverter.Adapter converterAdapter) {
- return (converterAdapter != null) ?
- converterAdapter.buildNewConverter(this, this.getContextNodeFactory()) :
- this.buildNullConverter();
- }
-
- protected void setConverter_(OrmConverter converter) {
- Converter old = this.converter;
- this.converter = converter;
- this.firePropertyChanged(CONVERTER_PROPERTY, old, converter);
- }
-
- protected void clearXmlConverterValues() {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- adapter.clearXmlValue(this.xmlAttributeMapping);
- }
- }
-
- protected OrmConverter buildConverter() {
- OrmXmlContextNodeFactory factory = this.getContextNodeFactory();
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- OrmConverter ormConverter = adapter.buildConverter(this, factory);
- if (ormConverter != null) {
- return ormConverter;
- }
- }
- return this.buildNullConverter();
- }
-
- protected void syncConverter() {
- OrmConverter.Adapter adapter = this.getXmlConverterAdapter();
- if (adapter == null) {
- if (this.converter.getType() != null) {
- this.setConverter_(this.buildNullConverter());
- }
- } else {
- if (this.converter.getType() == adapter.getConverterType()) {
- this.converter.synchronizeWithResourceModel();
- } else {
- this.setConverter_(adapter.buildNewConverter(this, this.getContextNodeFactory()));
- }
- }
- }
-
- /**
- * Return the first adapter whose converter value is set in the XML mapping.
- * Return <code>null</code> if there are no converter values in the XML.
- */
- protected OrmConverter.Adapter getXmlConverterAdapter() {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.isActive(this.xmlAttributeMapping)) {
- return adapter;
- }
- }
- return null;
- }
-
- protected OrmConverter buildNullConverter() {
- return new NullOrmConverter(this);
- }
-
-
- // ********** converter adapters **********
-
- /**
- * Return the converter adapter for the specified converter type.
- */
- protected OrmConverter.Adapter getConverterAdapter(Class<? extends Converter> converterType) {
- for (OrmConverter.Adapter adapter : this.getConverterAdapters()) {
- if (adapter.getConverterType() == converterType) {
- return adapter;
- }
- }
- return null;
- }
-
- protected Iterable<OrmConverter.Adapter> getConverterAdapters() {
- return CONVERTER_ADAPTERS;
- }
-
-
- // ********** misc **********
-
- public String getKey() {
- return MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY;
- }
-
- public int getXmlSequence() {
- return 30;
- }
-
- public void initializeOn(OrmAttributeMapping newMapping) {
- newMapping.initializeFromOrmVersionMapping(this);
- }
-
- @Override
- protected void initializeFromOrmColumnMapping(OrmColumnMapping oldMapping) {
- super.initializeFromOrmColumnMapping(oldMapping);
- this.column.initializeFrom(oldMapping.getColumn());
- }
-
- public void addXmlAttributeMappingTo(Attributes xmlAttributes) {
- xmlAttributes.getVersions().add(this.xmlAttributeMapping);
- }
-
- public void removeXmlAttributeMappingFrom(Attributes xmlAttributes) {
- xmlAttributes.getVersions().remove(this.xmlAttributeMapping);
- }
-
-
- // ********** OrmColumn.Owner implementation **********
-
- public String getDefaultColumnName() {
- return this.name;
- }
-
- public String getDefaultTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public XmlColumn getXmlColumn() {
- return this.xmlAttributeMapping.getColumn();
- }
-
- public XmlColumn buildXmlColumn() {
- XmlColumn xmlColumn = OrmFactory.eINSTANCE.createXmlColumn();
- this.xmlAttributeMapping.setColumn(xmlColumn);
- return xmlColumn;
- }
-
- public void removeXmlColumn() {
- this.xmlAttributeMapping.setColumn(null);
- }
-
-
- // ********** refactoring **********
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createRenameTypeEdits(originalType, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createMoveTypeEdits(originalType, newPackage) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- 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) {
- return (this.converter != null) ?
- this.converter.createRenamePackageEdits(originalPackage, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.column.validate(messages, reporter);
- this.converter.validate(messages, reporter);
- this.validateAttributeType(messages);
- }
-
- protected void validateAttributeType(List<IMessage> messages) {
- if (!ArrayTools.contains(VERSION_MAPPING_SUPPORTED_TYPES, this.getPersistentAttribute().getTypeName())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.PERSISTENT_ATTRIBUTE_INVALID_VERSION_MAPPING_TYPE,
- new String[] {this.getName()},
- this,
- this.getNameTextRange()
- )
- );
- }
- }
-
- public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) {
- return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualBaseColumn.java
deleted file mode 100644
index 96cd8a6fe7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualBaseColumn.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
-import org.eclipse.jpt.jpa.core.context.VirtualBaseColumn;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-
-public abstract class AbstractOrmVirtualBaseColumn<O extends ReadOnlyNamedColumn.Owner, C extends BaseColumn>
- extends AbstractOrmVirtualNamedColumn<O, C>
- implements VirtualBaseColumn
-{
- protected String specifiedTable;
- protected String defaultTable;
-
- protected Boolean specifiedUnique;
- protected boolean defaultUnique;
-
- protected Boolean specifiedNullable;
- protected boolean defaultNullable;
-
- protected Boolean specifiedInsertable;
- protected boolean defaultInsertable;
-
- protected Boolean specifiedUpdatable;
- protected boolean defaultUpdatable;
-
-
- protected AbstractOrmVirtualBaseColumn(XmlContextNode parent, O owner) {
- super(parent, owner);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
-
- this.setSpecifiedTable(this.buildSpecifiedTable());
- this.setDefaultTable(this.buildDefaultTable());
-
- this.setSpecifiedUnique(this.buildSpecifiedUnique());
- this.setDefaultUnique(this.buildDefaultUnique());
-
- this.setSpecifiedNullable(this.buildSpecifiedNullable());
- this.setDefaultNullable(this.buildDefaultNullable());
-
- this.setSpecifiedInsertable(this.buildSpecifiedInsertable());
- this.setDefaultInsertable(this.buildDefaultInsertable());
-
- this.setSpecifiedUpdatable(this.buildSpecifiedUpdatable());
- this.setDefaultUpdatable(this.buildDefaultUpdatable());
- }
-
-
- // ********** table **********
-
- public String getTable() {
- return (this.specifiedTable != null) ? this.specifiedTable : this.defaultTable;
- }
-
- public String getSpecifiedTable() {
- return this.specifiedTable;
- }
-
- protected void setSpecifiedTable(String table) {
- String old = this.specifiedTable;
- this.specifiedTable = table;
- this.firePropertyChanged(SPECIFIED_TABLE_PROPERTY, old, table);
- }
-
- protected String buildSpecifiedTable() {
- return this.getOverriddenColumn().getSpecifiedTable();
- }
-
- public String getDefaultTable() {
- return this.defaultTable;
- }
-
- protected void setDefaultTable(String table) {
- String old = this.defaultTable;
- this.defaultTable = table;
- this.firePropertyChanged(DEFAULT_TABLE_PROPERTY, old, table);
- }
-
- protected String buildDefaultTable() {
- return this.owner.getDefaultTableName();
- }
-
-
- // ********** unique **********
-
- public boolean isUnique() {
- return (this.specifiedUnique != null) ? this.specifiedUnique.booleanValue() : this.isDefaultUnique();
- }
-
- public Boolean getSpecifiedUnique() {
- return this.specifiedUnique;
- }
-
- protected void setSpecifiedUnique(Boolean unique) {
- Boolean old = this.specifiedUnique;
- this.specifiedUnique = unique;
- this.firePropertyChanged(SPECIFIED_UNIQUE_PROPERTY, old, unique);
- }
-
- protected Boolean buildSpecifiedUnique() {
- return this.getOverriddenColumn().getSpecifiedUnique();
- }
-
- public boolean isDefaultUnique() {
- return this.defaultUnique;
- }
-
- protected void setDefaultUnique(boolean unique) {
- boolean old = this.defaultUnique;
- this.defaultUnique = unique;
- this.firePropertyChanged(DEFAULT_UNIQUE_PROPERTY, old, unique);
- }
-
- protected boolean buildDefaultUnique() {
- return DEFAULT_UNIQUE;
- }
-
-
- // ********** nullable **********
-
- public boolean isNullable() {
- return (this.specifiedNullable != null) ? this.specifiedNullable.booleanValue() : this.isDefaultNullable();
- }
-
- public Boolean getSpecifiedNullable() {
- return this.specifiedNullable;
- }
-
- protected void setSpecifiedNullable(Boolean nullable) {
- Boolean old = this.specifiedNullable;
- this.specifiedNullable = nullable;
- this.firePropertyChanged(SPECIFIED_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected Boolean buildSpecifiedNullable() {
- return this.getOverriddenColumn().getSpecifiedNullable();
- }
-
- public boolean isDefaultNullable() {
- return this.defaultNullable;
- }
-
- protected void setDefaultNullable(boolean nullable) {
- boolean old = this.defaultNullable;
- this.defaultNullable = nullable;
- this.firePropertyChanged(DEFAULT_NULLABLE_PROPERTY, old, nullable);
- }
-
- protected boolean buildDefaultNullable() {
- return DEFAULT_NULLABLE;
- }
-
-
- // ********** insertable **********
-
- public boolean isInsertable() {
- return (this.specifiedInsertable != null) ? this.specifiedInsertable.booleanValue() : this.isDefaultInsertable();
- }
-
- public Boolean getSpecifiedInsertable() {
- return this.specifiedInsertable;
- }
-
- protected void setSpecifiedInsertable(Boolean insertable) {
- Boolean old = this.specifiedInsertable;
- this.specifiedInsertable = insertable;
- this.firePropertyChanged(SPECIFIED_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected Boolean buildSpecifiedInsertable() {
- return this.getOverriddenColumn().getSpecifiedInsertable();
- }
-
- public boolean isDefaultInsertable() {
- return this.defaultInsertable;
- }
-
- protected void setDefaultInsertable(boolean insertable) {
- boolean old = this.defaultInsertable;
- this.defaultInsertable = insertable;
- this.firePropertyChanged(DEFAULT_INSERTABLE_PROPERTY, old, insertable);
- }
-
- protected boolean buildDefaultInsertable() {
- return DEFAULT_INSERTABLE;
- }
-
-
- // ********** updatable **********
-
- public boolean isUpdatable() {
- return (this.specifiedUpdatable != null) ? this.specifiedUpdatable.booleanValue() : this.isDefaultUpdatable();
- }
-
- public Boolean getSpecifiedUpdatable() {
- return this.specifiedUpdatable;
- }
-
- protected void setSpecifiedUpdatable(Boolean updatable) {
- Boolean old = this.specifiedUpdatable;
- this.specifiedUpdatable = updatable;
- this.firePropertyChanged(SPECIFIED_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected Boolean buildSpecifiedUpdatable() {
- return this.getOverriddenColumn().getSpecifiedUpdatable();
- }
-
- public boolean isDefaultUpdatable() {
- return this.defaultUpdatable;
- }
-
- protected void setDefaultUpdatable(boolean updatable) {
- boolean old = this.defaultUpdatable;
- this.defaultUpdatable = updatable;
- this.firePropertyChanged(DEFAULT_UPDATABLE_PROPERTY, old, updatable);
- }
-
- protected boolean buildDefaultUpdatable() {
- return DEFAULT_UPDATABLE;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualNamedColumn.java
deleted file mode 100644
index a13e9d8835..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualNamedColumn.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn;
-import org.eclipse.jpt.jpa.core.context.VirtualNamedColumn;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-
-/**
- * <code>orm.xml</code> virtual<ul>
- * <li>column
- * <li>join column
- * </ul>
- * <strong>NB:</strong> all state is sync'ed/updated in {@link #update()}
- * because <em>all</em> of its derived from the context model (i.e. none of it
- * is derived from the resource model).
- */
-public abstract class AbstractOrmVirtualNamedColumn<O extends ReadOnlyNamedColumn.Owner, C extends NamedColumn>
- extends AbstractOrmXmlContextNode
- implements VirtualNamedColumn
-{
- protected final O owner;
-
- protected String specifiedName;
- protected String defaultName;
-
- protected String columnDefinition;
-
-
- protected AbstractOrmVirtualNamedColumn(XmlContextNode parent, O owner) {
- super(parent);
- this.owner = owner;
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
-
- this.setSpecifiedName(this.buildSpecifiedName());
- this.setDefaultName(this.buildDefaultName());
-
- this.setColumnDefinition(this.buildColumnDefinition());
- }
-
-
- // ********** column **********
-
- /**
- * This should never return <code>null</code>.
- */
- public abstract C getOverriddenColumn();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- protected void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- return this.getOverriddenColumn().getSpecifiedName();
- }
-
- 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);
- }
-
- protected String buildDefaultName() {
- return this.owner.getDefaultColumnName();
- }
-
-
- // ********** column definition **********
-
- public String getColumnDefinition() {
- return this.columnDefinition;
- }
-
- protected void setColumnDefinition(String columnDefinition) {
- String old = this.columnDefinition;
- this.columnDefinition = columnDefinition;
- this.firePropertyChanged(COLUMN_DEFINITION_PROPERTY, old, columnDefinition);
- }
-
- protected String buildColumnDefinition() {
- return this.getOverriddenColumn().getColumnDefinition();
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange() {
- return this.getParent().getValidationTextRange();
- }
-
-
- // ********** misc **********
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- String table = this.getTable();
- if (table != null) {
- sb.append(table);
- sb.append('.');
- }
- sb.append(this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualReferenceTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualReferenceTable.java
deleted file mode 100644
index 2e366584cc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualReferenceTable.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReferenceTable;
-import org.eclipse.jpt.jpa.core.context.VirtualReferenceTable;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-
-public abstract class AbstractOrmVirtualReferenceTable<T extends ReferenceTable>
- extends AbstractOrmVirtualTable<T>
- implements VirtualReferenceTable
-{
- protected final Vector<OrmVirtualJoinColumn> specifiedJoinColumns = new Vector<OrmVirtualJoinColumn>();
- protected final SpecifiedJoinColumnContainerAdapter specifiedJoinColumnContainerAdapter = new SpecifiedJoinColumnContainerAdapter();
- protected final ReadOnlyJoinColumn.Owner joinColumnOwner;
-
- protected OrmVirtualJoinColumn defaultJoinColumn;
-
-
- protected AbstractOrmVirtualReferenceTable(XmlContextNode parent) {
- super(parent);
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateSpecifiedJoinColumns();
- this.updateDefaultJoinColumn();
- }
-
-
- // ********** join columns **********
-
- public ListIterator<OrmVirtualJoinColumn> joinColumns() {
- return this.getJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getJoinColumns() {
- return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ? this.specifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize();
- }
-
-
- // ********** specified join columns **********
-
- public ListIterator<OrmVirtualJoinColumn> specifiedJoinColumns() {
- return this.getSpecifiedJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getSpecifiedJoinColumns() {
- return new LiveCloneListIterable<OrmVirtualJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return this.specifiedJoinColumns.size() != 0;
- }
-
- public OrmVirtualJoinColumn getSpecifiedJoinColumn(int index) {
- return this.specifiedJoinColumns.get(index);
- }
-
- protected void updateSpecifiedJoinColumns() {
- ContextContainerTools.update(this.specifiedJoinColumnContainerAdapter);
- }
-
- protected Iterable<JoinColumn> getOverriddenJoinColumns() {
- return CollectionTools.iterable(this.getOverriddenTable().specifiedJoinColumns());
- }
-
- protected void moveSpecifiedJoinColumn(int index, OrmVirtualJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected OrmVirtualJoinColumn addSpecifiedJoinColumn(int index, JoinColumn joinColumn) {
- OrmVirtualJoinColumn virtualJoinColumn = this.buildJoinColumn(joinColumn);
- this.addItemToList(index, virtualJoinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- return virtualJoinColumn;
- }
-
- protected void removeSpecifiedJoinColumn(OrmVirtualJoinColumn joinColumn) {
- this.removeItemFromList(joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- /**
- * specified join column container adapter
- */
- protected class SpecifiedJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualJoinColumn, JoinColumn>
- {
- public Iterable<OrmVirtualJoinColumn> getContextElements() {
- return AbstractOrmVirtualReferenceTable.this.getSpecifiedJoinColumns();
- }
- public Iterable<JoinColumn> getResourceElements() {
- return AbstractOrmVirtualReferenceTable.this.getOverriddenJoinColumns();
- }
- public JoinColumn getResourceElement(OrmVirtualJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, OrmVirtualJoinColumn element) {
- AbstractOrmVirtualReferenceTable.this.moveSpecifiedJoinColumn(index, element);
- }
- public void addContextElement(int index, JoinColumn element) {
- AbstractOrmVirtualReferenceTable.this.addSpecifiedJoinColumn(index, element);
- }
- public void removeContextElement(OrmVirtualJoinColumn element) {
- AbstractOrmVirtualReferenceTable.this.removeSpecifiedJoinColumn(element);
- }
- }
-
-
- // ********** default join column **********
-
- public OrmVirtualJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(OrmVirtualJoinColumn joinColumn) {
- OrmVirtualJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn);
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getDefaultJoinColumns() {
- return (this.defaultJoinColumn != null) ?
- new SingleElementListIterable<OrmVirtualJoinColumn>(this.defaultJoinColumn) :
- EmptyListIterable.<OrmVirtualJoinColumn>instance();
- }
-
- protected int getDefaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultJoinColumn() {
- if (this.buildsDefaultJoinColumn()) {
- if (this.defaultJoinColumn == null) {
- this.setDefaultJoinColumn(this.buildJoinColumn(this.getOverriddenTable().getDefaultJoinColumn()));
- } else {
- this.defaultJoinColumn.update();
- }
- } else {
- this.setDefaultJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultJoinColumn() {
- return ! this.hasSpecifiedJoinColumns();
- }
-
-
- // ********** misc **********
-
- protected OrmVirtualJoinColumn buildJoinColumn(JoinColumn joinColumn) {
- return this.buildJoinColumn(this.joinColumnOwner, joinColumn);
- }
-
- protected OrmVirtualJoinColumn buildJoinColumn(ReadOnlyJoinColumn.Owner owner, JoinColumn joinColumn) {
- return this.getContextNodeFactory().buildOrmVirtualJoinColumn(this, owner, joinColumn);
- }
-
- protected abstract ReadOnlyJoinColumn.Owner buildJoinColumnOwner();
-
- @Override
- protected String buildDefaultSchema() {
- return this.getContextDefaultSchema();
- }
-
- @Override
- protected String buildDefaultCatalog() {
- return this.getContextDefaultCatalog();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualTable.java
deleted file mode 100644
index a2da665475..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualTable.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.NameTools;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.VirtualTable;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualUniqueConstraint;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.db.Catalog;
-import org.eclipse.jpt.jpa.db.Schema;
-import org.eclipse.jpt.jpa.db.SchemaContainer;
-
-public abstract class AbstractOrmVirtualTable<T extends Table>
- extends AbstractOrmXmlContextNode
- implements VirtualTable
-{
- protected String specifiedName;
- protected String defaultName;
-
- protected String specifiedSchema;
- protected String defaultSchema;
-
- protected String specifiedCatalog;
- protected String defaultCatalog;
-
- protected final Vector<OrmVirtualUniqueConstraint> uniqueConstraints = new Vector<OrmVirtualUniqueConstraint>();
- protected final UniqueConstraintContainerAdapter uniqueConstraintContainerAdapter = new UniqueConstraintContainerAdapter();
-
-
- protected AbstractOrmVirtualTable(XmlContextNode parent) {
- super(parent);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
-
- this.setSpecifiedName(this.buildSpecifiedName());
- this.setDefaultName(this.buildDefaultName());
-
- this.setSpecifiedSchema(this.buildSpecifiedSchema());
- this.setDefaultSchema(this.buildDefaultSchema());
-
- this.setSpecifiedCatalog(this.buildSpecifiedCatalog());
- this.setDefaultCatalog(this.buildDefaultCatalog());
-
- this.updateUniqueConstraints();
- }
-
-
- // ********** table **********
-
- /**
- * This should never return <code>null</code>.
- */
- public abstract T getOverriddenTable();
-
-
- // ********** name **********
-
- public String getName() {
- return (this.specifiedName != null) ? this.specifiedName : this.defaultName;
- }
-
- public String getSpecifiedName() {
- return this.specifiedName;
- }
-
- protected void setSpecifiedName(String name) {
- String old = this.specifiedName;
- this.specifiedName = name;
- this.firePropertyChanged(SPECIFIED_NAME_PROPERTY, old, name);
- }
-
- protected String buildSpecifiedName() {
- return this.getOverriddenTable().getSpecifiedName();
- }
-
- 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);
- }
-
- protected abstract String buildDefaultName();
-
-
- // ********** schema **********
-
- public String getSchema() {
- return (this.specifiedSchema != null) ? this.specifiedSchema : this.defaultSchema;
- }
-
- public String getSpecifiedSchema() {
- return this.specifiedSchema;
- }
-
- protected void setSpecifiedSchema(String schema) {
- String old = this.specifiedSchema;
- this.specifiedSchema = schema;
- this.firePropertyChanged(SPECIFIED_SCHEMA_PROPERTY, old, schema);
- }
-
- protected String buildSpecifiedSchema() {
- return this.getOverriddenTable().getSchema();
- }
-
- public String getDefaultSchema() {
- return this.defaultSchema;
- }
-
- protected void setDefaultSchema(String schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- protected abstract String buildDefaultSchema();
-
-
- // ********** catalog **********
-
- public String getCatalog() {
- return (this.specifiedCatalog != null) ? this.specifiedCatalog : this.defaultCatalog;
- }
-
- public String getSpecifiedCatalog() {
- return this.specifiedCatalog;
- }
-
- protected void setSpecifiedCatalog(String catalog) {
- String old = this.specifiedCatalog;
- this.specifiedCatalog = catalog;
- this.firePropertyChanged(SPECIFIED_CATALOG_PROPERTY, old, catalog);
- }
-
- protected String buildSpecifiedCatalog() {
- return this.getOverriddenTable().getCatalog();
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- protected abstract String buildDefaultCatalog();
-
-
- // ********** unique constraints **********
-
- public ListIterator<OrmVirtualUniqueConstraint> uniqueConstraints() {
- return this.getUniqueConstraints().iterator();
- }
-
- protected ListIterable<OrmVirtualUniqueConstraint> getUniqueConstraints() {
- return new LiveCloneListIterable<OrmVirtualUniqueConstraint>(this.uniqueConstraints);
- }
-
- public int uniqueConstraintsSize() {
- return this.uniqueConstraints.size();
- }
-
- public OrmVirtualUniqueConstraint getUniqueConstraint(int index) {
- return this.uniqueConstraints.get(index);
- }
-
- protected void updateUniqueConstraints() {
- ContextContainerTools.update(this.uniqueConstraintContainerAdapter);
- }
-
- protected Iterable<UniqueConstraint> getOverriddenUniqueConstraints() {
- return CollectionTools.iterable(this.getOverriddenTable().uniqueConstraints());
- }
-
- protected void moveUniqueConstraint(int index, OrmVirtualUniqueConstraint constraint) {
- this.moveItemInList(index, constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- protected OrmVirtualUniqueConstraint addUniqueConstraint(int index, UniqueConstraint uniqueConstraint) {
- OrmVirtualUniqueConstraint virtualConstraint = this.buildUniqueConstraint(uniqueConstraint);
- this.addItemToList(index, virtualConstraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- return virtualConstraint;
- }
-
- protected OrmVirtualUniqueConstraint buildUniqueConstraint(UniqueConstraint uniqueConstraint) {
- return this.getContextNodeFactory().buildOrmVirtualUniqueConstraint(this, uniqueConstraint);
- }
-
- protected void removeUniqueConstraint(OrmVirtualUniqueConstraint constraint) {
- this.removeItemFromList(constraint, this.uniqueConstraints, UNIQUE_CONSTRAINTS_LIST);
- }
-
- /**
- * unique constraint container adapter
- */
- protected class UniqueConstraintContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualUniqueConstraint, UniqueConstraint>
- {
- public Iterable<OrmVirtualUniqueConstraint> getContextElements() {
- return AbstractOrmVirtualTable.this.getUniqueConstraints();
- }
- public Iterable<UniqueConstraint> getResourceElements() {
- return AbstractOrmVirtualTable.this.getOverriddenUniqueConstraints();
- }
- public UniqueConstraint getResourceElement(OrmVirtualUniqueConstraint contextElement) {
- return contextElement.getOverriddenUniqueConstraint();
- }
- public void moveContextElement(int index, OrmVirtualUniqueConstraint element) {
- AbstractOrmVirtualTable.this.moveUniqueConstraint(index, element);
- }
- public void addContextElement(int index, UniqueConstraint resourceElement) {
- AbstractOrmVirtualTable.this.addUniqueConstraint(index, resourceElement);
- }
- public void removeContextElement(OrmVirtualUniqueConstraint element) {
- AbstractOrmVirtualTable.this.removeUniqueConstraint(element);
- }
- }
-
-
- // ********** database stuff **********
-
- public org.eclipse.jpt.jpa.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.resolveDbCatalog(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.resolveDbCatalog(catalog);
- }
-
- protected boolean isResolved() {
- return this.getDbTable() != null;
- }
-
- protected 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.
- */
- protected boolean hasResolvedCatalog() {
- String catalog = this.getCatalog();
- return (catalog == null) || (this.resolveDbCatalog(catalog) != null);
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange() {
- return this.getParent().getValidationTextRange();
- }
-
-
- // ********** misc **********
-
- @Override
- public XmlContextNode getParent() {
- return (XmlContextNode) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.buildQualifiedName());
- }
-
- protected String buildQualifiedName() {
- return NameTools.buildQualifiedDatabaseObjectName(this.getCatalog(), this.getSchema(), this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java
deleted file mode 100644
index 7fb4faac81..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNode.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.AbstractXmlContextNode;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmXml;
-import org.eclipse.jpt.jpa.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.jpa.core.context.MappingFile}
- * implementation.
- */
-public abstract class AbstractOrmXmlContextNode
- extends AbstractXmlContextNode
-{
- protected AbstractOrmXmlContextNode(JpaContextNode parent) {
- super(parent);
- }
-
-
- // ********** convenience methods **********
-
- @Override
- public EntityMappings getMappingFileRoot() {
- return (EntityMappings) super.getMappingFileRoot();
- }
-
- // TODO bjv need to cascade up containment hierarchy... (need public API:
- // JpaContextNode.getMappingFileDefinition() ?)
- protected OrmXmlDefinition getMappingFileDefinition() {
- OrmXml ormXml = this.getMappingFileRoot().getParent();
- if (ormXml instanceof GenericOrmXml) {
- return ((GenericOrmXml) ormXml).getMappingFileDefinition();
- }
- return (OrmXmlDefinition) this.getJpaPlatform().getResourceDefinition(this.getResourceType());
- }
-
- protected EFactory getResourceNodeFactory() {
- return this.getMappingFileDefinition().getResourceNodeFactory();
- }
-
- // TODO bjv need to add API to orm.xml/entity mappings interface...
- protected boolean isOrmXml2_0Compatible() {
- String version = this.getMappingFileRoot().getVersion();
- return (version != null) && version.equals("2.0"); //$NON-NLS-1$
- }
-
- /**
- * Call {@link #isOrmXml2_0Compatible()} before calling this method.
- */
- protected OrmXml2_0ContextNodeFactory getContextNodeFactory2_0() {
- return (OrmXml2_0ContextNodeFactory) this.getContextNodeFactory();
- }
-
- protected OrmXmlContextNodeFactory getContextNodeFactory() {
- return this.getMappingFileDefinition().getContextNodeFactory();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java
deleted file mode 100644
index fd4ac81334..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlContextNodeFactory.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.UniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.XmlContextNode;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn.Owner;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmConverter;
-import org.eclipse.jpt.jpa.core.context.orm.OrmDiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddedMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratedValue;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGeneratorContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.orm.OrmNamedNativeQuery;
-import org.eclipse.jpt.jpa.core.context.orm.OrmNamedQuery;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOrderable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitDefaults;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQueryContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQueryHint;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmSequenceGenerator;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTableGenerator;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTransientMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmUniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVersionMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverrideRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualUniqueConstraint;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericEntityMappings;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmAssociationOverride;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmAttributeOverride;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmAttributeOverrideContainer;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmBasicMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmDiscriminatorColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEmbeddable;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEmbeddedIdMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEmbeddedMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEntity;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmEnumeratedConverter;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmGeneratedValue;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmGeneratorContainer;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmIdMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmJoinTable;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmLobConverter;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmManyToManyMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmManyToOneMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmMappedSuperclass;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmNamedNativeQuery;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmNamedQuery;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmNullAttributeMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmOneToManyMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmOneToOneMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmOrderable;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmOverrideRelationship;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmPersistenceUnitDefaults;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmPersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmPersistentType;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmQueryContainer;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmQueryHint;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmSecondaryTable;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmSequenceGenerator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmTable;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmTableGenerator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmTemporalConverter;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmTransientMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmUniqueConstraint;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVersionMapping;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualAssociationOverride;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualAttributeOverride;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualOverrideRelationship;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.GenericOrmVirtualUniqueConstraint;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.UnsupportedOrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeOverride;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddedId;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntityMappings;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlGeneratedValue;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlGeneratorContainer;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlId;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedNativeQuery;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlNamedQuery;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlNullAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlQueryContainer;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlQueryHint;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlSecondaryTable;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlSequenceGenerator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTableGenerator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlUniqueConstraint;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlVersion;
-
-public abstract class AbstractOrmXmlContextNodeFactory
- implements OrmXmlContextNodeFactory
-{
- public EntityMappings buildEntityMappings(OrmXml parent, XmlEntityMappings xmlEntityMappings) {
- return new GenericEntityMappings(parent, xmlEntityMappings);
- }
-
- public OrmPersistenceUnitMetadata buildOrmPersistenceUnitMetadata(EntityMappings parent) {
- return new GenericOrmPersistenceUnitMetadata(parent);
- }
-
- public OrmPersistenceUnitDefaults buildOrmPersistenceUnitDefaults(OrmPersistenceUnitMetadata parent) {
- return new GenericOrmPersistenceUnitDefaults(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, XmlAttributeMapping xmlMapping) {
- return new GenericOrmPersistentAttribute(parent, xmlMapping);
- }
-
- public OrmReadOnlyPersistentAttribute buildVirtualOrmPersistentAttribute(OrmPersistentType parent, JavaResourcePersistentAttribute javaResourcePersistentAttribute) {
- return new VirtualOrmPersistentAttribute(parent, javaResourcePersistentAttribute);
- }
-
- 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 OrmVirtualSecondaryTable buildOrmVirtualSecondaryTable(OrmEntity parent, JavaSecondaryTable javaSecondaryTable) {
- return new GenericOrmVirtualSecondaryTable(parent, javaSecondaryTable);
- }
-
- public OrmPrimaryKeyJoinColumn buildOrmPrimaryKeyJoinColumn(XmlContextNode parent, OrmBaseJoinColumn.Owner owner, XmlPrimaryKeyJoinColumn resourcePrimaryKeyJoinColumn) {
- return new GenericOrmPrimaryKeyJoinColumn(parent, owner, resourcePrimaryKeyJoinColumn);
- }
-
- public OrmVirtualPrimaryKeyJoinColumn buildOrmVirtualPrimaryKeyJoinColumn(XmlContextNode parent, Owner owner, JavaPrimaryKeyJoinColumn javaPrimaryKeyJoinColumn) {
- return new GenericOrmVirtualPrimaryKeyJoinColumn(parent, owner, javaPrimaryKeyJoinColumn);
- }
-
- public OrmJoinTable buildOrmJoinTable(OrmJoinTableRelationshipStrategy parent, Table.Owner owner) {
- return new GenericOrmJoinTable(parent, owner);
- }
-
- public OrmVirtualJoinTable buildOrmVirtualJoinTable(OrmVirtualJoinTableRelationshipStrategy parent, JoinTable overriddenTable) {
- return new GenericOrmVirtualJoinTable(parent, overriddenTable);
- }
-
- public OrmJoinColumn buildOrmJoinColumn(XmlContextNode parent, OrmJoinColumn.Owner owner, XmlJoinColumn xmlJoinColumn) {
- return new GenericOrmJoinColumn(parent, owner, xmlJoinColumn);
- }
-
- public OrmVirtualJoinColumn buildOrmVirtualJoinColumn(XmlContextNode parent, ReadOnlyJoinColumn.Owner owner, JoinColumn joinColumn) {
- return new GenericOrmVirtualJoinColumn(parent, owner, joinColumn);
- }
-
- 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 OrmAttributeOverride buildOrmAttributeOverride(OrmAttributeOverrideContainer parent, XmlAttributeOverride xmlOverride) {
- return new GenericOrmAttributeOverride(parent, xmlOverride);
- }
-
- public OrmVirtualAttributeOverride buildOrmVirtualAttributeOverride(OrmAttributeOverrideContainer parent, String name) {
- return new GenericOrmVirtualAttributeOverride(parent, name);
- }
-
- public OrmAssociationOverride buildOrmAssociationOverride(OrmAssociationOverrideContainer parent, XmlAssociationOverride xmlOverride) {
- return new GenericOrmAssociationOverride(parent, xmlOverride);
- }
-
- public OrmVirtualAssociationOverride buildOrmVirtualAssociationOverride(OrmAssociationOverrideContainer parent, String name) {
- return new GenericOrmVirtualAssociationOverride(parent, name);
- }
-
- public OrmOverrideRelationship buildOrmOverrideRelationship(OrmAssociationOverride parent) {
- return new GenericOrmOverrideRelationship(parent);
- }
-
- public OrmVirtualOverrideRelationship buildOrmVirtualOverrideRelationship(OrmVirtualAssociationOverride parent) {
- return new GenericOrmVirtualOverrideRelationship(parent);
- }
-
- 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 OrmVirtualColumn buildOrmVirtualColumn(XmlContextNode parent, OrmVirtualColumn.Owner owner) {
- return new GenericOrmVirtualColumn(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 OrmVirtualUniqueConstraint buildOrmVirtualUniqueConstraint(XmlContextNode parent, UniqueConstraint overriddenUniqueConstraint) {
- return new GenericOrmVirtualUniqueConstraint(parent, overriddenUniqueConstraint);
- }
-
- public OrmConverter buildOrmEnumeratedConverter(OrmAttributeMapping parent) {
- return new GenericOrmEnumeratedConverter(parent);
- }
-
- public OrmConverter buildOrmLobConverter(OrmAttributeMapping parent) {
- return new GenericOrmLobConverter(parent);
- }
-
- public OrmConverter buildOrmTemporalConverter(OrmAttributeMapping parent) {
- return new GenericOrmTemporalConverter(parent);
- }
-
- public OrmOrderable buildOrmOrderable(OrmAttributeMapping parent) {
- return new GenericOrmOrderable(parent);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java
deleted file mode 100644
index 97b9f47aac..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmXmlDefinition.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.ArrayList;
-
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.UnsupportedOrmAttributeMappingDefinition;
-
-/**
- * All the state in the definition should be "static"
- * (i.e. unchanging once it is initialized).
- */
-public abstract class AbstractOrmXmlDefinition
- implements OrmXmlDefinition
-{
- protected final OrmXmlContextNodeFactory factory;
-
- protected ArrayList<OrmTypeMappingDefinition> typeMappingDefinitions;
-
- protected ArrayList<OrmAttributeMappingDefinition> attributeMappingDefinitions;
-
-
- /**
- * zero-argument constructor
- */
- protected AbstractOrmXmlDefinition() {
- super();
- this.factory = this.buildContextNodeFactory();
- }
-
-
- // ********** factory **********
-
- protected abstract OrmXmlContextNodeFactory buildContextNodeFactory();
-
- public OrmXmlContextNodeFactory getContextNodeFactory() {
- return this.factory;
- }
-
-
- // ********** type mapping definitions **********
-
- public OrmTypeMappingDefinition getTypeMappingDefinition(String mappingKey) {
- for (OrmTypeMappingDefinition definition : this.getTypeMappingDefinitions()) {
- if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) {
- return definition;
- }
- }
- throw new IllegalArgumentException("Illegal type mapping key: " + mappingKey); //$NON-NLS-1$
- }
-
- /**
- * Return a list of mapping definitions to use for types in
- * <code>orm.xml</code> mapping files.
- * The order is unimportant.
- */
- protected synchronized ArrayList<OrmTypeMappingDefinition> getTypeMappingDefinitions() {
- if (this.typeMappingDefinitions == null) {
- this.typeMappingDefinitions = this.buildTypeMappingDefinitions();
- }
- return this.typeMappingDefinitions;
- }
-
- protected ArrayList<OrmTypeMappingDefinition> buildTypeMappingDefinitions() {
- ArrayList<OrmTypeMappingDefinition> definitions = new ArrayList<OrmTypeMappingDefinition>();
- this.addTypeMappingDefinitionsTo(definitions);
- return definitions;
- }
-
- protected abstract void addTypeMappingDefinitionsTo(ArrayList<OrmTypeMappingDefinition> definitions);
-
-
- // ********** attribute mapping definitions **********
-
- public OrmAttributeMappingDefinition getAttributeMappingDefinition(String mappingKey) {
- for (OrmAttributeMappingDefinition definition : this.getAttributeMappingDefinitions()) {
- if (Tools.valuesAreEqual(definition.getKey(), mappingKey)) {
- return definition;
- }
- }
- return UnsupportedOrmAttributeMappingDefinition.instance();
- }
-
- /**
- * Return a list of mapping definitions to use for attributes in
- * <code>orm.xml</code> mapping files.
- * The order is unimportant.
- */
- protected synchronized ArrayList<OrmAttributeMappingDefinition> getAttributeMappingDefinitions() {
- if (this.attributeMappingDefinitions == null) {
- this.attributeMappingDefinitions = this.buildAttributeMappingDefinitions();
- }
- return this.attributeMappingDefinitions;
- }
-
- protected ArrayList<OrmAttributeMappingDefinition> buildAttributeMappingDefinitions() {
- ArrayList<OrmAttributeMappingDefinition> definitions = new ArrayList<OrmAttributeMappingDefinition>();
- this.addAttributeMappingDefinitionsTo(definitions);
- return definitions;
- }
-
- protected abstract void addAttributeMappingDefinitionsTo(ArrayList<OrmAttributeMappingDefinition> definitions);
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmIdClassReference.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmIdClassReference.java
deleted file mode 100644
index c42c4892dc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmIdClassReference.java
+++ /dev/null
@@ -1,375 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.internal.utility.JDTTools;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.java.JavaIdClassReference;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmIdClassReference;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.AbstractXmlContextNode;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlClassReference;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlIdClassContainer;
-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> ID class reference
- */
-public class GenericOrmIdClassReference
- extends AbstractXmlContextNode
- implements OrmIdClassReference
-{
- protected final Owner owner;
-
- protected String specifiedIdClassName;
- protected String defaultIdClassName;
- protected JavaPersistentType idClass;
-
-
- public GenericOrmIdClassReference(OrmTypeMapping parent, Owner owner) {
- super(parent);
- this.owner = owner;
- this.specifiedIdClassName = this.buildSpecifiedIdClassName();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setSpecifiedIdClassName_(this.buildSpecifiedIdClassName());
- // sync the id class *after* we have the specified name
- this.syncIdClass();
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultIdClassName(this.buildDefaultIdClassName());
- this.updateIdClass();
- }
-
-
- // ********** id class name **********
-
- public String getIdClassName() {
- return (this.specifiedIdClassName != null) ? this.specifiedIdClassName : this.defaultIdClassName;
- }
-
- public String getSpecifiedIdClassName() {
- return this.specifiedIdClassName;
- }
-
- public void setSpecifiedIdClassName(String name) {
- if (this.valuesAreDifferent(this.specifiedIdClassName, name)) {
- XmlClassReference xmlClassRef = this.getXmlIdClassRefForUpdate();
- this.setSpecifiedIdClassName_(name);
- xmlClassRef.setClassName(name);
- this.removeXmlIdClassRefIfUnset();
- }
- }
-
- /**
- * We clear out {@link #idClass} here because we cannot compare its name
- * to the specified name, since it may have been prefixed by the entity
- * mappings package.
- */
- protected void setSpecifiedIdClassName_(String name) {
- String old = this.specifiedIdClassName;
- this.specifiedIdClassName = name;
- if (this.firePropertyChanged(SPECIFIED_ID_CLASS_NAME_PROPERTY, old, name)) {
- // clear out the Java type here, it will be rebuilt during "update"
- if (this.idClass != null) {
- this.idClass.dispose();
- this.setIdClass(null);
- }
- }
- }
-
- protected String buildSpecifiedIdClassName() {
- XmlClassReference xmlIdClassRef = this.getXmlIdClassRef();
- return (xmlIdClassRef == null) ? null : xmlIdClassRef.getClassName();
- }
-
- public String getDefaultIdClassName() {
- return this.defaultIdClassName;
- }
-
- protected void setDefaultIdClassName(String name) {
- String old = this.defaultIdClassName;
- this.defaultIdClassName = name;
- this.firePropertyChanged(DEFAULT_ID_CLASS_NAME_PROPERTY, old, name);
- }
-
- protected String buildDefaultIdClassName() {
- JavaIdClassReference javaRef = this.owner.getJavaIdClassReferenceForDefaults();
- return (javaRef == null) ? null : javaRef.getFullyQualifiedIdClassName();
- }
-
- public boolean isSpecified() {
- return this.getIdClassName() != null;
- }
-
-
- // ********** xml id class ref **********
-
- /**
- * Return null if the XML class ref does not exists.
- */
- protected XmlClassReference getXmlIdClassRef() {
- return this.getXmlIdClassContainer().getIdClass();
- }
-
- /**
- * Build the XML class ref if it does not exist.
- */
- protected XmlClassReference getXmlIdClassRefForUpdate() {
- XmlClassReference xmlClassRef = this.getXmlIdClassRef();
- return (xmlClassRef != null) ? xmlClassRef : this.buildXmlIdClassRef();
- }
-
- protected XmlClassReference buildXmlIdClassRef() {
- XmlClassReference ref = OrmFactory.eINSTANCE.createXmlClassReference();
- this.getXmlIdClassContainer().setIdClass(ref);
- return ref;
- }
-
- protected void removeXmlIdClassRefIfUnset() {
- if (this.getXmlIdClassRef().isUnset()) {
- this.removeXmlIdClassRef();
- }
- }
-
- protected void removeXmlIdClassRef() {
- this.getXmlIdClassContainer().setIdClass(null);
- }
-
-
- // ********** id class **********
-
- public JavaPersistentType getIdClass() {
- return this.idClass;
- }
-
- protected void setIdClass(JavaPersistentType idClass) {
- JavaPersistentType old = this.idClass;
- this.idClass = idClass;
- this.firePropertyChanged(ID_CLASS_PROPERTY, old, idClass);
- }
-
- /**
- * If the specified ID class name changes during
- * <em>sync</em>, the ID class will be cleared out in
- * {@link #setSpecifiedIdClassName_(String)}. If we get here and
- * the ID class is still present, we can
- * <code>sync</code> it. Of course, it might be still obsolete if the
- * entity mappings's package has changed....
- *
- * @see #updateIdClass()
- */
- protected void syncIdClass() {
- if (this.idClass != null) {
- this.idClass.synchronizeWithResourceModel();
- }
- }
-
- /**
- * @see #syncIdClass()
- */
- protected void updateIdClass() {
- JavaResourcePersistentType resourceIdClass = this.resolveJavaResourceIdClass();
- if (resourceIdClass == null) {
- if (this.idClass != null) {
- this.idClass.dispose();
- this.setIdClass(null);
- }
- } else {
- if (this.idClass == null) {
- this.setIdClass(this.buildIdClass(resourceIdClass));
- } else {
- if (this.idClass.getResourcePersistentType() == resourceIdClass) {
- this.idClass.update();
- } else {
- this.idClass.dispose();
- this.setIdClass(this.buildIdClass(resourceIdClass));
- }
- }
- }
- }
-
- // TODO I'm not sure we should be go to the entity mappings to resolve
- // our name if it is taken from the Java ID class reference...
- protected JavaResourcePersistentType resolveJavaResourceIdClass() {
- String idClassName = this.getIdClassName();
- if (idClassName == null) {
- return null;
- }
- JavaResourcePersistentType jrpt = this.getEntityMappings().resolveJavaResourcePersistentType(idClassName);
- return (jrpt == null) ? null : (jrpt.isMapped() ? null : jrpt);
- }
-
- protected JavaPersistentType buildIdClass(JavaResourcePersistentType resourceIdClass) {
- return this.getJpaFactory().buildJavaPersistentType(this, resourceIdClass);
- }
-
- public char getIdClassEnclosingTypeSeparator() {
- return '$';
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmTypeMapping getParent() {
- return (OrmTypeMapping) super.getParent();
- }
-
- protected OrmTypeMapping getTypeMapping() {
- return this.getParent();
- }
-
- protected OrmPersistentType getPersistentType() {
- return this.getTypeMapping().getPersistentType();
- }
-
- protected XmlIdClassContainer getXmlIdClassContainer() {
- return this.owner.getXmlIdClassContainer();
- }
-
- protected EntityMappings getEntityMappings() {
- return (EntityMappings) this.getMappingFileRoot();
- }
-
-
- // ********** PersistentType.Owner implementation **********
-
- public AccessType getOverridePersistentTypeAccess() {
- return this.getPersistentType().getAccess();
- }
-
- public AccessType getDefaultPersistentTypeAccess() {
- // this shouldn't be needed, since we've specified an override access, but just to be safe ...
- return this.getPersistentType().getAccess();
- }
-
-
- // ********** refactoring **********
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return this.isFor(originalType.getFullyQualifiedName('.')) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenameEdit(originalType, newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createRenameEdit(IType originalType, String newName) {
- return this.getXmlIdClassRef().createRenameEdit(originalType, newName);
- }
-
- protected boolean isFor(String typeName) {
- return (this.idClass != null) && this.idClass.isFor(typeName);
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.isFor(originalType.getFullyQualifiedName('.')) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newPackage.getElementName())) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.isIn(originalPackage) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenamePackageEdit(newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createRenamePackageEdit(String newName) {
- return this.getXmlIdClassRef().createRenamePackageEdit(newName);
- }
-
- protected boolean isIn(IPackageFragment originalPackage) {
- return (this.idClass != null) && this.idClass.isIn(originalPackage);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- // most validation is done "holistically" from the type mapping level
- this.validateIdClass(messages, reporter);
- }
-
- protected void validateIdClass(List<IMessage> messages, IReporter reporter) {
- IJavaProject javaProject = getJpaProject().getJavaProject();
- if (this.isSpecified()) {
- JavaResourcePersistentType jrpt = getJpaProject().getJavaResourcePersistentType(this.getIdClassName());
- if ((jrpt != null) && (jrpt.isMapped())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TYPE_MAPPING_ID_CLASS_NOT_VALID,
- new String[] {jrpt.getName()},
- this,
- this.getValidationTextRange()
- )
- );
- } else if (StringTools.stringIsEmpty(this.getIdClassName())) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TYPE_MAPPING_ID_CLASS_NAME_EMPTY,
- EMPTY_STRING_ARRAY,
- this,
- this.getValidationTextRange()
- )
- );
- } else if (JDTTools.findType(javaProject, this.getIdClassName()) == null) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.TYPE_MAPPING_ID_CLASS_NOT_EXIST,
- new String[] { this.getIdClassName()},
- this,
- this.getValidationTextRange()
- )
- );
- }
- }
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.getXmlValidationTextRange();
- return (textRange != null) ? textRange : this.getTypeMapping().getValidationTextRange();
- }
-
- protected TextRange getXmlValidationTextRange() {
- XmlClassReference xmlIdClassRef = this.getXmlIdClassRef();
- return (xmlIdClassRef == null) ? null : xmlIdClassRef.getClassNameTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java
deleted file mode 100644
index e4a2fc81e0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToManyRelationship.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToManyRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToMany;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmManyToManyRelationship
- extends AbstractOrmMappingRelationship<OrmManyToManyMapping>
- implements OrmManyToManyRelationship
-{
- protected final OrmMappedByRelationshipStrategy mappedByStrategy;
-
- protected final OrmJoinTableRelationshipStrategy joinTableStrategy;
-
-
- public GenericOrmManyToManyRelationship(OrmManyToManyMapping parent) {
- super(parent);
- this.mappedByStrategy = this.buildMappedByStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mappedByStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.mappedByStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected OrmRelationshipStrategy buildStrategy() {
- if (this.mappedByStrategy.getMappedByAttribute() != null) {
- return this.mappedByStrategy;
- }
- return this.joinTableStrategy;
- }
-
-
- // ********** mapped by strategy **********
-
- public OrmMappedByRelationshipStrategy getMappedByStrategy() {
- return this.mappedByStrategy;
- }
-
- public boolean strategyIsMappedBy() {
- return this.strategy == this.mappedByStrategy;
- }
-
- public void setStrategyToMappedBy() {
- this.mappedByStrategy.addStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mapping) {
- return mapping.getKey() == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY;
- }
-
- protected OrmMappedByRelationshipStrategy buildMappedByStrategy() {
- return new GenericOrmMappedByRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public OrmJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public void setStrategyToJoinTable() {
- // join table is the default strategy, so no need to add to resource
- this.mappedByStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- protected OrmJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return new GenericOrmMappingJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromMappedByRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- }
-
- @Override
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- super.initializeFromMappedByRelationship(oldRelationship);
- this.mappedByStrategy.initializeFrom(oldRelationship.getMappedByStrategy());
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- protected XmlManyToMany getXmlMapping() {
- return (XmlManyToMany) super.getXmlMapping();
- }
-
- public XmlManyToMany getXmlContainer() {
- return this.getXmlMapping();
- }
-
- public boolean isOwner() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByStrategy.relationshipIsOwnedBy(mapping);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.mappedByStrategy.validate(messages, reporter);
- this.joinTableStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java
deleted file mode 100644
index 39a61109b0..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmManyToOneRelationship.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmManyToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmManyToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmManyToOneRelationship
- extends AbstractOrmMappingRelationship<OrmManyToOneMapping>
- implements OrmManyToOneRelationship2_0
-{
- protected final OrmJoinColumnRelationshipStrategy joinColumnStrategy;
-
- // JPA 2.0
- protected final OrmJoinTableRelationshipStrategy joinTableStrategy;
-
-
- public GenericOrmManyToOneRelationship(OrmManyToOneMapping parent) {
- super(parent);
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.joinColumnStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected OrmRelationshipStrategy buildStrategy() {
- if (this.isJpa2_0Compatible()) {
- if (this.joinTableStrategy.getJoinTable() != null){
- return this.joinTableStrategy;
- }
- }
- return this.joinColumnStrategy;
- }
-
-
- // ********** join table strategy **********
-
- public OrmJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public void setStrategyToJoinTable() {
- this.joinTableStrategy.addStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- protected OrmJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return this.isJpa2_0Compatible() ?
- new GenericOrmMappingJoinTableRelationshipStrategy(this) :
- new NullOrmJoinTableRelationshipStrategy(this);
- }
-
-
-
- // ********** join column strategy **********
-
- public OrmJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- // join column strategy is the default; so no need to add stuff,
- // just remove all the others
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return this.joinTableStrategy.getJoinTable() == null;
- }
-
- protected OrmJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return new GenericOrmMappingJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromJoinColumnRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- @Override
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- super.initializeFromJoinColumnRelationship(oldRelationship);
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- protected XmlManyToOne getXmlMapping() {
- return (XmlManyToOne) super.getXmlMapping();
- }
-
- public XmlManyToOne getXmlContainer() {
- return this.getXmlMapping();
- }
-
- public boolean isOwner() {
- return true;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return false;
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.joinColumnStrategy.validate(messages, reporter);
- this.joinTableStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
deleted file mode 100644
index b7e8c4ba8c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.ArrayTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlMappedByMapping;
-import org.eclipse.jpt.jpa.db.Table;
-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 GenericOrmMappedByRelationshipStrategy
- extends AbstractOrmXmlContextNode
- implements OrmMappedByRelationshipStrategy
-{
- protected String mappedByAttribute;
-
-
- public GenericOrmMappedByRelationshipStrategy(OrmMappedByRelationship parent) {
- super(parent);
- this.mappedByAttribute = this.getXmlMappedByMapping().getMappedBy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setMappedByAttribute_(this.getXmlMappedByMapping().getMappedBy());
- }
-
-
- // ********** mapped by attribute **********
-
- public String getMappedByAttribute() {
- return this.mappedByAttribute;
- }
-
- public void setMappedByAttribute(String mappedByAttribute) {
- this.setMappedByAttribute_(mappedByAttribute);
- this.getXmlMappedByMapping().setMappedBy(mappedByAttribute);
- }
-
- protected void setMappedByAttribute_(String mappedByAttribute) {
- String old = this.mappedByAttribute;
- this.mappedByAttribute = mappedByAttribute;
- this.firePropertyChanged(MAPPED_BY_ATTRIBUTE_PROPERTY, old, mappedByAttribute);
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmMappedByRelationship getParent() {
- return (OrmMappedByRelationship) super.getParent();
- }
-
- public OrmMappedByRelationship getRelationship() {
- return this.getParent();
- }
-
- protected XmlMappedByMapping getXmlMappedByMapping() {
- return this.getRelationship().getXmlContainer();
- }
-
- public void initializeFrom(MappedByRelationshipStrategy oldStrategy) {
- this.setMappedByAttribute(oldStrategy.getMappedByAttribute());
- }
-
- public String getTableName() {
- RelationshipMapping owner = this.getRelationshipOwner();
- return (owner == null) ? null : owner.getRelationship().getStrategy().getTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- RelationshipMapping owner = this.getRelationshipOwner();
- return (owner == null) ? null : owner.getRelationship().getStrategy().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- RelationshipMapping owner = this.getRelationshipOwner();
- return (owner != null) && owner.getRelationship().getStrategy().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- // this will not be called if getRelationshipOwner() returns null
- return this.getRelationshipOwner().getRelationship().getStrategy().getColumnTableNotValidDescription();
- }
-
- protected RelationshipMapping getRelationshipOwner() {
- return this.getRelationshipMapping().getRelationshipOwner();
- }
-
- public boolean isOverridable() {
- return false;
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- public boolean relationshipIsOwnedBy(RelationshipMapping otherMapping) {
- String thisEntityName = this.getEntityName();
- Entity otherEntity = otherMapping.getResolvedTargetEntity();
- String otherEntityName = (otherEntity == null) ? null : otherEntity.getName();
- return Tools.valuesAreEqual(thisEntityName, otherEntityName) &&
- Tools.valuesAreEqual(this.mappedByAttribute, otherMapping.getName());
- }
-
- protected String getEntityName() {
- Entity entity = this.getRelationship().getEntity();
- return (entity == null) ? null : entity.getName();
- }
-
- public void addStrategy() {
- if (this.mappedByAttribute == null) {
- this.setMappedByAttribute(""); //$NON-NLS-1$
- }
- }
-
- public void removeStrategy() {
- if (this.mappedByAttribute != null) {
- this.setMappedByAttribute(null);
- }
- }
-
- public Iterator<String> candidateMappedByAttributeNames() {
- return this.getRelationshipMapping().allTargetEntityAttributeNames();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
-
- if (this.mappedByAttribute == 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(
- this.buildMessage(
- JpaValidationMessages.MAPPING_UNRESOLVED_MAPPED_BY,
- new String[] {this.mappedByAttribute}
- )
- );
- return;
- }
-
- if ( ! this.getRelationship().mayBeMappedBy(mappedByMapping)) {
- messages.add(
- this.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(
- this.buildMessage(
- JpaValidationMessages.MAPPING_MAPPED_BY_ON_BOTH_SIDES,
- new String[] {this.mappedByAttribute}
- )
- );
- }
- }
-
- protected IMessage buildMessage(String msgID, String[] parms) {
- PersistentAttribute attribute = this.getRelationshipMapping().getPersistentAttribute();
- String attributeDescription = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName());
- parms = ArrayTools.add(parms, 0, attributeDescription);
- return DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- msgID,
- parms,
- this,
- this.getValidationTextRange()
- );
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.getXmlMappedByMapping().getMappedByTextRange();
- return (textRange != null) ? textRange : this.getRelationship().getValidationTextRange();
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinColumnRelationshipStrategy.java
deleted file mode 100644
index 242b287424..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappingJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn.Owner;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.EntityTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.db.Table;
-
-public class GenericOrmMappingJoinColumnRelationshipStrategy
- extends AbstractOrmJoinColumnRelationshipStrategy
-{
- protected final boolean targetForeignKey;
-
-
- /**
- * The default strategy is for a "source" foreign key.
- */
- public GenericOrmMappingJoinColumnRelationshipStrategy(OrmMappingJoinColumnRelationship parent) {
- this(parent, false);
- }
-
- public GenericOrmMappingJoinColumnRelationshipStrategy(OrmMappingJoinColumnRelationship parent, boolean targetForeignKey) {
- super(parent);
- this.targetForeignKey = targetForeignKey;
- }
-
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isOverridable() {
- return true;
- }
-
- public TypeMapping getRelationshipSource() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return this.targetForeignKey ?
- mapping.getResolvedTargetEntity() :
- mapping.getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return this.targetForeignKey ?
- mapping.getTypeMapping() :
- mapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping target = this.getRelationshipTarget();
- return (target instanceof Entity) ? (Entity) target : null;
- }
-
- public boolean isTargetForeignKey() {
- return this.targetForeignKey;
- }
-
-
- // ********** validation **********
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- public TextRange getValidationTextRange() {
- return this.getRelationship().getValidationTextRange();
- }
-
-
- // ********** join column owner **********
-
- 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 GenericOrmMappingJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.getRelationshipMapping().getName();
- }
-
- protected PersistentAttribute getPersistentAttribute() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.getRelationshipMapping().getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.candidateTableNames();
- }
-
- public Table resolveDbTable(String tableName) {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.resolveDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange() {
- return GenericOrmMappingJoinColumnRelationshipStrategy.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new JoinColumnValidator(this.getPersistentAttribute(), (JoinColumn) column, this, (JoinColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinTableRelationshipStrategy.java
deleted file mode 100644
index dc2597f119..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappingJoinTableRelationshipStrategy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.Table;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappingJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.InverseJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableTableDescriptionProvider;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.JoinTableValidator;
-
-public class GenericOrmMappingJoinTableRelationshipStrategy
- extends AbstractOrmJoinTableRelationshipStrategy
-{
- public GenericOrmMappingJoinTableRelationshipStrategy(OrmMappingJoinTableRelationship parent) {
- super(parent);
- }
-
-
- public boolean isOverridable() {
- return this.getJpaPlatformVariation().isJoinTableOverridable();
- }
-
-
- // ********** validation **********
-
- public boolean validatesAgainstDatabase() {
- return this.getRelationshipMapping().validatesAgainstDatabase();
- }
-
- public TextRange getValidationTextRange() {
- return this.getRelationship().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, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- return new InverseJoinColumnValidator(this.getPersistentAttribute(), column, owner, textRangeResolver, new JoinTableTableDescriptionProvider());
- }
-
- public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) {
- return new JoinTableValidator(this.getPersistentAttribute(), (JoinTable) table, textRangeResolver);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java
deleted file mode 100644
index 674c6bb988..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToManyRelationship.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToManyMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.orm.NullOrmJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToManyRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmOneToManyRelationship
- extends AbstractOrmMappingRelationship<OrmOneToManyMapping>
- implements OrmOneToManyRelationship2_0
-{
- protected final OrmMappedByRelationshipStrategy mappedByStrategy;
-
- protected final OrmJoinTableRelationshipStrategy joinTableStrategy;
-
- // JPA 2.0 or EclipseLink
- protected final boolean supportsJoinColumnStrategy;
- protected final OrmJoinColumnRelationshipStrategy joinColumnStrategy;
-
-
- public GenericOrmOneToManyRelationship(OrmOneToManyMapping parent, boolean supportsJoinColumnStrategy) {
- super(parent);
- this.mappedByStrategy = this.buildMappedByStrategy();
- this.supportsJoinColumnStrategy = supportsJoinColumnStrategy;
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
-
- // build join table strategy last since it's dependent on the other strategies
- this.joinTableStrategy = this.buildJoinTableStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mappedByStrategy.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.mappedByStrategy.update();
- this.joinColumnStrategy.update();
- this.joinTableStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected OrmRelationshipStrategy buildStrategy() {
- if (this.mappedByStrategy.getMappedByAttribute() != null) {
- return this.mappedByStrategy;
- }
- if (this.supportsJoinColumnStrategy) {
- if (this.joinColumnStrategy.hasSpecifiedJoinColumns()) {
- return this.joinColumnStrategy;
- }
- }
- return this.joinTableStrategy;
- }
-
-
- // ********** mapped by strategy **********
-
- public OrmMappedByRelationshipStrategy getMappedByStrategy() {
- return this.mappedByStrategy;
- }
-
- public boolean strategyIsMappedBy() {
- return this.strategy == this.mappedByStrategy;
- }
-
- public final void setStrategyToMappedBy() {
- this.mappedByStrategy.addStrategy();
- this.joinTableStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mapping) {
- String key = mapping.getKey();
- if (key == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY) {
- return true;
- }
- if (this.supportsJoinColumnStrategy) {
- return key == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
- return false;
- }
-
- protected OrmMappedByRelationshipStrategy buildMappedByStrategy() {
- return new GenericOrmMappedByRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public OrmJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public final void setStrategyToJoinTable() {
- // join table is default, so no need to add to resource
- this.mappedByStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return (this.mappedByStrategy.getMappedByAttribute() == null) &&
- ! this.joinColumnStrategy.hasSpecifiedJoinColumns();
- }
-
- protected OrmJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return new GenericOrmMappingJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** join column strategy **********
-
- public OrmJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- this.joinColumnStrategy.addStrategy();
- this.mappedByStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return false;
- }
-
- protected OrmJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return this.supportsJoinColumnStrategy ?
- new GenericOrmMappingJoinColumnRelationshipStrategy(this, true) : // true = target foreign key
- new NullOrmJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromMappedByRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- newRelationship.initializeFromJoinColumnRelationship(this);
- }
-
- @Override
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- super.initializeFromMappedByRelationship(oldRelationship);
- this.mappedByStrategy.initializeFrom(oldRelationship.getMappedByStrategy());
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- @Override
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- super.initializeFromJoinColumnRelationship(oldRelationship);
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- protected XmlOneToMany getXmlMapping() {
- return (XmlOneToMany) super.getXmlMapping();
- }
-
- public XmlOneToMany getXmlContainer() {
- return this.getXmlMapping();
- }
-
- public boolean isOwner() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByStrategy.relationshipIsOwnedBy(mapping);
- }
-
- @Override
- public boolean isTargetForeignKey() {
- return this.joinColumnStrategy.isTargetForeignKey();
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.mappedByStrategy.validate(messages, reporter);
- this.joinTableStrategy.validate(messages, reporter);
- this.joinColumnStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java
deleted file mode 100644
index 1f7fbbd2cb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOneToOneRelationship.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.MappedByRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedByRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOneToOneMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOneToOneRelationship2_0;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmOneToOneRelationship
- extends AbstractOrmMappingRelationship<OrmOneToOneMapping>
- implements OrmOneToOneRelationship2_0
-{
- protected final OrmMappedByRelationshipStrategy mappedByStrategy;
-
- protected final OrmPrimaryKeyJoinColumnRelationshipStrategy primaryKeyJoinColumnStrategy;
-
- // JPA 2.0
- protected final OrmJoinTableRelationshipStrategy joinTableStrategy;
-
- protected final OrmJoinColumnRelationshipStrategy joinColumnStrategy;
-
-
- public GenericOrmOneToOneRelationship(OrmOneToOneMapping parent) {
- super(parent);
- this.mappedByStrategy = this.buildMappedByStrategy();
- this.primaryKeyJoinColumnStrategy = this.buildPrimaryKeyJoinColumnStrategy();
- this.joinTableStrategy = this.buildJoinTableStrategy();
- this.joinColumnStrategy = this.buildJoinColumnStrategy();
-
- this.strategy = this.buildStrategy();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mappedByStrategy.synchronizeWithResourceModel();
- this.primaryKeyJoinColumnStrategy.synchronizeWithResourceModel();
- this.joinTableStrategy.synchronizeWithResourceModel();
- this.joinColumnStrategy.synchronizeWithResourceModel();
- }
-
- @Override
- public void update() {
- super.update();
- this.mappedByStrategy.update();
- this.primaryKeyJoinColumnStrategy.update();
- this.joinTableStrategy.update();
- this.joinColumnStrategy.update();
- }
-
-
- // ********** strategy **********
-
- @Override
- protected OrmRelationshipStrategy buildStrategy() {
- if (this.mappedByStrategy.getMappedByAttribute() != null) {
- return this.mappedByStrategy;
- }
- if (this.primaryKeyJoinColumnStrategy.hasPrimaryKeyJoinColumns()) {
- return this.primaryKeyJoinColumnStrategy;
- }
- if (this.isJpa2_0Compatible()) {
- if (this.joinTableStrategy.getJoinTable() != null){
- return this.joinTableStrategy;
- }
- }
- return this.joinColumnStrategy;
- }
-
-
- // ********** mapped by strategy **********
-
- public OrmMappedByRelationshipStrategy getMappedByStrategy() {
- return this.mappedByStrategy;
- }
-
- public boolean strategyIsMappedBy() {
- return this.strategy == this.mappedByStrategy;
- }
-
- public void setStrategyToMappedBy() {
- this.mappedByStrategy.addStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.primaryKeyJoinColumnStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayBeMappedBy(AttributeMapping mapping) {
- return mapping.getKey() == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY;
- }
-
- protected OrmMappedByRelationshipStrategy buildMappedByStrategy() {
- return new GenericOrmMappedByRelationshipStrategy(this);
- }
-
-
- // ********** primary key join column strategy **********
-
- public OrmPrimaryKeyJoinColumnRelationshipStrategy getPrimaryKeyJoinColumnStrategy() {
- return this.primaryKeyJoinColumnStrategy;
- }
-
- public boolean strategyIsPrimaryKeyJoinColumn() {
- return this.strategy == this.primaryKeyJoinColumnStrategy;
- }
-
- public void setStrategyToPrimaryKeyJoinColumn() {
- this.primaryKeyJoinColumnStrategy.addStrategy();
- this.mappedByStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- protected OrmPrimaryKeyJoinColumnRelationshipStrategy buildPrimaryKeyJoinColumnStrategy() {
- return new GenericOrmPrimaryKeyJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** join table strategy **********
-
- public OrmJoinTableRelationshipStrategy getJoinTableStrategy() {
- return this.joinTableStrategy;
- }
-
- public boolean strategyIsJoinTable() {
- return this.strategy == this.joinTableStrategy;
- }
-
- public void setStrategyToJoinTable() {
- this.joinTableStrategy.addStrategy();
- this.mappedByStrategy.removeStrategy();
- this.joinColumnStrategy.removeStrategy();
- this.primaryKeyJoinColumnStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinTable() {
- return false;
- }
-
- protected OrmJoinTableRelationshipStrategy buildJoinTableStrategy() {
- return this.isJpa2_0Compatible() ?
- new GenericOrmMappingJoinTableRelationshipStrategy(this) :
- new NullOrmJoinTableRelationshipStrategy(this);
- }
-
-
- // ********** join column strategy **********
-
- public OrmJoinColumnRelationshipStrategy getJoinColumnStrategy() {
- return this.joinColumnStrategy;
- }
-
- public boolean strategyIsJoinColumn() {
- return this.strategy == this.joinColumnStrategy;
- }
-
- public void setStrategyToJoinColumn() {
- // join column strategy is the default; so no need to add stuff,
- // just remove all the others
- this.mappedByStrategy.removeStrategy();
- this.primaryKeyJoinColumnStrategy.removeStrategy();
- this.joinTableStrategy.removeStrategy();
- this.updateStrategy();
- }
-
- public boolean mayHaveDefaultJoinColumn() {
- return (this.mappedByStrategy.getMappedByAttribute() == null) &&
- (this.primaryKeyJoinColumnStrategy.primaryKeyJoinColumnsSize() == 0) &&
- (this.joinTableStrategy.getJoinTable() == null);
- }
-
- protected OrmJoinColumnRelationshipStrategy buildJoinColumnStrategy() {
- return new GenericOrmMappingJoinColumnRelationshipStrategy(this);
- }
-
-
- // ********** conversions **********
-
- public void initializeOn(Relationship newRelationship) {
- newRelationship.initializeFromMappedByRelationship(this);
- newRelationship.initializeFromJoinTableRelationship(this);
- newRelationship.initializeFromJoinColumnRelationship(this);
- // no other pk join column relationships yet
- }
-
- @Override
- public void initializeFromMappedByRelationship(MappedByRelationship oldRelationship) {
- super.initializeFromMappedByRelationship(oldRelationship);
- this.mappedByStrategy.initializeFrom(oldRelationship.getMappedByStrategy());
- }
-
- @Override
- public void initializeFromJoinTableRelationship(ReadOnlyJoinTableRelationship oldRelationship) {
- super.initializeFromJoinTableRelationship(oldRelationship);
- this.joinTableStrategy.initializeFrom(oldRelationship.getJoinTableStrategy());
- }
-
- @Override
- public void initializeFromJoinColumnRelationship(ReadOnlyJoinColumnRelationship oldRelationship) {
- super.initializeFromJoinColumnRelationship(oldRelationship);
- this.joinColumnStrategy.initializeFrom(oldRelationship.getJoinColumnStrategy());
- }
-
-
- // ********** misc **********
-
- @Override
- protected XmlOneToOne getXmlMapping() {
- return (XmlOneToOne) super.getXmlMapping();
- }
-
- public XmlOneToOne getXmlContainer() {
- return this.getXmlMapping();
- }
-
- public boolean isOwner() {
- return this.mappedByStrategy.getMappedByAttribute() == null;
- }
-
- public boolean isOwnedBy(RelationshipMapping mapping) {
- return this.mappedByStrategy.relationshipIsOwnedBy(mapping);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.mappedByStrategy.validate(messages, reporter);
- this.primaryKeyJoinColumnStrategy.validate(messages, reporter);
- this.joinTableStrategy.validate(messages, reporter);
- this.joinColumnStrategy.validate(messages, reporter);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOverrideJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOverrideJoinColumnRelationshipStrategy.java
deleted file mode 100644
index f6f28b8520..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmOverrideJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.BaseColumn;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOverrideRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn.Owner;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.db.Table;
-
-public class GenericOrmOverrideJoinColumnRelationshipStrategy
- extends AbstractOrmJoinColumnRelationshipStrategy
-{
- public GenericOrmOverrideJoinColumnRelationshipStrategy(OrmOverrideRelationship parent) {
- super(parent);
- }
-
- @Override
- protected Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- public boolean isTargetForeignKey() {
- RelationshipMapping relationshipMapping = this.getRelationshipMapping();
- return (relationshipMapping != null) &&
- relationshipMapping.getRelationship().isTargetForeignKey();
- }
-
- public TypeMapping getRelationshipSource() {
- return this.isTargetForeignKey() ?
- this.getRelationshipMapping().getResolvedTargetEntity() :
- this.getAssociationOverrideContainer().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- return this.isTargetForeignKey() ?
- this.getAssociationOverrideContainer().getTypeMapping() :
- this.getRelationshipMappingTargetEntity();
- }
-
- protected TypeMapping getRelationshipMappingTargetEntity() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return (mapping == null) ? null : mapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping target = this.getRelationshipTarget();
- return (target instanceof Entity) ? (Entity) target : null;
- }
-
- @Override
- public RelationshipMapping getRelationshipMapping() {
- return this.getAssociationOverride().getMapping();
- }
-
- protected String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- @Override
- public String getTableName() {
- return this.isTargetForeignKey() ?
- super.getTableName() :
- this.getAssociationOverrideContainer().getDefaultTableName();
- }
-
- @Override
- public Table resolveDbTable(String tableName) {
- return this.isTargetForeignKey() ?
- super.resolveDbTable(tableName) :
- this.getAssociationOverrideContainer().resolveDbTable(tableName);
- }
-
- @Override
- public boolean tableNameIsInvalid(String tableName) {
- return this.isTargetForeignKey() ?
- super.tableNameIsInvalid(tableName) :
- this.getAssociationOverrideContainer().tableNameIsInvalid(tableName);
- }
-
- @Override
- public Iterator<String> candidateTableNames() {
- return this.isTargetForeignKey() ?
- super.candidateTableNames() :
- this.getAssociationOverrideContainer().candidateTableNames();
- }
-
- public String getColumnTableNotValidDescription() {
- return null;
- }
-
- public boolean isOverridable() {
- return false;
- }
-
- protected OrmAssociationOverride getAssociationOverride() {
- return this.getRelationship().getAssociationOverride();
- }
-
- protected AssociationOverrideContainer getAssociationOverrideContainer() {
- return this.getAssociationOverride().getContainer();
- }
-
- @Override
- public OrmOverrideRelationship getRelationship() {
- return (OrmOverrideRelationship) super.getRelationship();
- }
-
- public TextRange getValidationTextRange() {
- return this.getRelationship().getValidationTextRange();
- }
-
-
- // ********** join column owner **********
-
- protected class JoinColumnOwner
- implements OrmJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- public String getDefaultTableName() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getAttributeName();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- RelationshipMapping relationshipMapping = GenericOrmOverrideJoinColumnRelationshipStrategy.this.getRelationshipMapping();
- return relationshipMapping == null ? null : relationshipMapping.getPersistentAttribute();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.candidateTableNames();
- }
-
- public Table resolveDbTable(String tableName) {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.resolveDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getReferencedColumnDbTable();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return false;
- }
-
- public int joinColumnsSize() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.joinColumnsSize();
- }
-
- public TextRange getValidationTextRange() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return this.getAssociationOverrideContainer().buildColumnValidator(this.getAssociationOverride(), (BaseColumn) column, this, (BaseColumnTextRangeResolver) textRangeResolver);
- }
-
- protected OrmAssociationOverride getAssociationOverride() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getAssociationOverride();
- }
-
- protected AssociationOverrideContainer getAssociationOverrideContainer() {
- return GenericOrmOverrideJoinColumnRelationshipStrategy.this.getAssociationOverrideContainer();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java
deleted file mode 100644
index 0aed2f60db..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.jpa.core.context.BaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.NamedColumn;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.OneToOnePrimaryKeyJoinColumnValidator;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationDescriptionMessages;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlPrimaryKeyJoinColumnContainer;
-import org.eclipse.jpt.jpa.db.Table;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-public class GenericOrmPrimaryKeyJoinColumnRelationshipStrategy
- extends AbstractOrmXmlContextNode
- implements OrmPrimaryKeyJoinColumnRelationshipStrategy
-{
- protected final Vector<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns = new Vector<OrmPrimaryKeyJoinColumn>();
- protected final PrimaryKeyJoinColumnContainerAdapter primaryKeyJoinColumnContainerAdapter;
- protected final OrmJoinColumn.Owner primaryKeyJoinColumnOwner;
-
-
- public GenericOrmPrimaryKeyJoinColumnRelationshipStrategy(OrmPrimaryKeyJoinColumnRelationship parent) {
- super(parent);
- this.primaryKeyJoinColumnContainerAdapter = this.buildPrimaryKeyJoinColumnContainerAdapter();
- this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner();
- this.initializePrimaryKeyJoinColumns();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncPrimaryKeyJoinColumns();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateNodes(this.getPrimaryKeyJoinColumns());
- }
-
-
- // ********** primary key join columns **********
-
- public ListIterator<OrmPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.getPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<OrmPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<OrmPrimaryKeyJoinColumn>(this.primaryKeyJoinColumns);
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.primaryKeyJoinColumns.size();
- }
-
- public boolean hasPrimaryKeyJoinColumns() {
- return this.primaryKeyJoinColumns.size() != 0;
- }
-
- public OrmPrimaryKeyJoinColumn getPrimaryKeyJoinColumn(int index) {
- return this.primaryKeyJoinColumns.get(index);
- }
-
- public OrmPrimaryKeyJoinColumn addPrimaryKeyJoinColumn() {
- return this.addPrimaryKeyJoinColumn(this.primaryKeyJoinColumns.size());
- }
-
- public OrmPrimaryKeyJoinColumn addPrimaryKeyJoinColumn(int index) {
- XmlPrimaryKeyJoinColumn xmlJoinColumn = this.buildXmlPrimaryKeyJoinColumn();
- OrmPrimaryKeyJoinColumn joinColumn = this.addPrimaryKeyJoinColumn_(index, xmlJoinColumn);
- this.getXmlPrimaryKeyJoinColumnContainer().getPrimaryKeyJoinColumns().add(index, xmlJoinColumn);
- return joinColumn;
- }
-
- protected XmlPrimaryKeyJoinColumn buildXmlPrimaryKeyJoinColumn() {
- return OrmFactory.eINSTANCE.createXmlPrimaryKeyJoinColumn();
- }
-
- public void removePrimaryKeyJoinColumn(PrimaryKeyJoinColumn joinColumn) {
- this.removePrimaryKeyJoinColumn(this.primaryKeyJoinColumns.indexOf(joinColumn));
- }
-
- public void removePrimaryKeyJoinColumn(int index) {
- this.removePrimaryKeyJoinColumn_(index);
- this.getXmlPrimaryKeyJoinColumnContainer().getPrimaryKeyJoinColumns().remove(index);
- }
-
- protected void removePrimaryKeyJoinColumn_(int index) {
- this.removeItemFromList(index, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- public void movePrimaryKeyJoinColumn(int targetIndex, int sourceIndex) {
- this.moveItemInList(targetIndex, sourceIndex, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- this.getXmlPrimaryKeyJoinColumnContainer().getPrimaryKeyJoinColumns().move(targetIndex, sourceIndex);
- }
-
- protected void initializePrimaryKeyJoinColumns() {
- for (XmlPrimaryKeyJoinColumn xmlJoinColumn : this.getXmlPrimaryKeyJoinColumns()) {
- this.primaryKeyJoinColumns.add(this.buildPrimaryKeyJoinColumn(xmlJoinColumn));
- }
- }
-
- protected void syncPrimaryKeyJoinColumns() {
- ContextContainerTools.synchronizeWithResourceModel(this.primaryKeyJoinColumnContainerAdapter);
- }
-
- protected Iterable<XmlPrimaryKeyJoinColumn> getXmlPrimaryKeyJoinColumns() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlPrimaryKeyJoinColumn>(this.getXmlPrimaryKeyJoinColumnContainer().getPrimaryKeyJoinColumns());
- }
-
- protected void movePrimaryKeyJoinColumn_(int index, OrmPrimaryKeyJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected OrmPrimaryKeyJoinColumn addPrimaryKeyJoinColumn_(int index, XmlPrimaryKeyJoinColumn xmlJoinColumn) {
- OrmPrimaryKeyJoinColumn joinColumn = this.buildPrimaryKeyJoinColumn(xmlJoinColumn);
- this.addItemToList(index, joinColumn, this.primaryKeyJoinColumns, PRIMARY_KEY_JOIN_COLUMNS_LIST);
- return joinColumn;
- }
-
- protected void removePrimaryKeyJoinColumn_(OrmPrimaryKeyJoinColumn joinColumn) {
- this.removePrimaryKeyJoinColumn_(this.primaryKeyJoinColumns.indexOf(joinColumn));
- }
-
- protected PrimaryKeyJoinColumnContainerAdapter buildPrimaryKeyJoinColumnContainerAdapter() {
- return new PrimaryKeyJoinColumnContainerAdapter();
- }
-
- /**
- * primary key join column container adapter
- */
- protected class PrimaryKeyJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmPrimaryKeyJoinColumn, XmlPrimaryKeyJoinColumn>
- {
- public Iterable<OrmPrimaryKeyJoinColumn> getContextElements() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.getPrimaryKeyJoinColumns();
- }
- public Iterable<XmlPrimaryKeyJoinColumn> getResourceElements() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.getXmlPrimaryKeyJoinColumns();
- }
- public XmlPrimaryKeyJoinColumn getResourceElement(OrmPrimaryKeyJoinColumn contextElement) {
- return contextElement.getXmlColumn();
- }
- public void moveContextElement(int index, OrmPrimaryKeyJoinColumn element) {
- GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.movePrimaryKeyJoinColumn_(index, element);
- }
- public void addContextElement(int index, XmlPrimaryKeyJoinColumn resourceElement) {
- GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.addPrimaryKeyJoinColumn_(index, resourceElement);
- }
- public void removeContextElement(OrmPrimaryKeyJoinColumn element) {
- GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.removePrimaryKeyJoinColumn_(element);
- }
- }
-
- protected OrmJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected OrmPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(XmlPrimaryKeyJoinColumn xmlJoinColumn) {
- return this.getContextNodeFactory().buildOrmPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, xmlJoinColumn);
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmPrimaryKeyJoinColumnRelationship getParent() {
- return (OrmPrimaryKeyJoinColumnRelationship) super.getParent();
- }
-
- public OrmPrimaryKeyJoinColumnRelationship getRelationship() {
- return this.getParent();
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return this.getRelationship().getMapping();
- }
-
- protected XmlPrimaryKeyJoinColumnContainer getXmlPrimaryKeyJoinColumnContainer() {
- return this.getRelationship().getXmlContainer();
- }
-
- public String getTableName() {
- return this.getTypeMapping().getPrimaryTableName();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public String getColumnTableNotValidDescription() {
- return JpaValidationDescriptionMessages.NOT_VALID_FOR_THIS_ENTITY;
- }
-
- protected TypeMapping getTypeMapping() {
- return this.getRelationshipMapping().getTypeMapping();
- }
-
- public void addStrategy() {
- if (this.primaryKeyJoinColumns.size() == 0) {
- this.addPrimaryKeyJoinColumn();
- }
- }
-
- public void removeStrategy() {
- for (int i = this.primaryKeyJoinColumns.size(); i-- > 0; ) {
- this.removePrimaryKeyJoinColumn(i);
- }
- }
-
- public boolean isOverridable() {
- return false;
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange() {
- return this.getRelationship().getValidationTextRange();
- }
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- for (OrmPrimaryKeyJoinColumn pkJoinColumn : this.getPrimaryKeyJoinColumns()) {
- pkJoinColumn.validate(messages, reporter);
- }
- }
-
-
- // ********** join column owner **********
-
- protected class PrimaryKeyJoinColumnOwner
- implements OrmJoinColumn.Owner
- {
- protected PrimaryKeyJoinColumnOwner() {
- super();
- }
-
- /**
- * by default, the join column is in the type mapping's primary table
- */
- public String getDefaultTableName() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public Entity getRelationshipTarget() {
- return this.getRelationshipMapping().getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- return this.getRelationshipMapping().getName();
- }
-
- protected PersistentAttribute getPersistentAttribute() {
- return this.getRelationshipMapping().getPersistentAttribute();
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return this.getTypeMapping().tableNameIsInvalid(tableName);
- }
-
- public Iterator<String> candidateTableNames() {
- return this.getTypeMapping().allAssociatedTableNames();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.getTypeMapping();
- }
-
- public Table resolveDbTable(String tableName) {
- return this.getTypeMapping().resolveDbTable(tableName);
- }
-
- public Table getReferencedColumnDbTable() {
- Entity relationshipTarget = this.getRelationshipTarget();
- return (relationshipTarget == null) ? null : relationshipTarget.getPrimaryDbTable();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return false;
- }
-
- public String getDefaultColumnName() {
- return null;
- }
-
- public int joinColumnsSize() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.primaryKeyJoinColumnsSize();
- }
-
- public TextRange getValidationTextRange() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.getValidationTextRange();
- }
-
- public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) {
- return new OneToOnePrimaryKeyJoinColumnValidator(this.getPersistentAttribute(), (BaseJoinColumn) column, this, (BaseJoinColumnTextRangeResolver) textRangeResolver);
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return GenericOrmPrimaryKeyJoinColumnRelationshipStrategy.this.getRelationshipMapping();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualJoinTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualJoinTable.java
deleted file mode 100644
index c93dd749e9..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualJoinTable.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinTable;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualRelationship;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.context.MappingTools;
-
-/**
- * <code>orm.xml</code> virtual join table
- */
-public class GenericOrmVirtualJoinTable
- extends AbstractOrmVirtualReferenceTable<JoinTable>
- implements OrmVirtualJoinTable
-{
- protected final JoinTable overriddenTable;
-
- protected final Vector<OrmVirtualJoinColumn> specifiedInverseJoinColumns = new Vector<OrmVirtualJoinColumn>();
- protected final SpecifiedInverseJoinColumnContainerAdapter specifiedInverseJoinColumnContainerAdapter = new SpecifiedInverseJoinColumnContainerAdapter();
- protected final ReadOnlyJoinColumn.Owner inverseJoinColumnOwner;
-
- protected OrmVirtualJoinColumn defaultInverseJoinColumn;
-
-
- public GenericOrmVirtualJoinTable(OrmVirtualJoinTableRelationshipStrategy parent, JoinTable overriddenTable) {
- super(parent);
- this.overriddenTable = overriddenTable;
- this.inverseJoinColumnOwner = this.buildInverseJoinColumnOwner();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateSpecifiedInverseJoinColumns();
- this.updateDefaultInverseJoinColumn();
- }
-
-
- // ********** table **********
-
- @Override
- public JoinTable getOverriddenTable() {
- return this.overriddenTable;
- }
-
-
- // ********** inverse join columns **********
-
- public ListIterator<OrmVirtualJoinColumn> inverseJoinColumns() {
- return this.getInverseJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getInverseJoinColumns() {
- return this.hasSpecifiedInverseJoinColumns() ? this.getSpecifiedInverseJoinColumns() : this.getDefaultInverseJoinColumns();
- }
-
- public int inverseJoinColumnsSize() {
- return this.hasSpecifiedInverseJoinColumns() ? this.specifiedInverseJoinColumnsSize() : this.getDefaultInverseJoinColumnsSize();
- }
-
-
- // ********** specified inverse join columns **********
-
- public ListIterator<OrmVirtualJoinColumn> specifiedInverseJoinColumns() {
- return this.getSpecifiedInverseJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getSpecifiedInverseJoinColumns() {
- return new LiveCloneListIterable<OrmVirtualJoinColumn>(this.specifiedInverseJoinColumns);
- }
-
- public int specifiedInverseJoinColumnsSize() {
- return this.specifiedInverseJoinColumns.size();
- }
-
- public boolean hasSpecifiedInverseJoinColumns() {
- return this.specifiedInverseJoinColumns.size() != 0;
- }
-
- public OrmVirtualJoinColumn getSpecifiedInverseJoinColumn(int index) {
- return this.specifiedInverseJoinColumns.get(index);
- }
-
- protected void updateSpecifiedInverseJoinColumns() {
- ContextContainerTools.update(this.specifiedInverseJoinColumnContainerAdapter);
- }
-
- protected Iterable<JoinColumn> getOverriddenInverseJoinColumns() {
- return CollectionTools.iterable(this.getOverriddenTable().specifiedInverseJoinColumns());
- }
-
- protected void moveSpecifiedInverseJoinColumn(int index, OrmVirtualJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedInverseJoinColumns, SPECIFIED_INVERSE_JOIN_COLUMNS_LIST);
- }
-
- protected OrmVirtualJoinColumn addSpecifiedInverseJoinColumn(int index, JoinColumn joinColumn) {
- OrmVirtualJoinColumn virtualJoinColumn = this.buildInverseJoinColumn(joinColumn);
- this.addItemToList(index, virtualJoinColumn, this.specifiedInverseJoinColumns, SPECIFIED_INVERSE_JOIN_COLUMNS_LIST);
- return virtualJoinColumn;
- }
-
- protected void removeSpecifiedInverseJoinColumn(OrmVirtualJoinColumn joinColumn) {
- this.removeItemFromList(joinColumn, this.specifiedInverseJoinColumns, SPECIFIED_INVERSE_JOIN_COLUMNS_LIST);
- }
-
- /**
- * specified inverse join column container adapter
- */
- protected class SpecifiedInverseJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualJoinColumn, JoinColumn>
- {
- public Iterable<OrmVirtualJoinColumn> getContextElements() {
- return GenericOrmVirtualJoinTable.this.getSpecifiedInverseJoinColumns();
- }
- public Iterable<JoinColumn> getResourceElements() {
- return GenericOrmVirtualJoinTable.this.getOverriddenInverseJoinColumns();
- }
- public JoinColumn getResourceElement(OrmVirtualJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, OrmVirtualJoinColumn element) {
- GenericOrmVirtualJoinTable.this.moveSpecifiedInverseJoinColumn(index, element);
- }
- public void addContextElement(int index, JoinColumn element) {
- GenericOrmVirtualJoinTable.this.addSpecifiedInverseJoinColumn(index, element);
- }
- public void removeContextElement(OrmVirtualJoinColumn element) {
- GenericOrmVirtualJoinTable.this.removeSpecifiedInverseJoinColumn(element);
- }
- }
-
-
- // ********** default inverse join column **********
-
- public OrmVirtualJoinColumn getDefaultInverseJoinColumn() {
- return this.defaultInverseJoinColumn;
- }
-
- protected void setDefaultInverseJoinColumn(OrmVirtualJoinColumn joinColumn) {
- OrmVirtualJoinColumn old = this.defaultInverseJoinColumn;
- this.defaultInverseJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_INVERSE_JOIN_COLUMN, old, joinColumn);
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getDefaultInverseJoinColumns() {
- return (this.defaultInverseJoinColumn != null) ?
- new SingleElementListIterable<OrmVirtualJoinColumn>(this.defaultInverseJoinColumn) :
- EmptyListIterable.<OrmVirtualJoinColumn>instance();
- }
-
- protected int getDefaultInverseJoinColumnsSize() {
- return (this.defaultInverseJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultInverseJoinColumn() {
- if (this.buildsDefaultInverseJoinColumn()) {
- if (this.defaultInverseJoinColumn == null) {
- this.setDefaultInverseJoinColumn(this.buildInverseJoinColumn(this.getOverriddenTable().getDefaultInverseJoinColumn()));
- } else {
- this.defaultInverseJoinColumn.update();
- }
- } else {
- this.setDefaultInverseJoinColumn(null);
- }
- }
-
- protected boolean buildsDefaultInverseJoinColumn() {
- return ! this.hasSpecifiedInverseJoinColumns();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmVirtualJoinTableRelationshipStrategy getParent() {
- return (OrmVirtualJoinTableRelationshipStrategy) super.getParent();
- }
-
- protected OrmVirtualJoinTableRelationshipStrategy getJoinStrategy() {
- return this.getParent();
- }
-
- @Override
- protected ReadOnlyJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
- protected ReadOnlyJoinColumn.Owner buildInverseJoinColumnOwner() {
- return new InverseJoinColumnOwner();
- }
-
- protected OrmVirtualJoinColumn buildInverseJoinColumn(JoinColumn joinColumn) {
- return this.buildJoinColumn(this.inverseJoinColumnOwner, joinColumn);
- }
-
- @Override
- protected String buildDefaultName() {
- return this.getJoinStrategy().getJoinTableDefaultName();
- }
-
- public RelationshipMapping getRelationshipMapping() {
- return this.getJoinStrategy().getRelationship().getMapping();
- }
-
- public PersistentAttribute getPersistentAttribute() {
- return this.getRelationshipMapping().getPersistentAttribute();
- }
-
-
- // ********** join column owners **********
-
- /**
- * just a little common behavior
- */
- protected abstract class AbstractJoinColumnOwner
- implements ReadOnlyJoinColumn.Owner
- {
- protected AbstractJoinColumnOwner() {
- super();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getRelationship().getTypeMapping();
- }
-
- /**
- * by default, the join column is, obviously, in the join table;
- * not sure whether it can be anywhere else...
- */
- public String getDefaultTableName() {
- return GenericOrmVirtualJoinTable.this.getName();
- }
-
- /**
- * @see MappingTools#buildJoinColumnDefaultName(org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn, org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn.Owner)
- */
- public String getDefaultColumnName() {
- throw new UnsupportedOperationException();
- }
-
- protected OrmVirtualRelationship getRelationship() {
- return GenericOrmVirtualJoinTable.this.getJoinStrategy().getRelationship();
- }
- }
-
-
- /**
- * owner for "back-pointer" join columns;
- * these point at the source/owning entity
- */
- protected class JoinColumnOwner
- extends AbstractJoinColumnOwner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- public Entity getRelationshipTarget() {
- return this.getRelationship().getEntity();
- }
-
- public String getAttributeName() {
- return MappingTools.getTargetAttributeName(GenericOrmVirtualJoinTable.this.getRelationshipMapping());
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericOrmVirtualJoinTable.this.defaultJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericOrmVirtualJoinTable.this.joinColumnsSize();
- }
- }
-
-
- /**
- * owner for "forward-pointer" join columns;
- * these point at the target/inverse entity
- */
- protected class InverseJoinColumnOwner
- extends AbstractJoinColumnOwner
- {
- protected InverseJoinColumnOwner() {
- super();
- }
-
- public Entity getRelationshipTarget() {
- RelationshipMapping relationshipMapping = GenericOrmVirtualJoinTable.this.getRelationshipMapping();
- return (relationshipMapping == null) ? null : relationshipMapping.getResolvedTargetEntity();
- }
-
- public String getAttributeName() {
- RelationshipMapping relationshipMapping = GenericOrmVirtualJoinTable.this.getRelationshipMapping();
- return (relationshipMapping == null) ? null : relationshipMapping.getName();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericOrmVirtualJoinTable.this.defaultInverseJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericOrmVirtualJoinTable.this.inverseJoinColumnsSize();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.java
deleted file mode 100644
index b341965c0e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.JoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.JoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.Relationship;
-import org.eclipse.jpt.jpa.core.context.RelationshipMapping;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAssociationOverrideContainer;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyAssociationOverride;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumnRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualJoinColumnRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualOverrideRelationship;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-
-public class GenericOrmVirtualOverrideJoinColumnRelationshipStrategy
- extends AbstractOrmXmlContextNode
- implements OrmVirtualJoinColumnRelationshipStrategy
-{
- protected final Vector<OrmVirtualJoinColumn> specifiedJoinColumns = new Vector<OrmVirtualJoinColumn>();
- protected final SpecifiedJoinColumnContainerAdapter specifiedJoinColumnContainerAdapter;
- protected final ReadOnlyJoinColumn.Owner joinColumnOwner;
-
- protected OrmVirtualJoinColumn defaultJoinColumn;
-
-
- public GenericOrmVirtualOverrideJoinColumnRelationshipStrategy(OrmVirtualJoinColumnRelationship parent) {
- super(parent);
- this.specifiedJoinColumnContainerAdapter = this.buildSpecifiedJoinColumnContainerAdapter();
- this.joinColumnOwner = this.buildJoinColumnOwner();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateSpecifiedJoinColumns();
- this.updateDefaultJoinColumn();
- }
-
-
- // ********** join columns **********
-
- public ListIterator<OrmVirtualJoinColumn> joinColumns() {
- return this.getJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getJoinColumns() {
- return this.hasSpecifiedJoinColumns() ? this.getSpecifiedJoinColumns() : this.getDefaultJoinColumns();
- }
-
- public int joinColumnsSize() {
- return this.hasSpecifiedJoinColumns() ? this.specifiedJoinColumnsSize() : this.getDefaultJoinColumnsSize();
- }
-
-
- // ********** specified join columns **********
-
- public ListIterator<OrmVirtualJoinColumn> specifiedJoinColumns() {
- return this.getSpecifiedJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getSpecifiedJoinColumns() {
- return new LiveCloneListIterable<OrmVirtualJoinColumn>(this.specifiedJoinColumns);
- }
-
- public int specifiedJoinColumnsSize() {
- return this.specifiedJoinColumns.size();
- }
-
- public boolean hasSpecifiedJoinColumns() {
- return this.specifiedJoinColumns.size() != 0;
- }
-
- public OrmVirtualJoinColumn getSpecifiedJoinColumn(int index) {
- return this.specifiedJoinColumns.get(index);
- }
-
- protected void updateSpecifiedJoinColumns() {
- ContextContainerTools.update(this.specifiedJoinColumnContainerAdapter);
- }
-
- protected Iterable<JoinColumn> getOverriddenSpecifiedJoinColumns() {
- JoinColumnRelationshipStrategy overriddenStrategy = this.getOverriddenStrategy();
- return (overriddenStrategy == null) ?
- EmptyIterable.<JoinColumn>instance() :
- CollectionTools.iterable(overriddenStrategy.specifiedJoinColumns());
- }
-
- protected void moveSpecifiedJoinColumn(int index, OrmVirtualJoinColumn joinColumn) {
- this.moveItemInList(index, joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected OrmVirtualJoinColumn addSpecifiedJoinColumn(int index, JoinColumn joinColumn) {
- OrmVirtualJoinColumn virtualJoinColumn = this.buildJoinColumn(joinColumn);
- this.addItemToList(index, virtualJoinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- return virtualJoinColumn;
- }
-
- protected void removeSpecifiedJoinColumn(OrmVirtualJoinColumn joinColumn) {
- this.removeItemFromList(joinColumn, this.specifiedJoinColumns, SPECIFIED_JOIN_COLUMNS_LIST);
- }
-
- protected SpecifiedJoinColumnContainerAdapter buildSpecifiedJoinColumnContainerAdapter() {
- return new SpecifiedJoinColumnContainerAdapter();
- }
-
- /**
- * specified join column container adapter
- */
- protected class SpecifiedJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualJoinColumn, JoinColumn>
- {
- public Iterable<OrmVirtualJoinColumn> getContextElements() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.getSpecifiedJoinColumns();
- }
- public Iterable<JoinColumn> getResourceElements() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.getOverriddenSpecifiedJoinColumns();
- }
- public JoinColumn getResourceElement(OrmVirtualJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, OrmVirtualJoinColumn element) {
- GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.moveSpecifiedJoinColumn(index, element);
- }
- public void addContextElement(int index, JoinColumn resourceElement) {
- GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.addSpecifiedJoinColumn(index, resourceElement);
- }
- public void removeContextElement(OrmVirtualJoinColumn element) {
- GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.removeSpecifiedJoinColumn(element);
- }
- }
-
- protected ReadOnlyJoinColumn.Owner buildJoinColumnOwner() {
- return new JoinColumnOwner();
- }
-
-
- // ********** default join column **********
-
- public OrmVirtualJoinColumn getDefaultJoinColumn() {
- return this.defaultJoinColumn;
- }
-
- protected void setDefaultJoinColumn(OrmVirtualJoinColumn joinColumn) {
- OrmVirtualJoinColumn old = this.defaultJoinColumn;
- this.defaultJoinColumn = joinColumn;
- this.firePropertyChanged(DEFAULT_JOIN_COLUMN_PROPERTY, old, joinColumn);
- }
-
- protected ListIterable<OrmVirtualJoinColumn> getDefaultJoinColumns() {
- return (this.defaultJoinColumn != null) ?
- new SingleElementListIterable<OrmVirtualJoinColumn>(this.defaultJoinColumn) :
- EmptyListIterable.<OrmVirtualJoinColumn>instance();
- }
-
- protected int getDefaultJoinColumnsSize() {
- return (this.defaultJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultJoinColumn() {
- JoinColumn overriddenDefaultJoinColumn = this.getOverriddenDefaultJoinColumn();
- if (overriddenDefaultJoinColumn == null) {
- if (this.defaultJoinColumn != null) {
- this.setDefaultJoinColumn(null);
- }
- } else {
- if ((this.defaultJoinColumn != null) && (this.defaultJoinColumn.getOverriddenColumn() == overriddenDefaultJoinColumn)) {
- this.defaultJoinColumn.update();
- } else {
- this.setDefaultJoinColumn(this.buildJoinColumn(overriddenDefaultJoinColumn));
- }
- }
- }
-
- protected JoinColumn getOverriddenDefaultJoinColumn() {
- JoinColumnRelationshipStrategy overriddenStrategy = this.getOverriddenStrategy();
- return (overriddenStrategy == null) ? null : overriddenStrategy.getDefaultJoinColumn();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmVirtualJoinColumnRelationship getParent() {
- return (OrmVirtualJoinColumnRelationship) super.getParent();
- }
-
- public OrmVirtualJoinColumnRelationship getRelationship() {
- return this.getParent();
- }
-
- protected JoinColumnRelationshipStrategy getOverriddenStrategy() {
- JoinColumnRelationship relationship = this.getOverriddenJoinColumnRelationship();
- return (relationship == null) ? null : relationship.getJoinColumnStrategy();
- }
-
- protected JoinColumnRelationship getOverriddenJoinColumnRelationship() {
- Relationship relationship = this.resolveOverriddenRelationship();
- return (relationship instanceof JoinColumnRelationship) ? (JoinColumnRelationship) relationship : null;
- }
-
- protected Relationship resolveOverriddenRelationship() {
- return this.getRelationship().resolveOverriddenRelationship();
- }
-
- public boolean isTargetForeignKey() {
- RelationshipMapping relationshipMapping = this.getRelationshipMapping();
- return (relationshipMapping != null) &&
- relationshipMapping.getRelationship().isTargetForeignKey();
- }
-
- public TypeMapping getRelationshipSource() {
- return this.isTargetForeignKey() ?
- this.getRelationshipMapping().getResolvedTargetEntity() :
- this.getAssociationOverrideContainer().getTypeMapping();
- }
-
- public TypeMapping getRelationshipTarget() {
- return this.isTargetForeignKey() ?
- this.getAssociationOverrideContainer().getTypeMapping() :
- this.getRelationshipMappingTargetEntity();
- }
-
- protected TypeMapping getRelationshipMappingTargetEntity() {
- RelationshipMapping mapping = this.getRelationshipMapping();
- return (mapping == null) ? null : mapping.getResolvedTargetEntity();
- }
-
- protected Entity getRelationshipTargetEntity() {
- TypeMapping target = this.getRelationshipTarget();
- return (target instanceof Entity) ? (Entity) target : null;
- }
-
- protected RelationshipMapping getRelationshipMapping() {
- return this.getAssociationOverride().getMapping();
- }
-
- protected OrmReadOnlyAssociationOverride getAssociationOverride() {
- return ((OrmVirtualOverrideRelationship) this.getRelationship()).getAssociationOverride();
- }
-
- protected OrmAssociationOverrideContainer getAssociationOverrideContainer() {
- return this.getAssociationOverride().getContainer();
- }
-
- public String getTableName() {
- return this.isTargetForeignKey() ?
- this.getSourceTableName() :
- this.getAssociationOverrideContainer().getDefaultTableName();
- }
-
- protected String getSourceTableName() {
- TypeMapping typeMapping = this.getRelationshipSource();
- return (typeMapping == null) ? null : typeMapping.getPrimaryTableName();
- }
-
- public TextRange getValidationTextRange() {
- return this.getRelationship().getValidationTextRange();
- }
-
- protected String getAttributeName() {
- return this.getAssociationOverride().getName();
- }
-
- protected OrmVirtualJoinColumn buildJoinColumn(JoinColumn overriddenJoinColumn) {
- return this.getContextNodeFactory().buildOrmVirtualJoinColumn(this, this.joinColumnOwner, overriddenJoinColumn);
- }
-
-
- // ********** join column owner **********
-
- protected class JoinColumnOwner
- implements ReadOnlyJoinColumn.Owner
- {
- protected JoinColumnOwner() {
- super();
- }
-
- public String getDefaultTableName() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.getTableName();
- }
-
- public String getDefaultColumnName() {
- //built in MappingTools.buildJoinColumnDefaultName()
- return null;
- }
-
- public String getAttributeName() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.getAttributeName();
- }
-
- public TypeMapping getTypeMapping() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.getRelationshipSource();
- }
-
- public Entity getRelationshipTarget() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.getRelationshipTargetEntity();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return false;
- }
-
- public int joinColumnsSize() {
- return GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.this.joinColumnsSize();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualSecondaryTable.java
deleted file mode 100644
index 8cb015eeb6..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualSecondaryTable.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.ListIterator;
-import java.util.Vector;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementListIterable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseJoinColumn;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.java.JavaSecondaryTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualSecondaryTable;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-
-/**
- * <code>orm.xml</code> virtual secondary table
- */
-public class GenericOrmVirtualSecondaryTable
- extends AbstractOrmVirtualTable<JavaSecondaryTable>
- implements OrmVirtualSecondaryTable
-{
- protected final JavaSecondaryTable overriddenTable;
-
- protected final Vector<OrmVirtualPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns = new Vector<OrmVirtualPrimaryKeyJoinColumn>();
- protected final SpecifiedPrimaryKeyJoinColumnContainerAdapter specifiedPrimaryKeyJoinColumnContainerAdapter = new SpecifiedPrimaryKeyJoinColumnContainerAdapter();
- protected final ReadOnlyBaseJoinColumn.Owner primaryKeyJoinColumnOwner;
-
- protected OrmVirtualPrimaryKeyJoinColumn defaultPrimaryKeyJoinColumn;
-
-
- public GenericOrmVirtualSecondaryTable(OrmEntity parent, JavaSecondaryTable overriddenTable) {
- super(parent);
- this.overriddenTable = overriddenTable;
- this.primaryKeyJoinColumnOwner = this.buildPrimaryKeyJoinColumnOwner();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void update() {
- super.update();
- this.updateSpecifiedPrimaryKeyJoinColumns();
- this.updateDefaultPrimaryKeyJoinColumn();
- }
-
-
- // ********** table **********
-
- @Override
- public JavaSecondaryTable getOverriddenTable() {
- return this.overriddenTable;
- }
-
-
- // ********** primary key join columns **********
-
- public ListIterator<OrmVirtualPrimaryKeyJoinColumn> primaryKeyJoinColumns() {
- return this.getPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
- return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.getSpecifiedPrimaryKeyJoinColumns() : this.getDefaultPrimaryKeyJoinColumns();
- }
-
- public int primaryKeyJoinColumnsSize() {
- return this.hasSpecifiedPrimaryKeyJoinColumns() ? this.specifiedPrimaryKeyJoinColumnsSize() : this.getDefaultPrimaryKeyJoinColumnsSize();
- }
-
-
- // ********** specified primary key join columns **********
-
- public ListIterator<OrmVirtualPrimaryKeyJoinColumn> specifiedPrimaryKeyJoinColumns() {
- return this.getSpecifiedPrimaryKeyJoinColumns().iterator();
- }
-
- protected ListIterable<OrmVirtualPrimaryKeyJoinColumn> getSpecifiedPrimaryKeyJoinColumns() {
- return new LiveCloneListIterable<OrmVirtualPrimaryKeyJoinColumn>(this.specifiedPrimaryKeyJoinColumns);
- }
-
- public int specifiedPrimaryKeyJoinColumnsSize() {
- return this.specifiedPrimaryKeyJoinColumns.size();
- }
-
- public boolean hasSpecifiedPrimaryKeyJoinColumns() {
- return this.specifiedPrimaryKeyJoinColumns.size() != 0;
- }
-
- public OrmVirtualPrimaryKeyJoinColumn getSpecifiedPrimaryKeyJoinColumn(int index) {
- return this.specifiedPrimaryKeyJoinColumns.get(index);
- }
-
- protected void updateSpecifiedPrimaryKeyJoinColumns() {
- ContextContainerTools.update(this.specifiedPrimaryKeyJoinColumnContainerAdapter);
- }
-
- protected Iterable<JavaPrimaryKeyJoinColumn> getOverriddenPrimaryKeyJoinColumns() {
- return CollectionTools.iterable(this.getOverriddenTable().specifiedPrimaryKeyJoinColumns());
- }
-
- protected void moveSpecifiedPrimaryKeyJoinColumn(int index, OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- this.moveItemInList(index, pkJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- protected OrmVirtualPrimaryKeyJoinColumn addSpecifiedPrimaryKeyJoinColumn(int index, JavaPrimaryKeyJoinColumn javaColumn) {
- OrmVirtualPrimaryKeyJoinColumn virtualColumn = this.buildPrimaryKeyJoinColumn(javaColumn);
- this.addItemToList(index, virtualColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- return virtualColumn;
- }
-
- protected void removeSpecifiedPrimaryKeyJoinColumn(OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- this.removeItemFromList(pkJoinColumn, this.specifiedPrimaryKeyJoinColumns, SPECIFIED_PRIMARY_KEY_JOIN_COLUMNS_LIST);
- }
-
- /**
- * specified primary key join column container adapter
- */
- protected class SpecifiedPrimaryKeyJoinColumnContainerAdapter
- implements ContextContainerTools.Adapter<OrmVirtualPrimaryKeyJoinColumn, JavaPrimaryKeyJoinColumn>
- {
- public Iterable<OrmVirtualPrimaryKeyJoinColumn> getContextElements() {
- return GenericOrmVirtualSecondaryTable.this.getSpecifiedPrimaryKeyJoinColumns();
- }
- public Iterable<JavaPrimaryKeyJoinColumn> getResourceElements() {
- return GenericOrmVirtualSecondaryTable.this.getOverriddenPrimaryKeyJoinColumns();
- }
- public JavaPrimaryKeyJoinColumn getResourceElement(OrmVirtualPrimaryKeyJoinColumn contextElement) {
- return contextElement.getOverriddenColumn();
- }
- public void moveContextElement(int index, OrmVirtualPrimaryKeyJoinColumn element) {
- GenericOrmVirtualSecondaryTable.this.moveSpecifiedPrimaryKeyJoinColumn(index, element);
- }
- public void addContextElement(int index, JavaPrimaryKeyJoinColumn element) {
- GenericOrmVirtualSecondaryTable.this.addSpecifiedPrimaryKeyJoinColumn(index, element);
- }
- public void removeContextElement(OrmVirtualPrimaryKeyJoinColumn element) {
- GenericOrmVirtualSecondaryTable.this.removeSpecifiedPrimaryKeyJoinColumn(element);
- }
- }
-
-
- // ********** default primary key join column **********
-
- public OrmVirtualPrimaryKeyJoinColumn getDefaultPrimaryKeyJoinColumn() {
- return this.defaultPrimaryKeyJoinColumn;
- }
-
- protected void setDefaultPrimaryKeyJoinColumn(OrmVirtualPrimaryKeyJoinColumn pkJoinColumn) {
- OrmVirtualPrimaryKeyJoinColumn old = this.defaultPrimaryKeyJoinColumn;
- this.defaultPrimaryKeyJoinColumn = pkJoinColumn;
- this.firePropertyChanged(DEFAULT_PRIMARY_KEY_JOIN_COLUMN, old, pkJoinColumn);
- }
-
- protected ListIterable<OrmVirtualPrimaryKeyJoinColumn> getDefaultPrimaryKeyJoinColumns() {
- return (this.defaultPrimaryKeyJoinColumn != null) ?
- new SingleElementListIterable<OrmVirtualPrimaryKeyJoinColumn>(this.defaultPrimaryKeyJoinColumn) :
- EmptyListIterable.<OrmVirtualPrimaryKeyJoinColumn>instance();
- }
-
- protected int getDefaultPrimaryKeyJoinColumnsSize() {
- return (this.defaultPrimaryKeyJoinColumn == null) ? 0 : 1;
- }
-
- protected void updateDefaultPrimaryKeyJoinColumn() {
- JavaPrimaryKeyJoinColumn overriddenColumn = this.getOverriddenTable().getDefaultPrimaryKeyJoinColumn();
- if (overriddenColumn == null) {
- this.setDefaultPrimaryKeyJoinColumn(null);
- } else {
- if ((this.defaultPrimaryKeyJoinColumn != null) && (this.defaultPrimaryKeyJoinColumn.getOverriddenColumn() == overriddenColumn)) {
- this.defaultPrimaryKeyJoinColumn.update();
- } else {
- this.setDefaultPrimaryKeyJoinColumn(this.buildPrimaryKeyJoinColumn(overriddenColumn));
- }
- }
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmEntity getParent() {
- return (OrmEntity) super.getParent();
- }
-
- protected OrmEntity getEntity() {
- return this.getParent();
- }
-
- public boolean isVirtual() {
- return true;
- }
-
- protected ReadOnlyBaseJoinColumn.Owner buildPrimaryKeyJoinColumnOwner() {
- return new PrimaryKeyJoinColumnOwner();
- }
-
- protected OrmVirtualPrimaryKeyJoinColumn buildPrimaryKeyJoinColumn(JavaPrimaryKeyJoinColumn javaColumn) {
- return this.getContextNodeFactory().buildOrmVirtualPrimaryKeyJoinColumn(this, this.primaryKeyJoinColumnOwner, javaColumn);
- }
-
-
- // ********** defaults **********
-
- /**
- * a secondary table doesn't have a default name
- */
- @Override
- protected String buildDefaultName() {
- return null;
- }
-
- @Override
- protected String buildDefaultSchema() {
- return this.getContextDefaultSchema();
- }
-
- @Override
- protected String buildDefaultCatalog() {
- return this.getContextDefaultCatalog();
- }
-
-
- // ********** primary key join column owner **********
-
- protected class PrimaryKeyJoinColumnOwner
- implements ReadOnlyBaseJoinColumn.Owner
- {
- protected OrmEntity getEntity() {
- return GenericOrmVirtualSecondaryTable.this.getEntity();
- }
-
- public TypeMapping getTypeMapping() {
- return this.getEntity();
- }
-
- public String getDefaultTableName() {
- return GenericOrmVirtualSecondaryTable.this.getName();
- }
-
- public String getDefaultColumnName() {
- if (this.joinColumnsSize() != 1) {
- return null;
- }
- Entity parentEntity = this.getEntity().getParentEntity();
- return (parentEntity != null) ?
- parentEntity.getPrimaryKeyColumnName() :
- this.getEntity().getPrimaryKeyColumnName();
- }
-
- public boolean joinColumnIsDefault(ReadOnlyBaseJoinColumn joinColumn) {
- return GenericOrmVirtualSecondaryTable.this.defaultPrimaryKeyJoinColumn == joinColumn;
- }
-
- public int joinColumnsSize() {
- return GenericOrmVirtualSecondaryTable.this.primaryKeyJoinColumnsSize();
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java
deleted file mode 100644
index 4711bbc93a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmXmlContextNodeFactory.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-
-public class GenericOrmXmlContextNodeFactory
- extends AbstractOrmXmlContextNodeFactory
-{
- // nothing
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/NullOrmJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/NullOrmJoinTableRelationshipStrategy.java
deleted file mode 100644
index 2e5b2ad2af..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/NullOrmJoinTableRelationshipStrategy.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.JoinColumn;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationship;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinTableRelationshipStrategy;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinTable;
-import org.eclipse.jpt.jpa.db.Table;
-
-public class NullOrmJoinTableRelationshipStrategy
- extends AbstractOrmXmlContextNode
- implements OrmJoinTableRelationshipStrategy
-{
- public NullOrmJoinTableRelationshipStrategy(OrmJoinTableRelationship parent) {
- super(parent);
- }
-
-
- // ********** join table **********
-
- public OrmJoinTable getJoinTable() {
- return null;
- }
-
-
- // ********** XML join table **********
-
- public XmlJoinTable getXmlJoinTable() {
- return null;
- }
-
- public XmlJoinTable buildXmlJoinTable() {
- throw new UnsupportedOperationException();
- }
-
- public void removeXmlJoinTable() {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** validation **********
-
- public TextRange getValidationTextRange() {
- return this.getRelationship().getValidationTextRange();
- }
-
- public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- throw new UnsupportedOperationException();
- }
-
- public JptValidator buildJoinTableInverseJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmJoinTableRelationship getParent() {
- return (OrmJoinTableRelationship) super.getParent();
- }
-
- public OrmJoinTableRelationship getRelationship() {
- return this.getParent();
- }
-
- public void initializeFrom(ReadOnlyJoinTableRelationshipStrategy oldStrategy) {
- // NOP
- }
-
- public void initializeFromVirtual(ReadOnlyJoinTableRelationshipStrategy virtualStrategy) {
- // NOP
- }
-
- public String getTableName() {
- return null;
- }
-
- public Table resolveDbTable(String tableName) {
- return null;
- }
-
- public boolean tableNameIsInvalid(String tableName) {
- return true;
- }
-
- public String getColumnTableNotValidDescription() {
- return null;
- }
-
- public String getJoinTableDefaultName() {
- return null;
- }
-
- public void addStrategy() {
- // NOP
- }
-
- public void removeStrategy() {
- // NOP
- }
-
- public boolean isOverridable() {
- return false;
- }
-
- public boolean validatesAgainstDatabase() {
- return false;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBaseColumnTextRangeResolver.java
deleted file mode 100644
index a26ed24f13..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBaseColumn;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBasicMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBasicMappingDefinition.java
deleted file mode 100644
index 503127b997..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmBasicMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmBasicMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlBasic;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddableDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddableDefinition.java
deleted file mode 100644
index 44b9ef4904..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEmbeddable;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddable;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java
deleted file mode 100644
index 5f73e84734..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedIdMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbeddedId;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedMappingDefinition.java
deleted file mode 100644
index 1f05a77656..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEmbeddedMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEmbedded;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityDefinition.java
deleted file mode 100644
index ef4931f35b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlEntity;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityTextRangeResolver.java
deleted file mode 100644
index af7d7c03c4..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmEntityTextRangeResolver.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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmEntity;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.EntityTextRangeResolver;
-
-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.getAttributeNamed(attributeName).getValidationTextRange();
- }
-
- protected OrmReadOnlyPersistentAttribute getAttributeNamed(String attributeName) {
- return this.entity.getPersistentType().getAttributeNamed(attributeName);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmIdMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmIdMappingDefinition.java
deleted file mode 100644
index e20a2a6f45..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmIdMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlId;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java
deleted file mode 100644
index 94c60a0300..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmJoinColumnTextRangeResolver.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Oracle.
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.context.BaseColumnTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.context.JoinColumnTextRangeResolver;
-
-public class OrmJoinColumnTextRangeResolver
- extends OrmNamedColumnTextRangeResolver
- implements 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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToManyMappingDefinition.java
deleted file mode 100644
index f3eac3d4cb..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToManyMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToMany;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToOneMappingDefinition.java
deleted file mode 100644
index a8a8a41efc..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmManyToOneMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlManyToOne;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassDefinition.java
deleted file mode 100644
index e0328eb994..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlMappedSuperclass;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTypeMapping;
-import org.eclipse.jpt.jpa.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.java
deleted file mode 100644
index 03c139a93e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmMappedSuperclassTextRangeResolver.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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmMappedSuperclass;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.PrimaryKeyTextRangeResolver;
-
-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.getAttributeNamed(attributeName).getValidationTextRange();
- }
-
- protected OrmReadOnlyPersistentAttribute getAttributeNamed(String attributeName) {
- return this.mappedSuperclass.getPersistentType().getAttributeNamed(attributeName);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmNamedColumnTextRangeResolver.java
deleted file mode 100644
index 37a19aec80..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmNamedColumn;
-import org.eclipse.jpt.jpa.core.internal.context.NamedColumnTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToManyMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToManyMappingDefinition.java
deleted file mode 100644
index ce0214dcd2..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToManyMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToMany;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToOneMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToOneMappingDefinition.java
deleted file mode 100644
index 722738c39c..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOneToOneMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlOneToOne;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOverrideTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmOverrideTextRangeResolver.java
deleted file mode 100644
index 0c1d8ee5b5..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmOverride;
-import org.eclipse.jpt.jpa.core.internal.context.OverrideTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPersistentAttributeTextRangeResolver.java
deleted file mode 100644
index fe9b812e24..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmPrimaryKeyJoinColumnTextRangeResolver.java
deleted file mode 100644
index 6fdeb4b124..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPrimaryKeyJoinColumn;
-import org.eclipse.jpt.jpa.core.internal.context.BaseJoinColumnTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTableTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTableTextRangeResolver.java
deleted file mode 100644
index 3a86a729c1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTableTextRangeResolver.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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTable;
-import org.eclipse.jpt.jpa.core.internal.context.TableTextRangeResolver;
-
-public class OrmTableTextRangeResolver
- implements TableTextRangeResolver
-{
- protected final OrmTable ormTable;
-
- public OrmTableTextRangeResolver(OrmTable ormTable) {
- this.ormTable = ormTable;
- }
-
- protected OrmTable 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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTransientMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTransientMappingDefinition.java
deleted file mode 100644
index 2f5e612f3a..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTransientMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlTransient;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmTypeMappingTextRangeResolver.java
deleted file mode 100644
index 3a769597e7..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.orm;
-
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.TypeMappingTextRangeResolver;
-
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmVersionMappingDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmVersionMappingDefinition.java
deleted file mode 100644
index cf82474d55..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/OrmVersionMappingDefinition.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2009 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.MappingKeys;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlVersion;
-import org.eclipse.jpt.jpa.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);
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
deleted file mode 100644
index 01eaa01a78..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/SpecifiedOrmPersistentAttribute.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.List;
-import org.eclipse.jdt.core.IPackageFragment;
-import org.eclipse.jdt.core.IType;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.CollectionMapping;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmStructureNodes;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.context.JptValidator;
-import org.eclipse.jpt.jpa.core.internal.context.PersistentAttributeTextRangeResolver;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <em>specified</em> <code>orm.xml</code> persistent attribute
- */
-public abstract class SpecifiedOrmPersistentAttribute
- extends AbstractOrmXmlContextNode
- implements OrmPersistentAttribute2_0
-{
- protected OrmAttributeMapping mapping; // never null
-
- /**
- * This will point to one of the following:<ul>
- * <li>an existing Java attribute (taken from the appropriate Java type)
- * <li>{@link #cachedJavaPersistentAttribute} if there is no such Java
- * attribute (i.e. the Java type's access type is different or it is
- * inherited from a non-persistent superclass)
- * <li><code>null</code> if there is no matching Java resource attribute
- * </ul>
- * @see #buildJavaPersistentAttribute()
- */
- protected JavaPersistentAttribute javaPersistentAttribute;
-
- /**
- * If present, this Java attribute's parent is the <code>orm.xml</code>
- * type.
- */
- protected JavaPersistentAttribute cachedJavaPersistentAttribute;
-
- protected AccessType defaultAccess;
-
-
- protected SpecifiedOrmPersistentAttribute(OrmPersistentType parent, XmlAttributeMapping xmlMapping) {
- super(parent);
- this.mapping = this.buildMapping(xmlMapping);
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.mapping.synchronizeWithResourceModel();
- if (this.cachedJavaPersistentAttribute != null) {
- this.cachedJavaPersistentAttribute.synchronizeWithResourceModel();
- }
- }
-
- @Override
- public void update() {
- super.update();
- this.setDefaultAccess(this.buildDefaultAccess());
- this.setJavaPersistentAttribute(this.buildJavaPersistentAttribute());
- this.mapping.update();
- if (this.cachedJavaPersistentAttribute != null) {
- this.cachedJavaPersistentAttribute.update();
- }
- }
-
-
- // ********** mapping **********
-
- public OrmAttributeMapping getMapping() {
- return this.mapping;
- }
-
- public String getMappingKey() {
- return this.mapping.getKey();
- }
-
- public OrmAttributeMapping setMappingKey(String mappingKey) {
- if (this.valuesAreDifferent(this.getMappingKey(), mappingKey)) {
- this.setMappingKey_(mappingKey);
- }
- return this.mapping;
- }
-
- protected void setMappingKey_(String mappingKey) {
- OrmAttributeMappingDefinition mappingDefinition = this.getMappingFileDefinition().getAttributeMappingDefinition(mappingKey);
- XmlAttributeMapping xmlAttributeMapping = mappingDefinition.buildResourceMapping(this.getResourceNodeFactory());
- this.setMapping(this.buildMapping(xmlAttributeMapping));
- }
-
- protected final OrmAttributeMapping buildMapping(XmlAttributeMapping xmlAttributeMapping) {
- OrmAttributeMappingDefinition md = this.getMappingFileDefinition().getAttributeMappingDefinition(xmlAttributeMapping.getMappingKey());
- return md.buildContextMapping(this, xmlAttributeMapping, this.getContextNodeFactory());
- }
-
- protected void setMapping(OrmAttributeMapping mapping) {
- OrmAttributeMapping old = this.mapping;
- this.mapping = mapping;
- this.firePropertyChanged(MAPPING_PROPERTY, old, mapping);
- this.getOwningPersistentType().changeMapping(this, old, mapping);
- }
-
- /**
- * <code>orm.xml</code> attributes do not have a default mapping;
- * they are always specified.
- */
- public String getDefaultMappingKey() {
- return null;
- }
-
- protected XmlAttributeMapping getXmlAttributeMapping() {
- return this.mapping.getXmlAttributeMapping();
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.mapping.getName();
- }
-
- public void nameChanged(String oldName, String newName) {
- this.firePropertyChanged(NAME_PROPERTY, oldName, newName);
- }
-
-
- // ********** Java persistent attribute **********
-
- public JavaPersistentAttribute getJavaPersistentAttribute() {
- return this.javaPersistentAttribute;
- }
-
- public JavaPersistentAttribute resolveJavaPersistentAttribute() {
- return this.getJavaPersistentAttribute();
- }
-
- protected void setJavaPersistentAttribute(JavaPersistentAttribute javaPersistentAttribute) {
- JavaPersistentAttribute old = this.javaPersistentAttribute;
- this.javaPersistentAttribute = javaPersistentAttribute;
- this.firePropertyChanged(JAVA_PERSISTENT_ATTRIBUTE_PROPERTY, old, javaPersistentAttribute);
- }
-
- protected JavaPersistentAttribute buildJavaPersistentAttribute() {
- String name = this.getName();
- if (name == null) {
- return null;
- }
- JavaPersistentType javaType = this.getOwningPersistentTypeJavaType();
- if (javaType == null) {
- return null;
- }
-
- ReadOnlyPersistentAttribute pAttribute = javaType.resolveAttribute(name);
- JavaPersistentAttribute javaAttribute = (pAttribute == null) ? null : pAttribute.getJavaPersistentAttribute();
- if ((javaAttribute != null) && (javaAttribute.getAccess() == this.getAccess())) {
- // we only want to cache the Java persistent attribute if we built it
- this.cachedJavaPersistentAttribute = null;
- return javaAttribute;
- }
-
- // If 'javaAttribute' is null, it might exist in a superclass that
- // is not persistent. In that case we need to build it ourselves.
- // If 'javaAttribute' access is different, 'javaType' will not hold
- // a corresponding Java persistent attribute. So, again, we need
- // to build it ourselves.
- return this.getCachedJavaAttribute();
- }
-
- protected JavaPersistentAttribute getCachedJavaAttribute() {
- JavaResourcePersistentType javaResourceType = this.getOwningPersistentTypeJavaType().getResourcePersistentType();
- JavaResourcePersistentAttribute javaResourceAttribute = this.getJavaResourceAttribute(javaResourceType);
- if (javaResourceAttribute == null) {
- // nothing in the resource inheritance hierarchy matches our name *and* access type
- this.cachedJavaPersistentAttribute = null;
- } else {
- if ((this.cachedJavaPersistentAttribute == null) ||
- (this.cachedJavaPersistentAttribute.getResourcePersistentAttribute() != javaResourceAttribute)) {
- // cache is stale
- this.cachedJavaPersistentAttribute = this.buildJavaPersistentAttribute(javaResourceAttribute);
- }
- }
- return this.cachedJavaPersistentAttribute;
- }
-
- /**
- * Search the specified Java resource type for the resource attribute
- * corresponding to this <code>orm.xml</code> attribute (i.e. the Java
- * resource attribute with the same name). If the specified Java resource
- * type does not have a corresponding attribute, search up its inheritance
- * hierarchy.
- */
- protected JavaResourcePersistentAttribute getJavaResourceAttribute(JavaResourcePersistentType javaResourceType) {
- for (JavaResourcePersistentAttribute javaResourceAttribute : this.getJavaResourceAttributes(javaResourceType)) {
- if (javaResourceAttribute.getName().equals(this.getName())) {
- return javaResourceAttribute;
- }
- }
- // climb up inheritance hierarchy
- String superclassName = javaResourceType.getSuperclassQualifiedName();
- if (superclassName == null) {
- return null;
- }
- JavaResourcePersistentType superclass = this.getJpaProject().getJavaResourcePersistentType(superclassName);
- if (superclass == null) {
- return null;
- }
- // recurse
- return this.getJavaResourceAttribute(superclass);
- }
-
- /**
- * Return the resource attributes with compatible access types.
- */
- protected Iterable<JavaResourcePersistentAttribute> getJavaResourceAttributes(JavaResourcePersistentType javaResourceType) {
- return CollectionTools.iterable(javaResourceType.persistableAttributes(this.getAccess().getJavaAccessType()));
- }
-
- protected JavaPersistentAttribute buildJavaPersistentAttribute(JavaResourcePersistentAttribute javaResourceAttribute) {
- // pass in our parent orm persistent type as the parent to the cached Java attribute...
- return this.getJpaFactory().buildJavaPersistentAttribute(this.getOwningPersistentType(), javaResourceAttribute);
- }
-
- public JavaResourcePersistentAttribute getJavaResourcePersistentAttribute() {
- return (this.javaPersistentAttribute == null) ? null : this.javaPersistentAttribute.getResourcePersistentAttribute();
- }
-
-
- // ********** access **********
-
- /**
- * Subclasses determine the specified access.
- */
- public AccessType getAccess() {
- AccessType specifiedAccess = this.getSpecifiedAccess();
- return (specifiedAccess != null) ? specifiedAccess : this.defaultAccess;
- }
-
- public abstract AccessType getSpecifiedAccess();
-
- 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);
- }
-
- protected AccessType buildDefaultAccess() {
- return this.getOwningPersistentType().getAccess();
- }
-
-
- // ********** specified/default **********
-
- public boolean isVirtual() {
- return false;
- }
-
- public OrmReadOnlyPersistentAttribute convertToVirtual() {
- return this.getOwningPersistentType().convertAttributeToVirtual(this);
- }
-
- public OrmPersistentAttribute convertToSpecified() {
- throw new UnsupportedOperationException();
- }
-
- public OrmPersistentAttribute convertToSpecified(String mappingKey) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return OrmStructureNodes.PERSISTENT_ATTRIBUTE_ID;
- }
-
- public JpaStructureNode getStructureNode(int offset) {
- return this;
- }
-
- public boolean contains(int textOffset) {
- return this.mapping.contains(textOffset);
- }
-
- public TextRange getSelectionTextRange() {
- return this.mapping.getSelectionTextRange();
- }
-
- public void dispose() {
- // nothing to dispose
- }
-
-
- // ********** refactoring **********
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return this.mapping.createRenameTypeEdits(originalType, newName);
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return this.mapping.createMoveTypeEdits(originalType, newPackage);
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return this.mapping.createRenamePackageEdits(originalPackage, newName);
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- this.validateAttribute(messages, reporter);
- this.mapping.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.getOwningTypeMapping().getClass_()
- },
- this.mapping,
- this.mapping.getNameTextRange()
- )
- );
- } else {
- this.buildAttibuteValidator().validate(messages, reporter);
- }
- }
-
- protected PersistentAttributeTextRangeResolver buildTextRangeResolver() {
- return new OrmPersistentAttributeTextRangeResolver(this);
- }
-
- protected abstract JptValidator buildAttibuteValidator();
-
- public TextRange getValidationTextRange() {
- return this.mapping.getValidationTextRange();
- }
-
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJpaContainerDefinition().getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJpaContainerDefinition().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.mapping);
- }
-
- public String getMetamodelTypeName() {
- JavaPersistentAttribute2_0 javaAttribute = (JavaPersistentAttribute2_0) this.javaPersistentAttribute;
- return (javaAttribute != null) ?
- javaAttribute.getMetamodelTypeName() :
- MetamodelField.DEFAULT_TYPE_NAME;
- }
-
- protected JavaPersistentAttribute.JpaContainerDefinition getJpaContainerDefinition() {
- JavaPersistentAttribute2_0 javaAttribute = (JavaPersistentAttribute2_0) this.javaPersistentAttribute;
- return (javaAttribute != null) ?
- javaAttribute.getJpaContainerDefinition() :
- JavaPersistentAttribute.JpaContainerDefinition.Null.instance();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmPersistentType getParent() {
- return (OrmPersistentType) super.getParent();
- }
-
- public OrmPersistentType getOwningPersistentType() {
- return this.getParent();
- }
-
- protected JavaPersistentType getOwningPersistentTypeJavaType() {
- return this.getOwningPersistentType().getJavaPersistentType();
- }
-
- public OrmTypeMapping getOwningTypeMapping() {
- return this.getOwningPersistentType().getMapping();
- }
-
- public String getPrimaryKeyColumnName() {
- return this.mapping.getPrimaryKeyColumnName();
- }
-
- public String getTypeName() {
- return (this.javaPersistentAttribute == null) ? null : this.javaPersistentAttribute.getTypeName();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java
deleted file mode 100644
index e2d1c95a4f..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/VirtualOrmPersistentAttribute.java
+++ /dev/null
@@ -1,601 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.context.orm;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import org.eclipse.jdt.core.dom.CompilationUnit;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.MethodSignature;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator;
-import org.eclipse.jpt.common.utility.model.event.StateChangeEvent;
-import org.eclipse.jpt.common.utility.model.listener.StateChangeListener;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.java.JavaAttributeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.orm.OrmStructureNodes;
-import org.eclipse.jpt.jpa.core.context.orm.OrmTypeMapping;
-import org.eclipse.jpt.jpa.core.internal.resource.java.source.SourceNode;
-import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmReadOnlyPersistentAttribute2_0;
-import org.eclipse.jpt.jpa.core.resource.java.Annotation;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentMember;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.java.NestableAnnotation;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <em>virtual</em> <code>orm.xml</code> persistent attribute
- */
-public class VirtualOrmPersistentAttribute
- extends AbstractOrmXmlContextNode
- implements OrmReadOnlyPersistentAttribute2_0
-{
- protected final JavaResourcePersistentAttribute javaResourceAttribute;
-
- /**
- * This is an "annotated" Java persistent attribute whose state is
- * determined by its annotations (just like a "normal" Java attribute).
- * Its parent is an <code>orm.xml</code> persistent type. This is necessary
- * because the Java attribute's <em>context</em> is the <code>orm.xml</code>
- * type (e.g. the Java attribute's default table is the table set in the
- * <code>orm.xml</code> type, not the Java type).
- * The {@link #originalJavaAttributeListener} keeps this attribute in sync
- * with any changes made via the Java context model.
- */
- protected final JavaPersistentAttribute annotatedJavaAttribute;
-
- /**
- * This is the "original" Java persistent attribute corresponding to
- * {@link #javaResourceAttribute} from the Java context model.
- * If it is found (it can be <code>null</code> if the <code>orm.xml</code>
- * access type differs from the Java access type), we need to listen to it
- * for changes so we can refresh our "local" Java attributes (since the
- * Java resource model does not fire change events, and trigger a
- * <em>sync</em>, when it is modified by the Java context model - if there
- * is no Java context attribute, the Java resource model can only be
- * modified via source code editing and we will <em>sync</em> appropriately).
- */
- protected JavaPersistentAttribute originalJavaAttribute;
- protected StateChangeListener originalJavaAttributeListener;
-
- /**
- * This is a simulated "unannotated" Java persistent attribute. It is built
- * only if necessary (i.e. when the <code>orm.xml</code> persistent type
- * has been tagged <em>metadata complete</em>). Like
- * {@link #annotatedJavaAttribute}, its parent is an
- * <code>orm.xml</code> persistent type.
- * The {@link #originalJavaAttributeListener} keeps this attribute in sync
- * with any changes made via the Java context model.
- */
- protected JavaPersistentAttribute unannotatedJavaAttribute;
-
- protected JavaAttributeMapping mapping; // never null
-
-
- public VirtualOrmPersistentAttribute(OrmPersistentType parent, JavaResourcePersistentAttribute javaResourceAttribute) {
- super(parent);
- this.javaResourceAttribute = javaResourceAttribute;
- this.annotatedJavaAttribute = this.buildAnnotatedJavaAttribute();
- this.mapping = this.buildMapping();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncLocalJavaAttributes();
- // 'mapping' belongs to one of the "local" Java persistent attributes
- }
-
- @Override
- public void update() {
- super.update();
- this.updateOriginalJavaAttribute();
- this.updateLocalJavaAttributes();
- this.setMapping(this.buildMapping());
- }
-
-
- // ********** mapping **********
-
- public JavaAttributeMapping getMapping() {
- return this.mapping;
- }
-
- protected void setMapping(JavaAttributeMapping mapping) {
- JavaAttributeMapping old = this.mapping;
- this.mapping = mapping;
- this.firePropertyChanged(DEFAULT_MAPPING_KEY_PROPERTY, old, mapping);
- }
-
- protected JavaAttributeMapping buildMapping() {
- return this.getJavaPersistentAttribute().getMapping();
- }
-
- public String getMappingKey() {
- return this.mapping.getKey();
- }
-
- public String getDefaultMappingKey() {
- return this.mapping.getKey();
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.mapping.getName();
- }
-
-
- // ********** Java persistent attribute **********
-
- public JavaPersistentAttribute getJavaPersistentAttribute() {
- return this.getOwningTypeMapping().isMetadataComplete() ?
- this.getUnannotatedJavaAttribute() :
- this.annotatedJavaAttribute;
- }
-
- public JavaPersistentAttribute resolveJavaPersistentAttribute() {
- JavaPersistentType javaType = this.getOwningPersistentType().getJavaPersistentType();
- return (javaType == null) ? null : javaType.getAttributeFor(this.javaResourceAttribute);
- }
-
- protected JavaPersistentAttribute2_0 getJavaPersistentAttribute2_0() {
- return (JavaPersistentAttribute2_0) this.getJavaPersistentAttribute();
- }
-
- protected JavaPersistentAttribute buildAnnotatedJavaAttribute() {
- return this.buildJavaAttribute(this.javaResourceAttribute);
- }
-
- protected JavaPersistentAttribute getUnannotatedJavaAttribute() {
- if (this.unannotatedJavaAttribute == null) {
- this.unannotatedJavaAttribute = this.buildUnannotatedJavaAttribute();
- }
- return this.unannotatedJavaAttribute;
- }
-
- protected JavaPersistentAttribute buildUnannotatedJavaAttribute() {
- return this.buildJavaAttribute(this.buildUnannotatedJavaResourceAttribute());
- }
-
- /**
- * Build a Java resource attribute that wraps the original Java resource
- * attribute and behaves as though it has no annotations. This will cause
- * all the settings in the Java <em>context</em> attribute to default.
- */
- protected JavaResourcePersistentAttribute buildUnannotatedJavaResourceAttribute() {
- return new UnannotatedJavaResourcePersistentAttribute(this.javaResourceAttribute);
- }
-
- protected JavaPersistentAttribute buildJavaAttribute(JavaResourcePersistentAttribute jrpa) {
- // pass in the orm persistent type as the parent...
- return this.getJpaFactory().buildJavaPersistentAttribute(this.getOwningPersistentType(), jrpa);
- }
-
- protected void syncLocalJavaAttributes() {
- this.annotatedJavaAttribute.synchronizeWithResourceModel();
- if (this.unannotatedJavaAttribute != null) {
- this.unannotatedJavaAttribute.synchronizeWithResourceModel();
- }
- }
-
- protected void updateLocalJavaAttributes() {
- this.annotatedJavaAttribute.update();
- if (this.unannotatedJavaAttribute != null) {
- this.unannotatedJavaAttribute.update();
- }
- }
-
- public JavaResourcePersistentAttribute getJavaResourcePersistentAttribute() {
- return this.javaResourceAttribute;
- }
-
-
- // ********** original Java persistent attribute **********
-
- protected void updateOriginalJavaAttribute() {
- JavaPersistentAttribute newJavaAttribute = this.resolveJavaPersistentAttribute();
- if (newJavaAttribute != this.originalJavaAttribute) {
- if (newJavaAttribute == null) {
- this.originalJavaAttribute.removeStateChangeListener(this.getOriginalJavaAttributeListener());
- this.originalJavaAttribute = null;
- } else {
- if (this.originalJavaAttribute != null) {
- this.originalJavaAttribute.removeStateChangeListener(this.getOriginalJavaAttributeListener());
- }
- this.originalJavaAttribute = newJavaAttribute;
- this.originalJavaAttribute.addStateChangeListener(this.getOriginalJavaAttributeListener());
- }
- }
- }
-
- protected StateChangeListener getOriginalJavaAttributeListener() {
- if (this.originalJavaAttributeListener == null) {
- this.originalJavaAttributeListener = this.buildOriginalJavaAttributeListener();
- }
- return this.originalJavaAttributeListener;
- }
-
- protected StateChangeListener buildOriginalJavaAttributeListener() {
- return new StateChangeListener() {
- public void stateChanged(StateChangeEvent event) {
- VirtualOrmPersistentAttribute.this.originalJavaAttributeChanged();
- }
- };
- }
-
- /**
- * If the "original" Java persistent attribute (or any of its parts) changes
- * we need to sync our "local" Java persistent attributes with any possible
- * changes to the Java resource model. This is necessary for when the Java
- * context model is modifying the Java resource model, but is redundant when
- * the Java resource model is triggering a <em>sync</em>.
- */
- protected void originalJavaAttributeChanged() {
- this.syncLocalJavaAttributes();
- }
-
-
- // ********** access **********
-
- public AccessType getAccess() {
- return this.getJavaPersistentAttribute().getAccess();
- }
-
-
- // ********** specified/default **********
-
- public boolean isVirtual() {
- return true;
- }
-
- public OrmReadOnlyPersistentAttribute convertToVirtual() {
- throw new UnsupportedOperationException();
- }
-
- public OrmPersistentAttribute convertToSpecified() {
- if (this.mapping.getKey() == null) {
- throw new IllegalStateException("Use convertToSpecified(String) instead and specify a mapping type"); //$NON-NLS-1$
- }
- return this.getOwningPersistentType().convertAttributeToSpecified(this);
- }
-
- public OrmPersistentAttribute convertToSpecified(String mappingKey) {
- return this.getOwningPersistentType().convertAttributeToSpecified(this, mappingKey);
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- public String getId() {
- return OrmStructureNodes.PERSISTENT_ATTRIBUTE_ID;
- }
-
- public JpaStructureNode getStructureNode(int offset) {
- return this;
- }
-
- public boolean contains(int textOffset) {
- return false;
- }
-
- public TextRange getSelectionTextRange() {
- return null;
- }
-
- public void dispose() {
- if (this.originalJavaAttribute != null) {
- this.originalJavaAttribute.removeStateChangeListener(this.getOriginalJavaAttributeListener());
- }
- }
-
-
- // ********** validation **********
-
- @Override
- public void validate(List<IMessage> messages, IReporter reporter) {
- super.validate(messages, reporter);
- // the Java attribute should not need an AST for validation from here
- this.getJavaPersistentAttribute().validate(messages, reporter, null);
- }
-
- public TextRange getValidationTextRange() {
- return this.getOwningTypeMapping().getAttributesTextRange();
- }
-
-
- // ********** metamodel **********
-
- public String getMetamodelContainerFieldTypeName() {
- return this.getJavaPersistentAttribute2_0().getMetamodelContainerFieldTypeName();
- }
-
- public String getMetamodelContainerFieldMapKeyTypeName() {
- return this.getJavaPersistentAttribute2_0().getMetamodelContainerFieldMapKeyTypeName();
- }
-
- public String getMetamodelTypeName() {
- return this.getJavaPersistentAttribute2_0().getMetamodelTypeName();
- }
-
-
- // ********** misc **********
-
- @Override
- public OrmPersistentType getParent() {
- return (OrmPersistentType) super.getParent();
- }
-
- public OrmPersistentType getOwningPersistentType() {
- return this.getParent();
- }
-
- public OrmTypeMapping getOwningTypeMapping() {
- return this.getOwningPersistentType().getMapping();
- }
-
- public String getPrimaryKeyColumnName() {
- return this.mapping.getPrimaryKeyColumnName();
- }
-
- public String getTypeName() {
- return this.getJavaPersistentAttribute().getTypeName();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
-
-
- // ********** unannotated Java resource persistent member **********
-
- /**
- * Wrap another Java resource member and suppress all its annotations.
- */
- protected abstract class UnannotatedJavaResourcePersistentMember<M extends JavaResourcePersistentMember>
- extends SourceNode
- implements JavaResourcePersistentMember
- {
- protected final M member;
-
- /**
- * these are built as needed
- */
- protected final HashMap<String, Annotation> nullAnnotationsCache = new HashMap<String, Annotation>();
-
-
- protected UnannotatedJavaResourcePersistentMember(M member) {
- super(member.getParent());
- this.member = member;
- }
-
- public void initialize(CompilationUnit astRoot) {
- // NOP
- }
-
- public void synchronizeWith(CompilationUnit astRoot) {
- // NOP
- }
-
-
- // ********** annotations **********
-
- public Iterator<Annotation> annotations() {
- return EmptyIterator.instance();
- }
-
- public int annotationsSize() {
- return 0;
- }
-
- public Annotation getAnnotation(String annotationName) {
- return null;
- }
-
- public synchronized Annotation getNonNullAnnotation(String annotationName) {
- Annotation annotation = this.nullAnnotationsCache.get(annotationName);
- if (annotation == null) {
- annotation = this.buildNullAnnotation(annotationName);
- this.nullAnnotationsCache.put(annotationName, annotation);
- }
- return annotation;
- }
-
- protected abstract Annotation buildNullAnnotation(String annotationName);
-
- public Iterator<NestableAnnotation> annotations(String nestableAnnotationName, String containerAnnotationName) {
- return EmptyIterator.instance();
- }
-
- public Annotation addAnnotation(String annotationName) {
- throw new UnsupportedOperationException();
- }
-
- public NestableAnnotation addAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) {
- throw new UnsupportedOperationException();
- }
-
- public void moveAnnotation(int targetIndex, int sourceIndex, String containerAnnotationName) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAnnotation(String annotationName) {
- throw new UnsupportedOperationException();
- }
-
- public void removeAnnotation(int index, String nestableAnnotationName, String containerAnnotationName) {
- throw new UnsupportedOperationException();
- }
-
- public Annotation setPrimaryAnnotation(String primaryAnnotationName, Iterable<String> supportingAnnotationNames) {
- throw new UnsupportedOperationException();
- }
-
- public void addStandAloneAnnotation(NestableAnnotation standAloneAnnotation) {
- throw new UnsupportedOperationException();
- }
-
-
- // ********** persistable **********
-
- public boolean isPersistable() {
- return this.member.isPersistable();
- }
-
-
- // ********** misc **********
-
- public boolean isAnnotated() {
- return false;
- }
-
- public boolean isFinal() {
- return this.member.isFinal();
- }
-
- public boolean isFor(String memberName, int occurrence) {
- return this.member.isFor(memberName, occurrence);
- }
-
- public TextRange getTextRange(CompilationUnit astRoot) {
- // should never be null
- return this.member.getTextRange(astRoot);
- }
-
- public TextRange getNameTextRange(CompilationUnit astRoot) {
- // should never be null
- return this.member.getNameTextRange(astRoot);
- }
-
- public void resolveTypes(CompilationUnit astRoot) {
- // NOP
- }
- }
-
-
- // ********** unannotated Java resource persistent member **********
-
- protected class UnannotatedJavaResourcePersistentAttribute
- extends UnannotatedJavaResourcePersistentMember<JavaResourcePersistentAttribute>
- implements JavaResourcePersistentAttribute
- {
- protected UnannotatedJavaResourcePersistentAttribute(JavaResourcePersistentAttribute attribute){
- super(attribute);
- }
-
-
- // ********** annotations **********
-
- @Override
- public Annotation buildNullAnnotation(String annotationName) {
- return (annotationName == null) ? null : this.buildNullAnnotation_(annotationName);
- }
-
- private Annotation buildNullAnnotation_(String annotationName) {
- return this.getAnnotationProvider().buildNullAttributeAnnotation(this, annotationName);
- }
-
-
- // ********** delegated behavior **********
-
- @Override
- public JavaResourcePersistentType getParent() {
- return this.member.getParent();
- }
-
- public JavaResourcePersistentType getResourcePersistentType() {
- return this.member.getResourcePersistentType();
- }
-
- public String getName() {
- return this.member.getName();
- }
-
- public boolean isFor(MethodSignature signature, int occurrence) {
- return this.member.isFor(signature, occurrence);
- }
-
- public boolean isField() {
- return this.member.isField();
- }
-
- public boolean isProperty() {
- return this.member.isProperty();
- }
-
- public org.eclipse.jpt.jpa.core.resource.java.AccessType getSpecifiedAccess() {
- return null;
- }
-
- public boolean typeIsSubTypeOf(String tn) {
- return this.member.typeIsSubTypeOf(tn);
- }
-
- public boolean typeIsVariablePrimitive() {
- return this.member.typeIsVariablePrimitive();
- }
-
- public int getModifiers() {
- return this.member.getModifiers();
- }
-
- public String getTypeName() {
- return this.member.getTypeName();
- }
-
- public boolean typeIsInterface() {
- return this.member.typeIsInterface();
- }
-
- public boolean typeIsEnum() {
- return this.member.typeIsEnum();
- }
-
- public ListIterator<String> typeSuperclassNames() {
- return this.member.typeSuperclassNames();
- }
-
- public Iterator<String> typeInterfaceNames() {
- return this.member.typeInterfaceNames();
- }
-
- public ListIterator<String> typeTypeArgumentNames() {
- return this.member.typeTypeArgumentNames();
- }
-
- public int typeTypeArgumentNamesSize() {
- return this.member.typeTypeArgumentNamesSize();
- }
-
- public String getTypeTypeArgumentName(int index) {
- return this.member.getTypeTypeArgumentName(index);
- }
-
- @Override
- public void toString(StringBuilder sb) {
- sb.append(this.getName());
- }
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
deleted file mode 100644
index 51180c17a1..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java
+++ /dev/null
@@ -1,389 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- ******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.jpa.core.JpaFile;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JarFile;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackageFragmentRoot;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlJarFileRef;
-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;
-
-/**
- * <code>persistence.xml</code> file
- * <br>
- * <code>jar-file</code> element
- */
-public abstract class AbstractJarFileRef
- extends AbstractPersistenceXmlContextNode
- implements JarFileRef
-{
- protected final XmlJarFileRef xmlJarFileRef;
-
- protected String fileName;
-
- /**
- * the jar file corresponding to the ref's file name;
- * this can be null if the name is invalid
- */
- protected JarFile jarFile;
-
-
- // ********** construction/initialization **********
-
- public AbstractJarFileRef(PersistenceUnit parent, XmlJarFileRef xmlJarFileRef) {
- super(parent);
- this.xmlJarFileRef = xmlJarFileRef;
- this.fileName = xmlJarFileRef.getFileName();
- this.jarFile = this.buildJarFile();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.setFileName_(this.xmlJarFileRef.getFileName());
- this.syncJarFile();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateJarFile();
- }
-
-
- // ********** JpaStructureNode implementation **********
-
- 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();
- }
- }
-
-
- // ********** file name **********
-
- public String getFileName() {
- return this.fileName;
- }
-
- public void setFileName(String fileName) {
- this.setFileName_(fileName);
- this.xmlJarFileRef.setFileName(fileName);
- }
-
- /**
- * We clear out {@link #jarFile} here because we cannot compare its file
- * name to the ref's file name, since it may have been munged (see
- * {@link #resolveJavaResourcePackageFragmentRoot_()}).
- */
- protected void setFileName_(String fileName) {
- String old = this.fileName;
- this.fileName = fileName;
- if (this.firePropertyChanged(FILE_NAME_PROPERTY, old, fileName)) {
- // clear out the jar file here, it will be rebuilt during "update"
- if (this.jarFile != null) {
- this.jarFile.dispose();
- this.setJarFile(null);
- }
- }
- }
-
-
- // ********** 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);
- }
-
- protected JarFile buildJarFile() {
- JavaResourcePackageFragmentRoot jrpfr = this.resolveJavaResourcePackageFragmentRoot();
- return (jrpfr == null) ? null : this.buildJarFile(jrpfr);
- }
-
- /**
- * If the file name changes during <em>sync</em>, the jar file will be
- * cleared out in {@link #setFileName_(String)}. If we get here and the jar
- * file is still present, we can <code>sync</code> it. Of course, it might
- * still be obsolete if other things have changed....
- *
- * @see #updateJarFile()
- */
- protected void syncJarFile() {
- if (this.jarFile != null) {
- this.jarFile.synchronizeWithResourceModel();
- }
- }
-
- /**
- * @see #syncJarFile()
- */
- protected void updateJarFile() {
- JavaResourcePackageFragmentRoot jrpfr = this.resolveJavaResourcePackageFragmentRoot();
- if (jrpfr == null) {
- if (this.jarFile != null) {
- this.jarFile.dispose();
- this.setJarFile(null);
- }
- } else {
- if (this.jarFile == null) {
- this.setJarFile(this.buildJarFile(jrpfr));
- } else {
- if (this.jarFile.getJarResourcePackageFragmentRoot() == jrpfr) {
- this.jarFile.update();
- } else {
- this.jarFile.dispose();
- this.setJarFile(this.buildJarFile(jrpfr));
- }
- }
- }
- }
-
- protected JavaResourcePackageFragmentRoot resolveJavaResourcePackageFragmentRoot() {
- return StringTools.stringIsEmpty(this.fileName) ? null : this.resolveJavaResourcePackageFragmentRoot_();
- }
-
- /**
- * pre-condition: 'fileName' is neither null nor empty
- */
- protected JavaResourcePackageFragmentRoot resolveJavaResourcePackageFragmentRoot_() {
- // first, attempt to resolve location specifically...
- JavaResourcePackageFragmentRoot jrpfr = this.resolveJrpfrOnDeploymentPath();
- // ...then guess, basically
- return (jrpfr != null) ? jrpfr : this.resolveJrpfrBestMatch();
- }
-
- /**
- * pre-condition: 'fileName' is neither null nor empty
- */
- protected JavaResourcePackageFragmentRoot resolveJrpfrOnDeploymentPath() {
- for (IPath runtimePath : this.buildRuntimeJarFilePath(new Path(this.fileName))) {
- IVirtualFile virtualJar = ComponentCore.createFile(this.getProject(), runtimePath);
- IFile realJar = virtualJar.getUnderlyingFile();
- if (realJar.exists() && realJar.getProject().equals(this.getProject())) {
- return this.getJpaProject().getJavaResourcePackageFragmentRoot(realJar.getProjectRelativePath().toString());
- }
- }
- return null;
- }
-
- /**
- * Return an array of runtime paths that may correspond
- * to the given persistence.xml jar file entry
- */
- protected IPath[] buildRuntimeJarFilePath(IPath jarFilePath) {
- IPath root = this.getJarRuntimeRootPath();
- return this.projectHasWebFacet() ?
- this.buildRuntimeJarFilePathWeb(root, jarFilePath) :
- this.buildRuntimeJarFilePathNonWeb(root, jarFilePath);
- }
-
- protected IPath getJarRuntimeRootPath() {
- return JptJpaCorePlugin.getJarRuntimeRootPath(this.getProject());
- }
-
- protected boolean projectHasWebFacet() {
- return JptJpaCorePlugin.projectHasWebFacet(this.getProject());
- }
-
- protected IPath[] buildRuntimeJarFilePathWeb(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[] buildRuntimeJarFilePathNonWeb(IPath root, IPath jarFilePath) {
- return new IPath[] {
- // assumes form "../lib/other.jar"
- root.append(jarFilePath)
- };
- }
-
- protected IProject getProject() {
- return this.getJpaProject().getProject();
- }
-
- /**
- * pre-condition: 'fileName' is neither null nor empty
- */
- protected JavaResourcePackageFragmentRoot resolveJrpfrBestMatch() {
- String jarFileName = new Path(this.fileName).lastSegment();
- for (JpaFile jpaFile : this.getJpaProject().getJarJpaFiles()) {
- if (jpaFile.getFile().getName().equals(jarFileName)) {
- return (JavaResourcePackageFragmentRoot) jpaFile.getResourceModel();
- }
- }
- return null;
- }
-
- /**
- * pre-condition: 'jrpfr' is not null
- */
- protected JarFile buildJarFile(JavaResourcePackageFragmentRoot jrpfr) {
- return this.getContextNodeFactory().buildJarFile(this, jrpfr);
- }
-
-
- // ********** JarFileRef implementation **********
-
- public XmlJarFileRef getXmlJarFileRef() {
- return this.xmlJarFileRef;
- }
-
- 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();
- }
-
-
- // ********** XmlContextNode implementation **********
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.getXmlJarFileRefTextRange();
- return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange();
- }
-
- protected TextRange getXmlJarFileRefTextRange() {
- return (this.xmlJarFileRef == null) ? null : this.xmlJarFileRef.getValidationTextRange();
- }
-
-
- // ********** refactoring **********
-
- public Iterable<ReplaceEdit> createReplaceFolderEdits(IFolder originalFolder, String newName) {
- return this.isIn(originalFolder) ?
- new SingleElementIterable<ReplaceEdit>(this.createReplaceFolderEdit(originalFolder, newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected ReplaceEdit createReplaceFolderEdit(IFolder originalFolder, String newName) {
- return this.xmlJarFileRef.createReplaceFolderEdit(originalFolder, newName);
- }
-
- protected boolean isIn(IFolder folder) {
- return (this.jarFile != null) && 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);
- }
-
-
- // ********** overrides **********
-
- @Override
- public PersistenceUnit getParent() {
- return (PersistenceUnit) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.fileName);
- }
-
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java
deleted file mode 100644
index 8ef469264d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractMappingFileRef.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.JptResourceType;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SingleElementIterable;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.context.MappingFile;
-import org.eclipse.jpt.jpa.core.context.MappingFilePersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.context.MappingFileRoot;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType;
-import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.resource.xml.JpaXmlResource;
-import org.eclipse.text.edits.DeleteEdit;
-import org.eclipse.text.edits.ReplaceEdit;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-
-/**
- * <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 <code>null</code> if the name is invalid.
- */
- protected MappingFile mappingFile;
-
-
- // ********** construction/initialization **********
-
- protected AbstractMappingFileRef(PersistenceUnit parent, String fileName) {
- super(parent);
- this.fileName = fileName;
- this.mappingFile = this.buildMappingFile();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
- this.syncMappingFile();
- }
-
- @Override
- public void update() {
- super.update();
- this.updateMappingFile();
- }
-
-
- // ********** 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) {
- return (this.mappingFile != null) && 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 syncMappingFile() {
- this.syncMappingFile(true);
- }
-
- /**
- * We call this method from both {@link #syncMappingFile()} and
- * {@link #updateMappingFile()} because<ul>
- * <li>a <em>sync</em> will occur when the file is edited directly;
- * and the user could modify something (e.g. the version number) that
- * triggers the file being "resolved" or not;
- * see {@link #resolveMappingFileXmlResource()}
- * <li>an <em>update</em> will occur whenever the entire file is added or
- * removed
- * </ul>
- */
- protected void syncMappingFile(boolean sync) {
- JpaXmlResource newXmlResource = this.resolveMappingFileXmlResource();
- if (newXmlResource == null) {
- if (this.mappingFile != null) {
- this.mappingFile.dispose();
- this.setMappingFile(null);
- }
- } else {
- if (this.mappingFile == null) {
- this.setMappingFile(this.buildMappingFile(newXmlResource));
- } else {
- if (this.mappingFile.getXmlResource() == newXmlResource) {
- if (sync) {
- this.mappingFile.synchronizeWithResourceModel();
- } else {
- this.mappingFile.update();
- }
- } else {
- // [seems like we should never get here; since if the file's
- // content type changed, the JPA project would return null... ~bjv]
- // if the resource's content type has changed, we completely rebuild the mapping file
- this.mappingFile.dispose();
- this.setMappingFile(this.buildMappingFile(newXmlResource));
- }
- }
- }
- }
-
- /**
- * 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;
- }
- JptResourceType resourceType = xmlResource.getResourceType();
- if (resourceType == null) {
- return null;
- }
- if ( ! this.getJpaPlatform().supportsResourceType(resourceType)) {
- return null;
- }
- return xmlResource;
- }
-
- /**
- * pre-condition: 'xmlResource' is not <code>null</code>
- */
- protected MappingFile buildMappingFile(JpaXmlResource xmlResource) {
- return this.getJpaFactory().buildMappingFile(this, xmlResource);
- }
-
- protected void updateMappingFile() {
- this.syncMappingFile(false);
- }
-
-
- // ********** 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();
- }
- }
-
-
- // ********** misc **********
-
- public boolean persistenceUnitMetadataExists() {
- MappingFilePersistenceUnitMetadata metadata = this.getPersistenceUnitMetadata();
- return (metadata != null) && metadata.resourceExists();
- }
-
- public MappingFilePersistenceUnitMetadata getPersistenceUnitMetadata() {
- MappingFileRoot root = this.getChildMappingFileRoot();
- return (root == null) ? null : root.getPersistenceUnitMetadata();
- }
-
- /**
- * The method {@link #getMappingFileRoot()} is already defined by
- * {@link org.eclipse.jpt.jpa.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);
- }
-
- @Override
- public PersistenceUnit getParent() {
- return (PersistenceUnit) super.getParent();
- }
-
- @Override
- public void toString(StringBuilder sb) {
- super.toString(sb);
- sb.append(this.fileName);
- }
-
- public Iterable<? extends PersistentType> getPersistentTypes() {
- return (this.mappingFile != null) ? this.mappingFile.getPersistentTypes() : EmptyIterable.<JavaPersistentType>instance();
- }
-
-
- // ********** 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(this.buildMappingFileValidationMessage());
- return;
- }
-
- this.mappingFile.validate(messages, reporter);
- }
-
- protected IMessage buildMappingFileValidationMessage() {
- int severity = IMessage.HIGH_SEVERITY;
- IFile file = this.getPlatformFile();
- if ( ! file.exists()) {
- return DefaultJpaValidationMessages.buildMessage(
- severity,
- JpaValidationMessages.PERSISTENCE_UNIT_NONEXISTENT_MAPPING_FILE,
- new String[] {this.fileName},
- this,
- this.getValidationTextRange()
- );
- }
- String msgText = this.mappingFileContentIsUnsupported() ?
- JpaValidationMessages.PERSISTENCE_UNIT_UNSUPPORTED_MAPPING_FILE_CONTENT :
- JpaValidationMessages.PERSISTENCE_UNIT_INVALID_MAPPING_FILE;
- return DefaultJpaValidationMessages.buildMessage(
- severity,
- msgText,
- new String[] {file.getName()},
- file
- );
- }
-
- protected IFile getPlatformFile() {
- return this.getJpaProject().getPlatformFile(new Path(this.fileName));
- }
-
- /**
- * pre-condition: {@link #getPlatformFile()} exists
- */
- protected boolean mappingFileContentIsUnsupported() {
- JpaXmlResource xmlResource = this.getJpaProject().getMappingFileXmlResource(new Path(this.fileName));
- return (xmlResource != null) && ! this.getJpaPlatform().supportsResourceType(xmlResource.getResourceType());
- }
-
-
- // ********** refactoring **********
-
- public Iterable<DeleteEdit> createDeleteTypeEdits(IType type) {
- return (this.mappingFile != null) ?
- this.mappingFile.createDeleteTypeEdits(type) :
- EmptyIterable.<DeleteEdit>instance();
- }
-
- public Iterable<ReplaceEdit> createRenameTypeEdits(IType originalType, String newName) {
- return (this.mappingFile != null) ?
- this.mappingFile.createRenameTypeEdits(originalType, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- public Iterable<ReplaceEdit> createMoveTypeEdits(IType originalType, IPackageFragment newPackage) {
- return (this.mappingFile != null) ?
- this.mappingFile.createMoveTypeEdits(originalType, newPackage) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- public Iterable<ReplaceEdit> createRenamePackageEdits(IPackageFragment originalPackage, String newName) {
- return (this.mappingFile != null) ?
- this.mappingFile.createRenamePackageEdits(originalPackage, newName) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- public Iterable<ReplaceEdit> createRenameMappingFileEdits(IFile originalFile, String newName) {
- return this.isFor(originalFile) ?
- new SingleElementIterable<ReplaceEdit>(this.createRenameEdit(originalFile, newName)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected abstract ReplaceEdit createRenameEdit(IFile originalFile, String newName);
-
- public Iterable<ReplaceEdit> createMoveMappingFileEdits(IFile originalFile, IPath runtineDestination) {
- return this.isFor(originalFile) ?
- new SingleElementIterable<ReplaceEdit>(this.createMoveEdit(originalFile, runtineDestination)) :
- EmptyIterable.<ReplaceEdit>instance();
- }
-
- protected abstract ReplaceEdit createMoveEdit(IFile originalFile, IPath runtineDestination);
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
deleted file mode 100644
index e3c8ef1e3d..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java
+++ /dev/null
@@ -1,2836 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2011 Oracle. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0, which accompanies this distribution
- * and is available at http://www.eclipse.org/legal/epl-v10.html.
- *
- * Contributors:
- * Oracle - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jpt.jpa.core.internal.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.common.core.utility.BodySourceWriter;
-import org.eclipse.jpt.common.core.utility.TextRange;
-import org.eclipse.jpt.common.utility.internal.CollectionTools;
-import org.eclipse.jpt.common.utility.internal.HashBag;
-import org.eclipse.jpt.common.utility.internal.NotNullFilter;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.Tools;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.CompositeListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.FilteringIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.ListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.LiveCloneListIterable;
-import org.eclipse.jpt.common.utility.internal.iterables.SubIterableWrapper;
-import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable;
-import org.eclipse.jpt.common.utility.internal.iterators.EmptyListIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.FilteringIterator;
-import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.JpaStructureNode;
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.AccessType;
-import org.eclipse.jpt.jpa.core.context.AttributeMapping;
-import org.eclipse.jpt.jpa.core.context.Embeddable;
-import org.eclipse.jpt.jpa.core.context.Entity;
-import org.eclipse.jpt.jpa.core.context.Generator;
-import org.eclipse.jpt.jpa.core.context.GeneratorContainer;
-import org.eclipse.jpt.jpa.core.context.IdMapping;
-import org.eclipse.jpt.jpa.core.context.MappingFile;
-import org.eclipse.jpt.jpa.core.context.MappingFilePersistenceUnitDefaults;
-import org.eclipse.jpt.jpa.core.context.MappingFilePersistenceUnitMetadata;
-import org.eclipse.jpt.jpa.core.context.PersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.PersistentType;
-import org.eclipse.jpt.jpa.core.context.Query;
-import org.eclipse.jpt.jpa.core.context.QueryContainer;
-import org.eclipse.jpt.jpa.core.context.ReadOnlyPersistentAttribute;
-import org.eclipse.jpt.jpa.core.context.TypeMapping;
-import org.eclipse.jpt.jpa.core.context.java.JavaGenerator;
-import org.eclipse.jpt.jpa.core.context.java.JavaQuery;
-import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
-import org.eclipse.jpt.jpa.core.context.orm.OrmGenerator;
-import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;
-import org.eclipse.jpt.jpa.core.context.orm.OrmQuery;
-import org.eclipse.jpt.jpa.core.context.orm.OrmXml;
-import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
-import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceStructureNodes;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitTransactionType;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistentTypeContainer;
-import org.eclipse.jpt.jpa.core.internal.context.ContextContainerTools;
-import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages;
-import org.eclipse.jpt.jpa.core.internal.validation.JpaValidationMessages;
-import org.eclipse.jpt.jpa.core.jpa2.JpaFactory2_0;
-import org.eclipse.jpt.jpa.core.jpa2.JpaProject2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.MappingFilePersistenceUnitDefaults2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelSourceType;
-import org.eclipse.jpt.jpa.core.jpa2.context.PersistentType2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.PersistenceUnit2_0;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.SharedCacheMode;
-import org.eclipse.jpt.jpa.core.jpa2.context.persistence.options.ValidationMode;
-import org.eclipse.jpt.jpa.core.jpa2.resource.java.JavaResourcePersistentType2_0;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentType;
-import org.eclipse.jpt.jpa.core.resource.persistence.PersistenceFactory;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlJarFileRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperties;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlProperty;
-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 final XmlPersistenceUnit xmlPersistenceUnit;
-
- protected String name;
-
- protected Boolean specifiedExcludeUnlistedClasses;
-
- 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 final SpecifiedMappingFileRefContainerAdapter specifiedMappingFileRefContainerAdapter = new SpecifiedMappingFileRefContainerAdapter();
- protected MappingFileRef impliedMappingFileRef;
-
- protected final Vector<JarFileRef> jarFileRefs = new Vector<JarFileRef>();
- protected final JarFileRefContainerAdapter jarFileRefContainerAdapter = new JarFileRefContainerAdapter();
-
- protected final Vector<ClassRef> specifiedClassRefs = new Vector<ClassRef>();
- protected final SpecifiedClassRefContainerAdapter specifiedClassRefContainerAdapter = new SpecifiedClassRefContainerAdapter();
-
- protected final Set<ClassRef> impliedClassRefs = Collections.synchronizedSet(new HashSet<ClassRef>());
- protected final ImpliedClassRefContainerAdapter impliedClassRefContainerAdapter = new ImpliedClassRefContainerAdapter();
-
- protected final Vector<Property> properties = new Vector<Property>();
- protected final PropertyContainerAdapter propertyContainerAdapter = new PropertyContainerAdapter();
-
- /* 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 boolean xmlMappingMetadataComplete;
- protected AccessType defaultAccess;
- protected String defaultCatalog;
- protected String defaultSchema;
- protected boolean defaultCascadePersist;
- protected boolean defaultDelimitedIdentifiers;
-
- //****** JPA 2.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.description = xmlPersistenceUnit.getDescription();
- this.provider = xmlPersistenceUnit.getProvider();
- this.jtaDataSource = xmlPersistenceUnit.getJtaDataSource();
- this.nonJtaDataSource = xmlPersistenceUnit.getNonJtaDataSource();
-
- // initialize the properties early because other things will need them...(?)
- this.initializeProperties();
-
- this.initializeSpecifiedMappingFileRefs();
- this.initializeJarFileRefs();
- this.initializeSpecifiedClassRefs();
-
- this.specifiedSharedCacheMode = this.buildSpecifiedSharedCacheMode();
- this.specifiedValidationMode = this.buildSpecifiedValidationMode();
-
- this.initializeMetamodelFiles();
- }
-
-
- // ********** synchronize/update **********
-
- @Override
- public void synchronizeWithResourceModel() {
- super.synchronizeWithResourceModel();
-
- this.setName_(this.xmlPersistenceUnit.getName());
- this.setSpecifiedExcludeUnlistedClasses_(this.xmlPersistenceUnit.getExcludeUnlistedClasses());
- this.setSpecifiedTransactionType_(this.buildSpecifiedTransactionType());
- this.setDescription_(this.xmlPersistenceUnit.getDescription());
- this.setProvider_(this.xmlPersistenceUnit.getProvider());
- this.setJtaDataSource_(this.xmlPersistenceUnit.getJtaDataSource());
- this.setNonJtaDataSource_(this.xmlPersistenceUnit.getNonJtaDataSource());
-
- this.syncSpecifiedMappingFileRefs();
- this.syncImpliedMappingFileRef();
-
- this.syncJarFileRefs();
-
- this.syncSpecifiedClassRefs();
- this.synchronizeNodesWithResourceModel(this.getImpliedClassRefs());
-
- this.syncProperties();
-
- this.setSpecifiedSharedCacheMode_(this.buildSpecifiedSharedCacheMode());
- this.setSpecifiedValidationMode_(this.buildSpecifiedValidationMode());
- }
-
- @Override
- public void update() {
- super.update();
-
- this.setDefaultTransactionType(this.buildDefaultTransactionType());
-
- // update specified class refs before mapping file refs because of
- // JpaFile root structure nodes - we want the mapping file to "win",
- // as it would in a JPA runtime implementation
- this.updateNodes(this.getSpecifiedClassRefs());
-
- this.updateNodes(this.getSpecifiedMappingFileRefs());
- this.updateImpliedMappingFileRef();
-
- this.updateNodes(this.getJarFileRefs());
-
- // update the implied class refs after all the other types, both
- // specified here and specified in the mapping files, are in place
- this.updateImpliedClassRefs();
-
- this.updateNodes(this.getProperties());
-
- this.updatePersistenceUnitMetadata();
-
- this.setGenerators(this.buildGenerators());
- this.setQueries(this.buildQueries());
-
- this.setDefaultSharedCacheMode(this.buildDefaultSharedCacheMode());
- this.setDefaultValidationMode(this.buildDefaultValidationMode());
- }
-
-
- // ********** JpaContextNode implementation **********
-
- @Override
- public Persistence getParent() {
- return (Persistence) super.getParent();
- }
-
- protected Persistence getPersistence() {
- return this.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 (JarFileRef jarFileRef : this.getJarFileRefs()) {
- jarFileRef.dispose();
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- mappingFileRef.dispose();
- }
- }
-
-
- // ********** name **********
-
- public String getName() {
- return this.name;
- }
-
- public void setName(String name) {
- this.setName_(name);
- this.xmlPersistenceUnit.setName(name);
- }
-
- protected void setName_(String name) {
- String old = this.name;
- this.name = 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 transactionType) {
- this.setSpecifiedTransactionType_(transactionType);
- this.xmlPersistenceUnit.setTransactionType(PersistenceUnitTransactionType.toXmlResourceModel(transactionType));
- }
-
- protected void setSpecifiedTransactionType_(PersistenceUnitTransactionType transactionType) {
- PersistenceUnitTransactionType old = this.specifiedTransactionType;
- this.specifiedTransactionType = transactionType;
- this.firePropertyChanged(SPECIFIED_TRANSACTION_TYPE_PROPERTY, old, transactionType);
- }
-
- public PersistenceUnitTransactionType getDefaultTransactionType() {
- return this.defaultTransactionType;
- }
-
- protected void setDefaultTransactionType(PersistenceUnitTransactionType transactionType) {
- PersistenceUnitTransactionType old = this.defaultTransactionType;
- this.defaultTransactionType = transactionType;
- this.firePropertyChanged(DEFAULT_TRANSACTION_TYPE_PROPERTY, old, transactionType);
- }
-
- 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) {
- this.setDescription_(description);
- this.xmlPersistenceUnit.setDescription(description);
- }
-
- protected void setDescription_(String description) {
- String old = this.description;
- this.description = description;
- this.firePropertyChanged(DESCRIPTION_PROPERTY, old, description);
- }
-
-
- // ********** provider **********
-
- public String getProvider() {
- return this.provider;
- }
-
- public void setProvider(String provider) {
- this.setProvider_(provider);
- this.xmlPersistenceUnit.setProvider(provider);
- }
-
- protected void setProvider_(String provider) {
- String old = this.provider;
- this.provider = provider;
- this.firePropertyChanged(PROVIDER_PROPERTY, old, provider);
- }
-
-
- // ********** JTA data source **********
-
- public String getJtaDataSource() {
- return this.jtaDataSource;
- }
-
- public void setJtaDataSource(String jtaDataSource) {
- this.setJtaDataSource_(jtaDataSource);
- this.xmlPersistenceUnit.setJtaDataSource(jtaDataSource);
- }
-
- protected void setJtaDataSource_(String jtaDataSource) {
- String old = this.jtaDataSource;
- this.jtaDataSource = jtaDataSource;
- this.firePropertyChanged(JTA_DATA_SOURCE_PROPERTY, old, jtaDataSource);
- }
-
-
- // ********** non-JTA data source **********
-
- public String getNonJtaDataSource() {
- return this.nonJtaDataSource;
- }
-
- public void setNonJtaDataSource(String nonJtaDataSource) {
- this.setNonJtaDataSource_(nonJtaDataSource);
- this.xmlPersistenceUnit.setNonJtaDataSource(nonJtaDataSource);
- }
-
- protected void setNonJtaDataSource_(String nonJtaDataSource) {
- String old = this.nonJtaDataSource;
- this.nonJtaDataSource = nonJtaDataSource;
- this.firePropertyChanged(NON_JTA_DATA_SOURCE_PROPERTY, old, nonJtaDataSource);
- }
-
-
- // ********** mapping file refs **********
-
- public ListIterator<MappingFileRef> mappingFileRefs() {
- return this.getMappingFileRefs().iterator();
- }
-
- protected Iterator<String> mappingFileRefNames() {
- return new TransformationIterator<MappingFileRef, String>(this.mappingFileRefs()) {
- @Override
- protected String transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.getFileName();
- }
- };
- }
-
- protected ListIterable<MappingFileRef> getMappingFileRefs() {
- return (this.impliedMappingFileRef == null) ?
- this.getSpecifiedMappingFileRefs() :
- this.getCombinedMappingFileRefs();
- }
-
- protected ListIterator<MappingFileRef> combinedMappingFileRefs() {
- return this.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;
- }
- };
- }
-
-
- // ********** 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(this.specifiedMappingFileRefs.size(), fileName);
- }
-
- public MappingFileRef addSpecifiedMappingFileRef(int index, String fileName) {
- XmlMappingFileRef xmlMappingFileRef = this.buildXmlMappingFileRef(fileName);
- MappingFileRef mappingFileRef = this.addSpecifiedMappingFileRef_(index, xmlMappingFileRef);
- this.xmlPersistenceUnit.getMappingFiles().add(index, xmlMappingFileRef);
- return mappingFileRef;
- }
-
- protected XmlMappingFileRef buildXmlMappingFileRef(String fileName) {
- XmlMappingFileRef ref = PersistenceFactory.eINSTANCE.createXmlMappingFileRef();
- ref.setFileName(fileName);
- return ref;
- }
-
- protected MappingFileRef buildSpecifiedMappingFileRef(XmlMappingFileRef xmlMappingFileRef) {
- return this.getContextNodeFactory().buildMappingFileRef(this, xmlMappingFileRef);
- }
-
- public void removeSpecifiedMappingFileRef(MappingFileRef mappingFileRef) {
- this.removeSpecifiedMappingFileRef(this.specifiedMappingFileRefs.indexOf(mappingFileRef));
- }
-
- public void removeSpecifiedMappingFileRef(int index) {
- this.removeSpecifiedMappingFileRef_(index);
- this.xmlPersistenceUnit.getMappingFiles().remove(index);
- }
-
- /**
- * dispose the mapping file ref
- */
- protected void removeSpecifiedMappingFileRef_(int index) {
- this.removeItemFromList(index, this.specifiedMappingFileRefs, SPECIFIED_MAPPING_FILE_REFS_LIST).dispose();
- }
-
- protected void initializeSpecifiedMappingFileRefs() {
- for (XmlMappingFileRef xmlMappingFileRef : this.getXmlMappingFileRefs()) {
- this.specifiedMappingFileRefs.add(this.buildSpecifiedMappingFileRef(xmlMappingFileRef));
- }
- }
-
- protected void syncSpecifiedMappingFileRefs() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedMappingFileRefContainerAdapter);
- }
-
- protected Iterable<XmlMappingFileRef> getXmlMappingFileRefs() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlMappingFileRef>(this.xmlPersistenceUnit.getMappingFiles());
- }
-
- protected void moveSpecifiedMappingFileRef_(int index, MappingFileRef mappingFileRef) {
- this.moveItemInList(index, mappingFileRef, this.specifiedMappingFileRefs, SPECIFIED_MAPPING_FILE_REFS_LIST);
- }
-
- protected MappingFileRef addSpecifiedMappingFileRef_(int index, XmlMappingFileRef xmlMappingFileRef) {
- MappingFileRef mappingFileRef = this.buildSpecifiedMappingFileRef(xmlMappingFileRef);
- this.addItemToList(index, mappingFileRef, this.specifiedMappingFileRefs, SPECIFIED_MAPPING_FILE_REFS_LIST);
- return mappingFileRef;
- }
-
- protected void removeSpecifiedMappingFileRef_(MappingFileRef mappingFileRef) {
- this.removeSpecifiedMappingFileRef_(this.specifiedMappingFileRefs.indexOf(mappingFileRef));
- }
-
- /**
- * specified mapping file ref container adapter
- */
- protected class SpecifiedMappingFileRefContainerAdapter
- implements ContextContainerTools.Adapter<MappingFileRef, XmlMappingFileRef>
- {
- public Iterable<MappingFileRef> getContextElements() {
- return AbstractPersistenceUnit.this.getSpecifiedMappingFileRefs();
- }
- public Iterable<XmlMappingFileRef> getResourceElements() {
- return AbstractPersistenceUnit.this.getXmlMappingFileRefs();
- }
- public XmlMappingFileRef getResourceElement(MappingFileRef contextElement) {
- return contextElement.getXmlMappingFileRef();
- }
- public void moveContextElement(int index, MappingFileRef element) {
- AbstractPersistenceUnit.this.moveSpecifiedMappingFileRef_(index, element);
- }
- public void addContextElement(int index, XmlMappingFileRef resourceElement) {
- AbstractPersistenceUnit.this.addSpecifiedMappingFileRef_(index, resourceElement);
- }
- public void removeContextElement(MappingFileRef element) {
- AbstractPersistenceUnit.this.removeSpecifiedMappingFileRef_(element);
- }
- }
-
-
- // ********** implied mapping file ref **********
-
- public MappingFileRef getImpliedMappingFileRef() {
- return this.impliedMappingFileRef;
- }
-
- protected MappingFileRef addImpliedMappingFileRef() {
- if (this.impliedMappingFileRef != null) {
- throw new IllegalStateException("The implied mapping file ref is already set: " + this.impliedMappingFileRef); //$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 removeImpliedMappingFileRef() {
- if (this.impliedMappingFileRef == null) {
- throw new IllegalStateException("The implied mapping file ref is already unset."); //$NON-NLS-1$
- }
- MappingFileRef old = this.impliedMappingFileRef;
- this.impliedMappingFileRef = null;
- old.dispose();
- this.firePropertyChanged(IMPLIED_MAPPING_FILE_REF_PROPERTY, old, null);
- }
-
- protected void syncImpliedMappingFileRef() {
- if (this.impliedMappingFileRef != null) {
- this.impliedMappingFileRef.synchronizeWithResourceModel();
- }
- }
-
- protected void updateImpliedMappingFileRef() {
- if (this.buildsImpliedMappingFile()) {
- if (this.impliedMappingFileRef == null) {
- this.addImpliedMappingFileRef();
- } else {
- this.impliedMappingFileRef.update();
- }
- } else {
- if (this.impliedMappingFileRef != null) {
- this.removeImpliedMappingFileRef();
- }
- }
- }
-
- protected boolean buildsImpliedMappingFile() {
- return this.impliedMappingFileIsNotSpecified() && this.impliedMappingFileExists();
- }
-
- protected boolean impliedMappingFileIsNotSpecified() {
- return ! this.impliedMappingFileIsSpecified();
- }
-
- protected boolean impliedMappingFileIsSpecified() {
- return this.mappingFileIsSpecified(JptJpaCorePlugin.DEFAULT_ORM_XML_RUNTIME_PATH.toString());
- }
-
- protected boolean mappingFileIsSpecified(String impliedMappingFileName) {
- for (MappingFileRef specifiedMappingFileRef : this.getSpecifiedMappingFileRefs()) {
- if (Tools.valuesAreEqual(specifiedMappingFileRef.getFileName(), impliedMappingFileName)) {
- return true;
- }
- }
- return false;
- }
-
- protected boolean impliedMappingFileExists() {
- return this.getJpaProject().getDefaultOrmXmlResource() != null;
- }
-
-
- // ********** JAR file refs **********
-
- public ListIterator<JarFileRef> jarFileRefs() {
- return this.getJarFileRefs().iterator();
- }
-
- protected ListIterable<JarFileRef> getJarFileRefs() {
- return new LiveCloneListIterable<JarFileRef>(this.jarFileRefs);
- }
-
- public int jarFileRefsSize() {
- return this.jarFileRefs.size();
- }
-
- protected Iterable<String> getJarFileNames() {
- return new TransformationIterable<JarFileRef, String>(this.getJarFileRefs()) {
- @Override
- protected String transform(JarFileRef jarFileRef) {
- return jarFileRef.getFileName();
- }
- };
- }
-
- public JarFileRef addJarFileRef(String fileName) {
- return this.addJarFileRef(this.jarFileRefs.size(), fileName);
- }
-
- public JarFileRef addJarFileRef(int index, String fileName) {
- XmlJarFileRef xmlJarFileRef = this.buildXmlJarFileRef(fileName);
- JarFileRef jarFileRef = this.addJarFileRef_(index, xmlJarFileRef);
- this.xmlPersistenceUnit.getJarFiles().add(index, xmlJarFileRef);
- return jarFileRef;
- }
-
- protected XmlJarFileRef buildXmlJarFileRef(String fileName) {
- XmlJarFileRef ref = PersistenceFactory.eINSTANCE.createXmlJarFileRef();
- ref.setFileName(fileName);
- return ref;
- }
-
- protected JarFileRef buildJarFileRef(XmlJarFileRef xmlJarFileRef) {
- return this.getContextNodeFactory().buildJarFileRef(this, xmlJarFileRef);
- }
-
- public void removeJarFileRef(JarFileRef jarFileRef) {
- this.removeJarFileRef(this.jarFileRefs.indexOf(jarFileRef));
- }
-
- public void removeJarFileRef(int index) {
- this.removeJarFileRef_(index);
- this.xmlPersistenceUnit.getJarFiles().remove(index);
- }
-
- /**
- * dispose the JAR file ref
- */
- protected void removeJarFileRef_(int index) {
- this.removeItemFromList(index, this.jarFileRefs, JAR_FILE_REFS_LIST).dispose();
- }
-
- protected void initializeJarFileRefs() {
- for (XmlJarFileRef xmlJarFileRef : this.getXmlJarFileRefs()) {
- this.jarFileRefs.add(this.buildJarFileRef(xmlJarFileRef));
- }
- }
-
- protected void syncJarFileRefs() {
- ContextContainerTools.synchronizeWithResourceModel(this.jarFileRefContainerAdapter);
- }
-
- protected Iterable<XmlJarFileRef> getXmlJarFileRefs() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlJarFileRef>(this.xmlPersistenceUnit.getJarFiles());
- }
-
- protected void moveJarFileRef_(int index, JarFileRef jarFileRef) {
- this.moveItemInList(index, jarFileRef, this.jarFileRefs, JAR_FILE_REFS_LIST);
- }
-
- protected JarFileRef addJarFileRef_(int index, XmlJarFileRef xmlJarFileRef) {
- JarFileRef jarFileRef = this.buildJarFileRef(xmlJarFileRef);
- this.addItemToList(index, jarFileRef, this.jarFileRefs, JAR_FILE_REFS_LIST);
- return jarFileRef;
- }
-
- protected void removeJarFileRef_(JarFileRef jarFileRef) {
- this.removeJarFileRef_(this.jarFileRefs.indexOf(jarFileRef));
- }
-
- /**
- * JAR file ref container adapter
- */
- protected class JarFileRefContainerAdapter
- implements ContextContainerTools.Adapter<JarFileRef, XmlJarFileRef>
- {
- public Iterable<JarFileRef> getContextElements() {
- return AbstractPersistenceUnit.this.getJarFileRefs();
- }
- public Iterable<XmlJarFileRef> getResourceElements() {
- return AbstractPersistenceUnit.this.getXmlJarFileRefs();
- }
- public XmlJarFileRef getResourceElement(JarFileRef contextElement) {
- return contextElement.getXmlJarFileRef();
- }
- public void moveContextElement(int index, JarFileRef element) {
- AbstractPersistenceUnit.this.moveJarFileRef_(index, element);
- }
- public void addContextElement(int index, XmlJarFileRef resourceElement) {
- AbstractPersistenceUnit.this.addJarFileRef_(index, resourceElement);
- }
- public void removeContextElement(JarFileRef element) {
- AbstractPersistenceUnit.this.removeJarFileRef_(element);
- }
- }
-
-
- // ********** 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();
- }
-
- /**
- * Return the class ref names, both specified and implied.
- */
- protected Iterable<String> getClassRefNames() {
- return new TransformationIterable<ClassRef, String>(this.getClassRefs()) {
- @Override
- protected String transform(ClassRef classRef) {
- return classRef.getClassName();
- }
- };
- }
-
-
- // ********** specified class refs **********
-
- public ListIterator<ClassRef> specifiedClassRefs() {
- return this.getSpecifiedClassRefs().iterator();
- }
-
- protected ListIterable<ClassRef> getSpecifiedClassRefs() {
- return new LiveCloneListIterable<ClassRef>(this.specifiedClassRefs);
- }
-
- public int specifiedClassRefsSize() {
- return this.specifiedClassRefs.size();
- }
-
- public ClassRef addSpecifiedClassRef(String className) {
- return this.addSpecifiedClassRef(this.specifiedClassRefs.size(), className);
- }
-
- public ClassRef addSpecifiedClassRef(int index, String className) {
- XmlJavaClassRef xmlClassRef = this.buildXmlJavaClassRef(className);
- ClassRef classRef = this.addSpecifiedClassRef_(index, xmlClassRef);
- this.xmlPersistenceUnit.getClasses().add(index, xmlClassRef);
- return classRef;
- }
-
- protected XmlJavaClassRef buildXmlJavaClassRef(String className) {
- XmlJavaClassRef ref = PersistenceFactory.eINSTANCE.createXmlJavaClassRef();
- ref.setJavaClass(className);
- return ref;
- }
-
- protected ClassRef buildClassRef(XmlJavaClassRef xmlClassRef) {
- return this.getContextNodeFactory().buildClassRef(this, xmlClassRef);
- }
-
- public void removeSpecifiedClassRef(ClassRef classRef) {
- this.removeSpecifiedClassRef(this.specifiedClassRefs.indexOf(classRef));
- }
-
- public void removeSpecifiedClassRef(int index) {
- this.removeSpecifiedClassRef_(index);
- this.xmlPersistenceUnit.getClasses().remove(index);
- }
-
- /**
- * dispose the class ref
- */
- protected void removeSpecifiedClassRef_(int index) {
- this.removeItemFromList(index, this.specifiedClassRefs, SPECIFIED_CLASS_REFS_LIST).dispose();
- }
-
- protected void initializeSpecifiedClassRefs() {
- for (XmlJavaClassRef xmlJavaClassRef : this.getXmlClassRefs()) {
- this.specifiedClassRefs.add(this.buildClassRef(xmlJavaClassRef));
- }
- }
-
- protected void syncSpecifiedClassRefs() {
- ContextContainerTools.synchronizeWithResourceModel(this.specifiedClassRefContainerAdapter);
- }
-
- protected Iterable<XmlJavaClassRef> getXmlClassRefs() {
- // clone to reduce chance of concurrency problems
- return new LiveCloneIterable<XmlJavaClassRef>(this.xmlPersistenceUnit.getClasses());
- }
-
- protected void moveSpecifiedClassRef_(int index, ClassRef classRef) {
- this.moveItemInList(index, classRef, this.specifiedClassRefs, SPECIFIED_CLASS_REFS_LIST);
- }
-
- protected ClassRef addSpecifiedClassRef_(int index, XmlJavaClassRef xmlClassRef) {
- ClassRef classRef = this.buildClassRef(xmlClassRef);
- this.addItemToList(index, classRef, this.specifiedClassRefs, SPECIFIED_CLASS_REFS_LIST);
- return classRef;
- }
-
- protected void removeSpecifiedClassRef_(ClassRef classRef) {
- this.removeSpecifiedClassRef_(this.specifiedClassRefs.indexOf(classRef));
- }
-
- /**
- * specified class ref container adapter
- */
- protected class SpecifiedClassRefContainerAdapter
- implements ContextContainerTools.Adapter<ClassRef, XmlJavaClassRef>
- {
- public Iterable<ClassRef> getContextElements() {
- return AbstractPersistenceUnit.this.getSpecifiedClassRefs();
- }
- public Iterable<XmlJavaClassRef> getResourceElements() {
- return AbstractPersistenceUnit.this.getXmlClassRefs();
- }
- public XmlJavaClassRef getResourceElement(ClassRef contextElement) {
- return contextElement.getXmlClassRef();
- }
- public void moveContextElement(int index, ClassRef element) {
- AbstractPersistenceUnit.this.moveSpecifiedClassRef_(index, element);
- }
- public void addContextElement(int index, XmlJavaClassRef resourceElement) {
- AbstractPersistenceUnit.this.addSpecifiedClassRef_(index, resourceElement);
- }
- public void removeContextElement(ClassRef element) {
- AbstractPersistenceUnit.this.removeSpecifiedClassRef_(element);
- }
- }
-
-
- // ********** virtual class refs **********
-
- public Iterator<ClassRef> impliedClassRefs() {
- return this.getImpliedClassRefs().iterator();
- }
-
- 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) {
- this.impliedClassRefs.remove(classRef);
- classRef.dispose();
- this.fireItemRemoved(IMPLIED_CLASS_REFS_COLLECTION, classRef);
- }
-
- protected void updateImpliedClassRefs() {
- ContextContainerTools.update(this.impliedClassRefContainerAdapter);
- }
-
- protected Iterable<String> getImpliedClassNames() {
- return this.excludesUnlistedClasses() ?
- EmptyIterable.<String>instance() :
- this.getImpliedClassNames_();
- }
-
- /**
- * Return the names of all the Java classes in the JPA project that are
- * mapped (i.e. have the appropriate annotation etc.) but not specified
- * in the persistence unit.
- */
- protected Iterable<String> getImpliedClassNames_() {
- return new FilteringIterable<String>(this.getJpaProject().getMappedJavaSourceClassNames()) {
- @Override
- protected boolean accept(String mappedClassName) {
- return ! AbstractPersistenceUnit.this.specifiesPersistentType(mappedClassName);
- }
- };
- }
-
- /**
- * Virtual class ref container adapter.
- * <p>
- * <strong>NB:</strong> The context class ref is matched with a resource
- * class by name.
- * <p>
- * This is used during <strong>both</strong> <em>sync</em> and
- * <em>update</em> because the list of implied class refs can be modified
- * in either situation. In particular, we cannot simply rely on
- * <em>update</em> because there are situations where a <em>sync</em> is
- * triggered but a follow-up <em>update</em> is not. (Of course, any
- * change discovered here will trigger an <em>update</em>.)
- * <p>
- * The most obvious example is when the JPA project is configured to
- * discover annotated classes and a Java class is annotated for the first
- * time (via code editing, not via the context model). This will trigger
- * a <em>sync</em>; but, since the unannotated class is not yet in the
- * context model and, as a result, the context model's state is untouched,
- * an <em>update</em> will not be triggered.
- * <p>
- * Obviously, other context model changes can change this collection (e.g.
- * setting whether the persistence unit excludes unlisted classes); o the
- * collection must also be synchronized during <em>update</em>.
- */
- protected class ImpliedClassRefContainerAdapter
- implements ContextContainerTools.Adapter<ClassRef, String>
- {
- public Iterable<ClassRef> getContextElements() {
- return AbstractPersistenceUnit.this.getImpliedClassRefs();
- }
- public Iterable<String> getResourceElements() {
- return AbstractPersistenceUnit.this.getImpliedClassNames();
- }
- public String getResourceElement(ClassRef contextElement) {
- return contextElement.getClassName();
- }
- public void moveContextElement(int index, ClassRef element) {
- // ignore moves - we don't care about the order of the implied class refs
- }
- public void addContextElement(int index, String resourceElement) {
- // ignore the index - we don't care about the order of the implied class refs
- AbstractPersistenceUnit.this.addImpliedClassRef(resourceElement);
- }
- public void removeContextElement(ClassRef element) {
- AbstractPersistenceUnit.this.removeImpliedClassRef(element);
- }
- }
-
-
- // ********** 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) {
- this.setSpecifiedExcludeUnlistedClasses_(specifiedExcludeUnlistedClasses);
- this.xmlPersistenceUnit.setExcludeUnlistedClasses(this.specifiedExcludeUnlistedClasses);
- }
-
- protected void setSpecifiedExcludeUnlistedClasses_(Boolean excludeUnlistedClasses) {
- Boolean old = this.specifiedExcludeUnlistedClasses;
- this.specifiedExcludeUnlistedClasses = excludeUnlistedClasses;
- this.firePropertyChanged(SPECIFIED_EXCLUDE_UNLISTED_CLASSES_PROPERTY, old, excludeUnlistedClasses);
- }
-
- public boolean getDefaultExcludeUnlistedClasses() {
- return false; // ???
- }
-
-
- // ********** properties **********
-
- public ListIterator<Property> properties() {
- return this.getProperties().iterator();
- }
-
- protected ListIterable<Property> getProperties() {
- return new LiveCloneListIterable<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) {
- return Tools.valuesAreEqual(property.getName(), 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) {
- XmlProperty xmlProperty = this.buildXmlProperty();
- Property property = this.addProperty_(index, xmlProperty);
-
- XmlProperties xmlProperties = this.xmlPersistenceUnit.getProperties();
- if (xmlProperties == null) {
- xmlProperties = this.buildXmlProperties();
- this.xmlPersistenceUnit.setProperties(xmlProperties);
- }
-
- xmlProperties.getProperties().add(index, xmlProperty);
- if (property.getName() != null) {
- this.propertyAdded(property.getName(), property.getValue());
- }
- return property;
- }
-
- protected XmlProperty buildXmlProperty() {
- return PersistenceFactory.eINSTANCE.createXmlProperty();
- }
-
- 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());
- }
- }
-
- 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);
- }
-
- protected void propertyAdded(String propertyName, String value) {
- this.propertyValueChanged(propertyName, value);
- }
-
- protected void propertyRemoved(String propertyName) {
- this.connection.propertyRemoved(propertyName);
- this.options.propertyRemoved(propertyName);
- }
-
- protected void initializeProperties() {
- for (XmlProperty xmlProperty : this.getXmlProperties()) {
- this.properties.add(this.buildProperty(xmlProperty));
- }
- this.connection = this.getContextNodeFactory().buildConnection(this);
- this.options = this.getContextNodeFactory().buildOptions(this);
- }
-
- protected void syncProperties() {
- ContextContainerTools.synchronizeWithResourceModel(this.propertyContainerAdapter);
- }
-
- protected Iterable<XmlProperty> getXmlProperties() {
- XmlProperties xmlProperties = this.xmlPersistenceUnit.getProperties();
- // clone to reduce chance of concurrency problems
- return (xmlProperties == null) ?
- EmptyIterable.<XmlProperty>instance() :
- new LiveCloneIterable<XmlProperty>(xmlProperties.getProperties());
- }
-
- protected void moveProperty_(int index, Property property) {
- this.moveItemInList(index, this.properties.indexOf(property), this.properties, PROPERTIES_LIST);
- }
-
- protected Property addProperty_(int index, XmlProperty xmlProperty) {
- Property property = this.buildProperty(xmlProperty);
- this.addItemToList(index, property, this.properties, PROPERTIES_LIST);
- if (property.getName() != null) {
- this.propertyAdded(property.getName(), property.getValue());
- }
- return property;
- }
-
- protected void removeProperty_(Property property) {
- this.removeItemFromList(property, this.properties, PROPERTIES_LIST);
- if (property.getName() != null) {
- this.propertyRemoved(property.getName());
- }
- }
-
- /**
- * property container adapter
- */
- protected class PropertyContainerAdapter
- implements ContextContainerTools.Adapter<Property, XmlProperty>
- {
- public Iterable<Property> getContextElements() {
- return AbstractPersistenceUnit.this.getProperties();
- }
- public Iterable<XmlProperty> getResourceElements() {
- return AbstractPersistenceUnit.this.getXmlProperties();
- }
- public XmlProperty getResourceElement(Property contextElement) {
- return contextElement.getXmlProperty();
- }
- public void moveContextElement(int index, Property element) {
- AbstractPersistenceUnit.this.moveProperty_(index, element);
- }
- public void addContextElement(int index, XmlProperty resourceElement) {
- AbstractPersistenceUnit.this.addProperty_(index, resourceElement);
- }
- public void removeContextElement(Property element) {
- AbstractPersistenceUnit.this.removeProperty_(element);
- }
- }
-
-
- // ********** mapping file (orm.xml) persistence unit metadata & defaults **********
-
- public boolean isXmlMappingMetadataComplete() {
- return this.xmlMappingMetadataComplete;
- }
-
- protected void setXmlMappingMetadataComplete(boolean xmlMappingMetadataComplete) {
- boolean old = this.xmlMappingMetadataComplete;
- this.xmlMappingMetadataComplete = xmlMappingMetadataComplete;
- this.firePropertyChanged(XML_MAPPING_METADATA_COMPLETE_PROPERTY, old, xmlMappingMetadataComplete);
- }
-
- protected boolean buildXmlMappingMetadataComplete(MappingFilePersistenceUnitMetadata metadata) {
- return (metadata == null) ? false : metadata.isXmlMappingMetadataComplete();
- }
-
- 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);
- }
-
- public String getDefaultCatalog() {
- return this.defaultCatalog;
- }
-
- protected void setDefaultCatalog(String catalog) {
- String old = this.defaultCatalog;
- this.defaultCatalog = catalog;
- this.firePropertyChanged(DEFAULT_CATALOG_PROPERTY, old, catalog);
- }
-
- protected String buildDefaultCatalog(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 schema) {
- String old = this.defaultSchema;
- this.defaultSchema = schema;
- this.firePropertyChanged(DEFAULT_SCHEMA_PROPERTY, old, schema);
- }
-
- 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 cascadePersist) {
- boolean old = this.defaultCascadePersist;
- this.defaultCascadePersist = cascadePersist;
- this.firePropertyChanged(DEFAULT_CASCADE_PERSIST_PROPERTY, old, cascadePersist);
- }
-
- protected boolean buildDefaultCascadePersist(MappingFilePersistenceUnitDefaults defaults) {
- return (defaults == null) ? false : defaults.isCascadePersist();
- }
-
- public boolean getDefaultDelimitedIdentifiers() {
- return this.defaultDelimitedIdentifiers;
- }
-
- protected void setDefaultDelimitedIdentifiers(boolean delimitedIdentifiers) {
- boolean old = this.defaultDelimitedIdentifiers;
- this.defaultDelimitedIdentifiers = delimitedIdentifiers;
- this.firePropertyChanged(DEFAULT_DELIMITED_IDENTIFIERS_PROPERTY, old, delimitedIdentifiers);
- }
-
- protected boolean buildDefaultDelimitedIdentifiers(MappingFilePersistenceUnitDefaults defaults) {
- return ( ! this.isJpa2_0Compatible()) ? false :
- (defaults == null) ? false : ((MappingFilePersistenceUnitDefaults2_0) defaults).isDelimitedIdentifiers();
- }
-
- protected void updatePersistenceUnitMetadata() {
- MappingFilePersistenceUnitMetadata metadata = this.getMetadata();
- this.setXmlMappingMetadataComplete(this.buildXmlMappingMetadataComplete(metadata));
-
- MappingFilePersistenceUnitDefaults defaults = (metadata == null) ? null : metadata.getPersistenceUnitDefaults();
- this.setDefaultAccess((defaults == null) ? null : defaults.getAccess());
- this.setDefaultCatalog(this.buildDefaultCatalog(defaults));
- this.setDefaultSchema(this.buildDefaultSchema(defaults));
- this.setDefaultDelimitedIdentifiers(this.buildDefaultDelimitedIdentifiers(defaults));
- }
-
- /**
- * return the first persistence unit metadata we encounter
- * in a mapping file
- */
- protected MappingFilePersistenceUnitMetadata getMetadata() {
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.persistenceUnitMetadataExists()) {
- return mappingFileRef.getPersistenceUnitMetadata();
- }
- }
- 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) {
- this.setSpecifiedSharedCacheMode_(specifiedSharedCacheMode);
- this.xmlPersistenceUnit.setSharedCacheMode(SharedCacheMode.toXmlResourceModel(specifiedSharedCacheMode));
- }
-
- protected void setSpecifiedSharedCacheMode_(SharedCacheMode sharedCacheMode) {
- SharedCacheMode old = this.specifiedSharedCacheMode;
- this.specifiedSharedCacheMode = sharedCacheMode;
- this.firePropertyChanged(SPECIFIED_SHARED_CACHE_MODE_PROPERTY, old, sharedCacheMode);
- }
-
- 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() {
- SharedCacheMode sharedCacheMode = this.getSharedCacheMode();
- if (sharedCacheMode == null) {
- return false; // this can happen during initial update...
- }
- switch (sharedCacheMode) {
- case NONE:
- case ENABLE_SELECTIVE:
- case UNSPECIFIED:
- return false;
- case ALL:
- case DISABLE_SELECTIVE:
- return true;
- default:
- throw new IllegalStateException("unknown mode: " + sharedCacheMode); //$NON-NLS-1$
- }
- }
-
- 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) {
- this.setSpecifiedValidationMode_(specifiedValidationMode);
- this.xmlPersistenceUnit.setValidationMode(ValidationMode.toXmlResourceModel(specifiedValidationMode));
- }
-
- protected void setSpecifiedValidationMode_(ValidationMode validationMode) {
- ValidationMode old = this.specifiedValidationMode;
- this.specifiedValidationMode = validationMode;
- this.firePropertyChanged(SPECIFIED_VALIDATION_MODE_PROPERTY, old, validationMode);
- }
-
- 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 Iterator<Generator> generators() {
- return this.getGenerators().iterator();
- }
-
- protected Iterable<Generator> getGenerators() {
- return new LiveCloneIterable<Generator>(this.generators);
- }
-
- public int generatorsSize() {
- return this.generators.size();
- }
-
- public void addGenerator(Generator generator) {
- this.generators.add(generator);
- }
-
- public Iterable<String> getUniqueGeneratorNames() {
- HashSet<String> names = new HashSet<String>(this.generators.size());
- this.addNonEmptyGeneratorNamesTo(names);
- return names;
- }
-
- protected void addNonEmptyGeneratorNamesTo(Set<String> names) {
- for (Generator generator : this.getGenerators()) {
- String generatorName = generator.getName();
- if (StringTools.stringIsNotEmpty(generatorName)) {
- names.add(generatorName);
- }
- }
- }
-
- protected void setGenerators(Iterable<Generator> generators) {
- this.synchronizeCollection(generators, this.generators, GENERATORS_COLLECTION);
- }
-
- /**
- * We only hold "active" generators; i.e. the mapping file generators and
- * the Java generators that are not "overridden" by mapping file
- * generators (by generator name).
- */
- protected Iterable<Generator> buildGenerators() {
- ArrayList<Generator> generatorList = new ArrayList<Generator>();
-
- this.addMappingFileGeneratorsTo(generatorList);
-
- HashMap<String, ArrayList<Generator>> mappingFileGenerators = this.mapGeneratorsByName(this.getMappingFileGenerators());
- HashMap<String, ArrayList<Generator>> javaGenerators = this.mapGeneratorsByName(this.getJavaGenerators());
- for (Map.Entry<String, ArrayList<Generator>> javaGeneratorEntry : javaGenerators.entrySet()) {
- if (mappingFileGenerators.get(javaGeneratorEntry.getKey()) == null) {
- generatorList.addAll(javaGeneratorEntry.getValue());
- }
- }
-
- return generatorList;
- }
-
- protected Iterable<Generator> getMappingFileGenerators() {
- ArrayList<Generator> generatorList = new ArrayList<Generator>();
- this.addMappingFileGeneratorsTo(generatorList);
- return generatorList;
- }
-
- protected void addMappingFileGeneratorsTo(ArrayList<Generator> generatorList) {
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- MappingFile mappingFile = mappingFileRef.getMappingFile();
- // TODO bjv - bogus cast - need to add API to MappingFileRef?
- if (mappingFile instanceof OrmXml) {
- EntityMappings entityMappings = ((OrmXml) mappingFile).getRoot();
- if (entityMappings != null) {
- CollectionTools.addAll(generatorList, entityMappings.getSequenceGenerators());
- CollectionTools.addAll(generatorList, entityMappings.getTableGenerators());
- }
- }
- }
- this.addGeneratorsTo(this.getMappingFilePersistentTypes(), generatorList);
- }
-
- /**
- * Include "overridden" Java generators.
- */
- protected Iterable<Generator> getJavaGenerators() {
- ArrayList<Generator> generatorList = new ArrayList<Generator>();
- this.addJavaGeneratorsTo(generatorList);
- return generatorList;
- }
-
- /**
- * Include "overridden" Java generators.
- */
- protected void addJavaGeneratorsTo(ArrayList<Generator> generatorList) {
- this.addGeneratorsTo(this.getAllJavaPersistentTypesUnique(), generatorList);
- }
-
- // TODO bjv - bogus casts - need to delegate...
- protected void addGeneratorsTo(Iterable<PersistentType> persistentTypes, ArrayList<Generator> generatorList) {
- for (PersistentType persistentType : persistentTypes) {
- TypeMapping typeMapping = persistentType.getMapping();
- if (typeMapping instanceof Entity) {
- this.addGeneratorsTo(((Entity) typeMapping).getGeneratorContainer(), generatorList);
- }
- for (ReadOnlyPersistentAttribute persistentAttribute : CollectionTools.iterable(persistentType.attributes())) {
- AttributeMapping attributeMapping = persistentAttribute.getMapping();
- if (attributeMapping instanceof IdMapping) {
- this.addGeneratorsTo(((IdMapping) attributeMapping).getGeneratorContainer(), generatorList);
- }
- }
- }
- }
-
- protected void addGeneratorsTo(GeneratorContainer generatorContainer, ArrayList<Generator> generatorList) {
- Generator generator = generatorContainer.getSequenceGenerator();
- if (generator != null) {
- generatorList.add(generator);
- }
- generator = generatorContainer.getTableGenerator();
- if (generator != null) {
- generatorList.add(generator);
- }
- }
-
- protected HashMap<String, ArrayList<Generator>> mapGeneratorsByName(Iterable<Generator> generatorList) {
- HashMap<String, ArrayList<Generator>> map = new HashMap<String, ArrayList<Generator>>();
- for (Generator generator : generatorList) {
- String generatorName = generator.getName();
- ArrayList<Generator> list = map.get(generatorName);
- if (list == null) {
- list = new ArrayList<Generator>();
- map.put(generatorName, list);
- }
- list.add(generator);
- }
- return map;
- }
-
-
- // ********** queries **********
-
- public Iterator<Query> queries() {
- return this.getQueries().iterator();
- }
-
- protected Iterable<Query> getQueries() {
- return new LiveCloneIterable<Query>(this.queries);
- }
-
- public int queriesSize() {
- return this.queries.size();
- }
-
- public void addQuery(Query query) {
- this.queries.add(query);
- }
-
- protected void setQueries(Iterable<Query> queries) {
- this.synchronizeCollection(queries, this.queries, QUERIES_COLLECTION);
- }
-
- /**
- * We only hold "active" queries; i.e. the mapping file queries and
- * the Java queries that are not "overridden" by mapping file
- * queries (by query name).
- */
- protected Iterable<Query> buildQueries() {
- ArrayList<Query> queryList = new ArrayList<Query>();
-
- this.addMappingFileQueriesTo(queryList);
-
- HashMap<String, ArrayList<Query>> mappingFileQueries = this.mapQueriesByName(this.getMappingFileQueries());
- HashMap<String, ArrayList<Query>> javaQueries = this.mapQueriesByName(this.getJavaQueries());
- for (Map.Entry<String, ArrayList<Query>> javaQueryEntry : javaQueries.entrySet()) {
- if (mappingFileQueries.get(javaQueryEntry.getKey()) == null) {
- queryList.addAll(javaQueryEntry.getValue());
- }
- }
-
- return queryList;
- }
-
- protected Iterable<Query> getMappingFileQueries() {
- ArrayList<Query> queryList = new ArrayList<Query>();
- this.addMappingFileQueriesTo(queryList);
- return queryList;
- }
-
- protected void addMappingFileQueriesTo(ArrayList<Query> queryList) {
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- MappingFile mappingFile = mappingFileRef.getMappingFile();
- // TODO bjv - bogus cast - need to add API to MappingFileRef?
- if (mappingFile instanceof OrmXml) {
- EntityMappings entityMappings = ((OrmXml) mappingFile).getRoot();
- if (entityMappings != null) {
- this.addQueriesTo(entityMappings.getQueryContainer(), queryList);
- }
- }
- }
- this.addMappingFileQueriesTo(this.getMappingFilePersistentTypes(), queryList);
- }
-
- // TODO bjv - bogus casts - need to delegate...
- protected void addMappingFileQueriesTo(Iterable<PersistentType> persistentTypes, ArrayList<Query> queryList) {
- for (PersistentType persistentType : persistentTypes) {
- TypeMapping typeMapping = persistentType.getMapping();
- if (typeMapping instanceof Entity) {
- this.addQueriesTo(((Entity) typeMapping).getQueryContainer(), queryList);
- }
- // spec does not allow queries to be defined on mapped superclasses in orm.xml (huh?)
- }
- }
-
- /**
- * Include "overridden" Java queries.
- */
- protected Iterable<Query> getJavaQueries() {
- ArrayList<Query> queryList = new ArrayList<Query>();
- this.addJavaQueriesTo(queryList);
- return queryList;
- }
-
- /**
- * Include "overridden" Java queries.
- */
- protected void addJavaQueriesTo(ArrayList<Query> queryList) {
- this.addJavaQueriesTo(this.getAllJavaPersistentTypesUnique(), queryList);
- }
-
- // TODO bjv - bogus casts - need to delegate...
- protected void addJavaQueriesTo(Iterable<PersistentType> persistentTypes, ArrayList<Query> queryList) {
- for (PersistentType persistentType : persistentTypes) {
- TypeMapping typeMapping = persistentType.getMapping();
- if (typeMapping instanceof Entity) {
- this.addQueriesTo(((Entity) typeMapping).getQueryContainer(), queryList);
- }
-// TODO not yet supported by Dali
-// else if (typeMapping instanceof MappedSuperclass) {
-// this.addQueriesTo(((MappedSuperclass) typeMapping).getQueryContainer(), queryList);
-// }
- }
- }
-
- protected void addQueriesTo(QueryContainer queryContainer, ArrayList<Query> queryList) {
- CollectionTools.addAll(queryList, queryContainer.namedQueries());
- CollectionTools.addAll(queryList, queryContainer.namedNativeQueries());
- }
-
- protected HashMap<String, ArrayList<Query>> mapQueriesByName(Iterable<Query> queryList) {
- HashMap<String, ArrayList<Query>> map = new HashMap<String, ArrayList<Query>>();
- for (Query query : queryList) {
- String queryName = query.getName();
- ArrayList<Query> list = map.get(queryName);
- if (list == null) {
- list = new ArrayList<Query>();
- map.put(queryName, list);
- }
- list.add(query);
- }
- return map;
- }
-
-
- // ********** persistent types **********
-
- @SuppressWarnings("unchecked")
- public Iterable<PersistentType> getPersistentTypes() {
- return new CompositeIterable<PersistentType>(
- this.getMappingFilePersistentTypes(),
- this.getJavaPersistentTypes()
- );
- }
-
- protected Iterable<PersistentType> getMappingFilePersistentTypes() {
- return new CompositeIterable<PersistentType>(this.getMappingFilePersistentTypeLists());
- }
-
- protected Iterable<Iterable<? extends PersistentType>> getMappingFilePersistentTypeLists() {
- return new TransformationIterable<PersistentTypeContainer, Iterable<? extends PersistentType>>(
- this.getMappingFileRefs(),
- PersistentTypeContainer.TRANSFORMER
- );
- }
-
- /**
- * Return the non-<code>null</code> mapping file Java persistent types;
- * i.e. the Java persistent types corresponding to the mapping file
- * persistent types that are not marked "metadata complete".
- * @see #getAllJavaPersistentTypesUnique()
- */
- protected Iterable<PersistentType> getMappingFileJavaPersistentTypes() {
- return new FilteringIterable<PersistentType>(
- this.getMappingFileJavaPersistentTypes_(),
- NotNullFilter.<PersistentType>instance()
- );
- }
-
- /**
- * The returned list will contain a <code>null</code> for each mapping file
- * persistent type that does not correspond to an existing Java type or is
- * marked "metadata complete".
- * @see #getMappingFileJavaPersistentTypes()
- */
- // TODO bjv remove - bogus cast to OrmPersistentType - probably need to add API to MappingFile
- // getOverriddenPersistentTypes()?
- protected Iterable<PersistentType> getMappingFileJavaPersistentTypes_() {
- return new TransformationIterable<PersistentType, PersistentType>(this.getMappingFilePersistentTypes()) {
- @Override
- protected PersistentType transform(PersistentType mappingFilePersistentType) {
- return (mappingFilePersistentType instanceof OrmPersistentType) ?
- this.transform((OrmPersistentType) mappingFilePersistentType) :
- null;
- }
- protected PersistentType transform(OrmPersistentType mappingFilePersistentType) {
- return mappingFilePersistentType.getMapping().isMetadataComplete() ?
- null :
- mappingFilePersistentType.getJavaPersistentType();
- }
- };
- }
-
- /**
- * Return the persistence unit's Java persistent types, as specified by
- * the class refs (both specified and implied) and jar files.
- * There can be duplicate types, and any of them may be overridden by a
- * mapping file persistence type.
- * @see #getMappingFilePersistentTypes()
- */
- @SuppressWarnings("unchecked")
- protected Iterable<PersistentType> getJavaPersistentTypes() {
- return new CompositeIterable<PersistentType>(
- this.getClassRefPersistentTypes(),
- this.getJarFilePersistentTypes()
- );
- }
-
- /**
- * Return the non-<code>null</code> class ref persistent types,
- * both specified and implied.
- */
- protected Iterable<PersistentType> getClassRefPersistentTypes() {
- return new FilteringIterable<PersistentType>(
- this.getClassRefPersistentTypes_(),
- NotNullFilter.<PersistentType>instance()
- );
- }
-
- /**
- * Both specified and implied. May contain <code>null</code>s.
- * @see #getClassRefPersistentTypes()
- */
- protected Iterable<PersistentType> getClassRefPersistentTypes_() {
- return new TransformationIterable<ClassRef, PersistentType>(this.getClassRefs()) {
- @Override
- protected PersistentType transform(ClassRef classRef) {
- return classRef.getJavaPersistentType();
- }
- };
- }
-
- /**
- * We only get <em>annotated</em> types from jar files.
- */
- protected Iterable<PersistentType> getJarFilePersistentTypes() {
- return new CompositeIterable<PersistentType>(this.getJarFilePersistentTypeLists());
- }
-
- /**
- * We only get <em>annotated</em> types from jar files.
- */
- protected Iterable<Iterable<? extends PersistentType>> getJarFilePersistentTypeLists() {
- return new TransformationIterable<PersistentTypeContainer, Iterable<? extends PersistentType>>(
- this.getJarFileRefs(),
- PersistentTypeContainer.TRANSFORMER
- );
- }
-
- public PersistentType getPersistentType(String typeName) {
- if (typeName == null) {
- return null;
- }
- // search order is significant(?)
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- PersistentType persistentType = mappingFileRef.getPersistentType(typeName);
- if (persistentType != null) {
- return persistentType;
- }
- }
- for (ClassRef classRef : this.getClassRefs()) {
- if (classRef.isFor(typeName)) {
- return classRef.getJavaPersistentType();
- }
- }
- for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- PersistentType persistentType = jarFileRef.getPersistentType(typeName);
- if (persistentType != null) {
- return persistentType;
- }
- }
- return null;
- }
-
- /**
- * Ignore implied class refs and jar files.
- */
- public boolean specifiesPersistentType(String typeName) {
- for (ClassRef classRef : this.getSpecifiedClassRefs()) {
- if (classRef.isFor(typeName)) {
- return true;
- }
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.getPersistentType(typeName) != null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return a list of <em>all</em> the persistence unit's Java persistent
- * types (including those referenced by the mapping files that are not
- * marked "metadata complete") with those with duplicate names removed.
- * Although this may not always be true, assume persistent types with
- * the same name reference the same Java type. (<strong>NB:</strong>
- * It's possible that a Java class in a jar file has the same name as a
- * Java class in the project and they be different....)
- * <p>
- * This is really only useful for the calculation of generators and queries,
- * which can be defined in Java annotations but still be "active" even
- * though their corresponding Java types/attributes have been overridden in
- * a mapping file.
- * <p>
- * The order of precedence:<ul>
- * <li>mapping files
- * <li>persistence unit class refs
- * <li>jar files
- * </ul>
- */
- protected Iterable<PersistentType> getAllJavaPersistentTypesUnique() {
- // order is significant(?)
- HashMap<String, PersistentType> map = new HashMap<String, PersistentType>();
- this.addPersistentTypesTo(this.getJarFilePersistentTypes(), map);
- this.addPersistentTypesTo(this.getClassRefPersistentTypes(), map);
- this.addPersistentTypesTo(this.getMappingFileJavaPersistentTypes(), map);
- return map.values();
- }
-
- /**
- * Add the specified persistent types to
- * the specified map keyed by persistent type name.
- */
- protected void addPersistentTypesTo(Iterable<? extends PersistentType> persistentTypes, HashMap<String, PersistentType> persistentTypeMap) {
- for (PersistentType pt : persistentTypes) {
- String ptName = pt.getName();
- if (ptName != null) {
- persistentTypeMap.put(ptName, pt);
- }
- }
- }
-
-
- // ********** type mappings **********
-
- public Entity getEntity(String typeName) {
- TypeMapping typeMapping = this.getTypeMapping(typeName);
- return (typeMapping instanceof Entity) ? (Entity) typeMapping : null;
- }
-
- public Embeddable getEmbeddable(String typeName) {
- TypeMapping typeMapping = this.getTypeMapping(typeName);
- return (typeMapping instanceof Embeddable) ? (Embeddable) typeMapping : null;
- }
-
- // TODO bjv - this should probably *not* return Java type mappings when PU is "metadata complete"...
- protected TypeMapping getTypeMapping(String typeName) {
- PersistentType persistentType = this.getPersistentType(typeName);
- return (persistentType == null) ? null : persistentType.getMapping();
- }
-
- public Iterable<Entity> getEntities() {
- return this.filterToEntities(this.getTypeMappings());
- }
-
- protected Iterable<Entity> filterToEntities(Iterable<TypeMapping> typeMappings) {
- return new SubIterableWrapper<TypeMapping, Entity>(this.filterToEntities_(typeMappings));
- }
-
- protected Iterable<TypeMapping> filterToEntities_(Iterable<TypeMapping> typeMappings) {
- return new FilteringIterable<TypeMapping>(typeMappings) {
- @Override
- protected boolean accept(TypeMapping typeMapping) {
- return typeMapping instanceof Entity;
- }
- };
- }
-
- // TODO bjv - this should probably *not* return Java type mappings when PU is "metadata complete"...
- protected Iterable<TypeMapping> getTypeMappings() {
- return new TransformationIterable<PersistentType, TypeMapping>(this.getPersistentTypes()) {
- @Override
- protected TypeMapping transform(PersistentType persistentType) {
- return persistentType.getMapping(); // the mapping should never be null
- }
- };
- }
-
-
- // ********** mapping file type mappings **********
-
- /**
- * Return a map of the entities defined in the persistence unit's mapping files,
- * keyed by entity name. Since there can be (erroneously) duplicate entity
- * names, each entity name is mapped to a <em>list</em> of entities.
- */
- protected HashMap<String, ArrayList<Entity>> mapMappingFileEntitiesByName() {
- return this.mapTypeMappingsByName(this.getMappingFileEntities());
- }
-
- protected <M extends TypeMapping> HashMap<String, ArrayList<M>> mapTypeMappingsByName(Iterable<M> typeMappings) {
- HashMap<String, ArrayList<M>> map = new HashMap<String, ArrayList<M>>();
- for (M typeMapping : typeMappings) {
- String typeMappingName = typeMapping.getName();
- ArrayList<M> list = map.get(typeMappingName);
- if (list == null) {
- list = new ArrayList<M>();
- map.put(typeMappingName, list);
- }
- list.add(typeMapping);
- }
- return map;
- }
-
- /**
- * Return all the entities defined in the persistence unit's mapping files
- * (i.e. excluding the Java entities).
- */
- protected Iterable<Entity> getMappingFileEntities() {
- return this.filterToEntities(this.getMappingFileTypeMappings());
- }
-
- /**
- * Return all the type mappings defined in the persistence unit's mapping
- * files (i.e. excluding the Java type mappings).
- */
- protected Iterable<TypeMapping> getMappingFileTypeMappings() {
- return new TransformationIterable<PersistentType, TypeMapping>(this.getMappingFilePersistentTypes()) {
- @Override
- protected TypeMapping transform(PersistentType persistentType) {
- return persistentType.getMapping();
- }
- };
- }
-
- // TODO remove VVVVVVVVVVVVVVVVV
- public Iterable<String> getOrmMappedClassNames() {
- return new TransformationIterable<PersistentType, String>(this.getMappingFilePersistentTypes()) {
- @Override
- protected String transform(PersistentType persistentType) {
- return persistentType.getName();
- }
- };
- }
-
- public Map<String, Set<String>> mapEntityNameToClassNames() {
- HashMap<String, ArrayList<Entity>> mappingFileEntitiesByName = this.mapMappingFileEntitiesByName();
- HashMap<String, Set<String>> map = new HashMap<String, Set<String>>(mappingFileEntitiesByName.size());
- for (Map.Entry<String, ArrayList<Entity>> entry : mappingFileEntitiesByName.entrySet()) {
- String entityName = entry.getKey();
- ArrayList<Entity> entities = entry.getValue();
- HashSet<String> entityClassNames = new HashSet<String>(entities.size());
- for (Entity entity : entities) {
- entityClassNames.add(entity.getPersistentType().getName());
- }
- map.put(entityName, entityClassNames);
- }
- return map;
- }
-
- public Iterator<String> ormEntityNames() {
- return this.getMappingFileEntityNames().iterator();
- }
-
- protected Iterable<String> getMappingFileEntityNames() {
- return new TransformationIterable<Entity, String>(this.getMappingFileEntities()) {
- @Override
- protected String transform(Entity entity) {
- return entity.getName();
- }
- };
- }
-
- public Iterable<Entity> getOrmEntities() {
- return this.getMappingFileEntities();
- }
- // remove ^^^^^^^^^^^^^^^^^
-
-
- // ********** Java type mappings **********
-
- // TODO remove VVVVVVVVVVVVVVVVV
- /**
- * These may be overridden in the mapping files.
- * @see #getJavaPersistentTypes()
- */
- public Iterable<Entity> getJavaEntities() {
- return this.filterToEntities(this.getJavaTypeMappings());
- }
-
- /**
- * These may be overridden in the mapping files.
- * @see #getJavaPersistentTypes()
- */
- protected Iterable<TypeMapping> getJavaTypeMappings() {
- return new TransformationIterable<PersistentType, TypeMapping>(this.getJavaPersistentTypes()) {
- @Override
- protected TypeMapping transform(PersistentType persistentType) {
- return persistentType.getMapping();
- }
- };
- }
-
- protected Iterator<String> javaEntityClassNames(){
- return new TransformationIterator<Entity, String>(this.getJavaEntities()) {
- @Override
- protected String transform(Entity javaEntity) {
- return javaEntity.getPersistentType().getName();
- }
- };
- }
-
- public Iterator<String> javaEntityNamesExclOverridden() {
- HashSet<String> ormMappedClassNames = CollectionTools.set(this.getOrmMappedClassNames());
- List<String> javaEntityNamesExclOverridden = new ArrayList<String>();
- for (Iterator<String> javaEntityClassNames = this.javaEntityClassNames(); javaEntityClassNames.hasNext();){
- String javaEntityClassName = javaEntityClassNames.next();
- if (!ormMappedClassNames.contains(javaEntityClassName)) {
- javaEntityNamesExclOverridden.add((this.getEntity(javaEntityClassName)).getName());
- }
- }
- return javaEntityNamesExclOverridden.iterator();
- }
-
- public Iterator<String> javaEntityNames(){
- return new TransformationIterator<Entity, String>(this.getJavaEntities()) {
- @Override
- protected String transform(Entity javaEntity) {
- return javaEntity.getName();
- }
- };
- }
- // remove ^^^^^^^^^^^^^^^^^
-
-
- // ********** misc **********
-
- public XmlPersistenceUnit getXmlPersistenceUnit() {
- return this.xmlPersistenceUnit;
- }
-
- public JpaStructureNode getStructureNode(int textOffset) {
- for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- if (jarFileRef.containsOffset(textOffset)) {
- return jarFileRef;
- }
- }
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.containsOffset(textOffset)) {
- return mappingFileRef;
- }
- }
- for (ClassRef classRef : this.getClassRefs()) {
- if (classRef.containsOffset(textOffset)) {
- return classRef;
- }
- }
- return this;
- }
-
- 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);
- }
-
-
- // ********** 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);
- this.validateGenerators(messages, reporter);
- this.validateQueries(messages, reporter);
- }
-
- protected void validateMappingFiles(List<IMessage> messages, IReporter reporter) {
- this.checkForMultiplePersistenceUnitMetadata(messages);
- this.checkForDuplicateMappingFiles(messages);
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- mappingFileRef.validate(messages, reporter);
- }
- }
-
- protected void checkForMultiplePersistenceUnitMetadata(List<IMessage> messages) {
- boolean first = true;
- for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) {
- if (mappingFileRef.persistenceUnitMetadataExists()) {
- if (first) {
- first = false;
- } else {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.NORMAL_SEVERITY,
- JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA,
- new String[] {mappingFileRef.getFileName()},
- mappingFileRef
- )
- );
- }
- }
- }
- }
-
- protected void checkForDuplicateMappingFiles(List<IMessage> messages) {
- HashBag<String> fileNames = CollectionTools.bag(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 void validateClassRefs(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateClasses(messages);
- for (ClassRef classRef : this.getClassRefs()) {
- classRef.validate(messages, reporter);
- }
- }
-
- protected void checkForDuplicateClasses(List<IMessage> messages) {
- HashBag<String> javaClassNames = CollectionTools.bag(this.getClassRefNames());
- for (ClassRef classRef : this.getClassRefs()) {
- String javaClassName = classRef.getClassName();
- if ((javaClassName != null) && (javaClassNames.count(javaClassName) > 1)) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.PERSISTENCE_UNIT_DUPLICATE_CLASS,
- new String[] {javaClassName},
- classRef,
- classRef.getValidationTextRange()
- )
- );
- }
- }
- }
-
- protected void validateJarFileRefs(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateJarFileRefs(messages);
- for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- jarFileRef.validate(messages, reporter);
- }
- }
-
- protected void checkForDuplicateJarFileRefs(List<IMessage> messages) {
- HashBag<String> jarFileNames = CollectionTools.bag(this.getJarFileNames());
- for (JarFileRef jarFileRef : this.getJarFileRefs()) {
- 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 void validateProperties(@SuppressWarnings("unused") List<IMessage> messages, @SuppressWarnings("unused") IReporter reporter) {
- // do nothing by default
- }
-
- /**
- * We validate generators here because Java persistent types that are
- * overridden in the <code>orm.xml</code> file are
- * not validated, but they may contain generators that are still "active"
- * and need to be validated
- * (i.e. a generator is <em>not</em> overridden when its entity or ID
- * mapping is overridden in the <code>orm.xml</code> file).
- * <p>
- * <strong>NB:</strong> <em>Any</em> <code>orm.xml</code> generator can
- * override <em>any</em> Java generator with the same name; they need not
- * be defined on the same entity or ID mapping. Just a bit inconsistent with
- * the typical "override" in JPA....
- */
- protected void validateGenerators(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateGenerators(messages);
- for (Generator generator : this.getGenerators()) {
- this.validate(generator, messages, reporter);
- }
- }
-
- protected void checkForDuplicateGenerators(List<IMessage> messages) {
- HashMap<String, ArrayList<Generator>> generatorsByName = this.mapGeneratorsByName(this.getGenerators());
- for (ArrayList<Generator> dups : generatorsByName.values()) {
- if (dups.size() > 1) {
- for (Generator dup : dups) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.GENERATOR_DUPLICATE_NAME,
- new String[] {dup.getName()},
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- }
- }
- }
-
- // TODO bjv isn't it obvious?
- protected TextRange extractNameTextRange(Generator generator) {
- return (generator instanceof OrmGenerator) ?
- ((OrmGenerator) generator).getNameTextRange() :
- ((JavaGenerator) generator).getNameTextRange(null);
- }
-
- // TODO bjv isn't it obvious?
- protected void validate(Generator generator, List<IMessage> messages, IReporter reporter) {
- if (generator instanceof OrmGenerator) {
- ((OrmGenerator) generator).validate(messages, reporter);
- } else {
- ((JavaGenerator) generator).validate(messages, reporter, null);
- }
- }
-
- /**
- * <strong>NB:</strong> We validate queries here.
- * @see #validateGenerators(List, IReporter)
- */
- protected void validateQueries(List<IMessage> messages, IReporter reporter) {
- this.checkForDuplicateQueries(messages);
- for (Query query : this.getQueries()) {
- this.validate(query, messages, reporter);
- }
- }
-
- protected void checkForDuplicateQueries(List<IMessage> messages) {
- HashMap<String, ArrayList<Query>> queriesByName = this.mapQueriesByName(this.getQueries());
- for (ArrayList<Query> dups : queriesByName.values()) {
- if (dups.size() > 1) {
- for (Query dup : dups) {
- messages.add(
- DefaultJpaValidationMessages.buildMessage(
- IMessage.HIGH_SEVERITY,
- JpaValidationMessages.QUERY_DUPLICATE_NAME,
- new String[] {dup.getName()},
- dup,
- this.extractNameTextRange(dup)
- )
- );
- }
- }
- }
- }
-
- // TODO bjv isn't it obvious?
- protected TextRange extractNameTextRange(Query query) {
- return (query instanceof OrmQuery) ?
- ((OrmQuery) query).getNameTextRange() :
- ((JavaQuery) query).getNameTextRange(null);
- }
-
- // TODO bjv isn't it obvious?
- protected void validate(Query query, List<IMessage> messages, IReporter reporter) {
- if (query instanceof OrmQuery) {
- ((OrmQuery) query).validate(messages, reporter);
- } else {
- ((JavaQuery) query).validate(messages, reporter, null);
- }
- }
-
- public boolean validatesAgainstDatabase() {
- return this.connectionProfileIsActive();
- }
-
- public TextRange getValidationTextRange() {
- TextRange textRange = this.xmlPersistenceUnit.getValidationTextRange();
- return (textRange != null) ? textRange : this.getPersistence().getValidationTextRange();
- }
-
-
- // ********** refactoring **********
-
- public Iterable<DeleteEdit> createDeleteTypeEdits(final IType type) {
- return new CompositeIterable<DeleteEdit>(
- new TransformationIterable<ClassRef, Iterable<DeleteEdit>>(this.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>>(this.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>(
- this.createSpecifiedClassRefRenameTypeEdits(originalType, newName),
- this.createPersistenceUnitPropertiesRenameTypeEdits(originalType, newName));
- }
-
- protected Iterable<ReplaceEdit> createSpecifiedClassRefRenameTypeEdits(final IType originalType, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<ClassRef, Iterable<ReplaceEdit>>(this.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>(
- this.createSpecifiedClassRefMoveTypeEdits(originalType, newPackage),
- this.createPersistenceUnitPropertiesMoveTypeEdits(originalType, newPackage));
- }
-
- protected Iterable<ReplaceEdit> createSpecifiedClassRefMoveTypeEdits(final IType originalType, final IPackageFragment newPackage) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<ClassRef, Iterable<ReplaceEdit>>(this.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>(
- this.createSpecifiedClassRefRenamePackageEdits(originalPackage, newName),
- this.createPersistenceUnitPropertiesRenamePackageEdits(originalPackage, newName));
- }
-
- protected Iterable<ReplaceEdit> createSpecifiedClassRefRenamePackageEdits(final IPackageFragment originalPackage, final String newName) {
- return new CompositeIterable<ReplaceEdit>(
- new TransformationIterable<ClassRef, Iterable<ReplaceEdit>>(this.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>>(this.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>>(this.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>>(this.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>>(this.getSpecifiedMappingFileRefs()) {
- @Override
- protected Iterable<ReplaceEdit> transform(MappingFileRef mappingFileRef) {
- return mappingFileRef.createMoveFolderEdits(originalFolder, runtimeDestination);
- }
- }
- );
- }
-
-
- // ********** metamodel **********
- // put metamodel stuff here so it can be shared by Generic and EclipseLink implementations
-
- public void initializeMetamodel() {
- this.initializeMetamodelFiles_();
- }
-
- protected void initializeMetamodelFiles() {
- if (this.isJpa2_0Compatible()) {
- 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, PersistentType> allPersistentTypes = new HashMap<String, PersistentType>();
- this.addPersistentTypesTo(this.getJarFilePersistentTypes(), allPersistentTypes);
- this.addPersistentTypesTo(this.getClassRefPersistentTypes(), allPersistentTypes);
- this.addPersistentTypesTo(this.getMappingFilePersistentTypes(), 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 (PersistentType type1_0 : allPersistentTypes.values()) {
- PersistentType2_0 type = (PersistentType2_0) type1_0;
- 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 = (PersistentType2_0) 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 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) {
- JptJpaCorePlugin.log(ex);
- return null;
- }
- }
-
- protected void deleteMetamodelFile(IFile file) {
- try {
- this.deleteMetamodelFile_(file);
- } catch (CoreException ex) {
- JptJpaCorePlugin.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnitProperties.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnitProperties.java
deleted file mode 100644
index 96edeee601..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.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.common.utility.internal.ReflectionTools;
-import org.eclipse.jpt.common.utility.internal.StringTools;
-import org.eclipse.jpt.common.utility.internal.iterables.EmptyIterable;
-import org.eclipse.jpt.common.utility.internal.model.AbstractModel;
-import org.eclipse.jpt.jpa.core.JpaProject;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNode.java
deleted file mode 100644
index 11431d2f8b..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.persistence;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.jpt.jpa.core.context.JpaContextNode;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlDefinition;
-import org.eclipse.jpt.jpa.core.internal.context.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.jpa.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlContextNodeFactory.java
deleted file mode 100644
index d0f241c83e..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.persistence;
-
-import org.eclipse.jpt.jpa.core.JptJpaCorePlugin;
-import org.eclipse.jpt.jpa.core.context.java.JarFile;
-import org.eclipse.jpt.jpa.core.context.persistence.ClassRef;
-import org.eclipse.jpt.jpa.core.context.persistence.JarFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.MappingFileRef;
-import org.eclipse.jpt.jpa.core.context.persistence.Persistence;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJarFile;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericJarFileRef;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericMappingFileRef;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistence;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceUnit;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceUnitProperty;
-import org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.ImpliedMappingFileRef;
-import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePackageFragmentRoot;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlJarFileRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlJavaClassRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlMappingFileRef;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistence;
-import org.eclipse.jpt.jpa.core.resource.persistence.XmlPersistenceUnit;
-import org.eclipse.jpt.jpa.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, JptJpaCorePlugin.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.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlDefinition.java
deleted file mode 100644
index 712ef7e546..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceXmlDefinition.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.jpa.core.internal.context.persistence;
-
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXmlContextNodeFactory;
-import org.eclipse.jpt.jpa.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 = this.buildContextNodeFactory();
- }
-
- protected abstract PersistenceXmlContextNodeFactory buildContextNodeFactory();
-
- public PersistenceXmlContextNodeFactory getContextNodeFactory() {
- return this.factory;
- }
-}
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/GenericPersistenceXmlContextNodeFactory.java
deleted file mode 100644
index 3f329ec9bd..0000000000
--- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/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.jpa.core.internal.context.persistence;
-
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit;
-import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnitProperties;
-import org.eclipse.jpt.jpa.core.internal.jpa2.context.persistence.connection.NullConnection2_0;
-import org.eclipse.jpt.jpa.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