diff options
author | bvosburgh | 2011-04-28 02:00:43 +0000 |
---|---|---|
committer | bvosburgh | 2011-04-28 02:00:43 +0000 |
commit | 91d39dcd91de9ef79763cec17430b395452b73f9 (patch) | |
tree | 8436ff8238739c092ce7d5058f8657a3b505181d /jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt | |
parent | e924740cdaae5f03ac6917e162fd98ad7d3971af (diff) | |
download | webtools.dali-91d39dcd91de9ef79763cec17430b395452b73f9.tar.gz webtools.dali-91d39dcd91de9ef79763cec17430b395452b73f9.tar.xz webtools.dali-91d39dcd91de9ef79763cec17430b395452b73f9.zip |
[336296] fix validation of virtual attribute mappings
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt')
134 files changed, 1095 insertions, 911 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java index a77d422449..56d56f6943 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/PersistentType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -13,6 +13,7 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.jpa.core.JpaStructureNode; import org.eclipse.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; @@ -159,17 +160,24 @@ public interface PersistentType */ void validate(List<IMessage> messages, IReporter reporter); + /** + * Return the text range to be used with any validation messages related + * to the persistent type. + */ + TextRange getValidationTextRange(); + // ********** misc ********** /** * Return whether the persistent type applies to the - * specified type name qualified with '.'. + * specified type name qualified with <code>'.'</code>. */ boolean isFor(String typeName); /** - * Return true if persistent type resolves to a java class in the given package fragment + * Return whether the persistent type resolves to a Java class in the + * specified package fragment. */ boolean isIn(IPackageFragment packageFragment); @@ -196,7 +204,7 @@ public interface PersistentType { /** * Return the access type that overrides the client persistent type's - * access type; <code>null</code> if there is no such access override + * access type; <code>null</code> if there is no such access override. */ AccessType getOverridePersistentTypeAccess(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java index 27b1653476..68f880167f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/java/JavaPersistentAttribute.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -31,7 +31,7 @@ import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute; public interface JavaPersistentAttribute extends PersistentAttribute, JavaJpaContextNode { - // ********** mapping ********** + // ********** covariant overrides ********** JavaAttributeMapping getMapping(); @@ -41,12 +41,13 @@ public interface JavaPersistentAttribute // ********** misc ********** /** - * Return the "resource" persistent attribute. + * Return the corresponding <em>resource</em> persistent attribute. */ JavaResourcePersistentAttribute getResourcePersistentAttribute(); /** - * Return whether the attribute contains the given offset into the text file. + * Return whether the attribute contains the given offset into its Java + * source code file. */ boolean contains(int offset, CompilationUnit astRoot); @@ -67,12 +68,14 @@ public interface JavaPersistentAttribute boolean isProperty(); /** - * Return whether the attribute is 'public', which is problematic for fields. + * Return whether the attribute is <code>public</code>, + * which is problematic for fields. */ boolean isPublic(); /** - * Return whether the attribute is 'final', which is problematic. + * Return whether the attribute is <code>final</code>, + * which is problematic. */ boolean isFinal(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmOverrideContainer.java index fb15a1aadc..6070d36550 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmOverrideContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmOverrideContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -33,6 +33,9 @@ import org.eclipse.jpt.jpa.core.resource.orm.XmlOverride; public interface OrmOverrideContainer extends OverrideContainer, XmlContextNode { + // we need this covariant override because there is no override *container* + // element in the orm.xml (there is just a list of overrides) + XmlContextNode getParent(); ListIterator<? extends OrmReadOnlyOverride> overrides(); OrmReadOnlyOverride getOverrideNamed(String name); ListIterator<? extends OrmOverride> specifiedOverrides(); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java index b0b82a3b03..b5b5c6ac12 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/orm/OrmPersistentType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -70,8 +70,8 @@ public interface OrmPersistentType // OrmReadOnlyPersistenAttribute.convertToSpecified(String mappingKey) OrmPersistentAttribute addSpecifiedAttribute(String mappingKey, String attributeName); - - // ********** virtual attributes ********** +// TODO bjv rename to 'defaultAttributes' + // ********** default attributes ********** String VIRTUAL_ATTRIBUTES_LIST = "virtualAttributes"; //$NON-NLS-1$ @@ -189,7 +189,8 @@ public interface OrmPersistentType String JAVA_PERSISTENT_TYPE_PROPERTY = "javaPersistentType"; //$NON-NLS-1$ /** - * Return the persistent type's default package. + * Return the persistent type's default package, as set in its entity + * mappings. */ String getDefaultPackage(); } 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 index 8149d527c6..48c80d43a2 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -10,6 +10,7 @@ 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; @@ -35,4 +36,12 @@ public abstract class AbstractXmlContextNode 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/java/AbstractJavaAttributeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaAttributeMapping.java index 1a92c17ab5..3d56fe46cc 100644 --- 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 @@ -181,6 +181,10 @@ public abstract class AbstractJavaAttributeMapping<A extends Annotation> return this.getTypeMapping().resolveDbTable(tableName); } + protected JavaPersistentAttribute getJavaPersistentAttribute() { + return this.getPersistentAttribute().getJavaPersistentAttribute(); + } + @Override public void toString(StringBuilder sb) { sb.append(this.getName()); @@ -309,7 +313,7 @@ public abstract class AbstractJavaAttributeMapping<A extends Annotation> public TextRange getValidationTextRange(CompilationUnit astRoot) { TextRange textRange = this.getMappingAnnotationTextRange(astRoot); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); + return (textRange != null) ? textRange : this.getPersistentAttribute().getValidationTextRange(astRoot); } protected TextRange getMappingAnnotationTextRange(CompilationUnit 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 index 5e2dd96aec..9fccee517c 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -125,8 +125,7 @@ public abstract class AbstractJavaBaseColumn<A extends BaseColumnAnnotation, O e } public TextRange getTableTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getColumnAnnotation().getTableTextRange(astRoot); - return (textRange != null) ? textRange : this.owner.getValidationTextRange(astRoot); + return this.getValidationTextRange(this.getColumnAnnotation().getTableTextRange(astRoot), astRoot); } 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 index 3444fc6e5d..44981608f8 100644 --- 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 @@ -1327,8 +1327,8 @@ public abstract class AbstractJavaEntity this.queryContainer.validate(messages, reporter, astRoot); this.attributeOverrideContainer.validate(messages, reporter, astRoot); this.associationOverrideContainer.validate(messages, reporter, astRoot); - this.validateEntityName(messages, reporter, astRoot); - this.validateDuplicateEntityNames(messages, reporter, astRoot); + this.validateEntityName(messages, astRoot); + this.validateDuplicateEntityNames(messages, astRoot); this.idClassReference.validate(messages, reporter, astRoot); } @@ -1337,8 +1337,7 @@ public abstract class AbstractJavaEntity return super.validatesAgainstDatabase() && ! this.isAbstractTablePerClass(); } - protected void validateEntityName(List<IMessage> messages, - IReporter reporter, CompilationUnit astRoot) { + protected void validateEntityName(List<IMessage> messages, CompilationUnit astRoot) { if (StringTools.stringIsEmpty(this.getName())){ messages.add( DefaultJpaValidationMessages.buildMessage( @@ -1352,8 +1351,7 @@ public abstract class AbstractJavaEntity } } - protected void validateDuplicateEntityNames(List<IMessage> messages, - IReporter reporter, CompilationUnit 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>(); @@ -1406,8 +1404,8 @@ public abstract class AbstractJavaEntity } return; } - if (getDataSource().connectionProfileIsActive() && this.isSingleTableDescendant()) { - if (this.table.isSpecifiedInResource() && !tableEqualsRootTable()) { + if (this.isSingleTableDescendant() && this.getDataSource().connectionProfileIsActive()) { + if (this.specifiedTableDoesNotMatchRootTable()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, @@ -1422,11 +1420,14 @@ public abstract class AbstractJavaEntity } this.table.validate(messages, reporter, astRoot); } - - private boolean tableEqualsRootTable() { - org.eclipse.jpt.jpa.db.Table table = this.table.getDbTable(); - org.eclipse.jpt.jpa.db.Table parentTable = this.getRootEntity().getTable().getDbTable(); - return table == parentTable; + + /** + * 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) { @@ -1524,15 +1525,15 @@ public abstract class AbstractJavaEntity } protected TextRange getDiscriminatorValueTextRange(CompilationUnit astRoot) { - return this.getDiscriminatorValueAnnotation().getTextRange(astRoot); + return this.getValidationTextRange(this.getDiscriminatorValueAnnotation().getTextRange(astRoot), astRoot); } protected TextRange getDiscriminatorColumnTextRange(CompilationUnit astRoot) { - return this.discriminatorColumn.getValidationTextRange(astRoot); + return this.getValidationTextRange(this.discriminatorColumn.getValidationTextRange(astRoot), astRoot); } protected TextRange getInheritanceStrategyTextRange(CompilationUnit astRoot) { - return this.getInheritanceAnnotation().getStrategyTextRange(astRoot); + return this.getValidationTextRange(this.getInheritanceAnnotation().getStrategyTextRange(astRoot), astRoot); } 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 index cc79849d49..22d76bf486 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -157,15 +157,12 @@ public abstract class AbstractJavaGenerator<A extends GeneratorAnnotation> // ********** text ranges ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getSelectionTextRange(astRoot); - } - - public TextRange getSelectionTextRange(CompilationUnit astRoot) { - return this.generatorAnnotation.getTextRange(astRoot); + TextRange textRange = this.generatorAnnotation.getTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); } public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.generatorAnnotation.getNameTextRange(astRoot); + return this.getValidationTextRange(this.generatorAnnotation.getNameTextRange(astRoot), astRoot); } @@ -213,6 +210,11 @@ public abstract class AbstractJavaGenerator<A extends GeneratorAnnotation> // ********** misc ********** + @Override + public JavaJpaContextNode getParent() { + return (JavaJpaContextNode) super.getParent(); + } + public A getGeneratorAnnotation() { return this.generatorAnnotation; } 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 index ac83d194a1..b0c8f2ff4b 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -389,8 +389,8 @@ public abstract class AbstractJavaIdMapping return this.getTypeMapping().allAssociatedTableNames(); } - public JptValidator buildColumnValidator(NamedColumn column, NamedColumnTextRangeResolver textRangeResolver) { - return new NamedColumnValidator((BaseColumn) column, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider()); + public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { + return new NamedColumnValidator((BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider()); } @@ -434,25 +434,19 @@ public abstract class AbstractJavaIdMapping public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); - // [JPA 2.0] if the column is specified, or if the id is not mapped by a relationship, - // then the column is validated. - // (In JPA 1.0, the column will always be validated, since the id is never mapped by a - // relationship) + // 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, - // then that is an error - // (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship) + // 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.buildMessage( - JpaValidationMessages.ID_MAPPING_MAPPED_BY_RELATIONSHIP_AND_COLUMN_SPECIFIED, - EMPTY_STRING_ARRAY, - this.column.getValidationTextRange(astRoot) - ) - ); + messages.add(this.buildMappedByRelationshipAndColumnSpecifiedMessage(astRoot)); } this.generatorContainer.validate(messages, reporter, astRoot); @@ -462,15 +456,31 @@ public abstract class AbstractJavaIdMapping 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) { - String attributeDescription = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, this.getPersistentAttribute().getName()); - parms = ArrayTools.add(parms, 0, attributeDescription); return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, msgID, - parms, + 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/AbstractJavaJpaContextNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaJpaContextNode.java index 92643cc26a..8026c69af9 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -14,6 +14,7 @@ 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; @@ -48,12 +49,12 @@ public abstract class AbstractJavaJpaContextNode /** * This method is called if the database is connected, allowing us to * get candidates from the various database tables etc. - * This method should NOT be cascaded to "child" objects; it should + * 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 #javaCompletionProposals(int, Filter, CompilationUnit). + * handled by {@link #javaCompletionProposals(int, Filter, CompilationUnit)}. */ @SuppressWarnings("unused") - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { return null; } @@ -69,4 +70,11 @@ public abstract class AbstractJavaJpaContextNode } } + /** + * 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/AbstractJavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaNamedColumn.java index fa129f27da..44615c5f91 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -17,6 +17,7 @@ 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; @@ -208,7 +209,7 @@ public abstract class AbstractJavaNamedColumn<A extends NamedColumnAnnotation, O // ********** Java completion proposals ********** @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; @@ -259,13 +260,15 @@ public abstract class AbstractJavaNamedColumn<A extends NamedColumnAnnotation, O } public TextRange getNameTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getColumnAnnotation().getNameTextRange(astRoot); - return (textRange != null) ? textRange : this.owner.getValidationTextRange(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; } 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 index f460c8dbfa..cf70a08a2b 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -205,11 +205,10 @@ public abstract class AbstractJavaOverride<C extends JavaOverrideContainer, A ex public TextRange getValidationTextRange(CompilationUnit astRoot) { TextRange textRange = this.overrideAnnotation.getTextRange(astRoot); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); + return (textRange != null) ? textRange : this.getContainer().getValidationTextRange(astRoot); } public TextRange getNameTextRange(CompilationUnit astRoot) { - TextRange textRange = this.overrideAnnotation.getNameTextRange(astRoot); - return (textRange != null) ? textRange : this.getValidationTextRange(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 index 63a0856e87..55053350af 100644 --- 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 @@ -11,6 +11,7 @@ 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; @@ -22,6 +23,7 @@ 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; @@ -34,6 +36,7 @@ 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; @@ -528,22 +531,15 @@ public abstract class AbstractJavaPersistentAttribute } public String getPrimaryKeyColumnName() { - return this.getMapping().getPrimaryKeyColumnName(); + return this.mapping.getPrimaryKeyColumnName(); } public String getTypeName() { return this.resourcePersistentAttribute.getTypeName(); } - /** - * Java attributes always correspond to attributes in the source code. - */ - public boolean isVirtual() { - return false; - } - public boolean contains(int offset, CompilationUnit astRoot) { - TextRange fullTextRange = this.getFullTextRange(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 @@ -551,10 +547,6 @@ public abstract class AbstractJavaPersistentAttribute return (fullTextRange == null) ? false : fullTextRange.includes(offset); } - protected TextRange getFullTextRange(CompilationUnit astRoot) { - return this.resourcePersistentAttribute.getTextRange(astRoot); - } - public Embeddable getEmbeddable() { String typeName = this.getTypeName(); return (typeName == null) ? null : this.getPersistenceUnit().getEmbeddable(typeName); @@ -585,16 +577,16 @@ public abstract class AbstractJavaPersistentAttribute // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getSelectionTextRange(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.getMapping().validate(messages, reporter, astRoot); + this.mapping.validate(messages, reporter, astRoot); } protected void validateAttribute(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { @@ -607,6 +599,24 @@ public abstract class AbstractJavaPersistentAttribute 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 ********** @@ -616,7 +626,7 @@ public abstract class AbstractJavaPersistentAttribute if (result != null) { return result; } - return this.getMapping().javaCompletionProposals(pos, filter, astRoot); + return this.mapping.javaCompletionProposals(pos, filter, astRoot); } @@ -627,7 +637,7 @@ public abstract class AbstractJavaPersistentAttribute } public String getMetamodelContainerFieldMapKeyTypeName() { - return this.getJpaContainerDefinition().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.getMapping()); + return this.getJpaContainerDefinition().getMetamodelContainerFieldMapKeyTypeName((CollectionMapping) this.mapping); } public String getMetamodelTypeName() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java index 3891dcca22..6ec801509b 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaPersistentType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -553,7 +553,7 @@ public abstract class AbstractJavaPersistentType } protected boolean contains(int offset, CompilationUnit astRoot) { - TextRange fullTextRange = this.getFullTextRange(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 @@ -561,10 +561,6 @@ public abstract class AbstractJavaPersistentType return (fullTextRange == null) ? false : fullTextRange.includes(offset); } - protected TextRange getFullTextRange(CompilationUnit astRoot) { - return this.resourcePersistentType.getTextRange(astRoot); - } - public TextRange getSelectionTextRange() { return this.getSelectionTextRange(this.buildASTRoot()); } @@ -670,6 +666,10 @@ public abstract class AbstractJavaPersistentType return this.getSelectionTextRange(astRoot); } + public TextRange getValidationTextRange() { + return this.getSelectionTextRange(); + } + // ********** misc ********** 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 index 9f92fa8592..829e5ebc78 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -204,6 +204,11 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation> // ********** misc ********** + @Override + public JavaJpaContextNode getParent() { + return (JavaJpaContextNode) super.getParent(); + } + public A getQueryAnnotation() { return this.queryAnnotation; } @@ -217,11 +222,12 @@ public abstract class AbstractJavaQuery<A extends QueryAnnotation> } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.queryAnnotation.getTextRange(astRoot); + TextRange textRange = this.queryAnnotation.getTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); } public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.queryAnnotation.getNameTextRange(astRoot); + return this.getValidationTextRange(this.queryAnnotation.getNameTextRange(astRoot), astRoot); } @Override 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 index 053fe6fb83..0760a1be4c 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -50,4 +50,12 @@ public abstract class AbstractJavaReadOnlyUniqueConstraint 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 index 95788f0127..77afa0ebf6 100644 --- 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 @@ -313,35 +313,51 @@ public abstract class AbstractJavaRelationshipMapping<A extends RelationshipMapp 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, - JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED, + msg, new String[] {this.getName()}, this, this.getValidationTextRange(astRoot) ) ); + return; } - else if (this.getResolvedTargetEntity() == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY, - new String[] {this.getTargetEntity(), this.getName()}, - this, - this.getTargetEntityTextRange(astRoot) - ) - ); + 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) { - A annotation = this.getMappingAnnotation(); - return (annotation == null) ? null : this.getTextRange(annotation.getTargetEntityTextRange(astRoot), astRoot); + return this.getValidationTextRange(this.getAnnotationTargetEntityTextRange(astRoot), astRoot); } - protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) { - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(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 index c81dbb41b1..0400ace268 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -104,7 +104,7 @@ public abstract class AbstractJavaSequenceGenerator<A extends SequenceGeneratorA * sequenceName */ @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; 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 index 302f4af238..ced9446238 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -447,7 +447,7 @@ public abstract class AbstractJavaTable<A extends BaseTableAnnotation> * name, schema, catalog */ @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; @@ -532,23 +532,20 @@ public abstract class AbstractJavaTable<A extends BaseTableAnnotation> } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getTableAnnotation().getTextRange(astRoot), astRoot); + TextRange textRange = this.getTableAnnotation().getTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); } public TextRange getNameTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getTableAnnotation().getNameTextRange(astRoot), astRoot); + return this.getValidationTextRange(this.getTableAnnotation().getNameTextRange(astRoot), astRoot); } public TextRange getSchemaTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getTableAnnotation().getSchemaTextRange(astRoot), astRoot); + return this.getValidationTextRange(this.getTableAnnotation().getSchemaTextRange(astRoot), astRoot); } public TextRange getCatalogTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getTableAnnotation().getCatalogTextRange(astRoot), astRoot); - } - - protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) { - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); + return this.getValidationTextRange(this.getTableAnnotation().getCatalogTextRange(astRoot), astRoot); } 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 index 517dbeab97..cb72435abd 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -22,7 +22,7 @@ import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; * <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 + * 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> @@ -119,14 +119,15 @@ public abstract class AbstractJavaVirtualNamedColumn<O extends ReadOnlyNamedColu // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; // not sure this column is validated... + return this.getParent().getValidationTextRange(astRoot); } // ********** misc ********** - public boolean isVirtual() { - return true; + @Override + public JavaJpaContextNode getParent() { + return (JavaJpaContextNode) super.getParent(); } @Override 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 index 6f589efad7..ca34875b28 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -53,7 +53,7 @@ public abstract class AbstractJavaVirtualOverride<C extends JavaOverrideContaine } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.getParent().getValidationTextRange(astRoot); + return this.getContainer().getValidationTextRange(astRoot); } @Override 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 index 466112abe3..fad37786bd 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -298,13 +298,18 @@ public abstract class AbstractJavaVirtualTable<T extends Table> // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getParent().getValidationTextRange(astRoot); } // ********** misc ********** @Override + public JavaJpaContextNode getParent() { + return (JavaJpaContextNode) super.getParent(); + } + + @Override public void toString(StringBuilder sb) { sb.append(this.buildQualifiedName()); } 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 index 7135925a3b..840e0bc0dd 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -263,9 +263,12 @@ public class GenericJavaIdClassReference } 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) ? - this.getTypeMapping().getValidationTextRange(astRoot) : - annotation.getTextRange(astRoot); + 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/GenericJavaMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/GenericJavaMappedByRelationshipStrategy.java index f682c69d90..592466b523 100644 --- 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 @@ -192,11 +192,6 @@ public class GenericJavaMappedByRelationshipStrategy // ********** validation ********** - public TextRange getValidationTextRange(CompilationUnit astRoot) { - OwnableRelationshipMappingAnnotation annotation = this.getMappingAnnotation(); - return (annotation == null) ? null : annotation.getMappedByTextRange(astRoot); - } - @Override public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); @@ -249,7 +244,10 @@ public class GenericJavaMappedByRelationshipStrategy protected IMessage buildMessage(String msgID, String[] parms, CompilationUnit astRoot) { PersistentAttribute attribute = this.getRelationshipMapping().getPersistentAttribute(); - String attributeDescription = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName()); + 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, @@ -259,4 +257,14 @@ public class GenericJavaMappedByRelationshipStrategy 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/orm/AbstractEntityMappings.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java index 1ba0d7ae9c..007914cb55 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractEntityMappings.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -261,7 +261,8 @@ public abstract class AbstractEntityMappings } public TextRange getValidationTextRange() { - return null; + TextRange textRange = this.xmlEntityMappings.getValidationTextRange(); + return (textRange != null) ? textRange : this.getOrmXml().getValidationTextRange(); } public boolean containsOffset(int textOffset) { 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 index 0c05faba25..e59a7af66c 100644 --- 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 @@ -64,6 +64,7 @@ public abstract class AbstractOrmAttributeMapping<X extends XmlAttributeMapping> extends AbstractOrmXmlContextNode implements OrmAttributeMapping, AttributeMapping2_0 { + // never null protected final X xmlAttributeMapping; protected String name; @@ -196,12 +197,6 @@ public abstract class AbstractOrmAttributeMapping<X extends XmlAttributeMapping> return this.getPersistentAttribute().getJavaPersistentAttribute(); } - // TODO remove this method - it will always return false... - // subclass member classes like this method - public boolean isVirtual() { - return false; - } - protected EntityMappings getEntityMappings() { return this.getPersistentAttribute().getOwningPersistentType().getParent(); } @@ -247,11 +242,13 @@ public abstract class AbstractOrmAttributeMapping<X extends XmlAttributeMapping> } 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.xmlAttributeMapping.getNameTextRange(); + return this.getValidationTextRange(this.xmlAttributeMapping.getNameTextRange()); } @Override 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 index 75782eb2f6..f6aa8a2149 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -287,7 +287,7 @@ public abstract class AbstractOrmBaseColumn<X extends AbstractXmlColumn, O exten // ********** validation ********** public TextRange getTableTextRange() { - return this.getTextRange(this.getXmlColumnTableTextRange()); + return this.getValidationTextRange(this.getXmlColumnTableTextRange()); } protected TextRange getXmlColumnTableTextRange() { 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 index 98cc922c63..9334507a51 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -26,9 +26,6 @@ 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.JavaAttributeMapping; -import org.eclipse.jpt.jpa.core.context.java.JavaAttributeOverride; -import org.eclipse.jpt.jpa.core.context.java.JavaBaseEmbeddedMapping; 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; @@ -177,22 +174,6 @@ public abstract class AbstractOrmBaseEmbeddedMapping<X extends AbstractXmlEmbedd this.attributeOverrideContainer.initializeFrom(oldMapping.getAttributeOverrideContainer()); } - protected JavaAttributeOverride getSpecifiedJavaAttributeOverrideNamed(String attributeName) { - JavaBaseEmbeddedMapping javaMapping = this.getJavaEmbeddedMapping(); - return (javaMapping == null) ? null : javaMapping.getAttributeOverrideContainer().getSpecifiedOverrideNamed(attributeName); - } - - protected JavaBaseEmbeddedMapping getJavaEmbeddedMapping() { - JavaAttributeMapping javaMapping = this.getJavaAttributeMapping(); - return ((javaMapping != null) && this.valuesAreEqual(javaMapping.getKey(), this.getKey())) ? - (JavaBaseEmbeddedMapping) javaMapping : null; - } - - protected JavaAttributeMapping getJavaAttributeMapping() { - JavaPersistentAttribute javaAttribute = this.getJavaPersistentAttribute(); - return (javaAttribute == null) ? null : javaAttribute.getMapping(); - } - @Override public Column resolveOverriddenColumn(String attributeName) { return this.isJpa2_0Compatible() ? this.resolveOverriddenColumn_(attributeName) : null; @@ -280,12 +261,6 @@ public abstract class AbstractOrmBaseEmbeddedMapping<X extends AbstractXmlEmbedd } public Column resolveOverriddenColumn(String attributeName) { - if (this.mappingIsVirtual() && ! this.getTypeMapping().isMetadataComplete()) { - JavaAttributeOverride javaOverride = AbstractOrmBaseEmbeddedMapping.this.getSpecifiedJavaAttributeOverrideNamed(attributeName); - if (javaOverride != null) { - return javaOverride.getColumn(); - } - } return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName); } @@ -320,9 +295,5 @@ public abstract class AbstractOrmBaseEmbeddedMapping<X extends AbstractXmlEmbedd protected OrmPersistentAttribute getPersistentAttribute() { return AbstractOrmBaseEmbeddedMapping.this.getPersistentAttribute(); } - - protected boolean mappingIsVirtual() { - return AbstractOrmBaseEmbeddedMapping.this.isVirtual(); - } } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java index b24fe397e3..3e0d3e3fb2 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmEntity.java @@ -1780,12 +1780,12 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> this.associationOverrideContainer.validate(messages, reporter); this.generatorContainer.validate(messages, reporter); this.queryContainer.validate(messages, reporter); - this.validateEntityName(messages, reporter); - this.validateDuplicateEntityNames(messages, reporter); + this.validateEntityName(messages); + this.validateDuplicateEntityNames(messages); this.idClassReference.validate(messages, reporter); } - protected void validateEntityName(List<IMessage> messages, IReporter reporter) { + protected void validateEntityName(List<IMessage> messages) { if (StringTools.stringIsEmpty(this.getName())){ messages.add( DefaultJpaValidationMessages.buildMessage( @@ -1799,8 +1799,7 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> } } - protected void validateDuplicateEntityNames(List<IMessage> messages, - IReporter reporter) { + protected void validateDuplicateEntityNames(List<IMessage> messages) { HashBag<String> javaEntityNamesExclOverridden = new HashBag<String>(); CollectionTools.addAll(javaEntityNamesExclOverridden, this.getPersistenceUnit().javaEntityNamesExclOverridden()); Map<String, Set<String>> map =this.getPersistenceUnit().mapEntityNameToClassNames(); @@ -1851,8 +1850,8 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> } return; } - if (getDataSource().connectionProfileIsActive() && this.isSingleTableDescendant()) { - if (this.resourceTableIsSpecified() && !tableNameEqualsRootTable()) { + if (this.isSingleTableDescendant() && this.getDataSource().connectionProfileIsActive()) { + if (this.specifiedTableDoesNotMatchRootTable()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, @@ -1868,10 +1867,13 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> this.table.validate(messages, reporter); } - private boolean tableNameEqualsRootTable() { - org.eclipse.jpt.jpa.db.Table table = this.table.getDbTable(); - org.eclipse.jpt.jpa.db.Table parentTable = this.getRootEntity().getTable().getDbTable(); - return table == parentTable; + /** + * 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) { @@ -1970,15 +1972,15 @@ public abstract class AbstractOrmEntity<X extends XmlEntity> } protected TextRange getDiscriminatorValueTextRange() { - return this.xmlTypeMapping.getDiscriminatorValueTextRange(); + return this.getValidationTextRange(this.xmlTypeMapping.getDiscriminatorValueTextRange()); } protected TextRange getDiscriminatorColumnTextRange() { - return this.xmlTypeMapping.getDiscriminatorColumn().getValidationTextRange(); + return this.getValidationTextRange(this.xmlTypeMapping.getDiscriminatorColumn().getValidationTextRange()); } protected TextRange getInheritanceStrategyTextRange() { - return this.xmlTypeMapping.getInheritanceStrategyTextRange(); + return this.getValidationTextRange(this.xmlTypeMapping.getInheritanceStrategyTextRange()); } 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 index 1a57454851..b82c822be0 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -156,13 +156,12 @@ public abstract class AbstractOrmGenerator<X extends XmlGenerator> // ********** text ranges ********** public TextRange getValidationTextRange() { - TextRange validationTextRange = this.xmlGenerator.getValidationTextRange(); - return (validationTextRange != null) ? validationTextRange : this.getParent().getValidationTextRange(); + TextRange textRange = this.xmlGenerator.getValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); } public TextRange getNameTextRange() { - TextRange nameTextRange = this.xmlGenerator.getNameTextRange(); - return (nameTextRange != null) ? nameTextRange : this.getValidationTextRange(); + return this.getValidationTextRange(this.xmlGenerator.getNameTextRange()); } @@ -199,15 +198,15 @@ public abstract class AbstractOrmGenerator<X extends XmlGenerator> // ********** misc ********** - public X getXmlGenerator() { - return this.xmlGenerator; - } - @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); } 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 index 6b01a760a2..3cf5ff56f6 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -452,18 +452,18 @@ public abstract class AbstractOrmIdMapping<X extends XmlId> public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); - // [JPA 2.0] if the column is specified, or if the id is not mapped by a relationship, - // then the column is validated. - // (In JPA 1.0, the column will always be validated, since the id is never mapped by a - // relationship) - if (this.isColumnSpecified() || ! this.isMappedByRelationship()) { + // 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, - // then that is an error - // (In JPA 1.0, this will never be the case, since the id is never mapped by a relationship) - if (this.isColumnSpecified() && this.isMappedByRelationship()) { + // 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()); } @@ -497,9 +497,7 @@ public abstract class AbstractOrmIdMapping<X extends XmlId> } protected String getAttributeDescriptionTemplate() { - return this.getPersistentAttribute().isVirtual() ? - JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC : - JpaValidationDescriptionMessages.ATTRIBUTE_DESC; + return JpaValidationDescriptionMessages.ATTRIBUTE_DESC; } public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { 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 index b5cc9a7179..0095c229ff 100644 --- 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 @@ -120,7 +120,7 @@ public abstract class AbstractOrmMappingRelationship<M extends OrmRelationshipMa } public boolean isVirtual() { - return this.getMapping().getPersistentAttribute().isVirtual(); + return false; } public boolean isTargetForeignKey() { 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 index 7179f06f50..2302baa0a4 100644 --- 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 @@ -719,10 +719,6 @@ public abstract class AbstractOrmMultiRelationshipMapping<X extends AbstractXmlM return AbstractOrmMultiRelationshipMapping.this.getName(); } - protected boolean mappingIsVirtual() { - return AbstractOrmMultiRelationshipMapping.this.isVirtual(); - } - protected OrmPersistentAttribute getPersistentAttribute() { return AbstractOrmMultiRelationshipMapping.this.getPersistentAttribute(); } @@ -785,12 +781,6 @@ public abstract class AbstractOrmMultiRelationshipMapping<X extends AbstractXmlM } public Column resolveOverriddenColumn(String attributeName) { - if (this.mappingIsVirtual() && ! this.getTypeMapping().isMetadataComplete()) { - JavaAttributeOverride javaOverride = this.getSpecifiedJavaAttributeOverrideNamed(attributeName); - if (javaOverride != null) { - return javaOverride.getColumn(); - } - } return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName); } 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 index 7bee99543e..c400e098f3 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -11,6 +11,7 @@ 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; @@ -232,7 +233,8 @@ public abstract class AbstractOrmNamedColumn<X extends AbstractXmlNamedColumn, O } public TextRange getValidationTextRange() { - return this.getTextRange(this.getXmlColumnTextRange()); + TextRange textRange = this.getXmlColumnTextRange(); + return (textRange != null) ? textRange : this.owner.getValidationTextRange(); } protected TextRange getXmlColumnTextRange() { @@ -241,7 +243,7 @@ public abstract class AbstractOrmNamedColumn<X extends AbstractXmlNamedColumn, O } public TextRange getNameTextRange() { - return this.getTextRange(this.getXmlColumnNameTextRange()); + return this.getValidationTextRange(this.getXmlColumnNameTextRange()); } protected TextRange getXmlColumnNameTextRange() { @@ -249,10 +251,6 @@ public abstract class AbstractOrmNamedColumn<X extends AbstractXmlNamedColumn, O return (xmlColumn == null) ? null : xmlColumn.getNameTextRange(); } - protected TextRange getTextRange(TextRange textRange) { - return (textRange != null) ? textRange : this.owner.getValidationTextRange(); - } - // ********** misc ********** @@ -261,6 +259,9 @@ public abstract class AbstractOrmNamedColumn<X extends AbstractXmlNamedColumn, O return (XmlContextNode) super.getParent(); } + /** + * This is used by the subclasses that implement {@link BaseJoinColumn}. + */ public boolean isVirtual() { return false; } 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 index 24afd7e93b..e5133e593f 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -48,7 +48,7 @@ public abstract class AbstractOrmQuery<X extends XmlQuery> super(parent); this.xmlQuery = xmlQuery; this.name = xmlQuery.getName(); - this.query = getUnescapeQuery(); + this.query = this.getUnescapedQuery(); this.initializeHints(); } @@ -58,7 +58,7 @@ public abstract class AbstractOrmQuery<X extends XmlQuery> public void synchronizeWithResourceModel() { super.synchronizeWithResourceModel(); this.setName_(this.xmlQuery.getName()); - this.setQuery_(this.getUnescapeQuery()); + this.setQuery_(this.getUnescapedQuery()); this.syncHints(); } @@ -105,19 +105,20 @@ public abstract class AbstractOrmQuery<X extends XmlQuery> this.firePropertyChanged(QUERY_PROPERTY, old, query); } - protected String getUnescapeQuery() { - String query = this.xmlQuery.getQuery(); - if (StringTools.stringIsNotEmpty(query)) { - query = ExpressionTools.unescape(query, new int[1]); + protected String getUnescapedQuery() { + String queryString = this.xmlQuery.getQuery(); + if (StringTools.stringIsNotEmpty(queryString)) { + queryString = ExpressionTools.unescape(queryString, new int[1]); } - return query; + return queryString; } - protected String convertToEscapeQuery(String query) { - if (StringTools.stringIsNotEmpty(query)) { - query = ExpressionTools.escape(query, new int[1]); + // TODO bjv add method to ExpressionTools? + protected String convertToEscapeQuery(String queryString) { + if (StringTools.stringIsNotEmpty(queryString)) { + queryString = ExpressionTools.escape(queryString, new int[1]); } - return query; + return queryString; } @@ -226,6 +227,11 @@ public abstract class AbstractOrmQuery<X extends XmlQuery> // ********** misc ********** + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); + } + public X getXmlQuery() { return this.xmlQuery; } @@ -239,15 +245,16 @@ public abstract class AbstractOrmQuery<X extends XmlQuery> } public TextRange getValidationTextRange() { - return this.xmlQuery.getValidationTextRange(); + TextRange textRange = this.xmlQuery.getValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); } public TextRange getNameTextRange() { - return this.xmlQuery.getNameTextRange(); + return this.getValidationTextRange(this.xmlQuery.getNameTextRange()); } public TextRange getQueryTextRange() { - return this.xmlQuery.getQueryTextRange(); + return this.getValidationTextRange(this.xmlQuery.getQueryTextRange()); } @Override 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 index 9382f0a57f..f400b4e027 100644 --- 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 @@ -356,50 +356,32 @@ public abstract class AbstractOrmRelationshipMapping<X extends AbstractXmlRelati protected void validateTargetEntity(List<IMessage> messages) { if (this.getTargetEntity() == null) { - String msg = this.isVirtual() ? - JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_NOT_DEFINED : - JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED; messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, - msg, + JpaValidationMessages.TARGET_ENTITY_NOT_DEFINED, new String[] {this.name}, this, this.getValidationTextRange() ) ); + return; } - else if (this.getResolvedTargetEntity() == null) { - if (this.isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_TARGET_ENTITY_IS_NOT_AN_ENTITY, - new String[] {this.name, this.getTargetEntity()}, - this, - this.getValidationTextRange() - ) - ); - } else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.TARGET_ENTITY_IS_NOT_AN_ENTITY, - new String[] {this.getTargetEntity(), this.name}, - this, - this.getTargetEntityTextRange() - ) - ); - } + 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 getTextRange(TextRange textRange) { - return (textRange != null) ? textRange : this.getPersistentAttribute().getValidationTextRange(); - } - protected TextRange getTargetEntityTextRange() { - return this.getTextRange(this.xmlAttributeMapping.getTargetEntityTextRange()); + return this.getValidationTextRange(this.xmlAttributeMapping.getTargetEntityTextRange()); } 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 index c7d5a9e302..d7c3600bcc 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -465,7 +465,8 @@ public abstract class AbstractOrmTable<X extends AbstractXmlTable> } public TextRange getValidationTextRange() { - return this.getTextRange(this.getXmlTableValidationTextRange()); + TextRange textRange = this.getXmlTableValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); } protected TextRange getXmlTableValidationTextRange() { @@ -474,7 +475,7 @@ public abstract class AbstractOrmTable<X extends AbstractXmlTable> } public TextRange getNameTextRange() { - return this.getTextRange(this.getXmlTableNameTextRange()); + return this.getValidationTextRange(this.getXmlTableNameTextRange()); } protected TextRange getXmlTableNameTextRange() { @@ -483,7 +484,7 @@ public abstract class AbstractOrmTable<X extends AbstractXmlTable> } public TextRange getSchemaTextRange() { - return this.getTextRange(this.getXmlTableSchemaTextRange()); + return this.getValidationTextRange(this.getXmlTableSchemaTextRange()); } protected TextRange getXmlTableSchemaTextRange() { @@ -492,7 +493,7 @@ public abstract class AbstractOrmTable<X extends AbstractXmlTable> } public TextRange getCatalogTextRange() { - return this.getTextRange(this.getXmlTableCatalogTextRange()); + return this.getValidationTextRange(this.getXmlTableCatalogTextRange()); } protected TextRange getXmlTableCatalogTextRange() { @@ -500,10 +501,6 @@ public abstract class AbstractOrmTable<X extends AbstractXmlTable> return (xmlTable == null) ? null : xmlTable.getCatalogTextRange(); } - protected TextRange getTextRange(TextRange textRange) { - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); - } - // ********** misc ********** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java index 1430c05804..124df96c1c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmTypeMapping.java @@ -57,6 +57,7 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping> extends AbstractOrmXmlContextNode implements OrmTypeMapping { + // never null protected final X xmlTypeMapping; protected String class_; @@ -393,15 +394,15 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping> } public TextRange getClassTextRange() { - return this.xmlTypeMapping.getClassTextRange(); + return this.getValidationTextRange(this.xmlTypeMapping.getClassTextRange()); } public TextRange getAttributesTextRange() { - return this.xmlTypeMapping.getAttributesTextRange(); + return this.getValidationTextRange(this.xmlTypeMapping.getAttributesTextRange()); } public TextRange getNameTextRange() { - return this.xmlTypeMapping.getNameTextRange(); + return this.getValidationTextRange(this.xmlTypeMapping.getNameTextRange()); } public boolean containsOffset(int textOffset) { @@ -492,6 +493,7 @@ public abstract class AbstractOrmTypeMapping<X extends XmlTypeMapping> } public TextRange getValidationTextRange() { - return this.xmlTypeMapping.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/AbstractOrmVirtualBaseColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/AbstractOrmVirtualBaseColumn.java index f41a3492f1..96cd8a6fe7 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -10,9 +10,9 @@ package org.eclipse.jpt.jpa.core.internal.context.orm; import org.eclipse.jpt.jpa.core.context.BaseColumn; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; 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> @@ -34,7 +34,7 @@ public abstract class AbstractOrmVirtualBaseColumn<O extends ReadOnlyNamedColumn protected boolean defaultUpdatable; - protected AbstractOrmVirtualBaseColumn(JpaContextNode parent, O owner) { + protected AbstractOrmVirtualBaseColumn(XmlContextNode parent, O owner) { super(parent, owner); } 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 index 93213006fc..a13e9d8835 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -10,10 +10,10 @@ package org.eclipse.jpt.jpa.core.internal.context.orm; import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; 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> @@ -36,7 +36,7 @@ public abstract class AbstractOrmVirtualNamedColumn<O extends ReadOnlyNamedColum protected String columnDefinition; - protected AbstractOrmVirtualNamedColumn(JpaContextNode parent, O owner) { + protected AbstractOrmVirtualNamedColumn(XmlContextNode parent, O owner) { super(parent); this.owner = owner; } @@ -118,14 +118,15 @@ public abstract class AbstractOrmVirtualNamedColumn<O extends ReadOnlyNamedColum // ********** validation ********** public TextRange getValidationTextRange() { - return null; // not sure this column is validated... + return this.getParent().getValidationTextRange(); } // ********** misc ********** - public boolean isVirtual() { - return true; + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); } @Override 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 index ff8ec49424..2e366584cc 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -17,10 +17,10 @@ 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.JpaContextNode; 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; @@ -35,7 +35,7 @@ public abstract class AbstractOrmVirtualReferenceTable<T extends ReferenceTable> protected OrmVirtualJoinColumn defaultJoinColumn; - protected AbstractOrmVirtualReferenceTable(JpaContextNode parent) { + protected AbstractOrmVirtualReferenceTable(XmlContextNode parent) { super(parent); this.joinColumnOwner = this.buildJoinColumnOwner(); } 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 index becc15dd8a..a2da665475 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -16,10 +16,10 @@ 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.JpaContextNode; 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; @@ -43,7 +43,7 @@ public abstract class AbstractOrmVirtualTable<T extends Table> protected final UniqueConstraintContainerAdapter uniqueConstraintContainerAdapter = new UniqueConstraintContainerAdapter(); - protected AbstractOrmVirtualTable(JpaContextNode parent) { + protected AbstractOrmVirtualTable(XmlContextNode parent) { super(parent); } @@ -297,13 +297,18 @@ public abstract class AbstractOrmVirtualTable<T extends Table> // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getParent().getValidationTextRange(); } // ********** misc ********** @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); + } + + @Override public void toString(StringBuilder sb) { sb.append(this.buildQualifiedName()); } 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 index 801b500dbe..c646d566f6 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -364,9 +364,12 @@ public class GenericOrmIdClassReference } public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlValidationTextRange(); + return (textRange != null) ? textRange : this.getTypeMapping().getValidationTextRange(); + } + + protected TextRange getXmlValidationTextRange() { XmlClassReference xmlIdClassRef = this.getXmlIdClassRef(); - return (xmlIdClassRef == null) ? - this.getTypeMapping().getValidationTextRange() : - xmlIdClassRef.getClassNameTextRange(); + 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/GenericOrmMappedByRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmMappedByRelationshipStrategy.java index 903f984532..b7e8c4ba8c 100644 --- 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 @@ -153,11 +153,6 @@ public class GenericOrmMappedByRelationshipStrategy // ********** validation ********** - public TextRange getValidationTextRange() { - TextRange mappedByTextRange = this.getXmlMappedByMapping().getMappedByTextRange(); - return (mappedByTextRange != null) ? mappedByTextRange : this.getRelationship().getValidationTextRange(); - } - @Override public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); @@ -207,10 +202,7 @@ public class GenericOrmMappedByRelationshipStrategy protected IMessage buildMessage(String msgID, String[] parms) { PersistentAttribute attribute = this.getRelationshipMapping().getPersistentAttribute(); - String attributeDescription = attribute.isVirtual() ? - JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC : - JpaValidationDescriptionMessages.ATTRIBUTE_DESC; - attributeDescription = NLS.bind(attributeDescription, attribute.getName()); + String attributeDescription = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, attribute.getName()); parms = ArrayTools.add(parms, 0, attributeDescription); return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, @@ -220,4 +212,9 @@ public class GenericOrmMappedByRelationshipStrategy 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/GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/orm/GenericOrmVirtualOverrideJoinColumnRelationshipStrategy.java index 6e10fe98a2..b341965c0e 100644 --- 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 @@ -280,7 +280,7 @@ public class GenericOrmVirtualOverrideJoinColumnRelationshipStrategy } public TextRange getValidationTextRange() { - return null; + return this.getRelationship().getValidationTextRange(); } protected String getAttributeName() { 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 index abee8a9261..2e5b2ad2af 100644 --- 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 @@ -17,7 +17,6 @@ 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.internal.context.TableTextRangeResolver; import org.eclipse.jpt.jpa.core.resource.orm.XmlJoinTable; import org.eclipse.jpt.jpa.db.Table; @@ -55,7 +54,7 @@ public class NullOrmJoinTableRelationshipStrategy // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getRelationship().getValidationTextRange(); } public JptValidator buildJoinTableJoinColumnValidator(JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { @@ -66,10 +65,6 @@ public class NullOrmJoinTableRelationshipStrategy throw new UnsupportedOperationException(); } - public JptValidator buildTableValidator(Table table, TableTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException(); - } - // ********** misc ********** 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 index 70e23586d1..01eaa01a78 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -53,14 +53,19 @@ public abstract class SpecifiedOrmPersistentAttribute /** * 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 acces type is different) + * <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; @@ -175,7 +180,7 @@ public abstract class SpecifiedOrmPersistentAttribute if (name == null) { return null; } - JavaPersistentType javaType = this.getOwningJavaPersistentType(); + JavaPersistentType javaType = this.getOwningPersistentTypeJavaType(); if (javaType == null) { return null; } @@ -197,7 +202,7 @@ public abstract class SpecifiedOrmPersistentAttribute } protected JavaPersistentAttribute getCachedJavaAttribute() { - JavaResourcePersistentType javaResourceType = this.getOwningJavaPersistentType().getResourcePersistentType(); + 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 @@ -212,6 +217,13 @@ public abstract class SpecifiedOrmPersistentAttribute 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())) { @@ -275,7 +287,7 @@ public abstract class SpecifiedOrmPersistentAttribute } - // ********** specified/virtual ********** + // ********** specified/default ********** public boolean isVirtual() { return false; @@ -407,7 +419,7 @@ public abstract class SpecifiedOrmPersistentAttribute return this.getParent(); } - protected JavaPersistentType getOwningJavaPersistentType() { + protected JavaPersistentType getOwningPersistentTypeJavaType() { return this.getOwningPersistentType().getJavaPersistentType(); } 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 index a45183eca7..e2d1c95a4f 100644 --- 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -11,6 +11,7 @@ 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; @@ -36,6 +37,8 @@ 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 @@ -50,22 +53,24 @@ public class VirtualOrmPersistentAttribute * 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 context is the <code>orm.xml</code> type - * (e.g. the Java attribute's default table is the table set in the + * 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's), 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). + * {@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; @@ -76,6 +81,8 @@ public class VirtualOrmPersistentAttribute * 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; @@ -257,7 +264,7 @@ public class VirtualOrmPersistentAttribute } - // ********** specified/virtual ********** + // ********** specified/default ********** public boolean isVirtual() { return true; @@ -306,6 +313,13 @@ public class VirtualOrmPersistentAttribute // ********** 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(); } @@ -466,10 +480,12 @@ public class VirtualOrmPersistentAttribute } 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); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java index 0413d8f066..51180c17a1 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractJarFileRef.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -303,6 +303,11 @@ public abstract class AbstractJarFileRef // ********** 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(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java index 82e42423a4..040e11868f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/persistence/AbstractPersistenceUnit.java @@ -295,6 +295,10 @@ public abstract class AbstractPersistenceUnit return (Persistence) super.getParent(); } + protected Persistence getPersistence() { + return this.getParent(); + } + @Override public PersistenceUnit getPersistenceUnit() { return this; @@ -1709,7 +1713,7 @@ public abstract class AbstractPersistenceUnit } } - protected void validateProperties(List<IMessage> messages, IReporter reporter) { + protected void validateProperties(@SuppressWarnings("unused") List<IMessage> messages, @SuppressWarnings("unused") IReporter reporter) { // do nothing by default } @@ -1718,7 +1722,8 @@ public abstract class AbstractPersistenceUnit } public TextRange getValidationTextRange() { - return this.xmlPersistenceUnit.getValidationTextRange(); + TextRange textRange = this.xmlPersistenceUnit.getValidationTextRange(); + return (textRange != null) ? textRange : this.getPersistence().getValidationTextRange(); } // ********** refactoring ********** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java index 81080e19ba..c48b0f14e3 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractNamedColumnValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -70,7 +70,7 @@ public abstract class AbstractNamedColumnValidator<C extends NamedColumn, R exte return new NullTableValidator(); } - protected boolean isPersistentAttributeVirtual() { + protected boolean attributeIsVirtual() { return (this.persistentAttribute != null) && this.persistentAttribute.isVirtual(); } @@ -94,7 +94,7 @@ public abstract class AbstractNamedColumnValidator<C extends NamedColumn, R exte } protected IMessage buildUnresolvedNameMessage() { - return this.isPersistentAttributeVirtual() ? + return this.attributeIsVirtual() ? this.buildVirtualAttributeUnresolvedNameMessage() : this.buildUnresolvedNameMessage(this.getUnresolvedNameMessage()); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java index b62e5a415f..8122811494 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractPersistentAttributeValidator.java @@ -1,20 +1,21 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.jpa1.context; import java.util.List; +import org.eclipse.jpt.jpa.core.MappingKeys; import org.eclipse.jpt.jpa.core.context.PersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; 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.wst.validation.internal.provisional.core.IMessage; import org.eclipse.wst.validation.internal.provisional.core.IReporter; @@ -36,39 +37,43 @@ public abstract class AbstractPersistentAttributeValidator } - public boolean validate(List<IMessage> messages, IReporter reporter) { - this.validateAttribute(messages); + public final boolean validate(List<IMessage> messages, IReporter reporter) { + if (this.persistentAttribute.getMappingKey() != MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY) { + this.validateMappedAttribute(messages); + } return true; } - protected abstract void validateAttribute(List<IMessage> messages); + protected abstract void validateMappedAttribute(List<IMessage> messages); - protected boolean isFieldAttribute() { - if (this.javaPersistentAttribute == null) { - return false; - } - return this.javaPersistentAttribute.isField(); + protected boolean attributeIsField() { + return (this.javaPersistentAttribute != null) && + this.javaPersistentAttribute.isField(); } - protected boolean isPropertyAttribute() { - if (this.javaPersistentAttribute == null) { - return false; - } - return this.javaPersistentAttribute.isProperty(); + protected boolean attributeIsProperty() { + return (this.javaPersistentAttribute != null) && + this.javaPersistentAttribute.isProperty(); } - protected boolean isFinalAttribute() { - if (this.javaPersistentAttribute == null) { - return false; - } - return this.javaPersistentAttribute.isFinal(); + protected boolean attributeIsFinal() { + return (this.javaPersistentAttribute != null) && + this.javaPersistentAttribute.isFinal(); } - protected boolean isPublicAttribute() { - if (this.javaPersistentAttribute == null) { - return false; - } - return this.javaPersistentAttribute.isPublic(); + protected boolean attributeIsPublic() { + return (this.javaPersistentAttribute != null) && + this.javaPersistentAttribute.isPublic(); } + + protected IMessage buildAttributeMessage(String msgID) { + return DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + msgID, + new String[] {this.persistentAttribute.getName()}, + this.persistentAttribute, + this.textRangeResolver.getAttributeTextRange() + ); + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java index 18b0a273bd..02c5751074 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/AbstractTableValidator.java @@ -1,13 +1,12 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.jpa1.context; import java.util.List; @@ -53,8 +52,8 @@ public abstract class AbstractTableValidator return this.textRangeResolver; } - protected boolean isPersistentAttributeVirtual() { - return this.persistentAttribute != null && this.persistentAttribute.isVirtual(); + protected boolean attributeIsVirtual() { + return (this.persistentAttribute != null) && this.persistentAttribute.isVirtual(); } protected String getPersistentAttributeName() { @@ -62,10 +61,8 @@ public abstract class AbstractTableValidator } public boolean validate(List<IMessage> messages, IReporter reporter) { - if (this.validatesAgainstDatabase()) { - return this.validateAgainstDatabase(messages); - } - return false; + return this.validatesAgainstDatabase() && + this.validateAgainstDatabase(messages); } protected boolean validatesAgainstDatabase() { @@ -74,18 +71,18 @@ public abstract class AbstractTableValidator protected boolean validateAgainstDatabase(List<IMessage> messages) { if ( ! this.table.catalogIsResolved()) { - messages.add(buildUnresolvedCatalogMessage()); + messages.add(this.buildUnresolvedCatalogMessage()); return false; } if ( ! this.table.schemaIsResolved()) { - messages.add(buildUnresolvedSchemaMessage()); + messages.add(this.buildUnresolvedSchemaMessage()); return false; } if ( ! this.table.isResolved()) { if (this.table.getName() != null) { //if name is null, the validation will be handled elsewhere, such as the target entity is not defined - messages.add(buildUnresolvedNameMessage()); + messages.add(this.buildUnresolvedNameMessage()); } return false; } @@ -93,10 +90,9 @@ public abstract class AbstractTableValidator } protected IMessage buildUnresolvedCatalogMessage() { - if (isPersistentAttributeVirtual()) { - return this.buildVirtualAttributeUnresolvedCatalogMessage(); - } - return this.buildUnresolvedCatalogMessage(this.getUnresolvedCatalogMessage()); + return this.attributeIsVirtual() ? + this.buildVirtualAttributeUnresolvedCatalogMessage() : + this.buildUnresolvedCatalogMessage(this.getUnresolvedCatalogMessage()); } protected abstract String getUnresolvedCatalogMessage(); @@ -105,8 +101,8 @@ public abstract class AbstractTableValidator return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, message, - new String[] {this.table.getCatalog(), this.table.getName()}, - this.table, + new String[] {this.table.getCatalog(), this.table.getName()}, + this.table, this.textRangeResolver.getCatalogTextRange() ); } @@ -116,7 +112,7 @@ public abstract class AbstractTableValidator IMessage.HIGH_SEVERITY, this.getVirtualAttributeUnresolvedCatalogMessage(), new String[] {this.getPersistentAttributeName(), this.table.getCatalog(), this.table.getName()}, - this.table, + this.table, this.textRangeResolver.getCatalogTextRange() ); } @@ -124,10 +120,9 @@ public abstract class AbstractTableValidator protected abstract String getVirtualAttributeUnresolvedCatalogMessage(); protected IMessage buildUnresolvedSchemaMessage() { - if (isPersistentAttributeVirtual()) { - return this.buildVirtualAttributeUnresolvedSchemaMessage(); - } - return this.buildUnresolvedSchemaMessage(this.getUnresolvedSchemaMessage()); + return this.attributeIsVirtual() ? + this.buildVirtualAttributeUnresolvedSchemaMessage() : + this.buildUnresolvedSchemaMessage(this.getUnresolvedSchemaMessage()); } protected abstract String getUnresolvedSchemaMessage(); @@ -136,8 +131,8 @@ public abstract class AbstractTableValidator return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, message, - new String[] {this.table.getSchema(), this.table.getName()}, - this.table, + new String[] {this.table.getSchema(), this.table.getName()}, + this.table, this.textRangeResolver.getSchemaTextRange() ); } @@ -147,7 +142,7 @@ public abstract class AbstractTableValidator IMessage.HIGH_SEVERITY, this.getVirtualAttributeUnresolvedSchemaMessage(), new String[] {this.getPersistentAttributeName(), this.table.getSchema(), this.table.getName()}, - this.table, + this.table, this.textRangeResolver.getSchemaTextRange() ); } @@ -155,10 +150,9 @@ public abstract class AbstractTableValidator protected abstract String getVirtualAttributeUnresolvedSchemaMessage(); protected IMessage buildUnresolvedNameMessage() { - if (isPersistentAttributeVirtual()) { - return this.buildVirtualAttributeUnresolvedNameMessage(); - } - return this.buildUnresolvedNameMessage(this.getUnresolvedNameMessage()); + return this.attributeIsVirtual() ? + this.buildVirtualAttributeUnresolvedNameMessage() : + this.buildUnresolvedNameMessage(this.getUnresolvedNameMessage()); } protected abstract String getUnresolvedNameMessage(); @@ -167,8 +161,8 @@ public abstract class AbstractTableValidator return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, message, - new String[] {this.table.getName()}, - this.table, + new String[] {this.table.getName()}, + this.table, this.textRangeResolver.getNameTextRange() ); } @@ -178,7 +172,7 @@ public abstract class AbstractTableValidator IMessage.HIGH_SEVERITY, this.getVirtualAttributeUnresolvedNameMessage(), new String[] {this.getPersistentAttributeName(), this.table.getName()}, - this.table, + this.table, this.textRangeResolver.getNameTextRange() ); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java index 8867a28110..de6e247ecd 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/BaseJoinColumnValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -79,7 +79,7 @@ public abstract class BaseJoinColumnValidator<C extends BaseJoinColumn, R extend } protected IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.isPersistentAttributeVirtual() ? + return this.attributeIsVirtual() ? this.buildVirtualAttributeUnresolvedReferencedColumnNameMessage() : this.buildUnresolvedReferencedColumnNameMessage(this.getUnresolvedReferencedColumnNameMessage()); } @@ -116,7 +116,7 @@ public abstract class BaseJoinColumnValidator<C extends BaseJoinColumn, R extend protected abstract String getVirtualAttributeUnresolvedReferencedColumnNameMessage(); protected IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.isPersistentAttributeVirtual() ? + return this.attributeIsVirtual() ? this.buildVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage() : this.buildUnspecifiedNameMultipleJoinColumnsMessage(this.getUnspecifiedNameMultipleJoinColumnsMessage()); } @@ -146,7 +146,7 @@ public abstract class BaseJoinColumnValidator<C extends BaseJoinColumn, R extend protected abstract String getVirtualAttributeUnspecifiedNameMultipleJoinColumnsMessage(); protected IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.isPersistentAttributeVirtual() ? + return this.attributeIsVirtual() ? this.buildVirtualAttributeUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() : this.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(this.getUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage()); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericPersistentAttributeValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericPersistentAttributeValidator.java index 8cee29d41a..021e64c459 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericPersistentAttributeValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/GenericPersistentAttributeValidator.java @@ -1,21 +1,18 @@ /******************************************************************************* - * 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 - *******************************************************************************/ + * 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.jpa1.context; import java.util.List; -import org.eclipse.jpt.jpa.core.MappingKeys; import org.eclipse.jpt.jpa.core.context.PersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; 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.wst.validation.internal.provisional.core.IMessage; @@ -29,34 +26,20 @@ public class GenericPersistentAttributeValidator } @Override - protected void validateAttribute(List<IMessage> messages) { - if (this.persistentAttribute.getMappingKey() == MappingKeys.TRANSIENT_ATTRIBUTE_MAPPING_KEY) { - return; - } - - if (this.isFieldAttribute()) { - if (this.isFinalAttribute()) { + protected void validateMappedAttribute(List<IMessage> messages) { + if (this.attributeIsField()) { + if (this.attributeIsFinal()) { messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_FIELD)); } - if (this.isPublicAttribute()) { + if (this.attributeIsPublic()) { messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_PUBLIC_FIELD)); } } - else if (this.isPropertyAttribute()) { + else if (this.attributeIsProperty()) { //TODO need to check both the getter and the setter - if (this.isFinalAttribute()) { + if (this.attributeIsFinal()) { messages.add(this.buildAttributeMessage(JpaValidationMessages.PERSISTENT_ATTRIBUTE_FINAL_GETTER)); } } } - - protected IMessage buildAttributeMessage(String msgID) { - return DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - msgID, - new String[] {this.persistentAttribute.getName()}, - this.persistentAttribute, - this.textRangeResolver.getAttributeTextRange() - ); - } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java index 15823d3b42..5d23f9305b 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/SecondaryTablePrimaryKeyJoinColumnValidator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -30,7 +30,7 @@ public class SecondaryTablePrimaryKeyJoinColumnValidator this.secondaryTable = secondaryTable; } - protected boolean isSecondaryTableVirtual() { + protected boolean secondaryTableIsVirtual() { return this.secondaryTable.isVirtual(); } @@ -40,7 +40,7 @@ public class SecondaryTablePrimaryKeyJoinColumnValidator @Override public IMessage buildUnresolvedNameMessage() { - return this.isSecondaryTableVirtual() ? + return this.secondaryTableIsVirtual() ? this.buildVirtualSecondaryTableUnresolvedNameMessage() : super.buildUnresolvedNameMessage(); } @@ -66,7 +66,7 @@ public class SecondaryTablePrimaryKeyJoinColumnValidator @Override public IMessage buildUnresolvedReferencedColumnNameMessage() { - return this.isSecondaryTableVirtual() ? + return this.secondaryTableIsVirtual() ? this.buildVirtualSecondaryTableUnresolvedReferencedColumnNameMessage() : super.buildUnresolvedReferencedColumnNameMessage(); } @@ -92,7 +92,7 @@ public class SecondaryTablePrimaryKeyJoinColumnValidator @Override public IMessage buildUnspecifiedNameMultipleJoinColumnsMessage() { - return this.isSecondaryTableVirtual() ? + return this.secondaryTableIsVirtual() ? this.buildVirtualSecondaryTableUnspecifiedNameMultipleJoinColumnsMessage() : super.buildUnspecifiedNameMultipleJoinColumnsMessage(); } @@ -114,7 +114,7 @@ public class SecondaryTablePrimaryKeyJoinColumnValidator @Override public IMessage buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() { - return this.isSecondaryTableVirtual() ? + return this.secondaryTableIsVirtual() ? this.buildVirtualSecondaryTableUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage() : super.buildUnspecifiedReferencedColumnNameMultipleJoinColumnsMessage(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java index 71d9610828..95be875fb6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -9,6 +9,8 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.core.internal.jpa1.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.JavaAttributeMapping; import org.eclipse.jpt.jpa.core.context.java.JavaConverter; import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; @@ -43,9 +45,16 @@ public abstract class AbstractJavaConverter return this.getResourcePersistentAttribute().getAnnotation(this.getAnnotationName()); } + protected abstract String getAnnotationName(); + + public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange(astRoot); + } + + protected abstract TextRange getAnnotationTextRange(CompilationUnit astRoot); + public void dispose() { // NOP } - - protected abstract String getAnnotationName(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java index 5c56ffc8f0..9320b1084f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/AbstractJavaOverrideContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -566,10 +566,13 @@ public abstract class AbstractJavaOverrideContainer< } public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getValidationAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.owner.getValidationTextRange(astRoot); + } + + protected TextRange getValidationAnnotationTextRange(CompilationUnit astRoot) { Annotation annotation = this.getValidationAnnotation(); - return (annotation != null) ? - annotation.getTextRange(astRoot) : - this.owner.getValidationTextRange(astRoot); + return (annotation == null) ? null : annotation.getTextRange(astRoot); } protected Annotation getValidationAnnotation() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java index 321792eaf2..604aea968a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaCascade.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -249,6 +249,11 @@ public class GenericJavaCascade } public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationCascadeTextRange(astRoot); + return (textRange != null) ? textRange : this.getMapping().getValidationTextRange(astRoot); + } + + protected TextRange getAnnotationCascadeTextRange(CompilationUnit astRoot) { RelationshipMappingAnnotation annotation = this.getMappingAnnotation(); return (annotation == null) ? null : annotation.getCascadeTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEnumeratedConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEnumeratedConverter.java index 0ef279813f..47336cfb95 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEnumeratedConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaEnumeratedConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -104,7 +104,8 @@ public class GenericJavaEnumeratedConverter // ********** validation ********** - public TextRange getValidationTextRange(CompilationUnit astRoot) { + @Override + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { return this.enumeratedAnnotation.getTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java index de5501141b..2d793a6521 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratedValue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -143,13 +143,18 @@ public class GenericJavaGeneratedValue return null; } - public TextRange getGeneratorTextRange(CompilationUnit astRoot) { - return this.generatedValueAnnotation.getGeneratorTextRange(astRoot); - } - // ********** misc ********** + @Override + public JavaIdMapping getParent() { + return (JavaIdMapping) super.getParent(); + } + + protected JavaIdMapping getIdMapping() { + return this.getParent(); + } + public GeneratedValueAnnotation getGeneratedValueAnnotation() { return this.generatedValueAnnotation; } @@ -208,13 +213,22 @@ public class GenericJavaGeneratedValue IMessage.HIGH_SEVERITY, JpaValidationMessages.ID_MAPPING_UNRESOLVED_GENERATOR_NAME, new String[] {generator}, - this.getParent(), + this.getIdMapping(), this.getGeneratorTextRange(astRoot) ) ); } public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.getIdMapping().getValidationTextRange(astRoot); + } + + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { return this.generatedValueAnnotation.getTextRange(astRoot); } + + public TextRange getGeneratorTextRange(CompilationUnit astRoot) { + return this.getValidationTextRange(this.generatedValueAnnotation.getGeneratorTextRange(astRoot), astRoot); + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java index 65d1ab157d..55a35e93d2 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaGeneratorContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -12,7 +12,6 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.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; @@ -220,6 +219,7 @@ public class GenericJavaGeneratorContainer return null; } + // ********** validation ********** @Override @@ -277,7 +277,19 @@ public class GenericJavaGeneratorContainer } public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getResourceTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); + } + + protected TextRange getResourceTextRange(CompilationUnit astRoot) { return this.owner.getResourceAnnotatedElement().getTextRange(astRoot); } + + // ********** 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/jpa1/context/java/GenericJavaJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java index de4e5b0c85..9052579cbe 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaJoinColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -128,8 +128,7 @@ public class GenericJavaJoinColumn } public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - TextRange textRange = this.getColumnAnnotation().getReferencedColumnNameTextRange(astRoot); - return (textRange != null) ? textRange : this.owner.getValidationTextRange(astRoot); + return this.getValidationTextRange(this.getColumnAnnotation().getReferencedColumnNameTextRange(astRoot), astRoot); } @@ -174,7 +173,7 @@ public class GenericJavaJoinColumn // ********** Java completion proposals ********** @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java index 9ccb2d3b51..e82aa65ea0 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaLobConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -43,7 +43,8 @@ public class GenericJavaLobConverter // ********** validation ********** - public TextRange getValidationTextRange(CompilationUnit astRoot) { + @Override + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { return this.lobAnnotation.getTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java index 21dd9cd90e..54c4ff871a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPersistentAttribute.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -47,6 +47,6 @@ public class GenericJavaPersistentAttribute @Override protected JptValidator buildAttibuteValidator(CompilationUnit astRoot) { - return new GenericPersistentAttributeValidator(this, this, buildTextRangeResolver(astRoot)); + return new GenericPersistentAttributeValidator(this, this, this.buildTextRangeResolver(astRoot)); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java index 8e5c92d5c4..a692c30c1d 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaPrimaryKeyJoinColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -155,7 +155,7 @@ public class GenericJavaPrimaryKeyJoinColumn // ********** Java completion proposals ********** @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; @@ -192,8 +192,7 @@ public class GenericJavaPrimaryKeyJoinColumn } public TextRange getReferencedColumnNameTextRange(CompilationUnit astRoot) { - TextRange textRange = this.columnAnnotation.getReferencedColumnNameTextRange(astRoot); - return textRange != null ? textRange : this.getValidationTextRange(astRoot); + return this.getValidationTextRange(this.columnAnnotation.getReferencedColumnNameTextRange(astRoot), astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java index c0c239bfe5..3cf33d79f4 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -367,7 +367,15 @@ public class GenericJavaQueryContainer } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.owner.getResourceAnnotatedElement().getTextRange(astRoot); + TextRange textRange = this.owner.getResourceAnnotatedElement().getTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); } + + // ********** 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/jpa1/context/java/GenericJavaQueryHint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java index ee05688b83..65a5a51027 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryHint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -86,11 +86,21 @@ public class GenericJavaQueryHint // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.queryHintAnnotation.getTextRange(astRoot); + TextRange textRange = this.queryHintAnnotation.getTextRange(astRoot); + return (textRange != null) ? textRange : this.getQuery().getValidationTextRange(astRoot); } - // ********** miscelleneous ********** + // ********** misc ********** + + @Override + public JavaQuery getParent() { + return (JavaQuery) super.getParent(); + } + + protected JavaQuery getQuery() { + return this.getParent(); + } public QueryHintAnnotation getQueryHintAnnotation() { return this.queryHintAnnotation; @@ -100,5 +110,4 @@ public class GenericJavaQueryHint 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/jpa1/context/java/GenericJavaTableGenerator.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java index f553c9b717..2bd6e5a3ab 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTableGenerator.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -459,7 +459,7 @@ public class GenericJavaTableGenerator * table, schema, catalog, pkColumnName, valueColumnName */ @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTemporalConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTemporalConverter.java index 7552b4963a..cce9eec8ec 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTemporalConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaTemporalConverter.java @@ -99,10 +99,10 @@ public class GenericJavaTemporalConverter @Override public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { super.validate(messages, reporter, astRoot); - this.validateAttributeTypeWithTemporal(messages, reporter, astRoot); + this.validateAttributeTypeWithTemporal(messages, astRoot); } - protected void validateAttributeTypeWithTemporal(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { + protected void validateAttributeTypeWithTemporal(List<IMessage> messages, CompilationUnit astRoot) { if (this.getAttributeMapping().getKey() == MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY) { String typeName = ((AbstractJavaElementCollectionMapping2_0) this.getAttributeMapping()).getFullyQualifiedTargetClass(); if (!ArrayTools.contains(TEMPORAL_MAPPING_SUPPORTED_TYPES, typeName)) { @@ -133,7 +133,8 @@ public class GenericJavaTemporalConverter } } - public TextRange getValidationTextRange(CompilationUnit astRoot) { + @Override + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { return this.temporalAnnotation.getTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java index 43eef86ff7..5f86c553af 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaUniqueConstraint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -86,7 +86,7 @@ public class GenericJavaUniqueConstraint // ********** Java completion proposals ********** @Override - public Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { + protected Iterator<String> connectedJavaCompletionProposals(int pos, Filter<String> filter, CompilationUnit astRoot) { Iterator<String> result = super.connectedJavaCompletionProposals(pos, filter, astRoot); if (result != null) { return result; @@ -117,7 +117,8 @@ public class GenericJavaUniqueConstraint // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return this.uniqueConstraintAnnotation.getTextRange(astRoot); + TextRange textRange = this.uniqueConstraintAnnotation.getTextRange(astRoot); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java index aeb114470b..0ee4c21397 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideJoinColumnRelationshipStrategy.java @@ -282,7 +282,7 @@ public class GenericJavaVirtualOverrideJoinColumnRelationshipStrategy } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getRelationship().getValidationTextRange(astRoot); } protected String getAttributeName() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java index b75f1d81a3..9989abfa97 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualOverrideRelationship.java @@ -164,6 +164,6 @@ public class GenericJavaVirtualOverrideRelationship // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getAssociationOverride().getValidationTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java index 388f871257..e0343034ad 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaVirtualUniqueConstraint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -41,7 +41,7 @@ public class GenericJavaVirtualUniqueConstraint // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getParent().getValidationTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java index 3908130b3c..d962bed134 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -43,6 +43,6 @@ public class NullJavaConverter } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getParent().getValidationTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java index 61ba4bc7bc..9c1efb0580 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinColumnRelationshipStrategy.java @@ -157,7 +157,7 @@ public class NullJavaJoinColumnRelationshipStrategy // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getRelationship().getValidationTextRange(astRoot); } public String getColumnTableNotValidDescription() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java index b5df2972f5..d9498d50ea 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/NullJavaJoinTableRelationshipStrategy.java @@ -46,7 +46,7 @@ public class NullJavaJoinTableRelationshipStrategy // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - throw new UnsupportedOperationException(); + return this.getRelationship().getValidationTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java index 1c73603b0a..2968119981 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -9,6 +9,7 @@ ******************************************************************************/ package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; +import org.eclipse.jpt.common.core.utility.TextRange; import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; import org.eclipse.jpt.jpa.core.context.orm.OrmConverter; import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmXmlContextNode; @@ -42,4 +43,14 @@ public abstract class AbstractOrmConverter protected XmlConvertibleMapping getXmlConvertibleMapping() { return (XmlConvertibleMapping) this.getXmlAttributeMapping(); } + + + // ********** validation ********** + + public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlValidationTextRange(); + return (textRange != null) ? textRange : this.getAttributeMapping().getValidationTextRange(); + } + + protected abstract TextRange getXmlValidationTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java index 4494cddecc..84e467a5bc 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverride.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -126,13 +126,17 @@ public abstract class AbstractOrmOverride<C extends OrmOverrideContainer, X exte return new OrmOverrideTextRangeResolver(this); } + /** + * @see AbstractOrmOverrideContainer#getValidationTextRange() + */ public TextRange getValidationTextRange() { TextRange textRange = this.xmlOverride.getValidationTextRange(); - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); + // skip the container since it really doesn't have a text range + // (also, this prevents a stack overflow) + return (textRange != null) ? textRange : this.getContainer().getParent().getValidationTextRange(); } public TextRange getNameTextRange() { - TextRange textRange = this.xmlOverride.getNameTextRange(); - return (textRange != null) ? textRange : this.getValidationTextRange(); + return this.getValidationTextRange(this.xmlOverride.getNameTextRange()); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java index b2d3ad9903..c84801e4cb 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmOverrideContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -400,6 +400,11 @@ public abstract class AbstractOrmOverrideContainer< // ********** misc ********** + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); + } + public TypeMapping getOverridableTypeMapping() { return this.owner.getOverridableTypeMapping(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java index 2a4dd9cd02..8b0df34953 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/AbstractOrmVirtualOverride.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -53,7 +53,7 @@ public abstract class AbstractOrmVirtualOverride<C extends OrmOverrideContainer> } public TextRange getValidationTextRange() { - return this.getParent().getValidationTextRange(); + return this.getContainer().getValidationTextRange(); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java index f27fde2d17..76cba3a5c8 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmCascade.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -295,9 +295,12 @@ public class GenericOrmCascade } public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlTextRange(); + return (textRange != null) ? textRange : this.getRelationshipMapping().getValidationTextRange(); + } + + protected TextRange getXmlTextRange() { CascadeType xmlCascade = this.getXmlCascade(); - return (xmlCascade != null) ? - xmlCascade.getValidationTextRange() : - this.getRelationshipMapping().getValidationTextRange(); + return (xmlCascade == null) ? null : xmlCascade.getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java index aa025b16e4..f3e84f98d6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEmbeddedMapping.java @@ -24,6 +24,7 @@ import org.eclipse.jpt.jpa.core.context.AssociationOverrideContainer; import org.eclipse.jpt.jpa.core.context.AttributeMapping; import org.eclipse.jpt.jpa.core.context.BaseColumn; 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.OverrideContainer; import org.eclipse.jpt.jpa.core.context.Override_; @@ -31,8 +32,6 @@ import org.eclipse.jpt.jpa.core.context.Relationship; import org.eclipse.jpt.jpa.core.context.RelationshipMapping; import org.eclipse.jpt.jpa.core.context.Table; import org.eclipse.jpt.jpa.core.context.TypeMapping; -import org.eclipse.jpt.jpa.core.context.JoinColumn.Owner; -import org.eclipse.jpt.jpa.core.context.java.JavaAssociationOverride; 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.OrmPersistentAttribute; @@ -52,7 +51,6 @@ import org.eclipse.jpt.jpa.core.internal.jpa1.context.AssociationOverrideValidat 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.JoinTableTableDescriptionProvider; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaEmbeddedMapping2_0; import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmEmbeddedMapping2_0; import org.eclipse.jpt.jpa.core.resource.orm.Attributes; import org.eclipse.jpt.jpa.core.resource.orm.XmlAssociationOverride; @@ -177,10 +175,6 @@ public class GenericOrmEmbeddedMapping return 80; } - protected JavaEmbeddedMapping2_0 getJavaEmbeddedMapping2_0() { - return (JavaEmbeddedMapping2_0) this.getJavaEmbeddedMapping(); - } - public void initializeOn(OrmAttributeMapping newMapping) { newMapping.initializeFromOrmEmbeddedMapping(this); } @@ -193,11 +187,6 @@ public class GenericOrmEmbeddedMapping xmlAttributes.getEmbeddeds().remove(this.xmlAttributeMapping); } - protected JavaAssociationOverride getSpecifiedJavaAssociationOverrideNamed(String attributeName) { - JavaEmbeddedMapping2_0 javaMapping = this.getJavaEmbeddedMapping2_0(); - return (javaMapping == null) ? null : javaMapping.getAssociationOverrideContainer().getSpecifiedOverrideNamed(attributeName); - } - @Override public Relationship resolveOverriddenRelationship(String attributeName) { return this.isJpa2_0Compatible() ? this.resolveOverriddenRelationship_(attributeName) : null; diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEnumeratedConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEnumeratedConverter.java index d923aec695..06bfd06add 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEnumeratedConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmEnumeratedConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -128,7 +128,8 @@ public class GenericOrmEnumeratedConverter // ********** validation ********** - public TextRange getValidationTextRange() { + @Override + protected TextRange getXmlValidationTextRange() { return this.getXmlConvertibleMapping().getEnumeratedTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java index 107502d1fe..33c0c8fc93 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratedValue.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -141,11 +141,6 @@ public class GenericOrmGeneratedValue return null; } - public TextRange getGeneratorTextRange() { - TextRange textRange = this.xmlGeneratedValue.getGeneratorTextRange(); - return textRange != null ? textRange : this.getValidationTextRange(); - } - // ********** misc ********** @@ -188,7 +183,11 @@ public class GenericOrmGeneratedValue } public TextRange getValidationTextRange() { - TextRange validationTextRange = this.xmlGeneratedValue.getValidationTextRange(); - return (validationTextRange != null) ? validationTextRange : this.getParent().getValidationTextRange(); + TextRange textRange = this.xmlGeneratedValue.getValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); + } + + public TextRange getGeneratorTextRange() { + return this.getValidationTextRange(this.xmlGeneratedValue.getGeneratorTextRange()); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java index 7cca101c7a..75972eb00c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmGeneratorContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -12,7 +12,6 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; import java.util.ArrayList; import java.util.Iterator; 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; @@ -256,6 +255,15 @@ public class GenericOrmGeneratorContainer } public TextRange getValidationTextRange() { - return this.xmlGeneratorContainer.getValidationTextRange(); + TextRange textRange = this.xmlGeneratorContainer.getValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); + } + + + // ********** misc ********** + + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java index 165d659ec5..b87a6661ed 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -171,7 +171,7 @@ public class GenericOrmJoinColumn } public TextRange getReferencedColumnNameTextRange() { - return this.getTextRange(this.xmlColumn.getReferencedColumnNameTextRange()); + return this.getValidationTextRange(this.xmlColumn.getReferencedColumnNameTextRange()); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java index a1bfda698f..9bd4e51936 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmJoinTable.java @@ -403,10 +403,6 @@ public class GenericOrmJoinTable return GenericOrmJoinTable.this.getValidationTextRange(); } - protected boolean isPersistentAttributeVirtual() { - return this.getPersistentAttribute().isVirtual(); - } - protected String getPersistentAttributeName() { return this.getPersistentAttribute().getName(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java index 324ceb7bff..94c52ecc93 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmLobConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -41,7 +41,8 @@ public class GenericOrmLobConverter // ********** validation ********** - public TextRange getValidationTextRange() { + @Override + protected TextRange getXmlValidationTextRange() { return this.getXmlConvertibleMapping().getLobTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java index 7ff900e4d1..47f0deb90e 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitDefaults.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -336,9 +336,12 @@ public class GenericOrmPersistenceUnitDefaults // ********** validation ********** public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlTextRange(); + return (textRange != null) ? textRange : this.getPersistenceUnitMetadata().getValidationTextRange(); + } + + protected TextRange getXmlTextRange() { XmlPersistenceUnitDefaults xmlDefaults = this.getXmlDefaults(); - return (xmlDefaults != null) ? - xmlDefaults.getValidationTextRange() : - this.getPersistenceUnitMetadata().getValidationTextRange(); + return (xmlDefaults == null) ? null : xmlDefaults.getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java index 63409c28f1..1fc8f131a5 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistenceUnitMetadata.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -171,8 +171,12 @@ public class GenericOrmPersistenceUnitMetadata return (EntityMappings) super.getParent(); } + protected EntityMappings getEntityMappings() { + return this.getParent(); + } + public XmlEntityMappings getXmlEntityMappings() { - return this.getParent().getXmlEntityMappings(); + return this.getEntityMappings().getXmlEntityMappings(); } public boolean resourceExists() { @@ -183,9 +187,12 @@ public class GenericOrmPersistenceUnitMetadata // ********** validation ********** public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlTextRange(); + return (textRange != null) ? textRange : this.getEntityMappings().getValidationTextRange(); + } + + protected TextRange getXmlTextRange() { XmlPersistenceUnitMetadata xmlMetadata = this.getXmlPersistenceUnitMetadata(); - return (xmlMetadata != null) ? - xmlMetadata.getValidationTextRange() : - this.getXmlEntityMappings().getValidationTextRange(); + return (xmlMetadata == null) ? null : xmlMetadata.getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java index 9689f948d5..e76cbc9db4 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPersistentType.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. + * 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. @@ -1131,7 +1131,8 @@ public class GenericOrmPersistentType } public TextRange getValidationTextRange() { - return this.mapping.getValidationTextRange(); + TextRange textRange = this.mapping.getValidationTextRange(); + return (textRange != null) ? textRange : this.getEntityMappings().getValidationTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java index 9761ef1cce..642231286e 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmPrimaryKeyJoinColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -168,6 +168,6 @@ public class GenericOrmPrimaryKeyJoinColumn } public TextRange getReferencedColumnNameTextRange() { - return this.getTextRange(this.xmlColumn.getReferencedColumnNameTextRange()); + return this.getValidationTextRange(this.xmlColumn.getReferencedColumnNameTextRange()); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java index 70fbb54835..c729a1062f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryContainer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -362,7 +362,15 @@ public class GenericOrmQueryContainer } public TextRange getValidationTextRange() { - return this.xmlQueryContainer.getValidationTextRange(); + TextRange textRange = this.xmlQueryContainer.getValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); } + + // ********** misc ********** + + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java index 36774ef58d..370b277edb 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmQueryHint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -85,11 +85,21 @@ public class GenericOrmQueryHint // ********** validation ********** public TextRange getValidationTextRange() { - return this.xmlQueryHint.getValidationTextRange(); + TextRange textRange = this.xmlQueryHint.getValidationTextRange(); + return (textRange != null) ? textRange : this.getQuery().getValidationTextRange(); } - // ********** miscelleneous ********** + // ********** misc ********** + + @Override + public OrmQuery getParent() { + return (OrmQuery) super.getParent(); + } + + protected OrmQuery getQuery() { + return this.getParent(); + } public XmlQueryHint getXmlQueryHint() { return this.xmlQueryHint; @@ -99,5 +109,4 @@ public class GenericOrmQueryHint 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/jpa1/context/orm/GenericOrmSecondaryTable.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java index 39971d0abb..e9c73a6993 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmSecondaryTable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -403,10 +403,6 @@ public class GenericOrmSecondaryTable return GenericOrmSecondaryTable.this.getValidationTextRange(); } - protected boolean isSecondaryTableVirtual() { - return GenericOrmSecondaryTable.this.isVirtual(); - } - protected String getSecondaryTableName() { return GenericOrmSecondaryTable.this.getName(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTemporalConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTemporalConverter.java index 977da242f7..0d9667e4bc 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTemporalConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmTemporalConverter.java @@ -94,10 +94,10 @@ public class GenericOrmTemporalConverter @Override public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); - this.validateAttributeTypeWithTemporal(messages, reporter); + this.validateAttributeTypeWithTemporal(messages); } - protected void validateAttributeTypeWithTemporal(List<IMessage> messages, IReporter reporter) { + protected void validateAttributeTypeWithTemporal(List<IMessage> messages) { if (this.getAttributeMapping().getKey() == MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY) { @SuppressWarnings("rawtypes") String typeName = ((AbstractOrmElementCollectionMapping2_0) this.getAttributeMapping()).getTargetClass(); @@ -129,7 +129,8 @@ public class GenericOrmTemporalConverter } } - public TextRange getValidationTextRange() { + @Override + protected TextRange getXmlValidationTextRange() { return this.getXmlConvertibleMapping().getTemporalTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java index 372829c881..37ff432641 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmUniqueConstraint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -81,12 +81,18 @@ public class GenericOrmUniqueConstraint // ********** validation ********** public TextRange getValidationTextRange() { - return this.xmlUniqueConstraint.getValidationTextRange(); + TextRange textRange = this.xmlUniqueConstraint.getValidationTextRange(); + return (textRange != null) ? textRange : this.getParent().getValidationTextRange(); } // ********** misc ********** + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); + } + public XmlUniqueConstraint getXmlUniqueConstraint() { return this.xmlUniqueConstraint; } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java index 3cf168ed05..6f50c93750 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -10,7 +10,7 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; import org.eclipse.jpt.jpa.core.context.Column; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; +import org.eclipse.jpt.jpa.core.context.XmlContextNode; import org.eclipse.jpt.jpa.core.context.orm.OrmVirtualColumn; import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmVirtualBaseColumn; @@ -31,7 +31,7 @@ public class GenericOrmVirtualColumn protected int defaultScale; - public GenericOrmVirtualColumn(JpaContextNode parent, OrmVirtualColumn.Owner owner) { + public GenericOrmVirtualColumn(XmlContextNode parent, OrmVirtualColumn.Owner owner) { super(parent, owner); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java index ceaef0bc75..dcf6cf5856 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualJoinColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -10,8 +10,8 @@ package org.eclipse.jpt.jpa.core.internal.jpa1.context.orm; import org.eclipse.jpt.jpa.core.context.JoinColumn; -import org.eclipse.jpt.jpa.core.context.JpaContextNode; import org.eclipse.jpt.jpa.core.context.ReadOnlyJoinColumn; +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.MappingTools; import org.eclipse.jpt.jpa.core.internal.context.orm.AbstractOrmVirtualBaseColumn; @@ -29,7 +29,7 @@ public class GenericOrmVirtualJoinColumn protected String defaultReferencedColumnName; - public GenericOrmVirtualJoinColumn(JpaContextNode parent, ReadOnlyJoinColumn.Owner owner, JoinColumn overriddenColumn) { + public GenericOrmVirtualJoinColumn(XmlContextNode parent, ReadOnlyJoinColumn.Owner owner, JoinColumn overriddenColumn) { super(parent, owner); this.overriddenColumn = overriddenColumn; } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java index f8211eddf6..b6d57f39c0 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualOverrideRelationship.java @@ -164,6 +164,6 @@ public class GenericOrmVirtualOverrideRelationship // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getAssociationOverride().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java index 6fe8eb779c..f7ee1413b1 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmVirtualUniqueConstraint.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 Oracle. All rights reserved. + * 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. @@ -40,12 +40,17 @@ public class GenericOrmVirtualUniqueConstraint // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getParent().getValidationTextRange(); } // ********** misc ********** + @Override + public XmlContextNode getParent() { + return (XmlContextNode) super.getParent(); + } + public UniqueConstraint getOverriddenUniqueConstraint() { return this.overriddenUniqueConstraint; } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java index 190e0fa341..d843d3334b 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/GenericOrmXml.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -276,6 +276,7 @@ public class GenericOrmXml } public TextRange getValidationTextRange() { + // since this is the entire file, point to the top of the file return TextRange.Empty.instance(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java index c0b5200071..9915124912 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmConverter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -32,7 +32,8 @@ public class NullOrmConverter return null; } - public TextRange getValidationTextRange() { + @Override + protected TextRange getXmlValidationTextRange() { return null; } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java index fb9c4fd2b7..986418a13c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/orm/NullOrmJoinColumnRelationshipStrategy.java @@ -96,7 +96,7 @@ public class NullOrmJoinColumnRelationshipStrategy // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getRelationship().getValidationTextRange(); } public String getColumnTableNotValidDescription() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java index 96ae45722e..1a95aa6256 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericClassRef.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -373,6 +373,11 @@ public class GenericClassRef } public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlValidationTextRange(); + return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange(); + } + + public TextRange getXmlValidationTextRange() { return this.isVirtual() ? null : this.xmlJavaClassRef.getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java index 45e923a079..43a0a78e9f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericMappingFileRef.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -94,6 +94,11 @@ public class GenericMappingFileRef // ********** validation ********** public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlValidationTextRange(); + return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange(); + } + + protected TextRange getXmlValidationTextRange() { return this.xmlMappingFileRef.getValidationTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java index 446be61a1a..491d9a6ec9 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistence.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -210,8 +210,13 @@ public class GenericPersistence return (PersistenceXml) super.getParent(); } + protected PersistenceXml getPersistenceXml() { + return this.getParent(); + } + public TextRange getValidationTextRange() { - return this.xmlPersistence.getValidationTextRange(); + TextRange textRange = this.xmlPersistence.getValidationTextRange(); + return (textRange != null) ? textRange : this.getPersistenceXml().getValidationTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java index 4c37d3d4b7..66e1110763 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceUnitProperty.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -75,7 +75,7 @@ public class GenericPersistenceUnitProperty String old = this.name; this.name = name; if (this.firePropertyChanged(NAME_PROPERTY, old, name)) { - this.getParent().propertyNameChanged(old, name, this.value); + this.getPersistenceUnit().propertyNameChanged(old, name, this.value); } } @@ -95,7 +95,7 @@ public class GenericPersistenceUnitProperty String old = this.value; this.value = value; if (this.firePropertyChanged(VALUE_PROPERTY, old, value)) { - this.getParent().propertyValueChanged(this.name, value); + this.getPersistenceUnit().propertyValueChanged(this.name, value); } } @@ -115,7 +115,8 @@ public class GenericPersistenceUnitProperty // ********** validation ********** public TextRange getValidationTextRange() { - return this.xmlProperty.getValidationTextRange(); + TextRange textRange = this.xmlProperty.getValidationTextRange(); + return (textRange != null) ? textRange : this.getPersistenceUnit().getValidationTextRange(); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java index fda1d6c9bf..d3ca90ee9b 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/persistence/GenericPersistenceXml.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -244,8 +244,8 @@ public class GenericPersistenceXml this.persistence.validate(messages, reporter); } - // never actually selected public TextRange getValidationTextRange() { + // since this is the entire file, point to the top of the file return TextRange.Empty.instance(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java index c1edb0eda8..1742b2d3dd 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/AbstractJavaElementCollectionMapping2_0.java @@ -1159,51 +1159,67 @@ public abstract class AbstractJavaElementCollectionMapping2_0 } protected void validateTargetClass(List<IMessage> messages, CompilationUnit astRoot) { - String targetClass = getFullyQualifiedTargetClass(); - IJavaProject javaProject = getJpaProject().getJavaProject(); + String targetClass = this.getFullyQualifiedTargetClass(); if (StringTools.stringIsEmpty(targetClass)) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange(astRoot) - ) - ); - } else if(targetClassExists(javaProject)) { - if (!JDTTools.typeIsBasic(javaProject, targetClass) && getResolvedTargetEmbeddable() == null) { + if (this.getPersistentAttribute().isVirtual()) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - new String[] {targetClass}, - this, - this.getTargetClassTextRange(astRoot) + JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, + new String[] {this.getName()}, + this, + this.getValidationTextRange(astRoot) + ) + ); + } else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, + EMPTY_STRING_ARRAY, + this, + this.getValidationTextRange(astRoot) ) ); } - } - } - - private boolean targetClassExists(IJavaProject javaProject) { - String targetClass = getFullyQualifiedTargetClass(); - if (!StringTools.stringIsEmpty(targetClass)) - { - if (JDTTools.findType(javaProject, targetClass) != null) { - return true; + return; + } + + IJavaProject javaProject = this.getJpaProject().getJavaProject(); + if (JDTTools.findType(javaProject, targetClass) != null) { + if ( ! JDTTools.typeIsBasic(javaProject, targetClass) && (this.getResolvedTargetEmbeddable() == null)) { + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, + new String[] {this.getName(), this.getTargetClass()}, + this, + this.getTargetClassTextRange(astRoot) + ) + ); + } else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, + new String[] {this.getTargetClass(), this.getName()}, + this, + this.getTargetClassTextRange(astRoot) + ) + ); + } } } - return false; } protected TextRange getTargetClassTextRange(CompilationUnit astRoot) { - ElementCollection2_0Annotation annotation = this.getMappingAnnotation(); - return (annotation == null) ? null : this.getTextRange(annotation.getTargetClassTextRange(astRoot), astRoot); + return this.getValidationTextRange(this.getAnnotationTargetClassTextRange(astRoot), astRoot); } - protected TextRange getTextRange(TextRange textRange, CompilationUnit astRoot) { - return (textRange != null) ? textRange : this.getParent().getValidationTextRange(astRoot); + protected TextRange getAnnotationTargetClassTextRange(CompilationUnit astRoot) { + ElementCollection2_0Annotation annotation = this.getMappingAnnotation(); + return (annotation == null) ? null : annotation.getTargetClassTextRange(astRoot); } protected void validateMapKeyClass(List<IMessage> messages, CompilationUnit astRoot) { @@ -1214,15 +1230,27 @@ public abstract class AbstractJavaElementCollectionMapping2_0 protected void validateMapKeyClass_(List<IMessage> messages, CompilationUnit astRoot) { if (this.getMapKeyClass() == null) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange(astRoot) - ) - ); + if (this.getPersistentAttribute().isVirtual()) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, + new String[] {this.getName()}, + this, + this.getValidationTextRange(astRoot) + ) + ); + } else { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, + EMPTY_STRING_ARRAY, + this, + this.getValidationTextRange(astRoot) + ) + ); + } } } @@ -1409,18 +1437,6 @@ public abstract class AbstractJavaElementCollectionMapping2_0 public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { return new AssociationOverrideJoinColumnValidator((AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) columnOwner, (JoinColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); } - - public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } - - public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ - } } @@ -1443,7 +1459,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) { return new AttributeOverrideValidator((AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); } - + @Override public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { return new AttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new CollectionTableTableDescriptionProvider()); @@ -1476,19 +1492,16 @@ public abstract class AbstractJavaElementCollectionMapping2_0 return new AssociationOverrideJoinColumnValidator((AssociationOverride) override, (JoinColumn) column, (JoinColumn.Owner) columnOwner, (JoinColumnTextRangeResolver) textRangeResolver, new CollectionTableTableDescriptionProvider()); } - @Override public JptValidator buildJoinTableJoinColumnValidator(AssociationOverride override, JoinColumn column, JoinColumn.Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ + throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a join table is not supported"); //$NON-NLS-1$ } - @Override public JptValidator buildJoinTableInverseJoinColumnValidator(AssociationOverride override, JoinColumn column, Owner owner, JoinColumnTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ + throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a join table is not supported"); //$NON-NLS-1$ } - @Override public JptValidator buildTableValidator(AssociationOverride override, Table table, TableTextRangeResolver textRangeResolver) { - throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a JoinTable is not supported"); //$NON-NLS-1$ + throw new UnsupportedOperationException("An element collection containing a nested relationship mapping using a join table is not supported"); //$NON-NLS-1$ } } @@ -1535,7 +1548,7 @@ public abstract class AbstractJavaElementCollectionMapping2_0 public JptValidator buildValidator(Override_ override, OverrideContainer container, OverrideTextRangeResolver textRangeResolver) { return new MapKeyAttributeOverrideValidator((AttributeOverride) override, (AttributeOverrideContainer) container, textRangeResolver, new EmbeddableOverrideDescriptionProvider()); } - + public JptValidator buildColumnValidator(Override_ override, BaseColumn column, BaseColumn.Owner columnOwner, BaseColumnTextRangeResolver textRangeResolver) { return new MapKeyAttributeOverrideColumnValidator((AttributeOverride) override, column, textRangeResolver, new CollectionTableTableDescriptionProvider()); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java index 0220fc6606..3d5e0db070 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaCacheable2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -159,6 +159,11 @@ public class GenericJavaCacheable2_0 // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.getCacheableHolder().getValidationTextRange(astRoot); + } + + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { Cacheable2_0Annotation annotation = this.getCacheableAnnotation(); return (annotation == null) ? null : annotation.getTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java index 9f5ec69202..3a49304c91 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaIdDerivedIdentityStrategy2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -131,6 +131,11 @@ public class GenericJavaIdDerivedIdentityStrategy2_0 } public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.getDerivedIdentity().getValidationTextRange(astRoot); + } + + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { IdAnnotation annotation = this.getAnnotation(); return (annotation == null) ? null : annotation.getTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java index df745d2cca..737a85bf0a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaMapsIdDerivedIdentityStrategy2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -28,6 +28,7 @@ import org.eclipse.jpt.jpa.core.MappingKeys; import org.eclipse.jpt.jpa.core.context.AttributeMapping; import org.eclipse.jpt.jpa.core.context.Embeddable; import org.eclipse.jpt.jpa.core.context.EmbeddedIdMapping; +import org.eclipse.jpt.jpa.core.context.PersistentAttribute; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaJpaContextNode; import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; @@ -344,7 +345,11 @@ public class GenericJavaMapsIdDerivedIdentityStrategy2_0 } protected IMessage buildMessage(String msgID, String[] parms, CompilationUnit astRoot) { - String attributeDescription = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, this.getPersistentAttribute().getName()); + PersistentAttribute attribute = this.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, @@ -356,6 +361,11 @@ public class GenericJavaMapsIdDerivedIdentityStrategy2_0 } public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.getDerivedIdentity().getValidationTextRange(astRoot); + } + + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { return this.getAnnotation().getTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java index c48a4acdc5..60ddabad13 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaOrphanRemoval2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -115,6 +115,11 @@ public class GenericJavaOrphanRemoval2_0 // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { + TextRange textRange = this.getAnnotationTextRange(astRoot); + return (textRange != null) ? textRange : this.getMapping().getValidationTextRange(astRoot); + } + + protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { OwningRelationshipMapping2_0Annotation annotation = this.getMappingAnnotation(); return (annotation == null) ? null : annotation.getOrphanRemovalTextRange(astRoot); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0.java index 2a4d21001e..32b5cab20c 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0.java @@ -116,6 +116,6 @@ public class GenericJavaVirtualOverrideJoinTableRelationshipStrategy2_0 // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getRelationship().getValidationTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaCacheable2_0.java index 275358b747..cedad0cb21 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaCacheable2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaCacheable2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -46,9 +46,21 @@ public class NullJavaCacheable2_0 } + // ********** misc ********** + + @Override + public JavaCacheableHolder2_0 getParent() { + return (JavaCacheableHolder2_0) super.getParent(); + } + + protected JavaCacheableHolder2_0 getCacheableHolder() { + return this.getParent(); + } + + // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getCacheableHolder().getValidationTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java index b03515ecd4..dbd78dd156 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaDerivedIdentity2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -86,11 +86,16 @@ public class NullJavaDerivedIdentity2_0 // ********** misc ********** + @Override + public JavaSingleRelationshipMapping getParent() { + return (JavaSingleRelationshipMapping) super.getParent(); + } + public JavaSingleRelationshipMapping2_0 getMapping() { return null; } public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getParent().getValidationTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java index 10f019ee07..9086e148a1 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaMapKeyColumn2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Oracle. All rights reserved. + * 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. @@ -259,15 +259,15 @@ public class NullJavaMapKeyColumn2_0 // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getParent().getValidationTextRange(astRoot); } public TextRange getNameTextRange(CompilationUnit astRoot) { - return null; + return this.getValidationTextRange(astRoot); } public TextRange getTableTextRange(CompilationUnit astRoot) { - return null; + return this.getValidationTextRange(astRoot); } public boolean tableNameIsInvalid() { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java index e2fd32bc54..200f20541b 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/NullJavaOrphanRemoval2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -46,9 +46,16 @@ public class NullJavaOrphanRemoval2_0 } + // ********** misc ********** + + @Override + public JavaOrphanRemovalHolder2_0 getParent() { + return (JavaOrphanRemovalHolder2_0) super.getParent(); + } + // ********** validation ********** public TextRange getValidationTextRange(CompilationUnit astRoot) { - return null; + return this.getParent().getValidationTextRange(astRoot); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java index 93d88459b7..30f2be34ee 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/AbstractOrmElementCollectionMapping2_0.java @@ -49,9 +49,6 @@ import org.eclipse.jpt.jpa.core.context.PersistentType; import org.eclipse.jpt.jpa.core.context.Relationship; import org.eclipse.jpt.jpa.core.context.Table; 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.JavaAttributeMapping; -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.OrmAssociationOverrideContainer; import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; @@ -92,7 +89,6 @@ import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0; import org.eclipse.jpt.jpa.core.jpa2.context.CollectionTable2_0; import org.eclipse.jpt.jpa.core.jpa2.context.MetamodelField; import org.eclipse.jpt.jpa.core.jpa2.context.Orderable2_0; -import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaElementCollectionMapping2_0; import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmCollectionTable2_0; import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmElementCollectionMapping2_0; import org.eclipse.jpt.jpa.core.jpa2.context.orm.OrmOrderable2_0; @@ -855,39 +851,6 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen } - // ********** Java override lookups ********** - - protected JavaAttributeOverride getSpecifiedJavaValueAttributeOverrideNamed(String attributeName) { - JavaElementCollectionMapping2_0 javaMapping = this.getJavaElementCollectionMapping(); - return (javaMapping == null) ? null : - javaMapping.getValueAttributeOverrideContainer().getSpecifiedOverrideNamed(attributeName); - } - - protected JavaAssociationOverride getSpecifiedJavaValueAssociationOverrideNamed(String attributeName) { - JavaElementCollectionMapping2_0 javaMapping = this.getJavaElementCollectionMapping(); - return (javaMapping == null) ? null : - javaMapping.getValueAssociationOverrideContainer().getSpecifiedOverrideNamed(attributeName); - } - - protected JavaAttributeOverride getSpecifiedJavaMapKeyAttributeOverrideNamed(String attributeName) { - JavaElementCollectionMapping2_0 javaMapping = this.getJavaElementCollectionMapping(); - return (javaMapping == null) ? null : - javaMapping.getMapKeyAttributeOverrideContainer().getSpecifiedOverrideNamed(attributeName); - } - - protected JavaElementCollectionMapping2_0 getJavaElementCollectionMapping() { - AttributeMapping javaAttributeMapping = this.getJavaAttributeMapping(); - return (javaAttributeMapping instanceof JavaElementCollectionMapping2_0) ? - (JavaElementCollectionMapping2_0) javaAttributeMapping : - null; - } - - protected JavaAttributeMapping getJavaAttributeMapping() { - JavaPersistentAttribute javaAttribute = this.getJavaPersistentAttribute(); - return (javaAttribute == null) ? null : javaAttribute.getMapping(); - } - - // ********** misc ********** @Override @@ -1217,121 +1180,69 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen } protected void validateTargetClass(List<IMessage> messages) { - String targetClass = getTargetClass(); - IJavaProject javaProject = getJpaProject().getJavaProject(); + String targetClass = this.getTargetClass(); if (StringTools.stringIsEmpty(targetClass)) { - if (this.isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - new String[] {this.name}, - this, - this.getValidationTextRange() - ) - ); - } else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } - } else if (!targetClassExists(javaProject)) { - if (this.isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST, - new String[] {this.name}, - this, - this.getTargetClassTextRange() - ) - ); - } else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST, - new String[] {this.name}, - this, - this.getTargetClassTextRange() - ) - ); - } - } else { - if (!JDTTools.typeIsBasic(javaProject, targetClass) && getResolvedTargetEmbeddable() == null) { - if (this.isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - new String[] {this.name, this.getTargetClass()}, - this, - this.getTargetClassTextRange() - ) - ); - } else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, - new String[] {this.getTargetClass(), this.name}, - this, - this.getTargetClassTextRange() - ) - ); - } - } + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_NOT_DEFINED, + EMPTY_STRING_ARRAY, + this, + this.getValidationTextRange() + ) + ); + return; } - } - - private boolean targetClassExists(IJavaProject javaProject) { - String targetClass = getTargetClass(); - if (!StringTools.stringIsEmpty(targetClass)) - { - if (JDTTools.findType(javaProject, targetClass) != null) { - return true; - } + + IJavaProject javaProject = this.getJpaProject().getJavaProject(); + if (JDTTools.findType(javaProject, targetClass) == null) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_DOES_NOT_EXIST, + new String[] {this.name}, + this, + this.getTargetClassTextRange() + ) + ); + return; + } + + if ( ! JDTTools.typeIsBasic(javaProject, targetClass) && (this.getResolvedTargetEmbeddable() == null)) { + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_TARGET_CLASS_MUST_BE_EMBEDDABLE_OR_BASIC_TYPE, + new String[] {this.getTargetClass(), this.name}, + this, + this.getTargetClassTextRange() + ) + ); } - return false; } - + protected TextRange getTargetClassTextRange() { - return this.xmlAttributeMapping.getTargetClassTextRange(); + return this.getValidationTextRange(this.xmlAttributeMapping.getTargetClassTextRange()); } protected void validateMapKeyClass(List<IMessage> messages) { JavaPersistentAttribute javaAttribute = this.getJavaPersistentAttribute(); if ((javaAttribute != null) && ! javaAttribute.getJpaContainerDefinition().isMap()) { - return; + this.validateMapKeyClass_(messages); } + } + + protected void validateMapKeyClass_(List<IMessage> messages) { if (this.getMapKeyClass() == null) { - if (this.isVirtual()) { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.VIRTUAL_ATTRIBUTE_ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - new String[] {this.name}, - this, - this.getValidationTextRange() - ) - ); - } else { - messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, - EMPTY_STRING_ARRAY, - this, - this.getValidationTextRange() - ) - ); - } + messages.add( + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.ELEMENT_COLLECTION_MAP_KEY_CLASS_NOT_DEFINED, + EMPTY_STRING_ARRAY, + this, + this.getValidationTextRange() + ) + ); } } @@ -1420,10 +1331,6 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen return AbstractOrmElementCollectionMapping2_0.this.getName(); } - protected boolean mappingIsVirtual() { - return AbstractOrmElementCollectionMapping2_0.this.isVirtual(); - } - protected OrmCollectionTable2_0 getCollectionTable() { return AbstractOrmElementCollectionMapping2_0.this.getCollectionTable(); } @@ -1518,12 +1425,6 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen } public Relationship resolveOverriddenRelationship(String attributeName) { - if (this.mappingIsVirtual() && ! this.getTypeMapping().isMetadataComplete()) { - JavaAssociationOverride override = AbstractOrmElementCollectionMapping2_0.this.getSpecifiedJavaValueAssociationOverrideNamed(attributeName); - if (override != null) { - return override.getRelationship(); - } - } return MappingTools.resolveOverriddenRelationship(this.getOverridableTypeMapping(), attributeName); } @@ -1569,12 +1470,6 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen } public Column resolveOverriddenColumn(String attributeName) { - if (this.mappingIsVirtual() && ! this.getTypeMapping().isMetadataComplete()) { - JavaAttributeOverride override = AbstractOrmElementCollectionMapping2_0.this.getSpecifiedJavaValueAttributeOverrideNamed(attributeName); - if (override != null) { - return override.getColumn(); - } - } return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName); } @@ -1608,12 +1503,6 @@ public abstract class AbstractOrmElementCollectionMapping2_0<X extends XmlElemen } public Column resolveOverriddenColumn(String attributeName) { - if (this.mappingIsVirtual() && ! this.getTypeMapping().isMetadataComplete()) { - JavaAttributeOverride override = AbstractOrmElementCollectionMapping2_0.this.getSpecifiedJavaMapKeyAttributeOverrideNamed(attributeName); - if (override != null) { - return override.getColumn(); - } - } return MappingTools.resolveOverriddenColumn(this.getOverridableTypeMapping(), attributeName); } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java index e3b01a30f2..976ba93809 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmCacheable2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -102,6 +102,7 @@ public class GenericOrmCacheable2_0 // ********** validation ********** public TextRange getValidationTextRange() { - return this.getXmlCacheable().getCacheableTextRange(); + TextRange textRange = this.getXmlCacheable().getCacheableTextRange(); + return (textRange != null) ? textRange : this.getCacheableHolder().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java index 7db7be432c..36b27d77fb 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmDerivedIdentity2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -26,9 +26,9 @@ public class GenericOrmDerivedIdentity2_0 { protected DerivedIdentityStrategy2_0 strategy; - protected OrmIdDerivedIdentityStrategy2_0 idStrategy; + protected final OrmIdDerivedIdentityStrategy2_0 idStrategy; - protected OrmMapsIdDerivedIdentityStrategy2_0 mapsIdStrategy; + protected final OrmMapsIdDerivedIdentityStrategy2_0 mapsIdStrategy; public GenericOrmDerivedIdentity2_0(OrmSingleRelationshipMapping2_0 parent) { diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java index cdf4e2a343..c4515a0e2a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmIdDerivedIdentityStrategy2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -102,13 +102,14 @@ public class GenericOrmIdDerivedIdentityStrategy2_0 // ********** validation ********** - public TextRange getValidationTextRange() { - return this.getXmlMapping().getIdTextRange(); - } - @Override public void validate(List<IMessage> messages, IReporter reporter) { super.validate(messages, reporter); // no validation rules } + + public TextRange getValidationTextRange() { + TextRange textRange = this.getXmlMapping().getIdTextRange(); + return (textRange != null) ? textRange : this.getDerivedIdentity().getValidationTextRange(); + } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java index a795658ba1..379b240259 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmMapsIdDerivedIdentityStrategy2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -260,11 +260,7 @@ public class GenericOrmMapsIdDerivedIdentityStrategy2_0 } protected IMessage buildMessage(String msgID, String[] parms) { - PersistentAttribute attribute = this.getPersistentAttribute(); - String attributeDescription = attribute.isVirtual() ? - JpaValidationDescriptionMessages.VIRTUAL_ATTRIBUTE_DESC : - JpaValidationDescriptionMessages.ATTRIBUTE_DESC; - attributeDescription = NLS.bind(attributeDescription, attribute.getName()); + String attributeDescription = NLS.bind(JpaValidationDescriptionMessages.ATTRIBUTE_DESC, this.getPersistentAttribute().getName()); parms = ArrayTools.add(parms, 0, attributeDescription); return DefaultJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java index 69ec1920af..e338f9655e 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmOrphanRemoval2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -112,7 +112,7 @@ public class GenericOrmOrphanRemoval2_0 // ********** validation ********** public TextRange getValidationTextRange() { - // TODO - return this.getXmlOrphanRemovable().getValidationTextRange(); + TextRange textRange = this.getXmlOrphanRemovable().getValidationTextRange(); + return (textRange != null) ? textRange : this.getMapping().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0.java index 72502c6d33..7d10e7a916 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0.java @@ -115,6 +115,6 @@ public class GenericOrmVirtualOverrideJoinTableRelationshipStrategy2_0 // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getRelationship().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java index 7ae634f53b..1a8eef92ed 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmCacheable2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -45,9 +45,17 @@ public class NullOrmCacheable2_0 } + // ********** misc ********** + + @Override + public OrmCacheableHolder2_0 getParent() { + return (OrmCacheableHolder2_0) super.getParent(); + } + + // ********** validation ********** public TextRange getValidationTextRange() { - return null; + return this.getParent().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java index 9bb81d55ea..8a26a2cb7a 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmDerivedIdentity2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -85,8 +85,13 @@ public class NullOrmDerivedIdentity2_0 // ********** misc ********** + @Override + public OrmSingleRelationshipMapping2_0 getParent() { + return (OrmSingleRelationshipMapping2_0) super.getParent(); + } + public OrmSingleRelationshipMapping2_0 getMapping() { - return (OrmSingleRelationshipMapping2_0) this.getParent(); + return this.getParent(); } public void initializeFrom(OrmDerivedIdentity2_0 oldDerivedIdentity) { @@ -94,6 +99,6 @@ public class NullOrmDerivedIdentity2_0 } public TextRange getValidationTextRange() { - return null; + return this.getMapping().getValidationTextRange(); } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java index 6ecbf93f32..104cef2cc6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/orm/NullOrmOrphanRemoval2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -45,9 +45,14 @@ public class NullOrmOrphanRemoval2_0 } - // ********** validation ********** + // ********** misc ********** + + @Override + public OrmOrphanRemovalHolder2_0 getParent() { + return (OrmOrphanRemovalHolder2_0) super.getParent(); + } public TextRange getValidationTextRange() { - return null; + return this.getParent().getValidationTextRange(); } -}
\ No newline at end of file +} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/resource/java/source/SourceAnnotation.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/resource/java/source/SourceAnnotation.java index 4631a1e7c8..c4e5d87a1f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/resource/java/source/SourceAnnotation.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/resource/java/source/SourceAnnotation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. + * 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. @@ -136,10 +136,13 @@ public abstract class SourceAnnotation<A extends AnnotatedElement> /** * Return the text range corresponding to the annotation. - * If the annotation is missing, return null. + * If the annotation is missing, return <code>null</code>. */ protected TextRange getAnnotationTextRange(CompilationUnit astRoot) { - return this.getTextRange(this.getAstAnnotation(astRoot)); + // the AST is null for virtual Java attributes + // TODO remove the AST null check once we start storing text ranges + // in the resource model + return (astRoot == null) ? null : this.getTextRange(this.getAstAnnotation(astRoot)); } /** @@ -177,10 +180,13 @@ public abstract class SourceAnnotation<A extends AnnotatedElement> /** * Return the text range corresponding to the specified element. - * If the element is missing, return null. + * If the element is missing, return <code>null</code>. */ protected TextRange getAnnotationElementTextRange(DeclarationAnnotationElementAdapter<?> adapter, CompilationUnit astRoot) { - return this.getTextRange(this.getAnnotationElementExpression(adapter, astRoot)); + // the AST is null for virtual Java attributes + // TODO remove the AST null check once we start storing text ranges + // in the resource model + return (astRoot == null) ? null : this.getTextRange(this.getAnnotationElementExpression(adapter, astRoot)); } /** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/DefaultJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/DefaultJpaValidationMessages.java index eedc8ee9ba..0acb9697d9 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/DefaultJpaValidationMessages.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/validation/DefaultJpaValidationMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 Oracle. All rights reserved. + * Copyright (c) 2005, 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. @@ -49,7 +49,7 @@ public class DefaultJpaValidationMessages { //log an exception and then continue without setting location information //At least the user will still get the validation message and will //be able to see other validation messages with valid textRanges - JptJpaCorePlugin.log(new IllegalArgumentException("Null text range for message ID: " + messageId)); //$NON-NLS-1$ + JptJpaCorePlugin.log(new NullPointerException("Null text range for message ID: " + messageId)); //$NON-NLS-1$ } else { message.setLineNo(textRange.getLineNumber()); diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2/context/MapsIdDerivedIdentityStrategy2_0.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2/context/MapsIdDerivedIdentityStrategy2_0.java index 37cd352442..d5309c83e6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2/context/MapsIdDerivedIdentityStrategy2_0.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/jpa2/context/MapsIdDerivedIdentityStrategy2_0.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. + * 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. @@ -26,9 +26,12 @@ import org.eclipse.jpt.jpa.core.context.AttributeMapping; public interface MapsIdDerivedIdentityStrategy2_0 extends DerivedIdentityStrategy2_0 { -// TODO bjv rename value to attribute name +// TODO bjv rename value to attributeName /** - * Return the specfied value, or in absence of that, the default value + * Return the specified attribute name, or in its absence, the default + * attribute name. This the name of the ID attribute the relationship + * mapping also maps (e.g. a Child's parent mapping also maps part of + * the Child's primary key, the parent ID). */ String getValue(); @@ -38,18 +41,19 @@ public interface MapsIdDerivedIdentityStrategy2_0 String SPECIFIED_VALUE_PROPERTY = "specifiedValue"; //$NON-NLS-1$ /** - * Return the specified value (the id which has been specified in code) - * Will return null if no value is specified + * Return the specified attribute name. + * Return <code>null</code> if no name is specified. */ String getSpecifiedValue(); /** - * Set the specified value (the id to specify in code) + * Set the specified attribute name. */ void setSpecifiedValue(String value); /** - * Return whether a default value is ever used (in some cases, there can be no default) + * Return whether a default value is ever used. + * (In some cases, there can be no default.) */ boolean usesDefaultValue(); @@ -59,18 +63,20 @@ public interface MapsIdDerivedIdentityStrategy2_0 String DEFAULT_VALUE_PROPERTY = "defaultValue"; //$NON-NLS-1$ /** - * Return the default value (the id which would be used in the absence of a specified value) + * Return the default attribute name. */ String getDefaultValue(); /** - * Return a sorted iterator of possible value choices + * Return a sorted list of possible attribute names. */ Iterable<String> getSortedValueChoices(); /** - * Return a resolved attribute mapping, which may be a mapping on the entity, or a mapping - * within an embeddable mapping on the entity + * Return attribute mapping referenced by the attribute name, + * which may be a mapping on the entity + * or a mapping within the embeddable mapping referenced by the entity's + * embedded ID mapping. */ AttributeMapping getResolvedAttributeMappingValue(); } |