diff options
author | kmoore | 2010-08-24 19:26:34 +0000 |
---|---|---|
committer | kmoore | 2010-08-24 19:26:34 +0000 |
commit | 3959074e70db1f75079132e998106a68859a1e54 (patch) | |
tree | fe9c59610ac5948796b21b2c5730f767df8764a7 /jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org | |
parent | d846e24ca6f6d33a339d61cca210261a533b41f9 (diff) | |
download | webtools.dali-3959074e70db1f75079132e998106a68859a1e54.tar.gz webtools.dali-3959074e70db1f75079132e998106a68859a1e54.tar.xz webtools.dali-3959074e70db1f75079132e998106a68859a1e54.zip |
132216 - Adding entity class related validation errors
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org')
10 files changed, 142 insertions, 14 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java index e071ee25ae..e3253e7ae7 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/EclipseLinkJpaValidationMessages.java @@ -13,13 +13,13 @@ package org.eclipse.jpt.eclipselink.core.internal; public interface EclipseLinkJpaValidationMessages { public static final String BUNDLE_NAME = "eclipselink_jpa_validation"; - + public static final String CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED = "CACHE_EXPIRY_AND_EXPIRY_TIME_OF_DAY_BOTH_SPECIFIED"; public static final String CONVERTER_CLASS_IMPLEMENTS_CONVERTER = "CONVERTER_CLASS_IMPLEMENTS_CONVERTER"; - + public static final String CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER = "CUSTOMIZER_CLASS_IMPLEMENTS_DESCRIPTOR_CUSTOMIZER"; - + public static final String MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE = "MULTIPLE_OBJECT_VALUES_FOR_DATA_VALUE"; public static final String PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING = "PERSISTENCE_UNIT_LEGACY_ENTITY_CACHING"; @@ -29,4 +29,6 @@ public interface EclipseLinkJpaValidationMessages { public static final String BASIC_COLLECTION_MAPPING_DEPRECATED = "BASIC_COLLECTION_MAPPING_DEPRECATED"; public static final String BASIC_MAP_MAPPING_DEPRECATED = "BASIC_MAP_MAPPING_DEPRECATED"; + public static final String ENTITY_MEMBER_CLASS_NOT_STATIC = "ENTITY_MEMBER_CLASS_NOT_STATIC"; + } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkEntityImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkEntityImpl.java index 9300e417f4..4a6c7863ef 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkEntityImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkEntityImpl.java @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.context.java; import java.util.List; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.java.JavaPersistentType; -import org.eclipse.jpt.core.internal.context.PrimaryKeyValidator; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.java.AbstractJavaEntity; import org.eclipse.jpt.core.jpa2.context.java.JavaCacheable2_0; import org.eclipse.jpt.core.jpa2.context.java.JavaCacheableHolder2_0; @@ -24,6 +24,7 @@ import org.eclipse.jpt.eclipselink.core.context.java.JavaEclipseLinkCaching; import org.eclipse.jpt.eclipselink.core.context.java.JavaEclipseLinkConverterHolder; import org.eclipse.jpt.eclipselink.core.context.java.JavaEclipseLinkEntity; import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkEntityPrimaryKeyValidator; +import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkEntityValidator; import org.eclipse.jpt.eclipselink.core.resource.java.EclipseLink; import org.eclipse.jpt.eclipselink.core.v2_0.resource.java.EclipseLinkClassExtractorAnnotation2_1; import org.eclipse.wst.validation.internal.provisional.core.IMessage; @@ -133,7 +134,12 @@ public class JavaEclipseLinkEntityImpl } @Override - protected PrimaryKeyValidator buildPrimaryKeyValidator(CompilationUnit astRoot) { + protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) { return new EclipseLinkEntityPrimaryKeyValidator(this, buildTextRangeResolver(astRoot)); } + + @Override + protected JptValidator buildEntityValidator(CompilationUnit astRoot) { + return new EclipseLinkEntityValidator(this, this.javaResourcePersistentType, buildTextRangeResolver(astRoot)); + } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java index 618ffadc75..92ee91c0fd 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkMappedSuperclassImpl.java @@ -12,7 +12,7 @@ package org.eclipse.jpt.eclipselink.core.internal.context.java; import java.util.List; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.java.JavaPersistentType; -import org.eclipse.jpt.core.internal.context.PrimaryKeyValidator; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.java.AbstractJavaMappedSuperclass; import org.eclipse.jpt.core.jpa2.context.Cacheable2_0; import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0; @@ -119,7 +119,7 @@ public class JavaEclipseLinkMappedSuperclassImpl } @Override - protected PrimaryKeyValidator buildPrimaryKeyValidator(CompilationUnit astRoot) { + protected JptValidator buildPrimaryKeyValidator(CompilationUnit astRoot) { return new EclipseLinkMappedSuperclassPrimaryKeyValidator(this, buildTextRangeResolver(astRoot)); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java index 465f7146d9..16206a7fbe 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/java/JavaEclipseLinkPersistentAttribute.java @@ -9,11 +9,14 @@ ******************************************************************************/ package org.eclipse.jpt.eclipselink.core.internal.context.java; +import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.context.AccessType; import org.eclipse.jpt.core.context.PersistentType; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.java.AbstractJavaPersistentAttribute; import org.eclipse.jpt.core.jpa2.context.java.JavaPersistentAttribute2_0; import org.eclipse.jpt.core.resource.java.JavaResourcePersistentAttribute; +import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkPersistentAttributeValidator; /** * EclipseLink Java persistent attribute @@ -67,4 +70,12 @@ public class JavaEclipseLinkPersistentAttribute this.typeIsContainer(interfaceName) || interfaceName.equals("org.eclipse.persistence.indirection.ValueHolderInterface"); //$NON-NLS-1$ } + + + // ********** validation ********** + + @Override + protected JptValidator buildAttibuteValidator(CompilationUnit astRoot) { + return new EclipseLinkPersistentAttributeValidator(this, this, buildTextRangeResolver(astRoot)); + } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java index e11b523afe..cbdb5f3756 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkEntityImpl.java @@ -14,7 +14,7 @@ import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IType; import org.eclipse.jpt.core.context.orm.EntityMappings; import org.eclipse.jpt.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.core.internal.context.PrimaryKeyValidator; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmEntity; import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0; import org.eclipse.jpt.core.jpa2.context.orm.OrmCacheable2_0; @@ -32,6 +32,7 @@ import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkCaching; import org.eclipse.jpt.eclipselink.core.context.orm.OrmEclipseLinkEntity; import org.eclipse.jpt.eclipselink.core.internal.context.java.JavaEclipseLinkCustomizer; import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkEntityPrimaryKeyValidator; +import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkEntityValidator; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlCacheHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlChangeTrackingHolder; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlConvertersHolder; @@ -304,7 +305,12 @@ public class OrmEclipseLinkEntityImpl } @Override - protected PrimaryKeyValidator buildPrimaryKeyValidator() { + protected JptValidator buildPrimaryKeyValidator() { return new EclipseLinkEntityPrimaryKeyValidator(this, buildTextRangeResolver()); } + + @Override + protected JptValidator buildEntityValidator() { + return new EclipseLinkEntityValidator(this, getJavaResourcePersistentType(), buildTextRangeResolver()); + } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java index 3bb6018d09..85cbc2f97f 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkMappedSuperclassImpl.java @@ -13,7 +13,7 @@ import java.util.List; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IType; import org.eclipse.jpt.core.context.orm.OrmPersistentType; -import org.eclipse.jpt.core.internal.context.PrimaryKeyValidator; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmMappedSuperclass; import org.eclipse.jpt.core.jpa2.context.Cacheable2_0; import org.eclipse.jpt.core.jpa2.context.CacheableHolder2_0; @@ -212,7 +212,7 @@ public class OrmEclipseLinkMappedSuperclassImpl } @Override - protected PrimaryKeyValidator buildPrimaryKeyValidator() { + protected JptValidator buildPrimaryKeyValidator() { return new EclipseLinkMappedSuperclassPrimaryKeyValidator(this, buildTextRangeResolver()); } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkPersistentAttribute.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkPersistentAttribute.java index bf776d3ed2..a055c157d0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkPersistentAttribute.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/context/orm/OrmEclipseLinkPersistentAttribute.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Oracle. All rights reserved. + * Copyright (c) 2009, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,8 +11,10 @@ package org.eclipse.jpt.eclipselink.core.internal.context.orm; import org.eclipse.jpt.core.context.AccessType; import org.eclipse.jpt.core.context.orm.OrmPersistentType; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmPersistentAttribute; import org.eclipse.jpt.core.resource.orm.XmlAttributeMapping; +import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkPersistentAttributeValidator; public class OrmEclipseLinkPersistentAttribute extends AbstractOrmPersistentAttribute @@ -35,4 +37,11 @@ public class OrmEclipseLinkPersistentAttribute extends AbstractOrmPersistentAttr throw new UnsupportedOperationException("specifiedAccess is not supported for OrmEclipseLinkPersistentAttribute"); //$NON-NLS-1$ } + + // ********** validation ********** + + @Override + protected JptValidator buildAttibuteValidator() { + return new EclipseLinkPersistentAttributeValidator(this, getJavaPersistentAttribute(), buildTextRangeResolver()); + } } diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/EclipseLinkEntityValidator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/EclipseLinkEntityValidator.java new file mode 100644 index 0000000000..61677584f1 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/EclipseLinkEntityValidator.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2010 Oracle. + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal.v1_1.context; + +import java.util.List; +import org.eclipse.jpt.core.context.Entity; +import org.eclipse.jpt.core.internal.context.EntityTextRangeResolver; +import org.eclipse.jpt.core.internal.jpa1.context.AbstractEntityValidator; +import org.eclipse.jpt.core.internal.validation.JpaValidationMessages; +import org.eclipse.jpt.core.resource.java.JavaResourcePersistentType; +import org.eclipse.jpt.eclipselink.core.internal.DefaultEclipseLinkJpaValidationMessages; +import org.eclipse.jpt.eclipselink.core.internal.EclipseLinkJpaValidationMessages; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; + +public class EclipseLinkEntityValidator + extends AbstractEntityValidator +{ + public EclipseLinkEntityValidator(Entity entity, JavaResourcePersistentType jrpt, EntityTextRangeResolver textRangeResolver) { + super(entity, jrpt, textRangeResolver); + } + + + @Override + protected void validateType(List<IMessage> messages) { + if (this.isMemberType() && !this.isStaticType()) { + messages.add(this.buildTypeMessage(EclipseLinkJpaValidationMessages.ENTITY_MEMBER_CLASS_NOT_STATIC)); + } + if (!this.hasNoArgConstructor()) { + messages.add(this.buildTypeMessage(JpaValidationMessages.ENTITY_CLASS_MISSING_NO_ARG_CONSTRUCTOR)); + } + } + + protected IMessage buildTypeMessage(String msgID) { + return DefaultEclipseLinkJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + msgID, + new String[] {this.entity.getName()}, + this.entity, + this.textRangeResolver.getTypeMappingTextRange() + ); + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/EclipseLinkPersistentAttributeValidator.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/EclipseLinkPersistentAttributeValidator.java new file mode 100644 index 0000000000..684941b5a4 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/EclipseLinkPersistentAttributeValidator.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2010 Oracle. + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Oracle - initial API and implementation + *******************************************************************************/ +package org.eclipse.jpt.eclipselink.core.internal.v1_1.context; + +import java.util.List; +import org.eclipse.jpt.core.context.PersistentAttribute; +import org.eclipse.jpt.core.context.java.JavaPersistentAttribute; +import org.eclipse.jpt.core.internal.context.PersistentAttributeTextRangeResolver; +import org.eclipse.jpt.core.internal.jpa1.context.AbstractPersistentAttributeValidator; +import org.eclipse.wst.validation.internal.provisional.core.IMessage; + +public class EclipseLinkPersistentAttributeValidator + extends AbstractPersistentAttributeValidator +{ + public EclipseLinkPersistentAttributeValidator( + PersistentAttribute persistentAttribute, JavaPersistentAttribute javaPersistentAttribute, PersistentAttributeTextRangeResolver textRangeResolver) + { + super(persistentAttribute, javaPersistentAttribute, textRangeResolver); + } + + @Override + protected void validateAttribute(List<IMessage> messages) { + return; + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/OrmEclipseLinkPersistentAttribute1_1.java b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/OrmEclipseLinkPersistentAttribute1_1.java index af446f8a42..00e06a19e0 100644 --- a/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/OrmEclipseLinkPersistentAttribute1_1.java +++ b/jpa/plugins/org.eclipse.jpt.eclipselink.core/src/org/eclipse/jpt/eclipselink/core/internal/v1_1/context/orm/OrmEclipseLinkPersistentAttribute1_1.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Oracle. All rights reserved. + * Copyright (c) 2008, 2010 Oracle. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0, which accompanies this distribution * and is available at http://www.eclipse.org/legal/epl-v10.html. @@ -11,7 +11,9 @@ package org.eclipse.jpt.eclipselink.core.internal.v1_1.context.orm; import org.eclipse.jpt.core.context.AccessType; import org.eclipse.jpt.core.context.orm.OrmPersistentType; +import org.eclipse.jpt.core.internal.context.JptValidator; import org.eclipse.jpt.core.internal.context.orm.AbstractOrmPersistentAttribute; +import org.eclipse.jpt.eclipselink.core.internal.v1_1.context.EclipseLinkPersistentAttributeValidator; import org.eclipse.jpt.eclipselink.core.resource.orm.XmlAttributeMapping; @@ -57,5 +59,12 @@ public class OrmEclipseLinkPersistentAttribute1_1 protected AccessType getResourceAccess() { return AccessType.fromOrmResourceModel(getResourceAttributeMapping().getAccess()); } - + + + // ********** validation ********** + + @Override + protected JptValidator buildAttibuteValidator() { + return new EclipseLinkPersistentAttributeValidator(this, getJavaPersistentAttribute(), buildTextRangeResolver()); + } } |