Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfullbright2008-09-02 09:27:36 -0400
committerpfullbright2008-09-02 09:27:36 -0400
commit3dd4686499f349c36ab3057a68740a1b763053c3 (patch)
treef3947b8c6630b84197d82271583748eb7e1e5865
parentaeaec4811ce3f1671426727f93157ac59f50ba05 (diff)
downloadwebtools.dali-3dd4686499f349c36ab3057a68740a1b763053c3.tar.gz
webtools.dali-3dd4686499f349c36ab3057a68740a1b763053c3.tar.xz
webtools.dali-3dd4686499f349c36ab3057a68740a1b763053c3.zip
[232225] - renaming DTP connection now renames JPT connection, invalid connection name shows up in properties and is (in)validated correctly
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties3
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaDataSource.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaProject.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java32
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java2
7 files changed, 51 insertions, 11 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
index 45e706a3fc..0d1c4d9a64 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_core.properties
@@ -21,6 +21,7 @@ VALIDATE_PERSISTENCE_UNIT_DOES_NOT_SPECIFIED=Persistence unit not specified
VALIDATE_PERSISTENCE_UNIT_NOT_IN_PROJECT=Persistence unit ''{0}'' not defined in project ''{1}''
VALIDATE_PLATFORM_NOT_SPECIFIED=Platform must be specified
VALIDATE_CONNECTION_NOT_SPECIFIED=Connection must be specified
+VALIDATE_CONNECTION_INVALID=Connection profile ''{0}'' does not exist
VALIDATE_CONNECTION_NOT_CONNECTED=Connection must be active to get data source specific help and validation.
VALIDATE_DEFAULT_SCHEMA_NOT_SPECIFIED=Default schema is not specified
VALIDATE_RUNTIME_NOT_SPECIFIED=There is no server runtime associated with this project to provide a JPA implementation
diff --git a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
index 96b6ab8345..a4dc14e3fe 100644
--- a/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
+++ b/jpa/plugins/org.eclipse.jpt.core/property_files/jpa_validation.properties
@@ -9,7 +9,8 @@
# Oracle. - initial API and implementation
###############################################################################
-PROJECT_NO_CONNECTION=No connection specified for project. No database-specific validation will be performed.
+PROJECT_NO_CONNECTION=No connection specified for project. No database-specific validation will be performed.
+PROJECT_INVALID_CONNECTION=Connection \"{0}\" does not exist. No database-specific validation will be performed.
PROJECT_INACTIVE_CONNECTION=Connection \"{0}\" is not active. No validation will be done against the data source.
PROJECT_NO_PERSISTENCE_XML=No persistence.xml file found in project
PROJECT_MULTIPLE_PERSISTENCE_XML=Multiple persistence.xml files in project
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaDataSource.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaDataSource.java
index 75295a050d..37aa54691f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaDataSource.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaDataSource.java
@@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal;
import org.eclipse.jpt.core.JpaDataSource;
import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.db.ConnectionAdapter;
import org.eclipse.jpt.db.ConnectionListener;
import org.eclipse.jpt.db.ConnectionProfile;
@@ -148,6 +149,9 @@ public class GenericJpaDataSource
public void connectionProfileChanged(ConnectionProfile profile) {
if (profile == GenericJpaDataSource.this.connectionProfile) {
GenericJpaDataSource.this.setConnectionProfileName(profile.getName());
+ // bug 232225 - also update project setting when connection profile
+ // name has changed
+ JptCorePlugin.setConnectionProfileName(getJpaProject().getProject(), profile.getName());
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaProject.java
index da6eb5bc3e..5add930069 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaProject.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/GenericJpaProject.java
@@ -13,7 +13,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -47,6 +46,7 @@ import org.eclipse.jpt.db.Schema;
import org.eclipse.jpt.utility.CommandExecutor;
import org.eclipse.jpt.utility.CommandExecutorProvider;
import org.eclipse.jpt.utility.internal.CollectionTools;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.CloneIterator;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
@@ -487,13 +487,14 @@ public class GenericJpaProject extends AbstractJpaNode implements JpaProject {
protected void addConnectionMessages(List<IMessage> messages) {
addNoConnectionMessage(messages);
+ addInvalidConnectionMessage(messages);
addInactiveConnectionMessage(messages);
}
protected boolean okToProceedForConnectionValidation = true;
protected void addNoConnectionMessage(List<IMessage> messages) {
- if (! this.getDataSource().hasAConnection()) {
+ if (StringTools.stringIsEmpty(this.getDataSource().getConnectionProfileName())) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.NORMAL_SEVERITY,
@@ -504,6 +505,19 @@ public class GenericJpaProject extends AbstractJpaNode implements JpaProject {
}
}
+ protected void addInvalidConnectionMessage(List<IMessage> messages) {
+ if (okToProceedForConnectionValidation && ! this.getDataSource().hasAConnection()) {
+ messages.add(
+ DefaultJpaValidationMessages.buildMessage(
+ IMessage.NORMAL_SEVERITY,
+ JpaValidationMessages.PROJECT_INVALID_CONNECTION,
+ new String[] {this.getDataSource().getConnectionProfileName()},
+ this)
+ );
+ okToProceedForConnectionValidation = false;
+ }
+ }
+
protected void addInactiveConnectionMessage(List<IMessage> messages) {
if (okToProceedForConnectionValidation && ! this.getDataSource().connectionProfileIsActive()) {
messages.add(
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
index 9a00d71134..39c2171588 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JptCoreMessages.java
@@ -44,6 +44,8 @@ public class JptCoreMessages extends NLS
public static String VALIDATE_CONNECTION_NOT_SPECIFIED;
+ public static String VALIDATE_CONNECTION_INVALID;
+
public static String VALIDATE_CONNECTION_NOT_CONNECTED;
public static String VALIDATE_DEFAULT_SCHEMA_NOT_SPECIFIED;
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java
index 1861925bf2..579e40ba9f 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java
@@ -71,7 +71,6 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
@Override
public Set<String> getPropertyNames() {
- @SuppressWarnings("unchecked")
Set<String> propertyNames = super.getPropertyNames();
propertyNames.add(PLATFORM_ID);
propertyNames.add(CONNECTION);
@@ -205,9 +204,7 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
if (propertyName.equals(CONNECTION)) {
return CollectionTools.array(
new TransformationIterator<String, DataModelPropertyDescriptor>(
- new CompositeIterator<String>(
- null,
- JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNames())) {
+ new CompositeIterator<String>(null, connectionNames())) {
@Override
protected DataModelPropertyDescriptor transform(String next) {
return connectionPropertyDescriptor(next);
@@ -304,6 +301,20 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
return getConnection().isActive();
}
+ private Iterator<String> connectionNames() {
+ String setValue = getStringProperty(CONNECTION);
+
+ List<String> connectionNames = CollectionTools.sort(CollectionTools.list(
+ JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNames()));
+
+ if (! StringTools.stringIsEmpty(setValue) && ! connectionNames.contains(setValue)) {
+ return new CompositeIterator<String>(setValue, connectionNames.iterator());
+ }
+ else {
+ return connectionNames.iterator();
+ }
+ }
+
private String getDefaultSchemaName() {
Schema defaultSchema = getConnection().getDefaultSchema();
return (defaultSchema == null) ? null : defaultSchema.getName();
@@ -342,10 +353,15 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
if (StringTools.stringIsEmpty(connectionName)) {
return OK_STATUS;
}
- return JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNamed(connectionName).isActive() ?
- OK_STATUS
- :
- CONNECTION_NOT_CONNECTED_STATUS;
+ ConnectionProfile connectionProfile = JptDbPlugin.instance().getConnectionProfileRepository().connectionProfileNamed(connectionName);
+ if (connectionProfile.isNull()) {
+ return buildErrorStatus(JptCoreMessages.bind(JptCoreMessages.VALIDATE_CONNECTION_INVALID, connectionName));
+
+ }
+ if (! connectionProfile.isActive()) {
+ return CONNECTION_NOT_CONNECTED_STATUS;
+ }
+ return OK_STATUS;
}
private IStatus validateUserOverrideDefaultSchema() {
diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
index ebc641afc7..baf203b64d 100644
--- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
+++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java
@@ -16,6 +16,8 @@ public interface JpaValidationMessages
public static final String PROJECT_NO_CONNECTION = "PROJECT_NO_CONNECTION";
+ public static final String PROJECT_INVALID_CONNECTION = "PROJECT_INVALID_CONNECTION";
+
public static final String PROJECT_INACTIVE_CONNECTION = "PROJECT_INACTIVE_CONNECTION";
public static final String PROJECT_NO_PERSISTENCE_XML = "PROJECT_NO_PERSISTENCE_XML";

Back to the top