Skip to main content
summaryrefslogtreecommitdiffstats
path: root/jpa
diff options
context:
space:
mode:
authorpfullbright2008-09-02 18:11:45 +0000
committerpfullbright2008-09-02 18:11:45 +0000
commitbff9aff18439f620e701e714f8ff4bec56cceefa (patch)
tree66550ebf0a8f7715295b277603d86c6cb80aace7 /jpa
parent16880849ffe8982e8a5828c9679638654ede8a34 (diff)
downloadwebtools.dali-bff9aff18439f620e701e714f8ff4bec56cceefa.tar.gz
webtools.dali-bff9aff18439f620e701e714f8ff4bec56cceefa.tar.xz
webtools.dali-bff9aff18439f620e701e714f8ff4bec56cceefa.zip
[232225] - renaming DTP connection now renames JPT connection, invalid connection name shows up in properties and is (in)validated correctly
Diffstat (limited to 'jpa')
-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.java9
-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.java1
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java43
-rw-r--r--jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/validation/JpaValidationMessages.java1
7 files changed, 56 insertions, 20 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 3ba21f06c7..e5b1b722a6 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
@@ -20,6 +20,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 bf44bff3e9..3b379f91f3 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
@@ -8,7 +8,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 9b2d896545..648192ffee 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
@@ -10,9 +10,9 @@
package org.eclipse.jpt.core.internal;
import java.util.Iterator;
-
import org.eclipse.jpt.core.JpaDataSource;
import org.eclipse.jpt.core.JpaProject;
+import org.eclipse.jpt.core.JptCorePlugin;
import org.eclipse.jpt.db.Catalog;
import org.eclipse.jpt.db.ConnectionAdapter;
import org.eclipse.jpt.db.ConnectionListener;
@@ -211,15 +211,20 @@ public class GenericJpaDataSource
public void connectionProfileRenamed(String oldName, String newName) {
if (GenericJpaDataSource.this.connectionProfile == null) {
+ if (newName.equals(connectionProfileName)) {
+ GenericJpaDataSource.this.setConnectionProfileName(newName);
+ }
return;
}
// the connection profile will already have the new name,
// we just need to synch the name held by the data source
if (newName.equals(GenericJpaDataSource.this.connectionProfile.getName())) {
GenericJpaDataSource.this.setConnectionProfileName(newName);
+ // bug 232225 - also update project setting when connection profile
+ // name has changed
+ JptCorePlugin.setConnectionProfileName(getJpaProject().getProject(), newName);
}
}
-
}
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 6f6727de0a..560b4d85cb 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;
@@ -481,13 +481,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.getConnectionProfile() == null) {
+ if (StringTools.stringIsEmpty(this.getDataSource().getConnectionProfileName())) {
messages.add(
DefaultJpaValidationMessages.buildMessage(
IMessage.NORMAL_SEVERITY,
@@ -498,6 +499,19 @@ public class GenericJpaProject extends AbstractJpaNode implements JpaProject {
}
}
+ protected void addInvalidConnectionMessage(List<IMessage> messages) {
+ if (okToProceedForConnectionValidation && this.getDataSource().getConnectionProfile() == null) {
+ 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 ecab723abe..210c2bfd34 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
@@ -28,6 +28,7 @@ public class JptCoreMessages {
public static String VALIDATE_PERSISTENCE_UNIT_NOT_IN_PROJECT;
public static String VALIDATE_PLATFORM_NOT_SPECIFIED;
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;
public static String VALIDATE_RUNTIME_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 45865c6846..05dcca8767 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
@@ -30,6 +30,7 @@ import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.iterators.CompositeIterator;
import org.eclipse.jpt.utility.internal.iterators.EmptyIterator;
import org.eclipse.jpt.utility.internal.iterators.TransformationIterator;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider;
import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
import org.eclipse.wst.common.frameworks.datamodel.DataModelPropertyDescriptor;
@@ -76,7 +77,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);
@@ -242,9 +242,7 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
if (propertyName.equals(CONNECTION)) {
return CollectionTools.array(
new TransformationIterator<String, DataModelPropertyDescriptor>(
- new CompositeIterator<String>(
- null,
- this.getConnectionProfileFactory().connectionProfileNames())) {
+ new CompositeIterator<String>(null, connectionNames())) {
@Override
protected DataModelPropertyDescriptor transform(String next) {
return connectionPropertyDescriptor(next);
@@ -386,6 +384,20 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
return cp.getDriverJarList();
}
+ private Iterator<String> connectionNames() {
+ String setValue = getStringProperty(CONNECTION);
+
+ List<String> connectionNames = CollectionTools.sort(CollectionTools.list(
+ this.getConnectionProfileFactory().connectionProfileNames()));
+
+ if (! StringTools.stringIsEmpty(setValue) && ! connectionNames.contains(setValue)) {
+ return new CompositeIterator<String>(setValue, connectionNames.iterator());
+ }
+ else {
+ return connectionNames.iterator();
+ }
+ }
+
private String getDefaultSchemaName() {
ConnectionProfile cp = this.getConnectionProfile();
if (cp == null) {
@@ -438,17 +450,18 @@ public class JpaFacetDataModelProvider extends FacetInstallDataModelProvider
}
private IStatus validateConnectionName(String connectionName) {
- return StringTools.stringIsEmpty(connectionName) ?
- OK_STATUS
- :
- this.getConnectionStatus(connectionName);
- }
-
- private IStatus getConnectionStatus(String connectionName) {
- return this.connectionIsActive(connectionName) ?
- OK_STATUS
- :
- CONNECTION_NOT_CONNECTED_STATUS;
+ if (StringTools.stringIsEmpty(connectionName)) {
+ return OK_STATUS;
+ }
+ ConnectionProfile connectionProfile = getConnectionProfile();
+ if (connectionProfile == null) {
+ return buildErrorStatus(NLS.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 b944542c64..41c46253c0 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
@@ -15,6 +15,7 @@ public interface JpaValidationMessages {
public static final String BUNDLE_NAME = "jpa_validation";
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";
public static final String PROJECT_MULTIPLE_PERSISTENCE_XML = "PROJECT_MULTIPLE_PERSISTENCE_XML";

Back to the top