diff options
author | bvosburgh | 2011-07-08 15:54:45 +0000 |
---|---|---|
committer | bvosburgh | 2011-07-08 15:54:45 +0000 |
commit | d7d2fa5b09ada50b46b5fc8134251c445bfa923f (patch) | |
tree | 027aeb263e53f4bc8c461f7d87d3588edea8aaa5 | |
parent | 20f9938518a379f20beb9d4860d0222ae4d9d767 (diff) | |
download | webtools.dali-d7d2fa5b09ada50b46b5fc8134251c445bfa923f.tar.gz webtools.dali-d7d2fa5b09ada50b46b5fc8134251c445bfa923f.tar.xz webtools.dali-d7d2fa5b09ada50b46b5fc8134251c445bfa923f.zip |
minor tweaks
7 files changed, 71 insertions, 61 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/VersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/VersionMapping.java index 94c08af969..eb47be8fb8 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/VersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/context/VersionMapping.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. @@ -24,8 +24,13 @@ package org.eclipse.jpt.jpa.core.context; public interface VersionMapping extends ColumnMapping, ConvertibleMapping { - static final String[] VERSION_MAPPING_SUPPORTED_TYPES = - {"int", "java.lang.Integer", "short", "java.lang.Short", "long", "java.lang.Long", "java.sql.Timestamp"}; - - // combine various interfaces + String[] SUPPORTED_TYPE_NAMES = { + int.class.getName(), + java.lang.Integer.class.getName(), + short.class.getName(), + java.lang.Short.class.getName(), + long.class.getName(), + java.lang.Long.class.getName(), + java.sql.Timestamp.class.getName() + }; } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java index a7a7a73a20..ff1c226e10 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/AbstractJpaNode.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,8 +156,10 @@ public abstract class AbstractJpaNode } /** - * Pre-condition: specified catalog <em>identifier</em> is not null. - * NB: Do not use the catalog <em>name</em>. + * Pre-condition: specified catalog <em>identifier</em> is not + * <code>null</code>. + * <p> + * <strong>NB:</strong> Do not use the catalog <em>name</em>. */ protected Catalog resolveDbCatalog(String catalog) { Database database = this.getDatabase(); @@ -219,5 +221,5 @@ public abstract class AbstractJpaNode /** * Useful for building validation messages. */ - public static final String[] EMPTY_STRING_ARRAY = StringTools.EMPTY_STRING_ARRAY; + protected static final String[] EMPTY_STRING_ARRAY = StringTools.EMPTY_STRING_ARRAY; } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java index 0a74da1dde..062b3dc591 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/context/java/AbstractJavaVersionMapping.java @@ -19,9 +19,9 @@ import org.eclipse.jpt.common.utility.internal.SimpleAssociation; import org.eclipse.jpt.common.utility.internal.iterables.ArrayIterable; import org.eclipse.jpt.jpa.core.JpaFactory; import org.eclipse.jpt.jpa.core.MappingKeys; -import org.eclipse.jpt.jpa.core.context.BaseColumn; import org.eclipse.jpt.jpa.core.context.Converter; -import org.eclipse.jpt.jpa.core.context.NamedColumn; +import org.eclipse.jpt.jpa.core.context.ReadOnlyBaseColumn; +import org.eclipse.jpt.jpa.core.context.ReadOnlyNamedColumn; import org.eclipse.jpt.jpa.core.context.java.JavaColumn; import org.eclipse.jpt.jpa.core.context.java.JavaConverter; import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; @@ -244,8 +244,8 @@ public abstract class AbstractJavaVersionMapping return this.getTypeMapping().allAssociatedTableNames(); } - public JptValidator buildColumnValidator(NamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { - return new NamedColumnValidator(this.getPersistentAttribute(), (BaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider()); + public JptValidator buildColumnValidator(ReadOnlyNamedColumn col, NamedColumnTextRangeResolver textRangeResolver) { + return new NamedColumnValidator(this.getPersistentAttribute(), (ReadOnlyBaseColumn) col, (BaseColumnTextRangeResolver) textRangeResolver, new EntityTableDescriptionProvider()); } @@ -279,7 +279,7 @@ public abstract class AbstractJavaVersionMapping } protected void validateAttributeType(List<IMessage> messages, CompilationUnit astRoot) { - if (!ArrayTools.contains(VERSION_MAPPING_SUPPORTED_TYPES, this.getPersistentAttribute().getTypeName())) { + if (!ArrayTools.contains(SUPPORTED_TYPE_NAMES, this.getPersistentAttribute().getTypeName())) { messages.add( DefaultJpaValidationMessages.buildMessage( IMessage.NORMAL_SEVERITY, 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 4efe641d41..8b51ef7b49 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 @@ -2218,15 +2218,6 @@ public abstract class AbstractPersistenceUnit sb.append(this.name); } - public int getPersistenceUnitMetadataSize() { - int persistenceUnitMetadatSize= 0; - for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) { - if (mappingFileRef.persistenceUnitMetadataExists()) { - persistenceUnitMetadatSize++; - } - } - return persistenceUnitMetadatSize; - } // ********** validation ********** @@ -2250,21 +2241,31 @@ public abstract class AbstractPersistenceUnit } protected void checkForMultiplePersistenceUnitMetadata(List<IMessage> messages) { - for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) { - if (mappingFileRef.persistenceUnitMetadataExists() && (this.getPersistenceUnitMetadataSize() > 1)) { + Iterable<MappingFileRef> pumdMappingFileRefs = this.getPersistenceUnitMetadataMappingFileRefs(); + if (CollectionTools.size(pumdMappingFileRefs) > 1) { + for (MappingFileRef mappingFileRef : pumdMappingFileRefs) { messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.NORMAL_SEVERITY, - JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA, - new String[] {mappingFileRef.getFileName()}, - mappingFileRef.getMappingFile(), - mappingFileRef.getPersistenceUnitMetadata().getValidationTextRange() - ) - ); + DefaultJpaValidationMessages.buildMessage( + IMessage.NORMAL_SEVERITY, + JpaValidationMessages.MAPPING_FILE_EXTRANEOUS_PERSISTENCE_UNIT_METADATA, + new String[] {mappingFileRef.getFileName()}, + mappingFileRef.getMappingFile(), + mappingFileRef.getPersistenceUnitMetadata().getValidationTextRange() + ) + ); } } } + protected Iterable<MappingFileRef> getPersistenceUnitMetadataMappingFileRefs() { + return new FilteringIterable<MappingFileRef>(this.getMappingFileRefs()) { + @Override + protected boolean accept(MappingFileRef mappingFileRef) { + return mappingFileRef.persistenceUnitMetadataExists(); + } + }; + } + protected void checkForDuplicateMappingFiles(List<IMessage> messages) { HashBag<String> fileNames = CollectionTools.bag(this.mappingFileRefNames()); for (MappingFileRef mappingFileRef : this.getMappingFileRefs()) { @@ -2359,19 +2360,21 @@ public abstract class AbstractPersistenceUnit protected void checkForDuplicateGenerators(List<IMessage> messages) { HashMap<String, ArrayList<Generator>> generatorsByName = this.mapGeneratorsByName(this.getGenerators()); - for (ArrayList<Generator> dups : generatorsByName.values()) { - if (dups.size() > 1) { - for (Generator dup : dups) { - if (!StringTools.stringIsEmpty(dup.getName())) { + for (Map.Entry<String, ArrayList<Generator>> entry : generatorsByName.entrySet()) { + String generatorName = entry.getKey(); + if (StringTools.stringIsNotEmpty(generatorName)) { // ignore empty names + ArrayList<Generator> dups = entry.getValue(); + if (dups.size() > 1) { + for (Generator dup : dups) { messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.GENERATOR_DUPLICATE_NAME, - new String[] {dup.getName()}, - dup, - this.extractNameTextRange(dup) - ) - ); + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.GENERATOR_DUPLICATE_NAME, + new String[] {generatorName}, + dup, + this.extractNameTextRange(dup) + ) + ); } } } @@ -2407,19 +2410,21 @@ public abstract class AbstractPersistenceUnit protected void checkForDuplicateQueries(List<IMessage> messages) { HashMap<String, ArrayList<Query>> queriesByName = this.mapQueriesByName(this.getQueries()); - for (ArrayList<Query> dups : queriesByName.values()) { - if (dups.size() > 1) { - for (Query dup : dups) { - if (!StringTools.stringIsEmpty(dup.getName())) { + for (Map.Entry<String, ArrayList<Query>> entry : queriesByName.entrySet()) { + String queryName = entry.getKey(); + if (StringTools.stringIsNotEmpty(queryName)) { // ignore empty names + ArrayList<Query> dups = entry.getValue(); + if (dups.size() > 1) { + for (Query dup : dups) { messages.add( - DefaultJpaValidationMessages.buildMessage( - IMessage.HIGH_SEVERITY, - JpaValidationMessages.QUERY_DUPLICATE_NAME, - new String[] {dup.getName()}, - dup, - this.extractNameTextRange(dup) - ) - ); + DefaultJpaValidationMessages.buildMessage( + IMessage.HIGH_SEVERITY, + JpaValidationMessages.QUERY_DUPLICATE_NAME, + new String[] {queryName}, + dup, + this.extractNameTextRange(dup) + ) + ); } } } diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java index e8e2168fe6..b00190e46f 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/GenericJpaDataSource.java @@ -47,8 +47,6 @@ public class GenericJpaDataSource */ protected final ConnectionListener connectionListener; - private static final long serialVersionUID = 1L; - // ********** constructor/initialization ********** diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java index 99d795de4e..00f02445cc 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/java/JavaEclipseLinkVersionMapping.java @@ -79,7 +79,7 @@ public class JavaEclipseLinkVersionMapping @Override protected void validateAttributeType(List<IMessage> messages, CompilationUnit astRoot) { - if (!ArrayTools.contains(VERSION_MAPPING_SUPPORTED_TYPES, this.getPersistentAttribute().getTypeName())) { + if (!ArrayTools.contains(SUPPORTED_TYPE_NAMES, this.getPersistentAttribute().getTypeName())) { messages.add( DefaultEclipseLinkJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, diff --git a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkVersionMapping.java b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkVersionMapping.java index 8afc39b0a2..77a0ec3dd6 100644 --- a/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkVersionMapping.java +++ b/jpa/plugins/org.eclipse.jpt.jpa.eclipselink.core/src/org/eclipse/jpt/jpa/eclipselink/core/internal/context/orm/OrmEclipseLinkVersionMapping.java @@ -80,7 +80,7 @@ public class OrmEclipseLinkVersionMapping @Override protected void validateAttributeType(List<IMessage> messages) { - if (!ArrayTools.contains(VERSION_MAPPING_SUPPORTED_TYPES, this.getPersistentAttribute().getTypeName())) { + if (!ArrayTools.contains(SUPPORTED_TYPE_NAMES, this.getPersistentAttribute().getTypeName())) { messages.add( DefaultEclipseLinkJpaValidationMessages.buildMessage( IMessage.HIGH_SEVERITY, |