Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-12-16 05:13:31 +0000
committerEike Stepper2016-12-16 05:13:31 +0000
commit6f3cfd8668e5ba4c346e4ba26230c37b7215c410 (patch)
treee50fa9150bb4e7aaba9d8a779e809e547eded245 /plugins
parent63e67c268c855f6ef13fc3eea0d8e7757a26229a (diff)
downloadcdo-6f3cfd8668e5ba4c346e4ba26230c37b7215c410.tar.gz
cdo-6f3cfd8668e5ba4c346e4ba26230c37b7215c410.tar.xz
cdo-6f3cfd8668e5ba4c346e4ba26230c37b7215c410.zip
[417741] [DB] Add support for database index creation with DBAnnotation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=417741
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBIndexAnnotation.java31
2 files changed, 33 insertions, 29 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
index 6d85854c6e..34aed6ef24 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
@@ -21,6 +21,7 @@ import org.eclipse.net4j.util.WrappedException;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.common.util.URI;
@@ -50,6 +51,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -285,6 +287,35 @@ public final class EMFUtil
return array;
}
+ /**
+ * @since 4.6
+ */
+ public static EList<EAnnotation> getAnnotations(EClass eClass, String sourceURI)
+ {
+ EList<EAnnotation> annotations = new BasicEList<EAnnotation>();
+ getAnnotations(eClass, sourceURI, annotations, new HashSet<EClass>());
+ return annotations;
+ }
+
+ private static void getAnnotations(EClass eClass, String sourceURI, EList<EAnnotation> annotations, Set<EClass> visited)
+ {
+ if (visited.add(eClass))
+ {
+ for (EAnnotation annotation : eClass.getEAnnotations())
+ {
+ if (sourceURI == null || sourceURI.equals(annotation.getSource()))
+ {
+ annotations.add(annotation);
+ }
+ }
+
+ for (EClass superType : eClass.getESuperTypes())
+ {
+ getAnnotations(superType, sourceURI, annotations, visited);
+ }
+ }
+ }
+
public static EPackage getTopLevelPackage(EPackage ePackage)
{
EPackage superPackage = ePackage.getESuperPackage();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBIndexAnnotation.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBIndexAnnotation.java
index 41ec7d24b4..71e7176a5b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBIndexAnnotation.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBIndexAnnotation.java
@@ -10,10 +10,9 @@
*/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
@@ -43,7 +42,7 @@ public final class DBIndexAnnotation
{
Set<List<EStructuralFeature>> indices = new HashSet<List<EStructuralFeature>>();
- for (EAnnotation annotation : getAnnotations(eClass))
+ for (EAnnotation annotation : EMFUtil.getAnnotations(eClass, SOURCE_URI))
{
List<EStructuralFeature> features = new ArrayList<EStructuralFeature>();
@@ -121,32 +120,6 @@ public final class DBIndexAnnotation
return indices;
}
- private static EList<EAnnotation> getAnnotations(EClass eClass)
- {
- EList<EAnnotation> annotations = new BasicEList<EAnnotation>();
- getAnnotations(eClass, annotations, new HashSet<EClass>());
- return annotations;
- }
-
- private static void getAnnotations(EClass eClass, EList<EAnnotation> annotations, Set<EClass> visited)
- {
- if (visited.add(eClass))
- {
- for (EAnnotation annotation : eClass.getEAnnotations())
- {
- if (SOURCE_URI.equals(annotation.getSource()))
- {
- annotations.add(annotation);
- }
- }
-
- for (EClass superType : eClass.getESuperTypes())
- {
- getAnnotations(superType, annotations, visited);
- }
- }
- }
-
private static EStructuralFeature getPersistentFeature(String featureName, EStructuralFeature[] allPersistentFeatures)
{
for (int i = 0; i < allPersistentFeatures.length; i++)

Back to the top