From 1e272a47e8da690ce4f56ce2126c6f7f0f3fb9cc Mon Sep 17 00:00:00 2001 From: Eike Stepper Date: Thu, 18 Oct 2018 09:48:25 +0200 Subject: [256856] Support model evolution https://bugs.eclipse.org/bugs/show_bug.cgi?id=256856 --- .../META-INF/MANIFEST.MF | 7 +- .../common/model/CDOPackageRegistryImpl.java | 9 +- .../plugin.properties | 1 + .../evolution/provider/EvolutionItemProvider.java | 15 + .../DefaultDiagnosticResolutionGenerator.java | 45 +- .../model/evolution.ecore | 19 + .../model/evolution.genmodel | 22 +- .../org/eclipse/emf/cdo/evolution/ChangeKind.java | 13 + .../org/eclipse/emf/cdo/evolution/Evolution.java | 61 +- .../emf/cdo/evolution/EvolutionPackage.java | 315 ++++++++- .../src/org/eclipse/emf/cdo/evolution/Model.java | 24 + .../org/eclipse/emf/cdo/evolution/ModelSet.java | 19 +- .../src/org/eclipse/emf/cdo/evolution/Release.java | 2 +- .../emf/cdo/evolution/impl/EvolutionImpl.java | 169 +++++ .../cdo/evolution/impl/EvolutionPackageImpl.java | 169 ++++- .../emf/cdo/evolution/impl/MigrationImpl.java | 18 +- .../eclipse/emf/cdo/evolution/impl/ModelImpl.java | 106 ++- .../emf/cdo/evolution/impl/ModelSetImpl.java | 110 ++- .../emf/cdo/evolution/impl/ReleaseImpl.java | 18 +- .../META-INF/MANIFEST.MF | 24 +- plugins/org.eclipse.emf.cdo.explorer.ui/pom.xml | 2 +- .../ui/checkouts/actions/ShowInActionProvider.java | 4 +- .../META-INF/MANIFEST.MF | 18 +- plugins/org.eclipse.emf.cdo.server.db/plugin.xml | 19 +- plugins/org.eclipse.emf.cdo.server.db/pom.xml | 2 +- .../org/eclipse/emf/cdo/server/db/CDODBUtil.java | 8 +- .../emf/cdo/server/db/IDBStoreAccessor.java | 3 +- .../emf/cdo/server/db/IMetaDataManager.java | 13 + .../emf/cdo/server/db/mapping/IClassMapping2.java | 46 ++ .../emf/cdo/server/db/mapping/IFeatureMapping.java | 27 + .../emf/cdo/server/db/mapping/IListMapping.java | 11 +- .../emf/cdo/server/db/mapping/IListMapping4.java | 33 + .../cdo/server/db/mapping/IMappingStrategy.java | 4 +- .../cdo/server/db/mapping/IMappingStrategy3.java | 41 ++ .../emf/cdo/server/db/mapping/INamingStrategy.java | 77 +++ .../emf/cdo/server/db/mapping/ITypeMapping.java | 7 +- .../emf/cdo/server/internal/db/CDODBSchema.java | 2 +- .../emf/cdo/server/internal/db/DBBrowserPage.java | 255 ------- .../emf/cdo/server/internal/db/DBMappingsPage.java | 157 +++++ .../emf/cdo/server/internal/db/DBSchemaPage.java | 83 +++ .../cdo/server/internal/db/DBStoreAccessor.java | 12 +- .../cdo/server/internal/db/DBStoreMigrator.java | 738 +++++++++++++++++++++ .../emf/cdo/server/internal/db/DBTablesPage.java | 271 ++++++++ .../cdo/server/internal/db/IObjectTypeMapper.java | 2 + .../cdo/server/internal/db/MetaDataManager.java | 384 +++++++---- .../db/mapping/AbstractMappingStrategy.java | 363 +++------- .../internal/db/mapping/DefaultNamingStrategy.java | 293 ++++++++ .../horizontal/AbstractBasicListTableMapping.java | 65 +- .../horizontal/AbstractFeatureMapTableMapping.java | 76 ++- .../horizontal/AbstractHorizontalClassMapping.java | 440 +++++++----- .../AbstractHorizontalMappingStrategy.java | 4 +- .../horizontal/AbstractListTableMapping.java | 87 ++- .../AuditFeatureMapTableMappingWithRanges.java | 31 +- .../AuditListTableMappingWithRanges.java | 57 +- .../BranchingFeatureMapTableMappingWithRanges.java | 32 +- .../BranchingListTableMappingWithRanges.java | 53 +- .../horizontal/DelegatingObjectTypeMapper.java | 14 + .../horizontal/HorizontalAuditClassMapping.java | 5 +- .../horizontal/HorizontalAuditMappingStrategy.java | 3 +- .../HorizontalAuditMappingStrategyWithRanges.java | 2 +- .../HorizontalBranchingClassMapping.java | 5 +- .../HorizontalBranchingMappingStrategy.java | 3 +- ...rizontalBranchingMappingStrategyWithRanges.java | 2 +- .../horizontal/HorizontalMappingStrategy.java | 41 +- .../horizontal/HorizontalNonAuditClassMapping.java | 5 +- .../HorizontalNonAuditMappingStrategy.java | 3 +- .../db/mapping/horizontal/ObjectTypeCache.java | 6 + .../db/mapping/horizontal/ObjectTypeTable.java | 34 + .../.classpath | 7 + .../org.eclipse.emf.cdo.server.evolution/.options | 3 + .../org.eclipse.emf.cdo.server.evolution/.project | 58 ++ .../.settings/org.eclipse.core.resources.prefs | 3 + .../.settings/org.eclipse.jdt.core.prefs | 394 +++++++++++ .../.settings/org.eclipse.jdt.launching.prefs | 3 + .../.settings/org.eclipse.jdt.ui.prefs | 119 ++++ .../org.eclipse.ltk.core.refactoring.prefs | 3 + .../.settings/org.eclipse.mylyn.tasks.ui.prefs | 4 + .../.settings/org.eclipse.mylyn.team.ui.prefs | 3 + .../.settings/org.eclipse.pde.api.tools.prefs | 95 +++ .../.settings/org.eclipse.pde.prefs | 31 + .../META-INF/MANIFEST.MF | 18 + .../about.html | 28 + .../build.properties | 26 + .../plugin.properties | 11 + .../plugin.xml | 23 + .../org.eclipse.emf.cdo.server.evolution/pom.xml | 31 + .../eclipse/emf/cdo/server/evolution/Renamer.java | 145 ++++ .../emf/cdo/server/evolution/package-info.java | 11 + .../evolution/bundle/CDOMigrateCommand.java | 80 +++ .../cdo/server/internal/evolution/bundle/OM.java | 44 ++ .../spi/evolution/AbstractMigrationContext.java | 239 +++++++ .../cdo/server/spi/evolution/EvolutionSupport.java | 24 + .../cdo/server/spi/evolution/MigrationContext.java | 19 + .../CDOServer.launch | 4 +- .../emf/cdo/internal/server/Repository.java | 32 +- .../internal/server/bundle/CDOCommandProvider.java | 25 +- ...CDO AllTests (H2 ALL) with ServerBrowser.launch | 2 +- .../META-INF/MANIFEST.MF | 18 +- .../evolution/company1.evolution | 553 +++++++++++++++ .../evolution/model1.ecore | 92 +++ plugins/org.eclipse.emf.cdo.tests.db/pom.xml | 2 +- .../org/eclipse/emf/cdo/tests/db/DBConfigs.java | 1 + .../eclipse/emf/cdo/tests/db/EvolutionTest.java | 618 +++++++++++++++++ .../org/eclipse/emf/cdo/tests/AbstractCDOTest.java | 84 +++ .../emf/cdo/tests/config/ISessionConfig.java | 2 + .../emf/cdo/tests/config/impl/ConfigTest.java | 10 + .../emf/cdo/tests/config/impl/SessionConfig.java | 15 +- plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF | 24 +- plugins/org.eclipse.net4j.db/pom.xml | 2 +- .../src/org/eclipse/net4j/db/IDBAdapter.java | 5 + .../src/org/eclipse/net4j/db/ddl/IDBField.java | 5 + .../org/eclipse/net4j/db/ddl/IDBSchemaElement.java | 2 +- .../src/org/eclipse/net4j/db/ddl/IDBTable.java | 5 + .../org/eclipse/net4j/internal/db/ddl/DBField.java | 16 + .../eclipse/net4j/internal/db/ddl/DBSchema.java | 15 + .../net4j/internal/db/ddl/DBSchemaElement.java | 19 +- .../org/eclipse/net4j/internal/db/ddl/DBTable.java | 29 + .../net4j/internal/db/ddl/DelegatingDBField.java | 5 + .../net4j/internal/db/ddl/DelegatingDBSchema.java | 5 + .../net4j/internal/db/ddl/DelegatingDBTable.java | 30 +- .../net4j/internal/db/ddl/delta/DBSchemaDelta.java | 15 +- .../src/org/eclipse/net4j/spi/db/DBAdapter.java | 5 + .../net4j/spi/db/ddl/InternalDBNamedElement.java | 52 ++ .../eclipse/net4j/spi/db/ddl/InternalDBSchema.java | 5 + .../eclipse/net4j/spi/db/ddl/InternalDBTable.java | 5 + .../net4j/util/collection/CollectionUtil.java | 15 + 126 files changed, 6977 insertions(+), 1171 deletions(-) create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping2.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IFeatureMapping.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping4.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy3.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/INamingStrategy.java delete mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBMappingsPage.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBSchemaPage.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreMigrator.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBTablesPage.java create mode 100644 plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/DefaultNamingStrategy.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.classpath create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.options create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.project create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.core.resources.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.core.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.launching.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.ui.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.ltk.core.refactoring.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.tasks.ui.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.team.ui.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.api.tools.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.prefs create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/META-INF/MANIFEST.MF create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/about.html create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/build.properties create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/plugin.properties create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/plugin.xml create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/pom.xml create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/Renamer.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/package-info.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/CDOMigrateCommand.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/OM.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/AbstractMigrationContext.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/EvolutionSupport.java create mode 100644 plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/MigrationContext.java create mode 100644 plugins/org.eclipse.emf.cdo.tests.db/evolution/company1.evolution create mode 100644 plugins/org.eclipse.emf.cdo.tests.db/evolution/model1.ecore create mode 100644 plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/EvolutionTest.java (limited to 'plugins') diff --git a/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF index 5ea7b064df..ec1a8b6fac 100644 --- a/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.common/META-INF/MANIFEST.MF @@ -39,9 +39,7 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100", org.eclipse.emf.cdo.ui, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.server.hibernate", - org.eclipse.emf.cdo.internal.common.branch;version="4.7.100"; - x-friends:="org.eclipse.emf.cdo.tests, - org.eclipse.emf.cdo.server.hibernate", + org.eclipse.emf.cdo.internal.common.branch;version="4.7.100";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.server.hibernate", org.eclipse.emf.cdo.internal.common.bundle;version="4.7.100";x-internal:=true, org.eclipse.emf.cdo.internal.common.commit;version="4.7.100"; x-friends:="org.eclipse.emf.cdo.common, @@ -73,7 +71,8 @@ Export-Package: org.eclipse.emf.cdo.common;version="4.7.100", org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.server.net4j, org.eclipse.emf.cdo.ui, - org.eclipse.emf.cdo.tests", + org.eclipse.emf.cdo.tests, + org.eclipse.emf.cdo.evolution", org.eclipse.emf.cdo.internal.common.revision;version="4.7.100"; x-friends:="org.eclipse.emf.cdo.common, org.eclipse.emf.cdo.common.db, diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java index e59108fa5d..57ee5a1cec 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java @@ -55,14 +55,14 @@ import java.util.Set; */ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements InternalCDOPackageRegistry { + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageRegistryImpl.class); + public static final EModelElement[] SYSTEM_ELEMENTS = new EModelElement[10]; - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageRegistryImpl.class); + private static final boolean EAGER_INTERNAL_CACHES = false; private static final long serialVersionUID = 1L; - private static final boolean eagerInternalCaches = false; - private boolean replacingDescriptors; private PackageProcessor packageProcessor; @@ -637,7 +637,8 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements Inte packageInfos = null; packageUnits = null; subTypes = null; - if (eagerInternalCaches) + + if (EAGER_INTERNAL_CACHES) { getPackageInfos(); getPackageUnits(); diff --git a/plugins/org.eclipse.emf.cdo.evolution.edit/plugin.properties b/plugins/org.eclipse.emf.cdo.evolution.edit/plugin.properties index eb5cb8ea7b..c0f8fbaa12 100644 --- a/plugins/org.eclipse.emf.cdo.evolution.edit/plugin.properties +++ b/plugins/org.eclipse.emf.cdo.evolution.edit/plugin.properties @@ -83,3 +83,4 @@ _UI_Unknown_type = Object _UI_Evolution_uniqueNamespaceURIs_feature = Unique Namespace UR Is _UI_Evolution_uniqueNamespaces_feature = Unique Namespaces _UI_Evolution_nextReleaseVersion_feature = Next Release Version +_UI_Evolution_initialRelease_feature = Initial Release diff --git a/plugins/org.eclipse.emf.cdo.evolution.edit/src/org/eclipse/emf/cdo/evolution/provider/EvolutionItemProvider.java b/plugins/org.eclipse.emf.cdo.evolution.edit/src/org/eclipse/emf/cdo/evolution/provider/EvolutionItemProvider.java index ceac47f72e..7df3632039 100644 --- a/plugins/org.eclipse.emf.cdo.evolution.edit/src/org/eclipse/emf/cdo/evolution/provider/EvolutionItemProvider.java +++ b/plugins/org.eclipse.emf.cdo.evolution.edit/src/org/eclipse/emf/cdo/evolution/provider/EvolutionItemProvider.java @@ -58,6 +58,7 @@ public class EvolutionItemProvider extends ModelSetItemProvider addAllPackagesPropertyDescriptor(object); addMissingPackagesPropertyDescriptor(object); addOrderedReleasesPropertyDescriptor(object); + addInitialReleasePropertyDescriptor(object); addLatestReleasePropertyDescriptor(object); addNextReleaseVersionPropertyDescriptor(object); } @@ -162,6 +163,20 @@ public class EvolutionItemProvider extends ModelSetItemProvider EvolutionPackage.Literals.EVOLUTION__ORDERED_RELEASES, false, false, false, null, null, null)); } + /** + * This adds a property descriptor for the Initial Release feature. + * + * + * @generated + */ + protected void addInitialReleasePropertyDescriptor(Object object) + { + itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(), + getString("_UI_Evolution_initialRelease_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Evolution_initialRelease_feature", "_UI_Evolution_type"), + EvolutionPackage.Literals.EVOLUTION__INITIAL_RELEASE, false, false, false, null, null, null)); + } + /** * This adds a property descriptor for the Latest Release feature. * diff --git a/plugins/org.eclipse.emf.cdo.evolution.editor/src/org/eclipse/emf/cdo/evolution/presentation/quickfix/DefaultDiagnosticResolutionGenerator.java b/plugins/org.eclipse.emf.cdo.evolution.editor/src/org/eclipse/emf/cdo/evolution/presentation/quickfix/DefaultDiagnosticResolutionGenerator.java index 679d55aab3..daa8c35bde 100644 --- a/plugins/org.eclipse.emf.cdo.evolution.editor/src/org/eclipse/emf/cdo/evolution/presentation/quickfix/DefaultDiagnosticResolutionGenerator.java +++ b/plugins/org.eclipse.emf.cdo.evolution.editor/src/org/eclipse/emf/cdo/evolution/presentation/quickfix/DefaultDiagnosticResolutionGenerator.java @@ -16,14 +16,11 @@ import org.eclipse.emf.cdo.evolution.Evolution; import org.eclipse.emf.cdo.evolution.EvolutionFactory; import org.eclipse.emf.cdo.evolution.FeaturePathMigration; import org.eclipse.emf.cdo.evolution.Model; -import org.eclipse.emf.cdo.evolution.Release; import org.eclipse.emf.cdo.evolution.impl.EvolutionImpl; -import org.eclipse.emf.cdo.evolution.impl.ModelSetChangeImpl; import org.eclipse.emf.cdo.evolution.presentation.quickfix.DiagnosticResolution.Generator; import org.eclipse.emf.cdo.evolution.util.DiagnosticID; import org.eclipse.emf.cdo.evolution.util.DiagnosticType; import org.eclipse.emf.cdo.evolution.util.ElementHandler; -import org.eclipse.emf.cdo.evolution.util.ElementRunnable; import org.eclipse.emf.cdo.evolution.util.EvolutionValidator; import org.eclipse.emf.cdo.evolution.util.IDAnnotation; @@ -35,7 +32,6 @@ import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -44,8 +40,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.dialogs.FilteredResourcesSelectionDialog; -import java.util.Collection; -import java.util.Date; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -145,9 +139,7 @@ public class DefaultDiagnosticResolutionGenerator extends BasicDiagnosticResolut if (object instanceof IFile) { IFile file = (IFile)object; - - Model model = EvolutionFactory.eINSTANCE.createModel(URI.createPlatformResourceURI(file.getFullPath().toString(), true)); - evolution.getModels().add(model); + evolution.addModel(URI.createPlatformResourceURI(file.getFullPath().toString(), true)); } } } @@ -195,10 +187,8 @@ public class DefaultDiagnosticResolutionGenerator extends BasicDiagnosticResolut @Override public void run(Diagnostic diagnostic) { - Model model = EvolutionFactory.eINSTANCE.createModel(uri); - Evolution evolution = (Evolution)data.get(0); - evolution.getModels().add(model); + evolution.addModel(uri); } }); } @@ -344,36 +334,7 @@ public class DefaultDiagnosticResolutionGenerator extends BasicDiagnosticResolut @Override public void run(Diagnostic diagnostic) { - Release release = EvolutionFactory.eINSTANCE.createRelease(); - release.setDate(new Date()); - release.setVersion(nextVersion); - - evolution.getReleases().add(release); - - Collection rootPackages = EcoreUtil.copyAll(evolution.getRootPackages()); - release.getRootPackages().addAll(rootPackages); - - // Prepare for new development... - - for (EPackage rootPackage : evolution.getRootPackages()) - { - ElementHandler.execute(rootPackage, new ElementRunnable() - { - public void run(EModelElement modelElement) - { - IDAnnotation.setOldValue(modelElement, null); - } - }); - } - - evolution.getMigrations().clear(); - - ModelSetChangeImpl change = (ModelSetChangeImpl)evolution.getChange(); - if (change != null) - { - change.reset(); - evolution.setChange(null); - } + evolution.createRelease(); } }); } diff --git a/plugins/org.eclipse.emf.cdo.evolution/model/evolution.ecore b/plugins/org.eclipse.emf.cdo.evolution/model/evolution.ecore index b40781227a..27ffab9fbe 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/model/evolution.ecore +++ b/plugins/org.eclipse.emf.cdo.evolution/model/evolution.ecore @@ -8,6 +8,9 @@ + + + @@ -45,6 +48,11 @@
+ + + + + @@ -69,9 +77,18 @@
+ + + + + + + + + @@ -93,6 +110,8 @@ eType="#//Release" containment="true" eOpposite="#//Release/evolution"/> + evolution.ecore @@ -30,6 +30,9 @@ + + + @@ -58,6 +61,11 @@ + + + + + @@ -70,11 +78,21 @@ + + + + + + + + + + {@link org.eclipse.emf.cdo.evolution.Evolution#getMissingPackages Missing Packages} *
  • {@link org.eclipse.emf.cdo.evolution.Evolution#getReleases Releases}
  • *
  • {@link org.eclipse.emf.cdo.evolution.Evolution#getOrderedReleases Ordered Releases}
  • + *
  • {@link org.eclipse.emf.cdo.evolution.Evolution#getInitialRelease Initial Release}
  • *
  • {@link org.eclipse.emf.cdo.evolution.Evolution#getLatestRelease Latest Release}
  • *
  • {@link org.eclipse.emf.cdo.evolution.Evolution#getNextReleaseVersion Next Release Version}
  • * @@ -50,7 +52,7 @@ public interface Evolution extends ModelSet * @return the value of the 'Models' containment reference list. * @see org.eclipse.emf.cdo.evolution.EvolutionPackage#getEvolution_Models() * @see org.eclipse.emf.cdo.evolution.Model#getEvolution - * @model opposite="evolution" containment="true" + * @model opposite="evolution" containment="true" resolveProxies="true" * @generated */ EList getModels(); @@ -208,7 +210,7 @@ public interface Evolution extends ModelSet * @return the value of the 'Releases' containment reference list. * @see org.eclipse.emf.cdo.evolution.EvolutionPackage#getEvolution_Releases() * @see org.eclipse.emf.cdo.evolution.Release#getEvolution - * @model opposite="evolution" containment="true" + * @model opposite="evolution" containment="true" resolveProxies="true" * @generated */ EList getReleases(); @@ -229,6 +231,21 @@ public interface Evolution extends ModelSet */ EList getOrderedReleases(); + /** + * Returns the value of the 'Initial Release' reference. + * + *

    + * If the meaning of the 'Initial Release' reference isn't clear, + * there really should be more of a description here... + *

    + * + * @return the value of the 'Initial Release' reference. + * @see org.eclipse.emf.cdo.evolution.EvolutionPackage#getEvolution_InitialRelease() + * @model transient="true" changeable="false" volatile="true" derived="true" + * @generated + */ + Release getInitialRelease(); + /** * Returns the value of the 'Latest Release' reference. * @@ -259,6 +276,30 @@ public interface Evolution extends ModelSet */ int getNextReleaseVersion(); + /** + * + * + * @model + * @generated + */ + boolean ensureIDs(); + + /** + * + * + * @model + * @generated + */ + Model getModel(String nsURI); + + /** + * + * + * @model uriDataType="org.eclipse.emf.cdo.evolution.URI" + * @generated + */ + Model addModel(URI uri); + /** * Returns the value of the 'Missing Packages' reference list. * The list contents are of type {@link org.eclipse.emf.ecore.EPackage}. @@ -283,4 +324,20 @@ public interface Evolution extends ModelSet */ Release getRelease(int version); + /** + * + * + * @model + * @generated + */ + Release createRelease(); + + /** + * + * + * @model + * @generated + */ + void save(); + } // Evolution diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/EvolutionPackage.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/EvolutionPackage.java index 3be6a2ddf1..6409c8f3fc 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/EvolutionPackage.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/EvolutionPackage.java @@ -142,6 +142,15 @@ public interface EvolutionPackage extends EPackage */ int MODEL_SET___GET_ALL_PACKAGES = 4; + /** + * The operation id for the 'Get Package' operation. + * + * + * @generated + * @ordered + */ + int MODEL_SET___GET_PACKAGE__STRING = 5; + /** * The operation id for the 'Contains Element' operation. * @@ -149,7 +158,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET___CONTAINS_ELEMENT__EMODELELEMENT = 5; + int MODEL_SET___CONTAINS_ELEMENT__EMODELELEMENT = 6; /** * The operation id for the 'Get Element' operation. @@ -158,7 +167,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET___GET_ELEMENT__STRING = 6; + int MODEL_SET___GET_ELEMENT__STRING = 7; /** * The operation id for the 'Get Element ID' operation. @@ -167,7 +176,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET___GET_ELEMENT_ID__EMODELELEMENT = 7; + int MODEL_SET___GET_ELEMENT_ID__EMODELELEMENT = 8; /** * The operation id for the 'Get Element ID' operation. @@ -176,7 +185,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET___GET_ELEMENT_ID__EMODELELEMENT_BOOLEAN = 8; + int MODEL_SET___GET_ELEMENT_ID__EMODELELEMENT_BOOLEAN = 9; /** * The operation id for the 'Compare' operation. @@ -185,7 +194,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET___COMPARE__MODELSET = 9; + int MODEL_SET___COMPARE__MODELSET = 10; /** * The operation id for the 'Get Migration' operation. @@ -194,7 +203,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET___GET_MIGRATION__STRING = 10; + int MODEL_SET___GET_MIGRATION__STRING = 11; /** * The number of operations of the 'Model Set' class. @@ -203,7 +212,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_SET_OPERATION_COUNT = 11; + int MODEL_SET_OPERATION_COUNT = 12; /** * The meta object id for the '{@link org.eclipse.emf.cdo.evolution.impl.ModelImpl Model}' class. @@ -288,6 +297,33 @@ public interface EvolutionPackage extends EPackage */ int MODEL_FEATURE_COUNT = 6; + /** + * The operation id for the 'Ensure IDs' operation. + * + * + * @generated + * @ordered + */ + int MODEL___ENSURE_IDS = 0; + + /** + * The operation id for the 'Get Package' operation. + * + * + * @generated + * @ordered + */ + int MODEL___GET_PACKAGE__STRING = 1; + + /** + * The operation id for the 'Save' operation. + * + * + * @generated + * @ordered + */ + int MODEL___SAVE = 2; + /** * The number of operations of the 'Model' class. * @@ -295,7 +331,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int MODEL_OPERATION_COUNT = 0; + int MODEL_OPERATION_COUNT = 3; /** * The feature id for the 'Change' containment reference. @@ -405,6 +441,15 @@ public interface EvolutionPackage extends EPackage */ int EVOLUTION__ORDERED_RELEASES = MODEL_SET_FEATURE_COUNT + 9; + /** + * The feature id for the 'Initial Release' reference. + * + * + * @generated + * @ordered + */ + int EVOLUTION__INITIAL_RELEASE = MODEL_SET_FEATURE_COUNT + 10; + /** * The feature id for the 'Latest Release' reference. * @@ -412,7 +457,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int EVOLUTION__LATEST_RELEASE = MODEL_SET_FEATURE_COUNT + 10; + int EVOLUTION__LATEST_RELEASE = MODEL_SET_FEATURE_COUNT + 11; /** * The feature id for the 'Next Release Version' attribute. @@ -421,7 +466,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int EVOLUTION__NEXT_RELEASE_VERSION = MODEL_SET_FEATURE_COUNT + 11; + int EVOLUTION__NEXT_RELEASE_VERSION = MODEL_SET_FEATURE_COUNT + 12; /** * The number of structural features of the 'Evolution' class. @@ -430,7 +475,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int EVOLUTION_FEATURE_COUNT = MODEL_SET_FEATURE_COUNT + 12; + int EVOLUTION_FEATURE_COUNT = MODEL_SET_FEATURE_COUNT + 13; /** * The operation id for the 'Get Evolution' operation. @@ -477,6 +522,15 @@ public interface EvolutionPackage extends EPackage */ int EVOLUTION___GET_ALL_PACKAGES = MODEL_SET___GET_ALL_PACKAGES; + /** + * The operation id for the 'Get Package' operation. + * + * + * @generated + * @ordered + */ + int EVOLUTION___GET_PACKAGE__STRING = MODEL_SET___GET_PACKAGE__STRING; + /** * The operation id for the 'Contains Element' operation. * @@ -531,6 +585,33 @@ public interface EvolutionPackage extends EPackage */ int EVOLUTION___GET_MIGRATION__STRING = MODEL_SET___GET_MIGRATION__STRING; + /** + * The operation id for the 'Ensure IDs' operation. + * + * + * @generated + * @ordered + */ + int EVOLUTION___ENSURE_IDS = MODEL_SET_OPERATION_COUNT + 0; + + /** + * The operation id for the 'Get Model' operation. + * + * + * @generated + * @ordered + */ + int EVOLUTION___GET_MODEL__STRING = MODEL_SET_OPERATION_COUNT + 1; + + /** + * The operation id for the 'Add Model' operation. + * + * + * @generated + * @ordered + */ + int EVOLUTION___ADD_MODEL__URI = MODEL_SET_OPERATION_COUNT + 2; + /** * The operation id for the 'Get Release' operation. * @@ -538,7 +619,25 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int EVOLUTION___GET_RELEASE__INT = MODEL_SET_OPERATION_COUNT + 0; + int EVOLUTION___GET_RELEASE__INT = MODEL_SET_OPERATION_COUNT + 3; + + /** + * The operation id for the 'Create Release' operation. + * + * + * @generated + * @ordered + */ + int EVOLUTION___CREATE_RELEASE = MODEL_SET_OPERATION_COUNT + 4; + + /** + * The operation id for the 'Save' operation. + * + * + * @generated + * @ordered + */ + int EVOLUTION___SAVE = MODEL_SET_OPERATION_COUNT + 5; /** * The number of operations of the 'Evolution' class. @@ -547,7 +646,7 @@ public interface EvolutionPackage extends EPackage * @generated * @ordered */ - int EVOLUTION_OPERATION_COUNT = MODEL_SET_OPERATION_COUNT + 1; + int EVOLUTION_OPERATION_COUNT = MODEL_SET_OPERATION_COUNT + 6; /** * The meta object id for the '{@link org.eclipse.emf.cdo.evolution.impl.ReleaseImpl Release}' class. @@ -694,6 +793,15 @@ public interface EvolutionPackage extends EPackage */ int RELEASE___GET_ALL_PACKAGES = MODEL_SET___GET_ALL_PACKAGES; + /** + * The operation id for the 'Get Package' operation. + * + * + * @generated + * @ordered + */ + int RELEASE___GET_PACKAGE__STRING = MODEL_SET___GET_PACKAGE__STRING; + /** * The operation id for the 'Contains Element' operation. * @@ -1432,6 +1540,16 @@ public interface EvolutionPackage extends EPackage */ EOperation getModelSet__GetAllPackages(); + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.ModelSet#getPackage(java.lang.String) Get Package}' operation. + * + * + * @return the meta object for the 'Get Package' operation. + * @see org.eclipse.emf.cdo.evolution.ModelSet#getPackage(java.lang.String) + * @generated + */ + EOperation getModelSet__GetPackage__String(); + /** * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.ModelSet#containsElement(org.eclipse.emf.ecore.EModelElement) Contains Element}' operation. * @@ -1568,6 +1686,36 @@ public interface EvolutionPackage extends EPackage */ EReference getModel_MissingPackages(); + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Model#ensureIDs() Ensure IDs}' operation. + * + * + * @return the meta object for the 'Ensure IDs' operation. + * @see org.eclipse.emf.cdo.evolution.Model#ensureIDs() + * @generated + */ + EOperation getModel__EnsureIDs(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Model#getPackage(java.lang.String) Get Package}' operation. + * + * + * @return the meta object for the 'Get Package' operation. + * @see org.eclipse.emf.cdo.evolution.Model#getPackage(java.lang.String) + * @generated + */ + EOperation getModel__GetPackage__String(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Model#save() Save}' operation. + * + * + * @return the meta object for the 'Save' operation. + * @see org.eclipse.emf.cdo.evolution.Model#save() + * @generated + */ + EOperation getModel__Save(); + /** * Returns the meta object for class '{@link org.eclipse.emf.cdo.evolution.Evolution Evolution}'. * @@ -1677,6 +1825,17 @@ public interface EvolutionPackage extends EPackage */ EReference getEvolution_OrderedReleases(); + /** + * Returns the meta object for the reference '{@link org.eclipse.emf.cdo.evolution.Evolution#getInitialRelease Initial Release}'. + * + * + * @return the meta object for the reference 'Initial Release'. + * @see org.eclipse.emf.cdo.evolution.Evolution#getInitialRelease() + * @see #getEvolution() + * @generated + */ + EReference getEvolution_InitialRelease(); + /** * Returns the meta object for the reference '{@link org.eclipse.emf.cdo.evolution.Evolution#getLatestRelease Latest Release}'. * @@ -1699,6 +1858,36 @@ public interface EvolutionPackage extends EPackage */ EAttribute getEvolution_NextReleaseVersion(); + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#ensureIDs() Ensure IDs}' operation. + * + * + * @return the meta object for the 'Ensure IDs' operation. + * @see org.eclipse.emf.cdo.evolution.Evolution#ensureIDs() + * @generated + */ + EOperation getEvolution__EnsureIDs(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#getModel(java.lang.String) Get Model}' operation. + * + * + * @return the meta object for the 'Get Model' operation. + * @see org.eclipse.emf.cdo.evolution.Evolution#getModel(java.lang.String) + * @generated + */ + EOperation getEvolution__GetModel__String(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#addModel(org.eclipse.emf.common.util.URI) Add Model}' operation. + * + * + * @return the meta object for the 'Add Model' operation. + * @see org.eclipse.emf.cdo.evolution.Evolution#addModel(org.eclipse.emf.common.util.URI) + * @generated + */ + EOperation getEvolution__AddModel__URI(); + /** * Returns the meta object for the reference list '{@link org.eclipse.emf.cdo.evolution.Evolution#getMissingPackages Missing Packages}'. * @@ -1720,6 +1909,26 @@ public interface EvolutionPackage extends EPackage */ EOperation getEvolution__GetRelease__int(); + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#createRelease() Create Release}' operation. + * + * + * @return the meta object for the 'Create Release' operation. + * @see org.eclipse.emf.cdo.evolution.Evolution#createRelease() + * @generated + */ + EOperation getEvolution__CreateRelease(); + + /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#save() Save}' operation. + * + * + * @return the meta object for the 'Save' operation. + * @see org.eclipse.emf.cdo.evolution.Evolution#save() + * @generated + */ + EOperation getEvolution__Save(); + /** * Returns the meta object for class '{@link org.eclipse.emf.cdo.evolution.Release Release}'. * @@ -2214,6 +2423,14 @@ public interface EvolutionPackage extends EPackage */ EOperation MODEL_SET___GET_ALL_PACKAGES = eINSTANCE.getModelSet__GetAllPackages(); + /** + * The meta object literal for the 'Get Package' operation. + * + * + * @generated + */ + EOperation MODEL_SET___GET_PACKAGE__STRING = eINSTANCE.getModelSet__GetPackage__String(); + /** * The meta object literal for the 'Contains Element' operation. * @@ -2320,6 +2537,30 @@ public interface EvolutionPackage extends EPackage */ EReference MODEL__MISSING_PACKAGES = eINSTANCE.getModel_MissingPackages(); + /** + * The meta object literal for the 'Ensure IDs' operation. + * + * + * @generated + */ + EOperation MODEL___ENSURE_IDS = eINSTANCE.getModel__EnsureIDs(); + + /** + * The meta object literal for the 'Get Package' operation. + * + * + * @generated + */ + EOperation MODEL___GET_PACKAGE__STRING = eINSTANCE.getModel__GetPackage__String(); + + /** + * The meta object literal for the 'Save' operation. + * + * + * @generated + */ + EOperation MODEL___SAVE = eINSTANCE.getModel__Save(); + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl Evolution}' class. * @@ -2402,6 +2643,14 @@ public interface EvolutionPackage extends EPackage */ EReference EVOLUTION__ORDERED_RELEASES = eINSTANCE.getEvolution_OrderedReleases(); + /** + * The meta object literal for the 'Initial Release' reference feature. + * + * + * @generated + */ + EReference EVOLUTION__INITIAL_RELEASE = eINSTANCE.getEvolution_InitialRelease(); + /** * The meta object literal for the 'Latest Release' reference feature. * @@ -2418,6 +2667,30 @@ public interface EvolutionPackage extends EPackage */ EAttribute EVOLUTION__NEXT_RELEASE_VERSION = eINSTANCE.getEvolution_NextReleaseVersion(); + /** + * The meta object literal for the 'Ensure IDs' operation. + * + * + * @generated + */ + EOperation EVOLUTION___ENSURE_IDS = eINSTANCE.getEvolution__EnsureIDs(); + + /** + * The meta object literal for the 'Get Model' operation. + * + * + * @generated + */ + EOperation EVOLUTION___GET_MODEL__STRING = eINSTANCE.getEvolution__GetModel__String(); + + /** + * The meta object literal for the 'Add Model' operation. + * + * + * @generated + */ + EOperation EVOLUTION___ADD_MODEL__URI = eINSTANCE.getEvolution__AddModel__URI(); + /** * The meta object literal for the 'Missing Packages' reference list feature. * @@ -2434,6 +2707,22 @@ public interface EvolutionPackage extends EPackage */ EOperation EVOLUTION___GET_RELEASE__INT = eINSTANCE.getEvolution__GetRelease__int(); + /** + * The meta object literal for the 'Create Release' operation. + * + * + * @generated + */ + EOperation EVOLUTION___CREATE_RELEASE = eINSTANCE.getEvolution__CreateRelease(); + + /** + * The meta object literal for the 'Save' operation. + * + * + * @generated + */ + EOperation EVOLUTION___SAVE = eINSTANCE.getEvolution__Save(); + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.evolution.impl.ReleaseImpl Release}' class. * diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Model.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Model.java index 77ad5c8e4e..a8cb53436c 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Model.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Model.java @@ -150,6 +150,30 @@ public interface Model extends CDOObject */ EList getMissingPackages(); + /** + * + * + * @model + * @generated + */ + boolean ensureIDs(); + + /** + * + * + * @model + * @generated + */ + EPackage getPackage(String nsURI); + + /** + * + * + * @model + * @generated + */ + void save(); + public ModelStatus getStatus(); /** diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ModelSet.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ModelSet.java index 9b4e61e5d5..2ef2cd0223 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ModelSet.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ModelSet.java @@ -3,10 +3,13 @@ package org.eclipse.emf.cdo.evolution; import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; /** * @@ -67,7 +70,7 @@ public interface ModelSet extends CDOObject * @return the value of the 'Migrations' containment reference list. * @see org.eclipse.emf.cdo.evolution.EvolutionPackage#getModelSet_Migrations() * @see org.eclipse.emf.cdo.evolution.Migration#getModelSet - * @model opposite="modelSet" containment="true" + * @model opposite="modelSet" containment="true" resolveProxies="true" * @generated */ EList getMigrations(); @@ -112,6 +115,14 @@ public interface ModelSet extends CDOObject */ EList getAllPackages(); + /** + * + * + * @model + * @generated + */ + EPackage getPackage(String nsURI); + /** * * @@ -160,4 +171,10 @@ public interface ModelSet extends CDOObject */ Migration getMigration(String diagnosticID); + EList getElementChanges(EClass elementType, ChangeKind... changeKinds); + + EList getPropertyChanges(EStructuralFeature feature, ChangeKind... changeKinds); + + CDOPackageRegistry createPackageRegistry(); + } // ModelSet diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Release.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Release.java index ef07d0dfbb..3a018c2384 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Release.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Release.java @@ -153,7 +153,7 @@ public interface Release extends ModelSet, Comparable * * @return the value of the 'Root Packages' containment reference list. * @see org.eclipse.emf.cdo.evolution.EvolutionPackage#getRelease_RootPackages() - * @model containment="true" + * @model containment="true" resolveProxies="true" * @generated */ EList getRootPackages(); diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionImpl.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionImpl.java index a4af9491d0..e33de61206 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionImpl.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionImpl.java @@ -3,16 +3,22 @@ package org.eclipse.emf.cdo.evolution.impl; import org.eclipse.emf.cdo.evolution.Evolution; +import org.eclipse.emf.cdo.evolution.EvolutionFactory; import org.eclipse.emf.cdo.evolution.EvolutionPackage; import org.eclipse.emf.cdo.evolution.Model; import org.eclipse.emf.cdo.evolution.Release; +import org.eclipse.emf.cdo.evolution.util.ElementHandler; +import org.eclipse.emf.cdo.evolution.util.ElementRunnable; +import org.eclipse.emf.cdo.evolution.util.IDAnnotation; import org.eclipse.net4j.util.collection.CollectionUtil; +import org.eclipse.net4j.util.io.IORuntimeException; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.util.ECollections; import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EObject; @@ -24,8 +30,10 @@ import org.eclipse.emf.ecore.util.EcoreEList; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.ecore.util.InternalEList; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Collection; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -49,6 +57,7 @@ import java.util.Set; *
  • {@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getMissingPackages Missing Packages}
  • *
  • {@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getReleases Releases}
  • *
  • {@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getOrderedReleases Ordered Releases}
  • + *
  • {@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getInitialRelease Initial Release}
  • *
  • {@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getLatestRelease Latest Release}
  • *
  • {@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getNextReleaseVersion Next Release Version}
  • * @@ -325,6 +334,72 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution return null; } + /** + * + * + * @generated NOT + */ + public Release createRelease() + { + final EvolutionImpl evolution = (EvolutionImpl)getEvolution(); + final int nextVersion = evolution.getNextReleaseVersion(); + + Release release = EvolutionFactory.eINSTANCE.createRelease(); + release.setDate(new Date()); + release.setVersion(nextVersion); + + evolution.getReleases().add(release); + + Collection rootPackages = EcoreUtil.copyAll(evolution.getRootPackages()); + release.getRootPackages().addAll(rootPackages); + + // Prepare for new development... + + for (EPackage rootPackage : evolution.getRootPackages()) + { + ElementHandler.execute(rootPackage, new ElementRunnable() + { + public void run(EModelElement modelElement) + { + IDAnnotation.setOldValue(modelElement, null); + } + }); + } + + evolution.getMigrations().clear(); + + ModelSetChangeImpl change = (ModelSetChangeImpl)evolution.getChange(); + if (change != null) + { + change.reset(); + evolution.setChange(null); + } + + return release; + } + + /** + * + * + * @generated NOT + */ + public void save() + { + try + { + eResource().save(null); + } + catch (IOException ex) + { + throw new IORuntimeException(ex); + } + + for (Model model : getModels()) + { + model.save(); + } + } + /** * * @@ -359,6 +434,33 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution return list; } + /** + * + * + * @generated + */ + public Release getInitialRelease() + { + Release initialRelease = basicGetInitialRelease(); + return initialRelease != null && ((EObject)initialRelease).eIsProxy() ? (Release)eResolveProxy((InternalEObject)initialRelease) : initialRelease; + } + + /** + * + * + * @generated NOT + */ + public Release basicGetInitialRelease() + { + EList orderedReleases = getOrderedReleases(); + if (orderedReleases.isEmpty()) + { + return null; + } + + return orderedReleases.get(orderedReleases.size() - 1); + } + /** * * @@ -397,6 +499,54 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution return latestRelease == null ? 1 : latestRelease.getVersion() + 1; } + /** + * + * + * @generated NOT + */ + public boolean ensureIDs() + { + boolean modified = false; + + for (Model model : getModels()) + { + modified |= model.ensureIDs(); + } + + return modified; + } + + /** + * + * + * @generated NOT + */ + public Model getModel(String nsURI) + { + for (Model model : getModels()) + { + EPackage ePackage = model.getPackage(nsURI); + if (ePackage != null) + { + return model; + } + } + + return null; + } + + /** + * + * + * @generated NOT + */ + public Model addModel(URI uri) + { + Model model = EvolutionFactory.eINSTANCE.createModel(uri); + getModels().add(model); + return model; + } + /** * * @@ -464,6 +614,12 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution return getReleases(); case EvolutionPackage.EVOLUTION__ORDERED_RELEASES: return getOrderedReleases(); + case EvolutionPackage.EVOLUTION__INITIAL_RELEASE: + if (resolve) + { + return getInitialRelease(); + } + return basicGetInitialRelease(); case EvolutionPackage.EVOLUTION__LATEST_RELEASE: if (resolve) { @@ -573,6 +729,8 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution return !getReleases().isEmpty(); case EvolutionPackage.EVOLUTION__ORDERED_RELEASES: return !getOrderedReleases().isEmpty(); + case EvolutionPackage.EVOLUTION__INITIAL_RELEASE: + return basicGetInitialRelease() != null; case EvolutionPackage.EVOLUTION__LATEST_RELEASE: return basicGetLatestRelease() != null; case EvolutionPackage.EVOLUTION__NEXT_RELEASE_VERSION: @@ -591,8 +749,19 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution { switch (operationID) { + case EvolutionPackage.EVOLUTION___ENSURE_IDS: + return ensureIDs(); + case EvolutionPackage.EVOLUTION___GET_MODEL__STRING: + return getModel((String)arguments.get(0)); + case EvolutionPackage.EVOLUTION___ADD_MODEL__URI: + return addModel((URI)arguments.get(0)); case EvolutionPackage.EVOLUTION___GET_RELEASE__INT: return getRelease((Integer)arguments.get(0)); + case EvolutionPackage.EVOLUTION___CREATE_RELEASE: + return createRelease(); + case EvolutionPackage.EVOLUTION___SAVE: + save(); + return null; } return super.eInvoke(operationID, arguments); } diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionPackageImpl.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionPackageImpl.java index 3f66950b8f..0c1247a11e 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionPackageImpl.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/EvolutionPackageImpl.java @@ -286,7 +286,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EOperation getModelSet__ContainsElement__EModelElement() + public EOperation getModelSet__GetPackage__String() { return modelSetEClass.getEOperations().get(5); } @@ -296,7 +296,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EOperation getModelSet__GetElement__String() + public EOperation getModelSet__ContainsElement__EModelElement() { return modelSetEClass.getEOperations().get(6); } @@ -306,7 +306,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EOperation getModelSet__GetElementID__EModelElement() + public EOperation getModelSet__GetElement__String() { return modelSetEClass.getEOperations().get(7); } @@ -316,7 +316,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EOperation getModelSet__GetElementID__EModelElement_boolean() + public EOperation getModelSet__GetElementID__EModelElement() { return modelSetEClass.getEOperations().get(8); } @@ -326,7 +326,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EOperation getModelSet__Compare__ModelSet() + public EOperation getModelSet__GetElementID__EModelElement_boolean() { return modelSetEClass.getEOperations().get(9); } @@ -336,11 +336,21 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EOperation getModelSet__GetMigration__String() + public EOperation getModelSet__Compare__ModelSet() { return modelSetEClass.getEOperations().get(10); } + /** + * + * + * @generated + */ + public EOperation getModelSet__GetMigration__String() + { + return modelSetEClass.getEOperations().get(11); + } + /** * * @@ -411,6 +421,36 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka return (EReference)modelEClass.getEStructuralFeatures().get(5); } + /** + * + * + * @generated + */ + public EOperation getModel__EnsureIDs() + { + return modelEClass.getEOperations().get(0); + } + + /** + * + * + * @generated + */ + public EOperation getModel__GetPackage__String() + { + return modelEClass.getEOperations().get(1); + } + + /** + * + * + * @generated + */ + public EOperation getModel__Save() + { + return modelEClass.getEOperations().get(2); + } + /** * * @@ -516,11 +556,21 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * * @generated */ - public EReference getEvolution_LatestRelease() + public EReference getEvolution_InitialRelease() { return (EReference)evolutionEClass.getEStructuralFeatures().get(10); } + /** + * + * + * @generated + */ + public EReference getEvolution_LatestRelease() + { + return (EReference)evolutionEClass.getEStructuralFeatures().get(11); + } + /** * * @@ -528,7 +578,37 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka */ public EAttribute getEvolution_NextReleaseVersion() { - return (EAttribute)evolutionEClass.getEStructuralFeatures().get(11); + return (EAttribute)evolutionEClass.getEStructuralFeatures().get(12); + } + + /** + * + * + * @generated + */ + public EOperation getEvolution__EnsureIDs() + { + return evolutionEClass.getEOperations().get(0); + } + + /** + * + * + * @generated + */ + public EOperation getEvolution__GetModel__String() + { + return evolutionEClass.getEOperations().get(1); + } + + /** + * + * + * @generated + */ + public EOperation getEvolution__AddModel__URI() + { + return evolutionEClass.getEOperations().get(2); } /** @@ -548,7 +628,27 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka */ public EOperation getEvolution__GetRelease__int() { - return evolutionEClass.getEOperations().get(0); + return evolutionEClass.getEOperations().get(3); + } + + /** + * + * + * @generated + */ + public EOperation getEvolution__CreateRelease() + { + return evolutionEClass.getEOperations().get(4); + } + + /** + * + * + * @generated + */ + public EOperation getEvolution__Save() + { + return evolutionEClass.getEOperations().get(5); } /** @@ -972,6 +1072,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka createEOperation(modelSetEClass, MODEL_SET___GET_PREVIOUS_RELEASE); createEOperation(modelSetEClass, MODEL_SET___GET_ROOT_PACKAGES); createEOperation(modelSetEClass, MODEL_SET___GET_ALL_PACKAGES); + createEOperation(modelSetEClass, MODEL_SET___GET_PACKAGE__STRING); createEOperation(modelSetEClass, MODEL_SET___CONTAINS_ELEMENT__EMODELELEMENT); createEOperation(modelSetEClass, MODEL_SET___GET_ELEMENT__STRING); createEOperation(modelSetEClass, MODEL_SET___GET_ELEMENT_ID__EMODELELEMENT); @@ -986,6 +1087,9 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka createEReference(modelEClass, MODEL__ALL_PACKAGES); createEReference(modelEClass, MODEL__REFERENCED_PACKAGES); createEReference(modelEClass, MODEL__MISSING_PACKAGES); + createEOperation(modelEClass, MODEL___ENSURE_IDS); + createEOperation(modelEClass, MODEL___GET_PACKAGE__STRING); + createEOperation(modelEClass, MODEL___SAVE); evolutionEClass = createEClass(EVOLUTION); createEAttribute(evolutionEClass, EVOLUTION__USE_ECORE_PACKAGE); @@ -998,9 +1102,15 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka createEReference(evolutionEClass, EVOLUTION__MISSING_PACKAGES); createEReference(evolutionEClass, EVOLUTION__RELEASES); createEReference(evolutionEClass, EVOLUTION__ORDERED_RELEASES); + createEReference(evolutionEClass, EVOLUTION__INITIAL_RELEASE); createEReference(evolutionEClass, EVOLUTION__LATEST_RELEASE); createEAttribute(evolutionEClass, EVOLUTION__NEXT_RELEASE_VERSION); + createEOperation(evolutionEClass, EVOLUTION___ENSURE_IDS); + createEOperation(evolutionEClass, EVOLUTION___GET_MODEL__STRING); + createEOperation(evolutionEClass, EVOLUTION___ADD_MODEL__URI); createEOperation(evolutionEClass, EVOLUTION___GET_RELEASE__INT); + createEOperation(evolutionEClass, EVOLUTION___CREATE_RELEASE); + createEOperation(evolutionEClass, EVOLUTION___SAVE); releaseEClass = createEClass(RELEASE); createEReference(releaseEClass, RELEASE__EVOLUTION); @@ -1099,7 +1209,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEReference(getModelSet_Change(), getModelSetChange(), null, "change", null, 0, 1, ModelSet.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEReference(getModelSet_Migrations(), getMigration(), getMigration_ModelSet(), "migrations", null, 0, -1, ModelSet.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEOperation(getModelSet__GetEvolution(), getEvolution(), "getEvolution", 0, 1, IS_UNIQUE, IS_ORDERED); @@ -1111,8 +1221,10 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEOperation(getModelSet__GetAllPackages(), ecorePackage.getEPackage(), "getAllPackages", 0, -1, IS_UNIQUE, IS_ORDERED); - EOperation op = initEOperation(getModelSet__ContainsElement__EModelElement(), theEcorePackage.getEBoolean(), "containsElement", 0, 1, IS_UNIQUE, - IS_ORDERED); + EOperation op = initEOperation(getModelSet__GetPackage__String(), theEcorePackage.getEPackage(), "getPackage", 0, 1, IS_UNIQUE, IS_ORDERED); + addEParameter(op, theEcorePackage.getEString(), "nsURI", 0, 1, IS_UNIQUE, IS_ORDERED); + + op = initEOperation(getModelSet__ContainsElement__EModelElement(), theEcorePackage.getEBoolean(), "containsElement", 0, 1, IS_UNIQUE, IS_ORDERED); addEParameter(op, theEcorePackage.getEModelElement(), "modelElement", 0, 1, IS_UNIQUE, IS_ORDERED); op = initEOperation(getModelSet__GetElement__String(), null, "getElement", 0, 1, IS_UNIQUE, IS_ORDERED); @@ -1138,7 +1250,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getModel_Evolution(), getEvolution(), getEvolution_Models(), "evolution", null, 1, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getModel_URI(), getURI(), "uRI", null, 0, 1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getModel_RootPackage(), theEcorePackage.getEPackage(), null, "rootPackage", null, 0, 1, Model.class, IS_TRANSIENT, IS_VOLATILE, @@ -1150,6 +1262,13 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEReference(getModel_MissingPackages(), theEcorePackage.getEPackage(), null, "missingPackages", null, 0, -1, Model.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEOperation(getModel__EnsureIDs(), ecorePackage.getEBoolean(), "ensureIDs", 0, 1, IS_UNIQUE, IS_ORDERED); + + op = initEOperation(getModel__GetPackage__String(), theEcorePackage.getEPackage(), "getPackage", 0, 1, IS_UNIQUE, IS_ORDERED); + addEParameter(op, theEcorePackage.getEString(), "nsURI", 0, 1, IS_UNIQUE, IS_ORDERED); + + initEOperation(getModel__Save(), null, "save", 0, 1, IS_UNIQUE, IS_ORDERED); + initEClass(evolutionEClass, Evolution.class, "Evolution", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getEvolution_UseEcorePackage(), ecorePackage.getEBoolean(), "useEcorePackage", "true", 0, 1, Evolution.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); @@ -1160,7 +1279,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEAttribute(getEvolution_UniqueNamespaces(), ecorePackage.getEBoolean(), "uniqueNamespaces", "true", 0, 1, Evolution.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getEvolution_Models(), getModel(), getModel_Evolution(), "models", null, 0, -1, Evolution.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, - IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getEvolution_RootPackages(), theEcorePackage.getEPackage(), null, "rootPackages", null, 0, -1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEReference(getEvolution_AllPackages(), theEcorePackage.getEPackage(), null, "allPackages", null, 0, -1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, @@ -1168,20 +1287,34 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEReference(getEvolution_MissingPackages(), theEcorePackage.getEPackage(), null, "missingPackages", null, 0, -1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEReference(getEvolution_Releases(), getRelease(), getRelease_Evolution(), "releases", null, 0, -1, Evolution.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getEvolution_OrderedReleases(), getRelease(), null, "orderedReleases", null, 0, -1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getEvolution_InitialRelease(), getRelease(), null, "initialRelease", null, 0, 1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, + !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEReference(getEvolution_LatestRelease(), getRelease(), null, "latestRelease", null, 0, 1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEAttribute(getEvolution_NextReleaseVersion(), theEcorePackage.getEInt(), "nextReleaseVersion", null, 0, 1, Evolution.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEOperation(getEvolution__EnsureIDs(), ecorePackage.getEBoolean(), "ensureIDs", 0, 1, IS_UNIQUE, IS_ORDERED); + + op = initEOperation(getEvolution__GetModel__String(), getModel(), "getModel", 0, 1, IS_UNIQUE, IS_ORDERED); + addEParameter(op, theEcorePackage.getEString(), "nsURI", 0, 1, IS_UNIQUE, IS_ORDERED); + + op = initEOperation(getEvolution__AddModel__URI(), getModel(), "addModel", 0, 1, IS_UNIQUE, IS_ORDERED); + addEParameter(op, getURI(), "uri", 0, 1, IS_UNIQUE, IS_ORDERED); + op = initEOperation(getEvolution__GetRelease__int(), getRelease(), "getRelease", 0, 1, IS_UNIQUE, IS_ORDERED); addEParameter(op, theEcorePackage.getEInt(), "version", 0, 1, IS_UNIQUE, IS_ORDERED); + initEOperation(getEvolution__CreateRelease(), getRelease(), "createRelease", 0, 1, IS_UNIQUE, IS_ORDERED); + + initEOperation(getEvolution__Save(), null, "save", 0, 1, IS_UNIQUE, IS_ORDERED); + initEClass(releaseEClass, Release.class, "Release", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getRelease_Evolution(), getEvolution(), getEvolution_Releases(), "evolution", null, 1, 1, Release.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getRelease_Version(), ecorePackage.getEInt(), "version", null, 1, 1, Release.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getRelease_Date(), ecorePackage.getEDate(), "date", null, 1, 1, Release.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, @@ -1191,7 +1324,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEReference(getRelease_PreviousRelease(), getRelease(), null, "previousRelease", null, 0, 1, Release.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); initEReference(getRelease_RootPackages(), theEcorePackage.getEPackage(), null, "rootPackages", null, 0, -1, Release.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getRelease_AllPackages(), theEcorePackage.getEPackage(), null, "allPackages", null, 0, -1, Release.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); @@ -1241,7 +1374,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka initEClass(migrationEClass, Migration.class, "Migration", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEReference(getMigration_ModelSet(), getModelSet(), getModelSet_Migrations(), "modelSet", null, 0, 1, Migration.class, !IS_TRANSIENT, !IS_VOLATILE, - IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getMigration_DiagnosticID(), ecorePackage.getEString(), "diagnosticID", null, 0, 1, Migration.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/MigrationImpl.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/MigrationImpl.java index 5f37be483b..5f6faaa454 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/MigrationImpl.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/MigrationImpl.java @@ -80,6 +80,16 @@ public abstract class MigrationImpl extends CDOObjectImpl implements Migration return (ModelSet)eDynamicGet(EvolutionPackage.MIGRATION__MODEL_SET, EvolutionPackage.Literals.MIGRATION__MODEL_SET, true, true); } + /** + * + * + * @generated + */ + public ModelSet basicGetModelSet() + { + return (ModelSet)eDynamicGet(EvolutionPackage.MIGRATION__MODEL_SET, EvolutionPackage.Literals.MIGRATION__MODEL_SET, false, true); + } + /** * * @@ -184,7 +194,11 @@ public abstract class MigrationImpl extends CDOObjectImpl implements Migration switch (featureID) { case EvolutionPackage.MIGRATION__MODEL_SET: - return getModelSet(); + if (resolve) + { + return getModelSet(); + } + return basicGetModelSet(); case EvolutionPackage.MIGRATION__DIAGNOSTIC_ID: return getDiagnosticID(); } @@ -242,7 +256,7 @@ public abstract class MigrationImpl extends CDOObjectImpl implements Migration switch (featureID) { case EvolutionPackage.MIGRATION__MODEL_SET: - return getModelSet() != null; + return basicGetModelSet() != null; case EvolutionPackage.MIGRATION__DIAGNOSTIC_ID: return DIAGNOSTIC_ID_EDEFAULT == null ? getDiagnosticID() != null : !DIAGNOSTIC_ID_EDEFAULT.equals(getDiagnosticID()); } diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelImpl.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelImpl.java index 577b41095b..b11d1f918c 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelImpl.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelImpl.java @@ -7,17 +7,24 @@ import org.eclipse.emf.cdo.etypes.EtypesPackage; import org.eclipse.emf.cdo.evolution.Evolution; import org.eclipse.emf.cdo.evolution.EvolutionPackage; import org.eclipse.emf.cdo.evolution.Model; +import org.eclipse.emf.cdo.evolution.util.ElementHandler; +import org.eclipse.emf.cdo.evolution.util.ElementRunnable; +import org.eclipse.emf.cdo.evolution.util.IDAnnotation; import org.eclipse.emf.internal.cdo.CDOObjectImpl; import org.eclipse.emf.internal.cdo.util.CompletePackageClosure; import org.eclipse.emf.internal.cdo.util.IPackageClosure; +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.io.IORuntimeException; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.ECollections; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EcorePackage; @@ -27,6 +34,8 @@ import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.ecore.util.EcoreEList; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.util.Collections; import java.util.Set; @@ -104,6 +113,16 @@ public class ModelImpl extends CDOObjectImpl implements Model return (Evolution)eDynamicGet(EvolutionPackage.MODEL__EVOLUTION, EvolutionPackage.Literals.MODEL__EVOLUTION, true, true); } + /** + * + * + * @generated + */ + public Evolution basicGetEvolution() + { + return (Evolution)eDynamicGet(EvolutionPackage.MODEL__EVOLUTION, EvolutionPackage.Literals.MODEL__EVOLUTION, false, true); + } + /** * * @@ -411,6 +430,64 @@ public class ModelImpl extends CDOObjectImpl implements Model return list; } + /** + * + * + * @generated NOT + */ + public boolean ensureIDs() + { + final boolean[] modified = { false }; + + ElementHandler.execute(getRootPackage(), new ElementRunnable() + { + public void run(EModelElement modelElement) + { + if (IDAnnotation.ensureValue(modelElement) != null) + { + modified[0] = true; + } + } + }); + + return modified[0]; + } + + /** + * + * + * @generated NOT + */ + public EPackage getPackage(String nsURI) + { + for (EPackage ePackage : getAllPackages()) + { + if (ObjectUtil.equals(ePackage.getNsURI(), nsURI)) + { + return ePackage; + } + } + + return null; + } + + /** + * + * + * @generated NOT + */ + public void save() + { + try + { + eResource().save(null); + } + catch (IOException ex) + { + throw new IORuntimeException(ex); + } + } + /** * * @@ -474,7 +551,11 @@ public class ModelImpl extends CDOObjectImpl implements Model switch (featureID) { case EvolutionPackage.MODEL__EVOLUTION: - return getEvolution(); + if (resolve) + { + return getEvolution(); + } + return basicGetEvolution(); case EvolutionPackage.MODEL__URI: return getURI(); case EvolutionPackage.MODEL__ROOT_PACKAGE: @@ -544,7 +625,7 @@ public class ModelImpl extends CDOObjectImpl implements Model switch (featureID) { case EvolutionPackage.MODEL__EVOLUTION: - return getEvolution() != null; + return basicGetEvolution() != null; case EvolutionPackage.MODEL__URI: return URI_EDEFAULT == null ? getURI() != null : !URI_EDEFAULT.equals(getURI()); case EvolutionPackage.MODEL__ROOT_PACKAGE: @@ -559,6 +640,27 @@ public class ModelImpl extends CDOObjectImpl implements Model return super.eIsSet(featureID); } + /** + * + * + * @generated + */ + @Override + public Object eInvoke(int operationID, EList arguments) throws InvocationTargetException + { + switch (operationID) + { + case EvolutionPackage.MODEL___ENSURE_IDS: + return ensureIDs(); + case EvolutionPackage.MODEL___GET_PACKAGE__STRING: + return getPackage((String)arguments.get(0)); + case EvolutionPackage.MODEL___SAVE: + save(); + return null; + } + return super.eInvoke(operationID, arguments); + } + public ModelStatus getStatus() { return status; diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelSetImpl.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelSetImpl.java index b7d7696a87..0ca60498bb 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelSetImpl.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ModelSetImpl.java @@ -2,6 +2,8 @@ */ package org.eclipse.emf.cdo.evolution.impl; +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; import org.eclipse.emf.cdo.evolution.Change; import org.eclipse.emf.cdo.evolution.ChangeKind; import org.eclipse.emf.cdo.evolution.ElementChange; @@ -16,9 +18,12 @@ import org.eclipse.emf.cdo.evolution.Release; import org.eclipse.emf.cdo.evolution.util.ElementHandler; import org.eclipse.emf.cdo.evolution.util.ElementRunnable; import org.eclipse.emf.cdo.evolution.util.IDAnnotation; +import org.eclipse.emf.cdo.internal.common.model.CDOPackageRegistryImpl; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader; import org.eclipse.emf.internal.cdo.CDOObjectImpl; +import org.eclipse.net4j.util.ImplementationError; import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.net4j.util.collection.CollectionUtil; @@ -264,6 +269,24 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet */ public abstract EList getAllPackages(); + /** + * + * + * @generated NOT + */ + public EPackage getPackage(String nsURI) + { + for (EPackage ePackage : getAllPackages()) + { + if (ObjectUtil.equals(ePackage.getNsURI(), nsURI)) + { + return ePackage; + } + } + + return null; + } + /** * * @@ -372,6 +395,87 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet return null; } + public EList getElementChanges(EClass elementType, ChangeKind... changeKinds) + { + ModelSetChange modelSetChange = getChange(); + + EList result = new BasicEList(); + collectElementChanges(result, modelSetChange, elementType, changeKinds); + return result; + } + + private void collectElementChanges(EList result, Change change, EClass elementType, ChangeKind... changeKinds) + { + if (change instanceof ElementChange) + { + ElementChange elementChange = (ElementChange)change; + + if (elementType == null || elementType.isSuperTypeOf(elementChange.getElement().eClass())) + { + if (changeKinds.length == 0 || elementChange.getKind().indexWithin(changeKinds) != -1) + { + result.add(elementChange); + } + } + } + + for (Change child : change.getChildren()) + { + collectElementChanges(result, child, elementType, changeKinds); + } + } + + public EList getPropertyChanges(EStructuralFeature feature, ChangeKind... changeKinds) + { + ModelSetChange modelSetChange = getChange(); + + EList result = new BasicEList(); + collectPropertyChanges(result, modelSetChange, feature, changeKinds); + return result; + } + + private void collectPropertyChanges(EList result, Change change, EStructuralFeature feature, ChangeKind... changeKinds) + { + if (change instanceof PropertyChange) + { + PropertyChange propertyChange = (PropertyChange)change; + + if (feature == null || feature == propertyChange.getFeature()) + { + if (changeKinds.length == 0 || propertyChange.getKind().indexWithin(changeKinds) != -1) + { + result.add(propertyChange); + } + } + } + + for (Change child : change.getChildren()) + { + collectPropertyChanges(result, child, feature, changeKinds); + } + } + + public CDOPackageRegistry createPackageRegistry() + { + CDOPackageRegistryImpl packageRegistry = new CDOPackageRegistryImpl(); + packageRegistry.setPackageLoader(new PackageLoader() + { + public EPackage[] loadPackages(CDOPackageUnit packageUnit) + { + throw new ImplementationError("All package units should be fully initialized -- no loading required"); + } + }); + + packageRegistry.activate(); + + for (EPackage rootPackage : getRootPackages()) + { + packageRegistry.putEPackage(rootPackage); + } + + return packageRegistry; + } + /** * * @@ -505,6 +609,8 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet return getRootPackages(); case EvolutionPackage.MODEL_SET___GET_ALL_PACKAGES: return getAllPackages(); + case EvolutionPackage.MODEL_SET___GET_PACKAGE__STRING: + return getPackage((String)arguments.get(0)); case EvolutionPackage.MODEL_SET___CONTAINS_ELEMENT__EMODELELEMENT: return containsElement((EModelElement)arguments.get(0)); case EvolutionPackage.MODEL_SET___GET_ELEMENT__STRING: @@ -620,7 +726,7 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet System.out.println(kind + " " + getLabel(oldElement) + " --> " + getLabel(newElement)); } - ElementChange elementChange = getElementChange(newElement, oldElement, kind, previousElementChanges); + ElementChange elementChange = getElementChange(oldElement, newElement, kind, previousElementChanges); getParentChange(elementChange, result).getChildren().add(elementChange); result.getElementChanges().put(oldElement, elementChange); result.getElementChanges().put(newElement, elementChange); @@ -853,7 +959,7 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet return modelSetChange; } - private static ElementChange getElementChange(EModelElement newElement, EModelElement oldElement, ChangeKind kind, + private static ElementChange getElementChange(EModelElement oldElement, EModelElement newElement, ChangeKind kind, Map previousElementChanges) { if (previousElementChanges != null) diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ReleaseImpl.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ReleaseImpl.java index f219630386..02e96d9e56 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ReleaseImpl.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/impl/ReleaseImpl.java @@ -202,6 +202,16 @@ public class ReleaseImpl extends ModelSetImpl implements Release return (Evolution)eDynamicGet(EvolutionPackage.RELEASE__EVOLUTION, EvolutionPackage.Literals.RELEASE__EVOLUTION, true, true); } + /** + * + * + * @generated + */ + public Evolution basicGetEvolution() + { + return (Evolution)eDynamicGet(EvolutionPackage.RELEASE__EVOLUTION, EvolutionPackage.Literals.RELEASE__EVOLUTION, false, true); + } + /** * * @@ -315,7 +325,11 @@ public class ReleaseImpl extends ModelSetImpl implements Release switch (featureID) { case EvolutionPackage.RELEASE__EVOLUTION: - return getEvolution(); + if (resolve) + { + return getEvolution(); + } + return basicGetEvolution(); case EvolutionPackage.RELEASE__VERSION: return getVersion(); case EvolutionPackage.RELEASE__DATE: @@ -405,7 +419,7 @@ public class ReleaseImpl extends ModelSetImpl implements Release switch (featureID) { case EvolutionPackage.RELEASE__EVOLUTION: - return getEvolution() != null; + return basicGetEvolution() != null; case EvolutionPackage.RELEASE__VERSION: return getVersion() != VERSION_EDEFAULT; case EvolutionPackage.RELEASE__DATE: diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF index 194ac9afc0..d03434e523 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.emf.cdo.explorer.ui;singleton:=true -Bundle-Version: 4.4.300.qualifier +Bundle-Version: 4.4.400.qualifier Bundle-Activator: org.eclipse.emf.cdo.explorer.ui.bundle.OM$Activator Bundle-Vendor: %providerName Bundle-ClassPath: . @@ -24,16 +24,16 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.emf.cdo.ui.shared;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.ui.compare;bundle-version="[4.0.0,5.0.0)";resolution:=optional, org.eclipse.emf.cdo.ui.team;bundle-version="[4.0.0,5.0.0)";resolution:=optional -Export-Package: org.eclipse.emf.cdo.explorer.ui;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.actions;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.application;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.bundle;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.checkouts;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.checkouts.actions;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.checkouts.wizards;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.handlers;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.properties;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.repositories;version="4.4.300";x-internal:=true, - org.eclipse.emf.cdo.explorer.ui.repositories.wizards;version="4.4.300";x-internal:=true +Export-Package: org.eclipse.emf.cdo.explorer.ui;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.actions;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.application;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.bundle;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.checkouts;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.checkouts.actions;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.checkouts.wizards;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.handlers;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.properties;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.repositories;version="4.4.400";x-internal:=true, + org.eclipse.emf.cdo.explorer.ui.repositories.wizards;version="4.4.400";x-internal:=true Eclipse-BuddyPolicy: registered Automatic-Module-Name: org.eclipse.emf.cdo.explorer.ui diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/pom.xml b/plugins/org.eclipse.emf.cdo.explorer.ui/pom.xml index f6bff891e2..d1ec0b96bf 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/pom.xml +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/pom.xml @@ -25,7 +25,7 @@ org.eclipse.emf.cdo org.eclipse.emf.cdo.explorer.ui - 4.4.300-SNAPSHOT + 4.4.400-SNAPSHOT eclipse-plugin diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/ShowInActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/ShowInActionProvider.java index 88fb4ed720..f1986fad19 100644 --- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/ShowInActionProvider.java +++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/ShowInActionProvider.java @@ -25,7 +25,7 @@ import org.eclipse.emf.cdo.internal.explorer.repositories.LocalCDORepository; import org.eclipse.emf.cdo.internal.ui.views.CDOSessionsView; import org.eclipse.emf.cdo.internal.ui.views.CDOTimeMachineView; import org.eclipse.emf.cdo.server.CDOServerBrowser; -import org.eclipse.emf.cdo.server.internal.db.DBBrowserPage; +import org.eclipse.emf.cdo.server.db.CDODBUtil; import org.eclipse.emf.cdo.session.CDOSession; import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace; @@ -367,7 +367,7 @@ public class ShowInActionProvider extends AbstractActionProvider public void run() { container.registerFactory(new CDOServerBrowser.ContainerBased.Factory(container)); - container.registerFactory(new DBBrowserPage.Factory()); + CDODBUtil.prepareContainer(container); String description = element.getType() + "-checkout-" + element.getID(); diff --git a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF index c647e64286..eeb863c4b8 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.server.db/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.server.db;singleton:=true -Bundle-Version: 4.6.0.qualifier +Bundle-Version: 4.7.0.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -11,12 +11,12 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ClassPath: . Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.net4j.db;bundle-version="[4.0.0,5.0.0)";visibility:=reexport, - org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport -Export-Package: org.eclipse.emf.cdo.server.db;version="4.6.0", - org.eclipse.emf.cdo.server.db.mapping;version="4.6.0", - org.eclipse.emf.cdo.server.internal.db;version="4.6.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db,org.eclipse.emf.cdo.explorer.ui", - org.eclipse.emf.cdo.server.internal.db.bundle;version="4.6.0";x-internal:=true, - org.eclipse.emf.cdo.server.internal.db.mapping;version="4.6.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db", - org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.6.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db", - org.eclipse.emf.cdo.server.internal.db.messages;version="4.6.0";x-internal:=true + org.eclipse.emf.cdo.server.evolution;bundle-version="[1.0.0,2.0.0)";visibility:=reexport +Export-Package: org.eclipse.emf.cdo.server.db;version="4.7.0", + org.eclipse.emf.cdo.server.db.mapping;version="4.7.0", + org.eclipse.emf.cdo.server.internal.db;version="4.7.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db,org.eclipse.emf.cdo.explorer.ui", + org.eclipse.emf.cdo.server.internal.db.bundle;version="4.7.0";x-internal:=true, + org.eclipse.emf.cdo.server.internal.db.mapping;version="4.7.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db", + org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;version="4.7.0";x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.emf.cdo.tests.db", + org.eclipse.emf.cdo.server.internal.db.messages;version="4.7.0";x-internal:=true Automatic-Module-Name: org.eclipse.emf.cdo.server.db diff --git a/plugins/org.eclipse.emf.cdo.server.db/plugin.xml b/plugins/org.eclipse.emf.cdo.server.db/plugin.xml index 9ccde6a50a..b7c0881896 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.server.db/plugin.xml @@ -15,13 +15,19 @@ - + + - + type="dbschema" + class="org.eclipse.emf.cdo.server.internal.db.DBSchemaPage$Factory"/> + - + diff --git a/plugins/org.eclipse.emf.cdo.server.db/pom.xml b/plugins/org.eclipse.emf.cdo.server.db/pom.xml index 4d4b891552..b9bbbb2f03 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/pom.xml +++ b/plugins/org.eclipse.emf.cdo.server.db/pom.xml @@ -25,7 +25,7 @@ org.eclipse.emf.cdo org.eclipse.emf.cdo.server.db - 4.6.0-SNAPSHOT + 4.7.0-SNAPSHOT eclipse-plugin diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java index 4e8e0a5fab..9b228e91fe 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java @@ -13,8 +13,10 @@ package org.eclipse.emf.cdo.server.db; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; -import org.eclipse.emf.cdo.server.internal.db.DBBrowserPage; +import org.eclipse.emf.cdo.server.internal.db.DBMappingsPage; +import org.eclipse.emf.cdo.server.internal.db.DBSchemaPage; import org.eclipse.emf.cdo.server.internal.db.DBStore; +import org.eclipse.emf.cdo.server.internal.db.DBTablesPage; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges; @@ -78,7 +80,9 @@ public final class CDODBUtil */ public static void prepareContainer(IManagedContainer container) { - container.registerFactory(new DBBrowserPage.Factory()); + container.registerFactory(new DBMappingsPage.Factory()); + container.registerFactory(new DBSchemaPage.Factory()); + container.registerFactory(new DBTablesPage.Factory()); } /** diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java index e21f8d52d8..35fc9967f3 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java @@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.server.db; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.server.IStoreAccessor; import org.eclipse.emf.cdo.server.IStoreAccessor.UnitSupport; +import org.eclipse.emf.cdo.server.spi.evolution.EvolutionSupport; import org.eclipse.net4j.db.IDBConnection; import org.eclipse.net4j.db.ddl.IDBTable; @@ -28,7 +29,7 @@ import java.sql.Connection; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface IDBStoreAccessor extends IStoreAccessor.Raw2, UnitSupport +public interface IDBStoreAccessor extends IStoreAccessor.Raw2, UnitSupport, EvolutionSupport { public IDBStore getStore(); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java index 23d2074d4b..5e451e063e 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMetaDataManager.java @@ -99,6 +99,19 @@ public interface IMetaDataManager */ public void writePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor); + /** + * Delete package units from the database. + * + * @param connection + * the DB connection to write to. + * @param packageUnits + * the package units to delete. + * @param monitor + * the monitor to indicate progress. + * @since 4.7 + */ + public void deletePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor); + /** * @since 3.0 */ diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping2.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping2.java new file mode 100644 index 0000000000..bd71a2613b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping2.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.db.mapping; + +import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; + +import org.eclipse.net4j.db.ddl.IDBField; +import org.eclipse.net4j.db.ddl.IDBSchema; +import org.eclipse.net4j.db.ddl.IDBTable; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.Map; + +/** + * An extension interface for {@link IClassMapping class mappings} that support units. + * + * @author Eike Stepper + * @since 4.7 + */ +public interface IClassMapping2 extends IClassMapping +{ + public void setTable(IDBTable table); + + public void initTable(IDBStoreAccessor accessor); + + public IDBTable createTable(IDBSchema schema, String tableName); + + public Map getUnsettableFields(); + + public Map getListSizeFields(); + + public IFeatureMapping[] createFeatureMappings(IDBTable table, boolean updateClassMapping, EStructuralFeature... features); + + public IFeatureMapping[] getFeatureMappings(); + + public IFeatureMapping getFeatureMapping(EStructuralFeature feature); +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IFeatureMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IFeatureMapping.java new file mode 100644 index 0000000000..8c64172042 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IFeatureMapping.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.db.mapping; + +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * Mapping of a {@link EStructuralFeature feature} to and from the database. + * + * @author Eike Stepper + * @since 4.7 + */ +public interface IFeatureMapping +{ + /** + * @return The feature which is associated with this mapping. + */ + public EStructuralFeature getFeature(); +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping.java index 045e63850c..350b4a3002 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping.java @@ -23,8 +23,6 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.net4j.db.ddl.IDBTable; -import org.eclipse.emf.ecore.EStructuralFeature; - import java.util.Collection; import java.util.List; @@ -35,15 +33,8 @@ import java.util.List; * @author Stefan Winkler * @since 2.0 */ -public interface IListMapping +public interface IListMapping extends IFeatureMapping { - /** - * Return the mapped feature. - * - * @return the mapped feature. - */ - public EStructuralFeature getFeature(); - /** * Returns all DB tables which are used by this feature. * diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping4.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping4.java new file mode 100644 index 0000000000..a39b28da83 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IListMapping4.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.db.mapping; + +import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; + +import org.eclipse.net4j.db.ddl.IDBSchema; +import org.eclipse.net4j.db.ddl.IDBTable; + +/** + * Extension interface to {@link IListMapping3}. + * + * @author Eike Stepper + * @since 4.7 + */ +public interface IListMapping4 extends IListMapping3 +{ + public IDBTable getTable(); + + public void setTable(IDBTable table); + + public void initTable(IDBStoreAccessor accessor); + + public IDBTable createTable(IDBSchema schema, String tableName); +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java index da87d29f3f..6924d8c44e 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy.java @@ -171,7 +171,7 @@ public interface IMappingStrategy * Should only be called by mapping classes. * * @param containingClass - * the class containeng the feature. + * the class containing the feature. * @param feature * the feature for which the table name should be created. * @return the created table name. It is guaranteed that the table name is compatible with the chosen database. @@ -372,7 +372,7 @@ public interface IMappingStrategy public String getListJoin(String attrTable, String listTable); /** - * Contains symbolic constants that specifiy valid keys of {@link IMappingStrategy#getProperties() mapping strategy properties}. + * Contains symbolic constants that specify valid keys of {@link IMappingStrategy#getProperties() mapping strategy properties}. * * @author Eike Stepper * @since 4.4 diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy3.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy3.java new file mode 100644 index 0000000000..54491f5829 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IMappingStrategy3.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.db.mapping; + +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.List; + +/** + * Interface to complement {@link IMappingStrategy}. + * + * @author Eike Stepper + * @since 4.7 + */ +public interface IMappingStrategy3 extends IMappingStrategy +{ + public INamingStrategy getNamingStrategy(); + + public void setNamingStrategy(INamingStrategy namingStrategy); + + public String getUnsettableFieldName(EStructuralFeature feature); + + public boolean isMapped(EClass eClass); + + public List getMappedClasses(CDOPackageUnit[] packageUnits); + + public IClassMapping createClassMapping(EClass eClass); + + public void clearClassMappings(); +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/INamingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/INamingStrategy.java new file mode 100644 index 0000000000..b7d9c090f6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/INamingStrategy.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.db.mapping; + +import org.eclipse.net4j.util.factory.ProductCreationException; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.Map; + +/** + * @author Eike Stepper + * @since 4.7 + */ +public interface INamingStrategy +{ + public void initialize(IMappingStrategy mappingStrategy); + + /** + * Create a suitable table name which can be used to map the given element. Should only be called by mapping classes. + * + * @param element + * the element for which the name should be created. It must hold: + * element instanceof EClass || element instanceof EPackage. + * @return the created table name. It is guaranteed that the table name is compatible with the chosen database. + */ + public String getTableName(ENamedElement element); + + /** + * Create a suitable table name which can be used to map the given element. Should only be called by mapping classes. + * Should only be called by mapping classes. + * + * @param containingClass + * the class that contains the feature. + * @param feature + * the feature for which the table name should be created. + * @return the created table name. It is guaranteed that the table name is compatible with the chosen database. + */ + public String getTableName(EClass containingClass, EStructuralFeature feature); + + /** + * Create a suitable column name which can be used to map the given element. Should only be called by mapping classes. + * + * @param feature + * the feature for which the column name should be created. + * @return the created column name. It is guaranteed that the name is compatible with the chosen database. + */ + public String getFieldName(EStructuralFeature feature); + + public String getUnsettableFieldName(EStructuralFeature feature); + + /** + * @author Eike Stepper + */ + public static abstract class Factory extends org.eclipse.net4j.util.factory.PropertiesFactory + { + public static final String PRODUCT_GROUP = "org.eclipse.emf.cdo.server.db.namingStrategies"; + + public Factory(String type) + { + super(PRODUCT_GROUP, type); + } + + @Override + public abstract INamingStrategy create(Map properties) throws ProductCreationException; + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java index a7f21053e4..4eaad7aa02 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java @@ -37,13 +37,8 @@ import java.util.Collection; * @author Stefan Winkler * @since 2.0 */ -public interface ITypeMapping +public interface ITypeMapping extends IFeatureMapping { - /** - * @return The feature which is associated with this mapping. - */ - public EStructuralFeature getFeature(); - /** * @return The db field which is associated with this mapping. */ diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java index 354249ff59..943445f12a 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java @@ -70,7 +70,7 @@ public class CDODBSchema PACKAGE_UNITS.addField("time_stamp", DBType.BIGINT); //$NON-NLS-1$ public static final IDBField PACKAGE_UNITS_PACKAGE_DATA = // - PACKAGE_UNITS.addField("package_data", DBType.BLOB); //$NON-NLS-1$ + PACKAGE_UNITS.addField("package_data", MetaDataManager.ZIP_PACKAGE_BYTES ? DBType.BLOB : DBType.CLOB); //$NON-NLS-1$ public static final IDBIndex INDEX_PACKAGE_UNITS_PK = // PACKAGE_UNITS.addIndex(IDBIndex.Type.PRIMARY_KEY, PACKAGE_UNITS_ID); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java deleted file mode 100644 index fe6b898f77..0000000000 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBBrowserPage.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) 2010-2013, 2015, 2016 Eike Stepper (Loehne, Germany) and others. - * 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: - * Eike Stepper - initial API and implementation - */ -package org.eclipse.emf.cdo.server.internal.db; - -import org.eclipse.emf.cdo.server.CDOServerBrowser; -import org.eclipse.emf.cdo.server.CDOServerBrowser.AbstractPage; -import org.eclipse.emf.cdo.spi.server.InternalRepository; - -import org.eclipse.net4j.db.DBException; -import org.eclipse.net4j.db.DBUtil; -import org.eclipse.net4j.db.IDBConnectionProvider; -import org.eclipse.net4j.util.factory.ProductCreationException; - -import java.io.PrintStream; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.List; - -/** - * @author Eike Stepper - * @since 4.0 - */ -public class DBBrowserPage extends AbstractPage -{ - public DBBrowserPage() - { - super("tables", "DB Tables"); - } - - public boolean canDisplay(InternalRepository repository) - { - return repository.getStore() instanceof IDBConnectionProvider; - } - - public void display(CDOServerBrowser browser, InternalRepository repository, PrintStream out) - { - IDBConnectionProvider connectionProvider = (IDBConnectionProvider)repository.getStore(); - Connection connection = null; - - try - { - connection = connectionProvider.getConnection(); - - out.print("\r\n"); - out.print("\r\n"); - - out.print("\r\n"); - - if (table != null) - { - out.print("\r\n"); - } - - out.print("\r\n"); - out.print("
    \r\n"); - String table = showTables(browser, out, connection, repository.getName()); - out.print("\r\n"); - showTable(browser, out, connection, table); - out.print("
    \r\n"); - } - catch (DBException ex) - { - ex.printStackTrace(); - } - finally - { - DBUtil.close(connection); - } - } - - /** - * @since 4.0 - */ - protected String showTables(CDOServerBrowser browser, PrintStream pout, Connection connection, String repo) - { - String table = browser.getParam("table"); - boolean used = browser.isParam("used"); - boolean schema = browser.isParam("schema"); - - pout.print("\r\n"); - pout.print( - "\r\n"); - pout.print("\r\n"); - pout.print("
    Empty tables:" + browser.href(used ? "Hidden" : "Shown", getName(), "used", String.valueOf(!used)) + "
    Row data:" + browser.href(schema ? "Hidden" : "Shown", getName(), "schema", String.valueOf(!schema)) - + "

    \r\n"); - - int totalRows = 0; - int usedTables = 0; - - List allTableNames = DBUtil.getAllTableNames(connection, repo); - for (String tableName : allTableNames) - { - if (table == null) - { - table = tableName; - } - - String label = browser.escape(tableName)/* .toLowerCase() */; - - int rowCount = DBUtil.getRowCount(connection, tableName); - if (rowCount > 0) - { - // label += " (" + rowCount + ")"; - totalRows += rowCount; - ++usedTables; - } - else if (used) - { - continue; - } - - if (tableName.equals(table)) - { - pout.print("" + label + ""); - } - else - { - pout.print(browser.href(label, getName(), "table", tableName, "order", null, "direction", null)); - } - - if (rowCount > 0) - { - pout.print(" (" + rowCount + ")"); - } - - pout.print("
    \r\n"); - } - - if (totalRows != 0) - { - int totalTables = allTableNames.size(); - int emptyTables = totalTables - usedTables; - - pout.print("
    " + totalTables + " tables total\r\n"); - pout.print("
    " + usedTables + " tables used (" + totalRows + " rows)\r\n"); - pout.print("
    " + emptyTables + " tables empty
    \r\n"); - } - - return table; - } - - /** - * @since 4.0 - */ - protected void showTable(CDOServerBrowser browser, PrintStream pout, Connection connection, String table) - { - try - { - String order = browser.getParam("order"); - executeQuery(browser, pout, connection, table, - "SELECT * FROM " + table + (order == null ? "" : " ORDER BY " + order + " " + browser.getParam("direction"))); - } - catch (Exception ex) - { - browser.removeParam("order"); - browser.removeParam("direction"); - executeQuery(browser, pout, connection, table, "SELECT * FROM " + table); - } - } - - protected void executeQuery(CDOServerBrowser browser, PrintStream pout, Connection connection, String table, String sql) - { - String order = browser.getParam("order"); - String direction = browser.getParam("direction"); - String highlight = browser.getParam("highlight"); - boolean schema = browser.isParam("schema"); - - Statement stmt = null; - ResultSet resultSet = null; - - try - { - stmt = connection.createStatement(); - resultSet = stmt.executeQuery(sql); - - ResultSetMetaData metaData = resultSet.getMetaData(); - int columns = metaData.getColumnCount(); - - pout.print("\r\n"); - pout.print("\r\n"); - pout.print("\r\n"); - pout.print("\r\n"); - for (int i = 0; i < columns; i++) - { - String column = metaData.getColumnLabel(1 + i); - String type = metaData.getColumnTypeName(1 + i).toLowerCase() + "(" + metaData.getPrecision(1 + i) + ")"; - - String dir = column.equals(order) && "ASC".equals(direction) ? "DESC" : "ASC"; - pout.print("\r\n"); - } - - pout.print("\r\n"); - - if (!schema) - { - int row = 0; - while (resultSet.next()) - { - ++row; - pout.print("\r\n"); - pout.print("\r\n"); - for (int i = 0; i < columns; i++) - { - String value = resultSet.getString(1 + i); - String bgcolor = highlight != null && highlight.equals(value) ? " bgcolor=\"#fffca6\"" : ""; - pout.print("" + browser.href(value, getName(), "highlight", value) + "\r\n"); - } - - pout.print("\r\n"); - } - } - - pout.print("
    " + table + "
     " + browser.href(column, getName(), "order", column, "direction", dir)); - pout.print("
    " + type + "
    " + row + "
    \r\n"); - } - catch (SQLException ex) - { - ex.printStackTrace(); - } - finally - { - DBUtil.close(resultSet); - DBUtil.close(stmt); - } - } - - /** - * @author Eike Stepper - */ - public static class Factory extends org.eclipse.net4j.util.factory.Factory - { - public static final String TYPE = "db"; - - public Factory() - { - super(PRODUCT_GROUP, TYPE); - } - - public DBBrowserPage create(String description) throws ProductCreationException - { - return new DBBrowserPage(); - } - } -} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBMappingsPage.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBMappingsPage.java new file mode 100644 index 0000000000..a0eb4ef3f5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBMappingsPage.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2010-2013, 2015, 2016 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.db; + +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.server.CDOServerBrowser; +import org.eclipse.emf.cdo.server.CDOServerBrowser.AbstractPage; +import org.eclipse.emf.cdo.server.db.IDBStore; +import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy3; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.db.ddl.IDBTable; +import org.eclipse.net4j.util.factory.ProductCreationException; + +import org.eclipse.emf.ecore.EClass; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class DBMappingsPage extends AbstractPage +{ + public DBMappingsPage() + { + super("mappings", "DB Mappings"); + } + + public boolean canDisplay(InternalRepository repository) + { + return repository.getStore() instanceof IDBStore; + } + + public void display(CDOServerBrowser browser, InternalRepository repository, PrintStream out) + { + boolean mapAll = "all".equals(browser.getParam("map")); + + IDBStore store = (IDBStore)repository.getStore(); + IMappingStrategy mappingStrategy = store.getMappingStrategy(); + Map classMappings = mappingStrategy.getClassMappings(mapAll); + + if (mappingStrategy instanceof IMappingStrategy3) + { + CDOPackageRegistry packageRegistry = store.getRepository().getPackageRegistry(); + CDOPackageUnit[] packageUnits = packageRegistry.getPackageUnits(); + + IMappingStrategy3 mappingStrategy3 = (IMappingStrategy3)mappingStrategy; + List mappedClasses = mappingStrategy3.getMappedClasses(packageUnits); + + int countMapped = classMappings.size(); + int countMappable = mappedClasses.size(); + + out.print("Mappable classes: " + countMappable + "
    \r\n"); + out.print("Mapped classes: " + countMapped + "
    \r\n"); + out.print("Unmapped classes: " + (countMappable - countMapped)); + + if (countMapped < countMappable) + { + out.print("   " + browser.href("(map all)", getName(), "map", "all")); + } + + out.print("
    \r\n"); + out.print("
    \r\n"); + } + + List qualifiedNames = new ArrayList(); + Map byQualifiedName = new LinkedHashMap(); + for (Map.Entry entry : classMappings.entrySet()) + { + EClass eClass = entry.getKey(); + IClassMapping classMapping = entry.getValue(); + + String qualifiedName = EMFUtil.getQualifiedName(eClass, "."); + qualifiedNames.add(qualifiedName); + byQualifiedName.put(qualifiedName, classMapping); + } + + Collections.sort(qualifiedNames); + + out.print("\r\n"); + out.print("\r\n"); + + for (String qualifiedName : qualifiedNames) + { + IClassMapping classMapping = byQualifiedName.get(qualifiedName); + List tables = classMapping.getDBTables(); + + boolean mapped = tables.get(0) != null; + String fontPrefix = mapped ? "" : ""; + String fontSuffix = mapped ? "" : ""; + + out.print("\r\n"); + } + + out.print("
    ClassTable
    "); + out.print(fontPrefix); + out.print(qualifiedName); + out.print(fontSuffix); + out.print(""); + + boolean first = true; + for (IDBTable table : tables) + { + if (table != null) + { + if (first) + { + first = false; + } + else + { + out.print("
    "); + } + + out.print(DBTablesPage.tableHRef(browser, table)); + } + } + + out.print("
    \r\n"); + } + + /** + * @author Eike Stepper + */ + public static class Factory extends org.eclipse.net4j.util.factory.Factory + { + public static final String TYPE = "dbmappings"; + + public Factory() + { + super(PRODUCT_GROUP, TYPE); + } + + public DBMappingsPage create(String description) throws ProductCreationException + { + return new DBMappingsPage(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBSchemaPage.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBSchemaPage.java new file mode 100644 index 0000000000..414c104f60 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBSchemaPage.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2010-2013, 2015, 2016 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.db; + +import org.eclipse.emf.cdo.server.CDOServerBrowser; +import org.eclipse.emf.cdo.server.CDOServerBrowser.AbstractPage; +import org.eclipse.emf.cdo.server.db.IDBStore; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.ddl.IDBSchema; +import org.eclipse.net4j.spi.db.ddl.InternalDBNamedElement.DumpFormat; +import org.eclipse.net4j.util.factory.ProductCreationException; +import org.eclipse.net4j.util.io.IOUtil; + +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintStream; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class DBSchemaPage extends AbstractPage +{ + public DBSchemaPage() + { + super("schema", "DB Schema"); + } + + public boolean canDisplay(InternalRepository repository) + { + return repository.getStore() instanceof IDBStore; + } + + public void display(CDOServerBrowser browser, InternalRepository repository, PrintStream out) + { + IDBStore store = (IDBStore)repository.getStore(); + IDBSchema schema = store.getDBSchema(); + + OutputStreamWriter writer = null; + + try + { + writer = new DumpFormat.HTML(out); + DBUtil.dump(schema, writer); + } + catch (IOException ex) + { + ex.printStackTrace(); + } + finally + { + IOUtil.close(writer); + } + } + + /** + * @author Eike Stepper + */ + public static class Factory extends org.eclipse.net4j.util.factory.Factory + { + public static final String TYPE = "dbschema"; + + public Factory() + { + super(PRODUCT_GROUP, TYPE); + } + + public DBSchemaPage create(String description) throws ProductCreationException + { + return new DBSchemaPage(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java index 99bfa0f933..5a332cdc8b 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java @@ -32,6 +32,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionCacheAdder; import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; import org.eclipse.emf.cdo.common.util.CDOQueryInfo; import org.eclipse.emf.cdo.eresource.EresourcePackage; +import org.eclipse.emf.cdo.evolution.Release; import org.eclipse.emf.cdo.server.IQueryHandler; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.ISession; @@ -52,6 +53,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy2; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.AbstractHorizontalClassMapping; import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.UnitMappingTable; +import org.eclipse.emf.cdo.server.spi.evolution.MigrationContext; import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader3; @@ -76,6 +78,7 @@ import org.eclipse.net4j.db.IDBDatabase; import org.eclipse.net4j.db.IDBPreparedStatement; import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability; import org.eclipse.net4j.db.IDBSchemaTransaction; +import org.eclipse.net4j.db.ddl.IDBSchema; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.internal.db.ddl.DBField; import org.eclipse.net4j.util.HexUtil; @@ -812,12 +815,13 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor, { IDBDatabase database = store.getDatabase(); IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction(); + IDBSchema schema = schemaTransaction.getWorkingCopy(); try { for (IDBTable table : createdTables) { - table.remove(); + schema.removeTable(table.getName()); } schemaTransaction.commit(); @@ -1508,6 +1512,12 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor, unitMappingTable.writeUnitMappings(this, unitMappings, timeStamp); } + public void migrateTo(Release release, MigrationContext context, OMMonitor monitor) + { + DBStoreMigrator migrator = new DBStoreMigrator(this, context, release); + migrator.migrate(monitor); + } + public void tableCreated(IDBTable table) { if (createdTables == null) diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreMigrator.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreMigrator.java new file mode 100644 index 0000000000..48940cd907 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreMigrator.java @@ -0,0 +1,738 @@ +/* + * Copyright (c) 2004-2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.db; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.evolution.ChangeKind; +import org.eclipse.emf.cdo.evolution.ElementChange; +import org.eclipse.emf.cdo.evolution.Release; +import org.eclipse.emf.cdo.evolution.util.ElementHandler; +import org.eclipse.emf.cdo.internal.server.Repository; +import org.eclipse.emf.cdo.server.db.IDBStore; +import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; +import org.eclipse.emf.cdo.server.db.IMetaDataManager; +import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; +import org.eclipse.emf.cdo.server.db.mapping.IClassMapping2; +import org.eclipse.emf.cdo.server.db.mapping.IFeatureMapping; +import org.eclipse.emf.cdo.server.db.mapping.IListMapping; +import org.eclipse.emf.cdo.server.db.mapping.IListMapping4; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy3; +import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; +import org.eclipse.emf.cdo.server.evolution.Renamer; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; +import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.AbstractHorizontalMappingStrategy; +import org.eclipse.emf.cdo.server.spi.evolution.MigrationContext; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.db.DBException; +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBAdapter; +import org.eclipse.net4j.db.IDBConnection; +import org.eclipse.net4j.db.IDBSchemaTransaction; +import org.eclipse.net4j.db.ddl.IDBField; +import org.eclipse.net4j.db.ddl.IDBSchema; +import org.eclipse.net4j.db.ddl.IDBTable; +import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta; +import org.eclipse.net4j.spi.db.ddl.InternalDBNamedElement; +import org.eclipse.net4j.spi.db.ddl.InternalDBSchema; +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.collection.Pair; +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; + +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class DBStoreMigrator +{ + private final IDBStoreAccessor accessor; + + private final MigrationContext context; + + private final Release release; + + private final Release oldRelease; + + private final IDBStore store; + + private final IDBAdapter dbAdapter; + + private final IMappingStrategy3 mappingStrategy; + + private final IMetaDataManager metaDataManager; + + private final InternalRepository repository; + + private final InternalCDOPackageRegistry repositoryPackageRegistry; + + private final Map oldToRepositoryElements = new HashMap(); + + private final Map repositoryToOldElements = new HashMap(); + + public DBStoreMigrator(IDBStoreAccessor accessor, MigrationContext context, Release release) + { + this.accessor = accessor; + this.context = context; + this.release = release; + + store = accessor.getStore(); + dbAdapter = store.getDBAdapter(); + mappingStrategy = (IMappingStrategy3)store.getMappingStrategy(); + metaDataManager = store.getMetaDataManager(); + + repository = (InternalRepository)store.getRepository(); + repositoryPackageRegistry = repository.getPackageRegistry(); + + //////////////////////////////////////////////////////////////////////////////////////// + // Build bidirectional mappings between repository and previous release classifiers. + //////////////////////////////////////////////////////////////////////////////////////// + + oldRelease = release.getPreviousRelease(); + if (oldRelease != null) + { + for (EPackage oldPackage : oldRelease.getAllPackages()) + { + EPackage repositoryPackage = repositoryPackageRegistry.getEPackage(oldPackage.getNsURI()); + if (repositoryPackage != null) + { + repositoryToOldElements.put(repositoryPackage, oldPackage); + oldToRepositoryElements.put(oldPackage, repositoryPackage); + + for (EClassifier oldClassifier : oldPackage.getEClassifiers()) + { + EClassifier repositoryClassifier = repositoryPackage.getEClassifier(oldClassifier.getName()); + if (repositoryClassifier != null) + { + repositoryToOldElements.put(repositoryClassifier, oldClassifier); + oldToRepositoryElements.put(oldClassifier, repositoryClassifier); + + if (oldClassifier instanceof EClass) + { + EClass oldClass = (EClass)oldClassifier; + EClass repositoryClass = (EClass)repositoryClassifier; + + for (EStructuralFeature oldFeature : oldClass.getEStructuralFeatures()) + { + EStructuralFeature repositoryFeature = repositoryClass.getEStructuralFeature(oldFeature.getName()); + if (repositoryFeature != null) + { + repositoryToOldElements.put(repositoryFeature, oldFeature); + oldToRepositoryElements.put(oldFeature, repositoryFeature); + } + } + } + else if (oldClassifier instanceof EEnum) + { + EEnum oldEnum = (EEnum)oldClassifier; + EEnum repositoryEnum = (EEnum)repositoryClassifier; + + for (EEnumLiteral oldLiteral : oldEnum.getELiterals()) + { + EEnumLiteral repositoryLiteral = repositoryEnum.getEEnumLiteral(oldLiteral.getName()); + if (repositoryLiteral != null) + { + repositoryToOldElements.put(repositoryLiteral, oldLiteral); + oldToRepositoryElements.put(oldLiteral, repositoryLiteral); + } + } + } + } + } + } + } + } + } + + public void migrate(OMMonitor monitor) + { + IDBConnection connection = accessor.getDBConnection(); + Statement statement = null; + + try + { + statement = connection.createStatement(); + migrate(connection, statement, monitor); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + finally + { + DBUtil.close(statement); + } + } + + public void migrate(IDBConnection connection, Statement statement, OMMonitor monitor) throws SQLException + { + InternalCDOPackageRegistry newPackageRegistry = (InternalCDOPackageRegistry)release.createPackageRegistry(); + InternalCDOPackageUnit[] newPackageUnits = newPackageRegistry.getPackageUnits(); + Map newToOldElements = release.getChange().getNewToOldElements(); + + //////////////////////////////////////////////////////////////////////////////////////// + // Compute all new class mappings in a temporary schema. + //////////////////////////////////////////////////////////////////////////////////////// + + Map newClassMappings = new HashMap(); + boolean oldSkipMappingInitialization = AbstractMappingStrategy.setSkipMappingInitialization(true); + + try + { + IDBSchema schema = DBUtil.createSchema("v" + release.getVersion()); + + for (EClass newClass : mappingStrategy.getMappedClasses(newPackageUnits)) + { + IClassMapping2 newClassMapping = (IClassMapping2)mappingStrategy.createClassMapping(newClass); + IDBTable newTable = newClassMapping.createTable(schema, mappingStrategy.getTableName(newClass)); + newClassMapping.setTable(newTable); + newClassMappings.put(newClass, newClassMapping); + + for (IListMapping listMapping : newClassMapping.getListMappings()) + { + IDBTable listTable = ((IListMapping4)listMapping).createTable(schema, mappingStrategy.getTableName(newClass, listMapping.getFeature())); + ((IListMapping4)listMapping).setTable(listTable); + monitor.checkCanceled(); + } + + monitor.checkCanceled(); + } + + // context.log("Computing " + DBUtil.dumpToString(schema)); + } + finally + { + AbstractMappingStrategy.setSkipMappingInitialization(oldSkipMappingInitialization); + } + + //////////////////////////////////////////////////////////////////////////////////////// + // Create renaming rules for the tables that become obsolete after the migration. + //////////////////////////////////////////////////////////////////////////////////////// + + Renamer tableRenamer = new TableRenamer(connection); + Set tablesToRemove = new HashSet(); + + int counter = 0; + for (ElementChange elementChange : release.getElementChanges(EcorePackage.Literals.ECLASS, ChangeKind.REMOVED)) + { + EClass oldClass = (EClass)elementChange.getOldElement(); + EClass repositoryClass = (EClass)oldToRepositoryElements.get(oldClass); + IClassMapping repositoryClassMapping = mappingStrategy.getClassMapping(repositoryClass); + + for (IDBTable table : repositoryClassMapping.getDBTables()) + { + if (table != null) + { + String tempName = "CDO_OLD_" + (++counter); + tableRenamer.addNames(table.getName(), tempName); + ((InternalDBNamedElement)table).setName(tempName); // TODO Remap in schema? + tablesToRemove.add(table); + } + + monitor.checkCanceled(); + } + + monitor.checkCanceled(); + } + + //////////////////////////////////////////////////////////////////////////////////////// + // Create renaming rules for the mapped tables of renamed classes and features. + //////////////////////////////////////////////////////////////////////////////////////// + + Set addedClassMappings = new HashSet(); + Map> oldToNewMetaIDs = new HashMap>(); + + for (IClassMapping2 newClassMapping : newClassMappings.values()) + { + EClass newClass = newClassMapping.getEClass(); + EClass oldClass = (EClass)newToOldElements.get(newClass); + + IClassMapping2 oldClassMapping = oldClass == null ? null : (IClassMapping2)mappingStrategy.getClassMapping(oldClass); + IDBTable table = oldClassMapping == null ? null : oldClassMapping.getDBTables().get(0); + + String oldTableName = table == null ? null : mappingStrategy.getTableName(oldClass); + String newTableName = mappingStrategy.getTableName(newClass); + + if (!newTableName.equals(oldTableName)) + { + tableRenamer.addNames(oldTableName, newTableName); + } + + if (oldClass != null) + { + if (newClass != null) + { + ColumnRenamer columnRenamer = null; + + if (table != null) + { + for (ITypeMapping newValueMapping : newClassMapping.getValueMappings()) + { + EStructuralFeature newFeature = newValueMapping.getFeature(); + EStructuralFeature oldFeature = (EStructuralFeature)newToOldElements.get(newFeature); + + String oldFieldName = oldFeature == null ? null : mappingStrategy.getFieldName(oldFeature); + String newFieldName = mappingStrategy.getFieldName(newFeature); + + if (!newFieldName.equals(oldFieldName)) + { + if (columnRenamer == null) + { + columnRenamer = new ColumnRenamer(connection, table); + } + + columnRenamer.addNames(oldFieldName, newFieldName); + } + + monitor.checkCanceled(); + } + } + + for (IListMapping newListMapping : newClassMapping.getListMappings()) + { + EStructuralFeature newFeature = newListMapping.getFeature(); + EStructuralFeature oldFeature = (EStructuralFeature)newToOldElements.get(newFeature); + + IListMapping4 oldListMapping = oldFeature == null ? null : (IListMapping4)oldClassMapping.getListMapping(oldFeature); + IDBTable listTable = oldListMapping == null ? null : oldListMapping.getTable(); + + oldTableName = listTable == null ? null : mappingStrategy.getTableName(oldClass, oldFeature); + newTableName = mappingStrategy.getTableName(newClass, newFeature); + + if (!newTableName.equals(oldTableName)) + { + tableRenamer.addNames(oldTableName, newTableName); + } + + if (table != null) + { + String oldListSizeFieldName = oldFeature == null ? null : mappingStrategy.getFieldName(oldFeature); + String newListSizeFieldName = mappingStrategy.getFieldName(newFeature); + + if (!newListSizeFieldName.equals(oldListSizeFieldName)) + { + if (columnRenamer == null) + { + columnRenamer = new ColumnRenamer(connection, table); + } + + columnRenamer.addNames(oldListSizeFieldName, newListSizeFieldName); + } + } + + monitor.checkCanceled(); + } + + if (columnRenamer != null) + { + columnRenamer.run(); + } + + CDOID oldMetaID = metaDataManager.getMetaID(oldClass, CDOBranchPoint.UNSPECIFIED_DATE); + CDOID newMetaID = metaDataManager.getMetaID(newClass, CDOBranchPoint.UNSPECIFIED_DATE); + if (!ObjectUtil.equals(oldMetaID, newMetaID)) + { + oldToNewMetaIDs.put(oldMetaID, Pair.create(newMetaID, newClass)); + + if (mappingStrategy instanceof AbstractHorizontalMappingStrategy) + { + AbstractHorizontalMappingStrategy horizontalMappingStrategy = (AbstractHorizontalMappingStrategy)mappingStrategy; + + int count = horizontalMappingStrategy.getObjectTypeMapper().changeObjectType(accessor, oldClass, newClass); + if (count > 0) + { + context.log("Changed type of " + count + " objects from " + oldMetaID + " to " + newMetaID // + + " (" + ElementHandler.getLabel(oldClass) + " --> " + ElementHandler.getLabel(newClass) + ")"); + } + } + } + } + } + else + { + addedClassMappings.add(newClassMapping); + } + + monitor.checkCanceled(); + } + + //////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + + tableRenamer.run(); + + //////////////////////////////////////////////////////////////////////////////////////// + // Create table columns for features added to existing classes. + //////////////////////////////////////////////////////////////////////////////////////// + + IDBSchemaTransaction schemaTransaction = null; + + try + { + for (IClassMapping2 newClassMapping : newClassMappings.values()) + { + EClass newClass = newClassMapping.getEClass(); + EClass oldClass = (EClass)newToOldElements.get(newClass); + if (oldClass != null) + { + EClass repositoryClass = (EClass)oldToRepositoryElements.get(oldClass); + + IClassMapping2 repositoryClassMapping = (IClassMapping2)mappingStrategy.getClassMapping(repositoryClass); + if (repositoryClassMapping != null) + { + IDBTable table = repositoryClassMapping.getDBTables().get(0); + if (table != null) + { + for (IFeatureMapping newFeatureMapping : newClassMapping.getFeatureMappings()) + { + EStructuralFeature newFeature = newFeatureMapping.getFeature(); + EStructuralFeature oldFeature = (EStructuralFeature)newToOldElements.get(newFeature); + if (oldFeature == null) + { + context.log("New feature " + newClass.getName() + "." + newFeature.getName()); + + if (schemaTransaction == null) + { + schemaTransaction = store.getDatabase().openSchemaTransaction(connection); + } + + IDBSchema workingCopy = schemaTransaction.getWorkingCopy(); + IDBTable workingTable = workingCopy.getTable(table.getName()); + repositoryClassMapping.createFeatureMappings(workingTable, false, newFeature); + } + } + } + } + } + } + + if (schemaTransaction != null) + { + IDBSchemaDelta schemaDelta = schemaTransaction.getSchemaDelta(); + context.log(DBUtil.dumpToString(schemaDelta)); + + schemaTransaction.commit(); + } + } + finally + { + IOUtil.close(schemaTransaction); + } + + //////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + + if (!tablesToRemove.isEmpty()) + { + context.log("Dropping obsolete tables:"); + + for (IDBTable table : tablesToRemove) + { + context.log(" " + table); + dbAdapter.dropTable(table, statement); + monitor.checkCanceled(); + } + } + + //////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + + if (oldRelease != null) + { + context.log("Removing old package units from system tables:"); + List repositoryPackageUnits = new ArrayList(); + + for (EPackage oldRootPackage : oldRelease.getRootPackages()) + { + EPackage repositoryRootPackage = (EPackage)oldToRepositoryElements.get(oldRootPackage); + InternalCDOPackageUnit repositoryPackageUnit = repositoryPackageRegistry.getPackageUnit(repositoryRootPackage); + repositoryPackageUnits.add(repositoryPackageUnit); + context.log(" " + repositoryPackageUnit.getID()); + } + + InternalCDOPackageUnit[] packageUnits = repositoryPackageUnits.toArray(new InternalCDOPackageUnit[repositoryPackageUnits.size()]); + metaDataManager.deletePackageUnits(connection, packageUnits, monitor); + } + + //////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + + context.log("Adding new package units to system tables:"); + for ( + + InternalCDOPackageUnit newPackageUnit : newPackageUnits) + { + context.log(" " + newPackageUnit.getID()); + } + + metaDataManager.writePackageUnits(accessor.getConnection(), newPackageUnits, monitor); + + //////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////// + + context.log("Committing migration results"); + connection.commit(); + + context.log("Reinitializing package registry"); + LifecycleUtil.deactivate(repositoryPackageRegistry); + LifecycleUtil.activate(repositoryPackageRegistry); + Repository.readPackageUnits(accessor, repositoryPackageRegistry); + + context.log("Resetting metadata manager"); + metaDataManager.clearMetaIDMappings(); + + context.log("Recomputing class mappings"); + mappingStrategy.clearClassMappings(); + mappingStrategy.getClassMappings(true); + + } + + /** + * @author Eike Stepper + */ + public abstract class LoggingRenamer extends Renamer + { + private int count; + + private String header; + + public LoggingRenamer(String header) + { + this.header = header; + } + + public int getCount() + { + return count; + } + + @Override + public void run() + { + try + { + super.run(); + + if (count != 0) + { + doFinally(true); + } + } + catch (RuntimeException ex) + { + if (count != 0) + { + doFinally(false); + } + + throw ex; + } + catch (Error ex) + { + if (count != 0) + { + doFinally(false); + } + + throw ex; + } + } + + protected void doInit() + { + } + + @Override + protected final void doRename(String oldName, String newName) + { + if (++count == 1) + { + context.log(header); + doInit(); + } + + context.log(" " + oldName + " --> " + newName); + doRename(oldName, newName, count); + } + + protected abstract void doRename(String oldName, String newName, int count); + + protected void doFinally(boolean success) + { + } + } + + /** + * @author Eike Stepper + */ + public abstract class JDBCRenamer extends LoggingRenamer + { + private final IDBConnection connection; + + private Statement statement; + + public JDBCRenamer(IDBConnection connection, String header) + { + super(header); + this.connection = connection; + } + + @Override + protected void doInit() + { + try + { + statement = connection.createStatement(); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + } + + @Override + protected void doRename(String oldName, String newName, int count) + { + String sql = getSQL(oldName, newName); + + try + { + statement.execute(sql); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + } + + protected abstract String getSQL(String oldName, String newName); + } + + /** + * @author Eike Stepper + */ + public class TableRenamer extends JDBCRenamer + { + public TableRenamer(IDBConnection connection) + { + super(connection, "Renaming tables:"); + + // Initialize the renamer with all existing table names. + for (IDBTable table : accessor.getStore().getDBSchema().getTables()) + { + addNames(table.getName(), null); + } + } + + @Override + protected String getSQL(String oldName, String newName) + { + return dbAdapter.sqlRenameTable(newName, oldName); + } + + @Override + protected void doRename(String oldName, String newName, int count) + { + super.doRename(oldName, newName, count); + + InternalDBSchema schema = (InternalDBSchema)accessor.getStore().getDBSchema(); + IDBTable table = schema.getTable(oldName); + schema.unlock(); + + try + { + table.rename(newName); + } + finally + { + schema.lock(); + } + } + } + + /** + * @author Eike Stepper + */ + public class ColumnRenamer extends JDBCRenamer + { + private final IDBTable table; + + public ColumnRenamer(IDBConnection connection, IDBTable table) + { + super(connection, "Renaming columns of table " + table + ":"); + this.table = table; + + // Initialize the renamer with all existing column names. + for (IDBField field : table.getFields()) + { + addNames(field.getName(), null); + } + } + + @Override + @SuppressWarnings("deprecation") + protected String getSQL(String oldName, String newName) + { + IDBField field = table.getField(oldName); + String restoreName = field.getName(); + field.setName(newName); + + try + { + return dbAdapter.sqlRenameField(field, oldName); + } + finally + { + field.setName(restoreName); + } + } + + @Override + protected void doRename(String oldName, String newName, int count) + { + super.doRename(oldName, newName, count); + + InternalDBSchema schema = (InternalDBSchema)accessor.getStore().getDBSchema(); + IDBField field = table.getField(oldName); + schema.unlock(); + + try + { + field.rename(newName); + } + finally + { + schema.lock(); + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBTablesPage.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBTablesPage.java new file mode 100644 index 0000000000..b0d38ef475 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBTablesPage.java @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2010-2013, 2015, 2016 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.db; + +import org.eclipse.emf.cdo.server.CDOServerBrowser; +import org.eclipse.emf.cdo.server.CDOServerBrowser.AbstractPage; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.db.DBException; +import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.IDBConnectionProvider; +import org.eclipse.net4j.db.ddl.IDBTable; +import org.eclipse.net4j.util.factory.ProductCreationException; + +import java.io.PrintStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.List; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class DBTablesPage extends AbstractPage +{ + private static final String PARAM_TABLE = "table"; + + private static final String NAME = "tables"; + + public DBTablesPage() + { + super(NAME, "DB Tables"); + } + + public boolean canDisplay(InternalRepository repository) + { + return repository.getStore() instanceof IDBConnectionProvider; + } + + public void display(CDOServerBrowser browser, InternalRepository repository, PrintStream out) + { + IDBConnectionProvider connectionProvider = (IDBConnectionProvider)repository.getStore(); + Connection connection = null; + + try + { + connection = connectionProvider.getConnection(); + + out.print("\r\n"); + out.print("\r\n"); + + out.print("\r\n"); + + if (table != null) + { + out.print("\r\n"); + } + + out.print("\r\n"); + out.print("
    \r\n"); + String table = showTables(browser, out, connection, repository.getName()); + out.print("\r\n"); + showTable(browser, out, connection, table); + out.print("
    \r\n"); + } + catch (DBException ex) + { + ex.printStackTrace(); + } + finally + { + DBUtil.close(connection); + } + } + + /** + * @since 4.0 + */ + protected String showTables(CDOServerBrowser browser, PrintStream pout, Connection connection, String repo) + { + String table = browser.getParam(PARAM_TABLE); + boolean used = browser.isParam("used"); + boolean schema = browser.isParam("schema"); + + pout.print("\r\n"); + pout.print( + "\r\n"); + pout.print("\r\n"); + pout.print("
    Empty tables:" + browser.href(used ? "Hidden" : "Shown", getName(), "used", String.valueOf(!used)) + "
    Row data:" + browser.href(schema ? "Hidden" : "Shown", getName(), "schema", String.valueOf(!schema)) + + "

    \r\n"); + + int totalRows = 0; + int usedTables = 0; + + List allTableNames = DBUtil.getAllTableNames(connection, repo); + for (String tableName : allTableNames) + { + if (table == null) + { + table = tableName; + } + + String label = browser.escape(tableName)/* .toLowerCase() */; + + int rowCount = DBUtil.getRowCount(connection, tableName); + if (rowCount > 0) + { + // label += " (" + rowCount + ")"; + totalRows += rowCount; + ++usedTables; + } + else if (used) + { + continue; + } + + if (tableName.equals(table)) + { + pout.print("" + label + ""); + } + else + { + pout.print(browser.href(label, getName(), PARAM_TABLE, tableName, "order", null, "direction", null)); + } + + if (rowCount > 0) + { + pout.print(" (" + rowCount + ")"); + } + + pout.print("
    \r\n"); + } + + if (totalRows != 0) + { + int totalTables = allTableNames.size(); + int emptyTables = totalTables - usedTables; + + pout.print("
    " + totalTables + " tables total\r\n"); + pout.print("
    " + usedTables + " tables used (" + totalRows + " rows)\r\n"); + pout.print("
    " + emptyTables + " tables empty
    \r\n"); + } + + return table; + } + + /** + * @since 4.0 + */ + protected void showTable(CDOServerBrowser browser, PrintStream pout, Connection connection, String table) + { + try + { + String order = browser.getParam("order"); + executeQuery(browser, pout, connection, table, + "SELECT * FROM " + table + (order == null ? "" : " ORDER BY " + order + " " + browser.getParam("direction"))); + } + catch (Exception ex) + { + browser.removeParam("order"); + browser.removeParam("direction"); + executeQuery(browser, pout, connection, table, "SELECT * FROM " + table); + } + } + + protected void executeQuery(CDOServerBrowser browser, PrintStream pout, Connection connection, String table, String sql) + { + String order = browser.getParam("order"); + String direction = browser.getParam("direction"); + String highlight = browser.getParam("highlight"); + boolean schema = browser.isParam("schema"); + + Statement stmt = null; + ResultSet resultSet = null; + + try + { + stmt = connection.createStatement(); + resultSet = stmt.executeQuery(sql); + + ResultSetMetaData metaData = resultSet.getMetaData(); + int columns = metaData.getColumnCount(); + + pout.print("\r\n"); + pout.print("\r\n"); + pout.print("\r\n"); + pout.print("\r\n"); + for (int i = 0; i < columns; i++) + { + String column = metaData.getColumnLabel(1 + i); + String type = metaData.getColumnTypeName(1 + i).toLowerCase() + "(" + metaData.getPrecision(1 + i) + ")"; + + String dir = column.equals(order) && "ASC".equals(direction) ? "DESC" : "ASC"; + pout.print("\r\n"); + } + + pout.print("\r\n"); + + if (!schema) + { + int row = 0; + while (resultSet.next()) + { + ++row; + pout.print("\r\n"); + pout.print("\r\n"); + for (int i = 0; i < columns; i++) + { + String value = resultSet.getString(1 + i); + String bgcolor = highlight != null && highlight.equals(value) ? " bgcolor=\"#fffca6\"" : ""; + pout.print("" + browser.href(value, getName(), "highlight", value) + "\r\n"); + } + + pout.print("\r\n"); + } + } + + pout.print("
    " + table + "
     " + browser.href(column, getName(), "order", column, "direction", dir)); + pout.print("
    " + type + "
    " + row + "
    \r\n"); + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + finally + { + DBUtil.close(resultSet); + DBUtil.close(stmt); + } + } + + public static String tableHRef(CDOServerBrowser browser, IDBTable table) + { + if (table == null) + { + return " "; + } + + String tableName = table.getName(); + return browser.href(tableName, NAME, PARAM_TABLE, tableName); + } + + /** + * @author Eike Stepper + */ + public static class Factory extends org.eclipse.net4j.util.factory.Factory + { + public static final String TYPE = "dbtables"; + + public Factory() + { + super(PRODUCT_GROUP, TYPE); + } + + public DBTablesPage create(String description) throws ProductCreationException + { + return new DBTablesPage(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/IObjectTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/IObjectTypeMapper.java index 642ecdd06d..03791515dd 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/IObjectTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/IObjectTypeMapper.java @@ -37,6 +37,8 @@ public interface IObjectTypeMapper public boolean removeObjectType(IDBStoreAccessor accessor, CDOID id); + public int changeObjectType(IDBStoreAccessor accessor, EClass oldType, EClass newType); + /** * Return the maximum object id managed by this cache. * diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java index 6dc45c79bd..b6f410f929 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java @@ -38,6 +38,7 @@ import org.eclipse.net4j.db.IDBPreparedStatement; import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability; import org.eclipse.net4j.db.IDBRowHandler; import org.eclipse.net4j.util.lifecycle.Lifecycle; +import org.eclipse.net4j.util.om.OMPlatform; import org.eclipse.net4j.util.om.monitor.Monitor; import org.eclipse.net4j.util.om.monitor.OMMonitor; import org.eclipse.net4j.util.om.monitor.OMMonitor.Async; @@ -65,9 +66,9 @@ import java.util.Map.Entry; */ public class MetaDataManager extends Lifecycle implements IMetaDataManager { - private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, MetaDataManager.class); + public static final boolean ZIP_PACKAGE_BYTES = OMPlatform.INSTANCE.isProperty("org.eclipse.emf.cdo.server.db.zipPackageBytes", true); - private static final boolean ZIP_PACKAGE_BYTES = true; + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, MetaDataManager.class); private IDBStore store; @@ -123,7 +124,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager { String where = CDODBSchema.PACKAGE_UNITS_ID.getName() + "='" + packageUnit.getID() + "'"; //$NON-NLS-1$ //$NON-NLS-2$ Object[] values = DBUtil.select(connection, where, CDODBSchema.PACKAGE_UNITS_PACKAGE_DATA); - byte[] bytes = (byte[])values[0]; + byte[] bytes = ZIP_PACKAGE_BYTES ? (byte[])values[0] : ((String)values[0]).getBytes(); EPackage ePackage = createEPackage(packageUnit, bytes); return EMFUtil.getAllPackages(ePackage); } @@ -133,96 +134,101 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager return readPackageUnits(connection, CDOBranchPoint.UNSPECIFIED_DATE, CDOBranchPoint.UNSPECIFIED_DATE, new Monitor()); } - public final void writePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) + private Collection readPackageUnits(Connection connection, long fromCommitTime, long toCommitTime, OMMonitor monitor) { - try + final Map packageUnits = new HashMap(); + IDBRowHandler unitRowHandler = new IDBRowHandler() { - monitor.begin(2); - fillSystemTables((IDBConnection)connection, packageUnits, monitor.fork()); - } - finally + public boolean handle(int row, final Object... values) + { + int index = DBUtil.asInt(values[1]); + long timestamp = DBUtil.asLong(values[2]); + + InternalCDOPackageUnit packageUnit = createPackageUnit(); + packageUnit.setOriginalType(CDOPackageUnit.Type.values()[index]); + packageUnit.setTimeStamp(timestamp); + + packageUnits.put((String)values[0], packageUnit); + return true; + } + }; + + String where = null; + if (fromCommitTime != CDOBranchPoint.UNSPECIFIED_DATE) { - monitor.done(); + where = CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.CORE_PACKAGE_URI + "' AND " + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + + CDOModelConstants.RESOURCE_PACKAGE_URI + "' AND " + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.TYPES_PACKAGE_URI + "' AND " + + CDODBSchema.PACKAGE_UNITS_TIME_STAMP + " BETWEEN " + fromCommitTime + " AND " + toCommitTime; } - } - public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime) throws IOException - { - // Export package units - String where = " WHERE p_u." + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.CORE_PACKAGE_URI + // - "' AND p_u." + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.RESOURCE_PACKAGE_URI + // - "' AND p_u." + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.TYPES_PACKAGE_URI + // - "' AND p_u." + CDODBSchema.PACKAGE_UNITS_TIME_STAMP + " BETWEEN " + fromCommitTime + " AND " + toCommitTime; - DBUtil.serializeTable(out, connection, CDODBSchema.PACKAGE_UNITS, "p_u", where); + DBUtil.select(connection, unitRowHandler, where, CDODBSchema.PACKAGE_UNITS_ID, CDODBSchema.PACKAGE_UNITS_ORIGINAL_TYPE, + CDODBSchema.PACKAGE_UNITS_TIME_STAMP); - // Export package infos - String join = ", " + CDODBSchema.PACKAGE_UNITS + " p_u" + where + " AND p_i." + CDODBSchema.PACKAGE_INFOS_UNIT + "=p_u." + CDODBSchema.PACKAGE_UNITS_ID; - DBUtil.serializeTable(out, connection, CDODBSchema.PACKAGE_INFOS, "p_i", join); - } + final Map> packageInfos = new HashMap>(); + IDBRowHandler infoRowHandler = new IDBRowHandler() + { + public boolean handle(int row, final Object... values) + { + InternalCDOPackageInfo packageInfo = createPackageInfo(); + packageInfo.setPackageURI((String)values[1]); + packageInfo.setParentURI((String)values[2]); - public Collection rawImport(Connection connection, CDODataInput in, long fromCommitTime, long toCommitTime, OMMonitor monitor) - throws IOException - { - monitor.begin(3); + String unit = (String)values[0]; + List list = packageInfos.get(unit); + if (list == null) + { + list = new ArrayList(); + packageInfos.put(unit, list); + } + + list.add(packageInfo); + return true; + } + }; + + monitor.begin(); + Async async = monitor.forkAsync(); try { - DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_UNITS, monitor.fork()); - DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_INFOS, monitor.fork()); - return readPackageUnits(connection, fromCommitTime, toCommitTime, monitor.fork()); + DBUtil.select(connection, infoRowHandler, CDODBSchema.PACKAGE_INFOS_UNIT, CDODBSchema.PACKAGE_INFOS_URI, CDODBSchema.PACKAGE_INFOS_PARENT); } finally { + async.stop(); monitor.done(); } - } - protected IDBStore getStore() - { - return store; - } - - @Override - protected void doBeforeActivate() throws Exception - { - checkState(store, "Store is not set"); //$NON-NLS-1$ - } - - @Override - protected void doDeactivate() throws Exception - { - clearMetaIDMappings(); - super.doDeactivate(); - } - - protected InternalCDOPackageInfo createPackageInfo() - { - return (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo(); - } - - protected InternalCDOPackageUnit createPackageUnit() - { - return (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit(); - } + for (Entry entry : packageUnits.entrySet()) + { + String id = entry.getKey(); + InternalCDOPackageUnit packageUnit = entry.getValue(); - private InternalCDOPackageRegistry getPackageRegistry() - { - return (InternalCDOPackageRegistry)store.getRepository().getPackageRegistry(); - } + List list = packageInfos.get(id); + InternalCDOPackageInfo[] array = list.toArray(new InternalCDOPackageInfo[list.size()]); + packageUnit.setPackageInfos(array); + } - private EPackage createEPackage(InternalCDOPackageUnit packageUnit, byte[] bytes) - { - ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(getPackageRegistry()); - return EMFUtil.createEPackage(packageUnit.getID(), bytes, ZIP_PACKAGE_BYTES, resourceSet, false); + return packageUnits.values(); } - private byte[] getEPackageBytes(InternalCDOPackageUnit packageUnit) + public final void writePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) { - EPackage ePackage = packageUnit.getTopLevelPackageInfo().getEPackage(); - return EMFUtil.getEPackageBytes(ePackage, ZIP_PACKAGE_BYTES, getPackageRegistry()); + try + { + monitor.begin(packageUnits.length); + for (InternalCDOPackageUnit packageUnit : packageUnits) + { + writePackageUnit((IDBConnection)connection, packageUnit, monitor.fork()); + } + } + finally + { + monitor.done(); + } } - private void fillSystemTables(IDBConnection connection, InternalCDOPackageUnit packageUnit, OMMonitor monitor) + private void writePackageUnit(IDBConnection connection, InternalCDOPackageUnit packageUnit, OMMonitor monitor) { if (TRACER.isEnabled()) { @@ -230,7 +236,6 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager } InternalCDOPackageInfo[] packageInfos = packageUnit.getPackageInfos(); - Async async = null; monitor.begin(1 + packageInfos.length); try @@ -241,6 +246,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager DBUtil.trace(sql); IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM); + Async async = null; try { @@ -248,7 +254,15 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager stmt.setString(1, packageUnit.getID()); stmt.setInt(2, packageUnit.getOriginalType().ordinal()); stmt.setLong(3, packageUnit.getTimeStamp()); - stmt.setBytes(4, getEPackageBytes(packageUnit)); + + if (ZIP_PACKAGE_BYTES) + { + stmt.setBytes(4, getEPackageBytes(packageUnit)); + } + else + { + stmt.setString(4, new String(getEPackageBytes(packageUnit))); + } if (stmt.execute()) { @@ -275,7 +289,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager for (InternalCDOPackageInfo packageInfo : packageInfos) { - fillSystemTables(connection, packageInfo, monitor); // Don't fork monitor + writePackageInfo(connection, packageInfo, monitor); // Don't fork monitor } } finally @@ -284,23 +298,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager } } - private void fillSystemTables(IDBConnection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) - { - try - { - monitor.begin(packageUnits.length); - for (InternalCDOPackageUnit packageUnit : packageUnits) - { - fillSystemTables(connection, packageUnit, monitor.fork()); - } - } - finally - { - monitor.done(); - } - } - - private void fillSystemTables(IDBConnection connection, InternalCDOPackageInfo packageInfo, OMMonitor monitor) + private void writePackageInfo(IDBConnection connection, InternalCDOPackageInfo packageInfo, OMMonitor monitor) { if (TRACER.isEnabled()) { @@ -348,82 +346,194 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager } } - private Collection readPackageUnits(Connection connection, long fromCommitTime, long toCommitTime, OMMonitor monitor) + public final void deletePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) { - final Map packageUnits = new HashMap(); - IDBRowHandler unitRowHandler = new IDBRowHandler() + try { - public boolean handle(int row, final Object... values) + monitor.begin(packageUnits.length); + for (InternalCDOPackageUnit packageUnit : packageUnits) { - int index = DBUtil.asInt(values[1]); - long timestamp = DBUtil.asLong(values[2]); - - InternalCDOPackageUnit packageUnit = createPackageUnit(); - packageUnit.setOriginalType(CDOPackageUnit.Type.values()[index]); - packageUnit.setTimeStamp(timestamp); - - packageUnits.put((String)values[0], packageUnit); - return true; + deletePackageUnit((IDBConnection)connection, packageUnit, monitor.fork()); } - }; + } + finally + { + monitor.done(); + } + } - String where = null; - if (fromCommitTime != CDOBranchPoint.UNSPECIFIED_DATE) + private void deletePackageUnit(IDBConnection connection, InternalCDOPackageUnit packageUnit, OMMonitor monitor) + { + if (TRACER.isEnabled()) { - where = CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.CORE_PACKAGE_URI + "' AND " + CDODBSchema.PACKAGE_UNITS_ID + "<>'" - + CDOModelConstants.RESOURCE_PACKAGE_URI + "' AND " + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.TYPES_PACKAGE_URI + "' AND " - + CDODBSchema.PACKAGE_UNITS_TIME_STAMP + " BETWEEN " + fromCommitTime + " AND " + toCommitTime; + TRACER.format("Deleting package unit: {0}", packageUnit); //$NON-NLS-1$ } - DBUtil.select(connection, unitRowHandler, where, CDODBSchema.PACKAGE_UNITS_ID, CDODBSchema.PACKAGE_UNITS_ORIGINAL_TYPE, - CDODBSchema.PACKAGE_UNITS_TIME_STAMP); + InternalCDOPackageInfo[] packageInfos = packageUnit.getPackageInfos(); + monitor.begin(1 + packageInfos.length); - final Map> packageInfos = new HashMap>(); - IDBRowHandler infoRowHandler = new IDBRowHandler() + try { - public boolean handle(int row, final Object... values) + String sql = "DELETE FROM " + CDODBSchema.PACKAGE_UNITS + " WHERE " + CDODBSchema.PACKAGE_UNITS_ID + "=?"; + DBUtil.trace(sql); + + IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.LOW); + Async async = null; + + try { - InternalCDOPackageInfo packageInfo = createPackageInfo(); - packageInfo.setPackageURI((String)values[1]); - packageInfo.setParentURI((String)values[2]); + async = monitor.forkAsync(); + stmt.setString(1, packageUnit.getID()); - String unit = (String)values[0]; - List list = packageInfos.get(unit); - if (list == null) + if (stmt.execute()) { - list = new ArrayList(); - packageInfos.put(unit, list); + throw new DBException("No result set expected"); //$NON-NLS-1$ } - list.add(packageInfo); - return true; + if (stmt.getUpdateCount() == 0) + { + throw new DBException("No row deleted from table " + CDODBSchema.PACKAGE_UNITS); //$NON-NLS-1$ + } + } + catch (SQLException ex) + { + throw new DBException(ex); + } + finally + { + DBUtil.close(stmt); + if (async != null) + { + async.stop(); + } } - }; - monitor.begin(); + for (InternalCDOPackageInfo packageInfo : packageInfos) + { + deletePackageInfo(connection, packageInfo, monitor); // Don't fork monitor + } + } + finally + { + monitor.done(); + } + } + + private void deletePackageInfo(IDBConnection connection, InternalCDOPackageInfo packageInfo, OMMonitor monitor) + { + if (TRACER.isEnabled()) + { + TRACER.format("Deleting package info: {0}", packageInfo); //$NON-NLS-1$ + } + + String sql = "DELETE FROM " + CDODBSchema.PACKAGE_INFOS + " WHERE " + CDODBSchema.PACKAGE_INFOS_URI + "=?"; + DBUtil.trace(sql); + + IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.LOW); Async async = monitor.forkAsync(); try { - DBUtil.select(connection, infoRowHandler, CDODBSchema.PACKAGE_INFOS_UNIT, CDODBSchema.PACKAGE_INFOS_URI, CDODBSchema.PACKAGE_INFOS_PARENT); + stmt.setString(1, packageInfo.getPackageURI()); + + if (stmt.execute()) + { + throw new DBException("No result set expected"); //$NON-NLS-1$ + } + + if (stmt.getUpdateCount() == 0) + { + throw new DBException("No row deleted from table " + CDODBSchema.PACKAGE_INFOS); //$NON-NLS-1$ + } + } + catch (SQLException ex) + { + throw new DBException(ex); } finally { - async.stop(); - monitor.done(); + DBUtil.close(stmt); + if (async != null) + { + async.stop(); + } } + } - for (Entry entry : packageUnits.entrySet()) - { - String id = entry.getKey(); - InternalCDOPackageUnit packageUnit = entry.getValue(); + public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime) throws IOException + { + // Export package units + String where = " WHERE p_u." + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.CORE_PACKAGE_URI + // + "' AND p_u." + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.RESOURCE_PACKAGE_URI + // + "' AND p_u." + CDODBSchema.PACKAGE_UNITS_ID + "<>'" + CDOModelConstants.TYPES_PACKAGE_URI + // + "' AND p_u." + CDODBSchema.PACKAGE_UNITS_TIME_STAMP + " BETWEEN " + fromCommitTime + " AND " + toCommitTime; + DBUtil.serializeTable(out, connection, CDODBSchema.PACKAGE_UNITS, "p_u", where); - List list = packageInfos.get(id); - InternalCDOPackageInfo[] array = list.toArray(new InternalCDOPackageInfo[list.size()]); - packageUnit.setPackageInfos(array); + // Export package infos + String join = ", " + CDODBSchema.PACKAGE_UNITS + " p_u" + where + " AND p_i." + CDODBSchema.PACKAGE_INFOS_UNIT + "=p_u." + CDODBSchema.PACKAGE_UNITS_ID; + DBUtil.serializeTable(out, connection, CDODBSchema.PACKAGE_INFOS, "p_i", join); + } + + public Collection rawImport(Connection connection, CDODataInput in, long fromCommitTime, long toCommitTime, OMMonitor monitor) + throws IOException + { + monitor.begin(3); + + try + { + DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_UNITS, monitor.fork()); + DBUtil.deserializeTable(in, connection, CDODBSchema.PACKAGE_INFOS, monitor.fork()); + return readPackageUnits(connection, fromCommitTime, toCommitTime, monitor.fork()); + } + finally + { + monitor.done(); } + } - return packageUnits.values(); + protected IDBStore getStore() + { + return store; + } + + @Override + protected void doBeforeActivate() throws Exception + { + checkState(store, "Store is not set"); //$NON-NLS-1$ + } + + @Override + protected void doDeactivate() throws Exception + { + clearMetaIDMappings(); + super.doDeactivate(); + } + + protected InternalCDOPackageInfo createPackageInfo() + { + return (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo(); + } + + protected InternalCDOPackageUnit createPackageUnit() + { + return (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit(); + } + + private InternalCDOPackageRegistry getPackageRegistry() + { + return (InternalCDOPackageRegistry)store.getRepository().getPackageRegistry(); + } + + private EPackage createEPackage(InternalCDOPackageUnit packageUnit, byte[] bytes) + { + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(getPackageRegistry()); + return EMFUtil.createEPackage(packageUnit.getID(), bytes, ZIP_PACKAGE_BYTES, resourceSet, false); + } + + private byte[] getEPackageBytes(InternalCDOPackageUnit packageUnit) + { + EPackage ePackage = packageUnit.getTopLevelPackageInfo().getEPackage(); + return EMFUtil.getEPackageBytes(ePackage, ZIP_PACKAGE_BYTES, getPackageRegistry()); } private void cacheMetaIDMapping(EModelElement modelElement, CDOID metaID) diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java index d7fae2b37c..d629db7579 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/AbstractMappingStrategy.java @@ -17,20 +17,19 @@ package org.eclipse.emf.cdo.server.internal.db.mapping; import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOFeatureType; -import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.common.model.CDOPackageInfo; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; -import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext; -import org.eclipse.emf.cdo.server.StoreThreadLocal; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IMetaDataManager; import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; import org.eclipse.emf.cdo.server.db.mapping.IListMapping; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy3; +import org.eclipse.emf.cdo.server.db.mapping.INamingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.DBAnnotation; import org.eclipse.emf.cdo.server.internal.db.ObjectIDIterator; @@ -45,8 +44,6 @@ import org.eclipse.net4j.db.DBException; import org.eclipse.net4j.db.DBUtil; import org.eclipse.net4j.db.ddl.IDBSchema; import org.eclipse.net4j.db.ddl.IDBTable; -import org.eclipse.net4j.util.ImplementationError; -import org.eclipse.net4j.util.StringUtil; import org.eclipse.net4j.util.collection.CloseableIterator; import org.eclipse.net4j.util.lifecycle.Lifecycle; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; @@ -55,20 +52,19 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor.Async; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EModelElement; import org.eclipse.emf.ecore.ENamedElement; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.util.FeatureMapUtil; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -81,32 +77,16 @@ import java.util.concurrent.ConcurrentMap; * @author Eike Stepper * @since 2.0 */ -public abstract class AbstractMappingStrategy extends Lifecycle implements IMappingStrategy +public abstract class AbstractMappingStrategy extends Lifecycle implements IMappingStrategy3 { - // --------- database name generation strings -------------- - protected static final String NAME_SEPARATOR = "_"; //$NON-NLS-1$ - - protected static final String TYPE_PREFIX_FEATURE = "F"; //$NON-NLS-1$ - - protected static final String TYPE_PREFIX_CLASS = "C"; //$NON-NLS-1$ - - protected static final String TYPE_PREFIX_PACKAGE = "P"; //$NON-NLS-1$ - - protected static final String GENERAL_PREFIX = "X"; //$NON-NLS-1$ - - protected static final String GENERAL_SUFFIX = "0"; //$NON-NLS-1$ - - /** - * Prefix for unsettable feature helper columns - */ - protected static final String CDO_SET_PREFIX = "cdo_set_"; //$NON-NLS-1$ - - protected static final String FEATURE_TABLE_SUFFIX = "_list"; //$NON-NLS-1$ + private static final ThreadLocal SKIP_MAPPING_INITIALIZATION = new ThreadLocal(); private IDBStore store; private Map properties; + private INamingStrategy namingStrategy; + private ConcurrentMap classMappings; private boolean allClassMappingsCreated; @@ -135,34 +115,15 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp this.properties = properties; } - public int getMaxTableNameLength() + public INamingStrategy getNamingStrategy() { - String value = getProperties().get(Props.MAX_TABLE_NAME_LENGTH); - return value == null ? store.getDBAdapter().getMaxTableNameLength() : Integer.valueOf(value); + return namingStrategy; } - public int getMaxFieldNameLength() + public void setNamingStrategy(INamingStrategy namingStrategy) { - String value = getProperties().get(Props.MAX_FIELD_NAME_LENGTH); - return value == null ? store.getDBAdapter().getMaxFieldNameLength() : Integer.valueOf(value); - } - - public boolean isQualifiedNames() - { - String value = getProperties().get(Props.QUALIFIED_NAMES); - return value == null ? false : Boolean.valueOf(value); - } - - public boolean isForceNamesWithID() - { - String value = getProperties().get(Props.FORCE_NAMES_WITH_ID); - return value == null ? false : Boolean.valueOf(value); - } - - public String getTableNamePrefix() - { - String value = getProperties().get(Props.TABLE_NAME_PREFIX); - return StringUtil.safe(value); + checkInactive(); + this.namingStrategy = namingStrategy; } public Set getForceIndexes() @@ -297,167 +258,24 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp protected abstract Collection getClassesWithObjectInfo(); - // -- database name demangling methods --------------------------------- - - private String getTableNamePrefix(EModelElement element) - { - String prefix = StringUtil.safe(DBAnnotation.TABLE_NAME_PREFIX.getValue(element)); - if (prefix.length() != 0 && !prefix.endsWith(NAME_SEPARATOR)) - { - prefix += NAME_SEPARATOR; - } - - EObject eContainer = element.eContainer(); - if (eContainer instanceof EModelElement) - { - EModelElement parent = (EModelElement)eContainer; - prefix = getTableNamePrefix(parent) + prefix; - } - - return prefix; - } - public String getTableName(ENamedElement element) { - String name = null; - String typePrefix = null; - - if (element instanceof EClass) - { - typePrefix = TYPE_PREFIX_CLASS; - name = DBAnnotation.TABLE_NAME.getValue(element); - if (name == null) - { - name = isQualifiedNames() ? EMFUtil.getQualifiedName((EClass)element, NAME_SEPARATOR) : element.getName(); - } - } - else if (element instanceof EPackage) - { - typePrefix = TYPE_PREFIX_PACKAGE; - name = DBAnnotation.TABLE_NAME.getValue(element); - if (name == null) - { - name = isQualifiedNames() ? EMFUtil.getQualifiedName((EPackage)element, NAME_SEPARATOR) : element.getName(); - } - } - else - { - throw new ImplementationError("Unknown element: " + element); //$NON-NLS-1$ - } - - String prefix = getTableNamePrefix(); - if (prefix.length() != 0 && !prefix.endsWith(NAME_SEPARATOR)) - { - prefix += NAME_SEPARATOR; - } - - prefix += getTableNamePrefix(element); - - String suffix = typePrefix + getUniqueID(element); - int maxTableNameLength = getMaxTableNameLength(); - - return getName(prefix + name, suffix, maxTableNameLength); + return namingStrategy.getTableName(element); } - public String getTableName(EClass eClass, EStructuralFeature feature) + public String getTableName(EClass containingClass, EStructuralFeature feature) { - String name = DBAnnotation.TABLE_NAME.getValue(eClass); - if (name == null) - { - name = isQualifiedNames() ? EMFUtil.getQualifiedName(eClass, NAME_SEPARATOR) : eClass.getName(); - } - - name += NAME_SEPARATOR; - name += feature.getName(); - name += FEATURE_TABLE_SUFFIX; - - String prefix = getTableNamePrefix(); - if (prefix.length() != 0 && !prefix.endsWith(NAME_SEPARATOR)) - { - prefix += NAME_SEPARATOR; - } - - prefix += getTableNamePrefix(feature); - - String suffix = TYPE_PREFIX_FEATURE + getUniqueID(feature); - int maxTableNameLength = getMaxTableNameLength(); - - return getName(prefix + name, suffix, maxTableNameLength); + return namingStrategy.getTableName(containingClass, feature); } public String getFieldName(EStructuralFeature feature) { - String name = DBAnnotation.COLUMN_NAME.getValue(feature); - if (name == null) - { - name = getName(feature.getName(), TYPE_PREFIX_FEATURE + getUniqueID(feature), getMaxFieldNameLength()); - } - - return name; + return namingStrategy.getFieldName(feature); } public String getUnsettableFieldName(EStructuralFeature feature) { - String name = DBAnnotation.COLUMN_NAME.getValue(feature); - if (name != null) - { - return CDO_SET_PREFIX + name; - } - - return getName(CDO_SET_PREFIX + feature.getName(), TYPE_PREFIX_FEATURE + getUniqueID(feature), getMaxFieldNameLength()); - } - - private String getName(String name, String suffix, int maxLength) - { - if (!store.getDBAdapter().isValidFirstChar(name.charAt(0))) - { - name = GENERAL_PREFIX + name; - } - - boolean forceNamesWithID = isForceNamesWithID(); - if (!forceNamesWithID && store.getDBAdapter().isReservedWord(name)) - { - name = name + GENERAL_SUFFIX; - } - - if (name.length() > maxLength || forceNamesWithID) - { - suffix = NAME_SEPARATOR + suffix.replace('-', 'S'); - int length = Math.min(name.length(), maxLength - suffix.length()); - if (length < 0) - { - // Most likely CDOIDs are client side-assigned, i.e., meta IDs are extrefs. See getUniqueID() - throw new IllegalStateException("Suffix is too long: " + suffix); - } - - name = name.substring(0, length) + suffix; - } - - return name; - } - - private String getUniqueID(ENamedElement element) - { - long timeStamp; - CommitContext commitContext = StoreThreadLocal.getCommitContext(); - if (commitContext != null) - { - timeStamp = commitContext.getBranchPoint().getTimeStamp(); - } - else - { - // This happens outside a commit, i.e. at system init time. - // Ensure that resulting ext refs are not replicated! - timeStamp = CDOBranchPoint.INVALID_DATE; - // timeStamp = getStore().getRepository().getTimeStamp(); - } - - IMetaDataManager metaDataManager = getMetaDataManager(); - CDOID result = metaDataManager.getMetaID(element, timeStamp); - - StringBuilder builder = new StringBuilder(); - CDOIDUtil.write(builder, result); - return builder.toString(); + return namingStrategy.getUnsettableFieldName(feature); } public void createMapping(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) @@ -471,7 +289,11 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp { async = monitor.forkAsync(); - mapPackageUnits(packageUnits, connection, false); + for (EClass eClass : getMappedClasses(packageUnits)) + { + IClassMapping classMapping = createClassMapping(eClass); + addClassMapping(classMapping); + } } } finally @@ -487,88 +309,73 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp public void removeMapping(Connection connection, InternalCDOPackageUnit[] packageUnits) { - mapPackageUnits(packageUnits, connection, true); - } - - protected Set mapPackageUnits(InternalCDOPackageUnit[] packageUnits, Connection connection, boolean unmap) - { - Set classMappings = new HashSet(); - - if (packageUnits != null && packageUnits.length != 0) + for (EClass eClass : getMappedClasses(packageUnits)) { - for (InternalCDOPackageUnit packageUnit : packageUnits) - { - InternalCDOPackageInfo[] packageInfos = packageUnit.getPackageInfos(); - mapPackageInfos(packageInfos, connection, unmap, classMappings); - } + removeClassMapping(eClass); } - - return classMappings; } - private void mapPackageInfos(InternalCDOPackageInfo[] packageInfos, Connection connection, boolean unmap, Set classMappings) + public boolean isMapped(EClass eClass) { - for (InternalCDOPackageInfo packageInfo : packageInfos) - { - EPackage ePackage = packageInfo.getEPackage(); - EClass[] persistentClasses = EMFUtil.getPersistentClasses(ePackage); - mapClasses(connection, unmap, persistentClasses, classMappings); - } + String mappingAnnotation = DBAnnotation.TABLE_MAPPING.getValue(eClass); + return mappingAnnotation == null || mappingAnnotation.equalsIgnoreCase(DBAnnotation.TABLE_MAPPING_NONE); } - private void mapClasses(Connection connection, boolean unmap, EClass[] eClasses, Set classMappings) + public List getMappedClasses(CDOPackageUnit[] packageUnits) { - for (EClass eClass : eClasses) + List result = new ArrayList(); + + if (packageUnits != null && packageUnits.length != 0) { - if (!(eClass.isInterface() || eClass.isAbstract())) + for (CDOPackageUnit packageUnit : packageUnits) { - String mappingAnnotation = DBAnnotation.TABLE_MAPPING.getValue(eClass); - - // TODO Maybe we should explicitly report unknown values of the annotation - if (mappingAnnotation != null && mappingAnnotation.equalsIgnoreCase(DBAnnotation.TABLE_MAPPING_NONE)) + for (CDOPackageInfo packageInfo : packageUnit.getPackageInfos()) { - continue; - } - - IClassMapping classMapping = unmap ? removeClassMapping(eClass) : createClassMapping(eClass); - if (classMapping != null) - { - classMappings.add(classMapping); + for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers()) + { + if (classifier instanceof EClass) + { + EClass eClass = (EClass)classifier; + if (isMapped(eClass)) + { + result.add(eClass); + } + } + } } } } + + return result; } - private IClassMapping createClassMapping(EClass eClass) + private void addClassMapping(IClassMapping classMapping) { - IClassMapping classMapping = doCreateClassMapping(eClass); if (classMapping != null) { + EClass eClass = classMapping.getEClass(); classMappings.put(eClass, classMapping); } - - return classMapping; } private IClassMapping removeClassMapping(EClass eClass) { - IClassMapping classMapping = classMappings.get(eClass); + IClassMapping classMapping = classMappings.remove(eClass); if (classMapping != null) { IDBSchema schema = getStore().getDBSchema(); for (IDBTable table : classMapping.getDBTables()) { - schema.removeTable(table.getName()); + if (table != null) + { + schema.removeTable(table.getName()); + } } - - classMappings.remove(eClass); } return classMapping; } - protected abstract IClassMapping doCreateClassMapping(EClass eClass); - public final IClassMapping getClassMapping(EClass eClass) { if (!isMapped(eClass)) @@ -591,6 +398,7 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp if (result == null) { result = createClassMapping(eClass); + addClassMapping(result); } } } @@ -604,11 +412,6 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp } public final Map getClassMappings(boolean createOnDemand) - { - return doGetClassMappings(createOnDemand); - } - - public final Map doGetClassMappings(boolean createOnDemand) { if (createOnDemand) { @@ -616,7 +419,7 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp { if (!allClassMappingsCreated) { - createAllClassMappings(); + ensureAllClassMappings(); allClassMappingsCreated = true; } } @@ -625,7 +428,7 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp return classMappings; } - private void createAllClassMappings() + private void ensureAllClassMappings() { InternalRepository repository = (InternalRepository)getStore().getRepository(); InternalCDOPackageRegistry packageRegistry = repository.getPackageRegistry(false); @@ -645,7 +448,14 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp } } - protected abstract boolean isMapped(EClass eClass); + public void clearClassMappings() + { + synchronized (classMappings) + { + classMappings.clear(); + allClassMappingsCreated = false; + } + } public ITypeMapping createValueMapping(EStructuralFeature feature) { @@ -678,9 +488,24 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp @Deprecated public abstract IListMapping doCreateFeatureMapMapping(EClass containingClass, EStructuralFeature feature); + @Override + protected void doActivate() throws Exception + { + super.doActivate(); + + if (namingStrategy == null) + { + namingStrategy = new DefaultNamingStrategy(); + } + + namingStrategy.initialize(this); + LifecycleUtil.activate(namingStrategy); + } + @Override protected void doDeactivate() throws Exception { + LifecycleUtil.deactivate(namingStrategy); deactivateClassMappings(); super.doDeactivate(); } @@ -717,4 +542,28 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp String value = mappingStrategy.getProperties().get(Props.EAGER_TABLE_CREATION); return value == null ? false : Boolean.valueOf(value); } + + public static boolean isSkipMappingInitialization() + { + return SKIP_MAPPING_INITIALIZATION.get() == Boolean.TRUE; + } + + public static boolean setSkipMappingInitialization(boolean value) + { + boolean oldValue = isSkipMappingInitialization(); + + if (value != oldValue) + { + if (value) + { + SKIP_MAPPING_INITIALIZATION.set(Boolean.TRUE); + } + else + { + SKIP_MAPPING_INITIALIZATION.remove(); + } + } + + return oldValue; + } } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/DefaultNamingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/DefaultNamingStrategy.java new file mode 100644 index 0000000000..90002954c5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/DefaultNamingStrategy.java @@ -0,0 +1,293 @@ +/* + * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others. + * 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: + * Eike Stepper - initial API and implementation + */ +package org.eclipse.emf.cdo.server.internal.db.mapping; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.server.IStoreAccessor.CommitContext; +import org.eclipse.emf.cdo.server.StoreThreadLocal; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.server.db.mapping.INamingStrategy; +import org.eclipse.emf.cdo.server.internal.db.DBAnnotation; + +import org.eclipse.net4j.util.StringUtil; +import org.eclipse.net4j.util.factory.ProductCreationException; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class DefaultNamingStrategy implements INamingStrategy +{ + public static final String NAME_SEPARATOR = "_"; //$NON-NLS-1$ + + public static final String TYPE_PREFIX_FEATURE = "F"; //$NON-NLS-1$ + + public static final String TYPE_PREFIX_CLASS = "C"; //$NON-NLS-1$ + + public static final String TYPE_PREFIX_PACKAGE = "P"; //$NON-NLS-1$ + + public static final String GENERAL_PREFIX = "X"; //$NON-NLS-1$ + + public static final String GENERAL_SUFFIX = "0"; //$NON-NLS-1$ + + /** + * Prefix for unsettable feature helper columns. + */ + public static final String CDO_SET_PREFIX = "cdo_set_"; //$NON-NLS-1$ + + public static final String FEATURE_TABLE_SUFFIX = "_list"; //$NON-NLS-1$ + + private IMappingStrategy mappingStrategy; + + public DefaultNamingStrategy() + { + } + + public void initialize(IMappingStrategy mappingStrategy) + { + this.mappingStrategy = mappingStrategy; + } + + public String getTableName(ENamedElement element) + { + String name = null; + String typePrefix = null; + + if (element instanceof EClass) + { + typePrefix = TYPE_PREFIX_CLASS; + name = DBAnnotation.TABLE_NAME.getValue(element); + if (name == null) + { + name = isQualifiedNames() ? EMFUtil.getQualifiedName((EClass)element, NAME_SEPARATOR) : element.getName(); + } + } + else if (element instanceof EPackage) + { + typePrefix = TYPE_PREFIX_PACKAGE; + name = DBAnnotation.TABLE_NAME.getValue(element); + if (name == null) + { + name = isQualifiedNames() ? EMFUtil.getQualifiedName((EPackage)element, NAME_SEPARATOR) : element.getName(); + } + } + else + { + throw new IllegalArgumentException("Unknown element: " + element); //$NON-NLS-1$ + } + + String prefix = getTableNamePrefix(); + if (prefix.length() != 0 && !prefix.endsWith(NAME_SEPARATOR)) + { + prefix += NAME_SEPARATOR; + } + + prefix += getTableNamePrefix(element); + + String suffix = typePrefix + getUniqueID(element); + int maxTableNameLength = getMaxTableNameLength(); + + return getName(prefix + name, suffix, maxTableNameLength); + } + + public String getTableName(EClass eClass, EStructuralFeature feature) + { + String name = DBAnnotation.TABLE_NAME.getValue(eClass); + if (name == null) + { + name = isQualifiedNames() ? EMFUtil.getQualifiedName(eClass, NAME_SEPARATOR) : eClass.getName(); + } + + name += NAME_SEPARATOR; + name += feature.getName(); + name += FEATURE_TABLE_SUFFIX; + + String prefix = getTableNamePrefix(); + if (prefix.length() != 0 && !prefix.endsWith(NAME_SEPARATOR)) + { + prefix += NAME_SEPARATOR; + } + + prefix += getTableNamePrefix(feature); + + String suffix = TYPE_PREFIX_FEATURE + getUniqueID(feature); + int maxTableNameLength = getMaxTableNameLength(); + + return getName(prefix + name, suffix, maxTableNameLength); + } + + public String getFieldName(EStructuralFeature feature) + { + String name = DBAnnotation.COLUMN_NAME.getValue(feature); + if (name == null) + { + name = getName(feature.getName(), TYPE_PREFIX_FEATURE + getUniqueID(feature), getMaxFieldNameLength()); + } + + return name; + } + + public String getUnsettableFieldName(EStructuralFeature feature) + { + String name = DBAnnotation.COLUMN_NAME.getValue(feature); + if (name != null) + { + return CDO_SET_PREFIX + name; + } + + return getName(CDO_SET_PREFIX + feature.getName(), TYPE_PREFIX_FEATURE + getUniqueID(feature), getMaxFieldNameLength()); + } + + protected int getMaxTableNameLength() + { + String value = mappingStrategy.getProperties().get(IMappingStrategy.Props.MAX_TABLE_NAME_LENGTH); + return value == null ? mappingStrategy.getStore().getDBAdapter().getMaxTableNameLength() : Integer.valueOf(value); + } + + protected int getMaxFieldNameLength() + { + String value = mappingStrategy.getProperties().get(IMappingStrategy.Props.MAX_FIELD_NAME_LENGTH); + return value == null ? mappingStrategy.getStore().getDBAdapter().getMaxFieldNameLength() : Integer.valueOf(value); + } + + protected boolean isQualifiedNames() + { + String value = mappingStrategy.getProperties().get(IMappingStrategy.Props.QUALIFIED_NAMES); + return value == null ? false : Boolean.valueOf(value); + } + + protected boolean isForceNamesWithID() + { + String value = mappingStrategy.getProperties().get(IMappingStrategy.Props.FORCE_NAMES_WITH_ID); + return value == null ? false : Boolean.valueOf(value); + } + + protected String getTableNamePrefix() + { + String value = mappingStrategy.getProperties().get(IMappingStrategy.Props.TABLE_NAME_PREFIX); + return StringUtil.safe(value); + } + + protected String getTableNamePrefix(EModelElement element) + { + String prefix = StringUtil.safe(DBAnnotation.TABLE_NAME_PREFIX.getValue(element)); + if (prefix.length() != 0 && !prefix.endsWith(NAME_SEPARATOR)) + { + prefix += NAME_SEPARATOR; + } + + EObject eContainer = element.eContainer(); + if (eContainer instanceof EModelElement) + { + EModelElement parent = (EModelElement)eContainer; + prefix = getTableNamePrefix(parent) + prefix; + } + + return prefix; + } + + protected String getName(String name, String suffix, int maxLength) + { + if (!isValidFirstChar(name)) + { + name = GENERAL_PREFIX + name; + } + + boolean forceNamesWithID = isForceNamesWithID(); + if (!forceNamesWithID && isReservedWord(name)) + { + name = name + GENERAL_SUFFIX; + } + + if (name.length() > maxLength || forceNamesWithID) + { + suffix = NAME_SEPARATOR + suffix.replace('-', 'S'); + int length = Math.min(name.length(), maxLength - suffix.length()); + if (length < 0) + { + // Most likely CDOIDs are client side-assigned, i.e., meta IDs are extrefs. See getUniqueID() + throw new IllegalStateException("Suffix is too long: " + suffix); + } + + name = name.substring(0, length) + suffix; + } + + return name; + } + + protected String getUniqueID(ENamedElement element) + { + long timeStamp; + CommitContext commitContext = StoreThreadLocal.getCommitContext(); + if (commitContext != null) + { + timeStamp = commitContext.getBranchPoint().getTimeStamp(); + } + else + { + // This happens outside a commit, i.e. at system init time. + // Ensure that resulting ext refs are not replicated! + timeStamp = CDOBranchPoint.INVALID_DATE; + // timeStamp = getStore().getRepository().getTimeStamp(); + } + + CDOID result = getMetaID(element, timeStamp); + + StringBuilder builder = new StringBuilder(); + CDOIDUtil.write(builder, result); + return builder.toString(); + } + + protected boolean isValidFirstChar(String name) + { + return mappingStrategy.getStore().getDBAdapter().isValidFirstChar(name.charAt(0)); + } + + protected boolean isReservedWord(String name) + { + return mappingStrategy.getStore().getDBAdapter().isReservedWord(name); + } + + protected CDOID getMetaID(ENamedElement element, long timeStamp) + { + return mappingStrategy.getStore().getMetaDataManager().getMetaID(element, timeStamp); + } + + /** + * @author Eike Stepper + */ + public static final class Factory extends INamingStrategy.Factory + { + private static final String TYPE = "default"; + + public Factory() + { + super(TYPE); + } + + @Override + public INamingStrategy create(Map properties) throws ProductCreationException + { + return new DefaultNamingStrategy(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java index 3ef1687ec1..7cf19c5a30 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractBasicListTableMapping.java @@ -27,7 +27,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IIDHandler; import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; -import org.eclipse.emf.cdo.server.db.mapping.IListMapping3; +import org.eclipse.emf.cdo.server.db.mapping.IListMapping4; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.DBIndexAnnotation; @@ -36,6 +36,7 @@ import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.net4j.db.DBException; import org.eclipse.net4j.db.DBUtil; +import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.emf.ecore.EClass; @@ -46,6 +47,7 @@ import java.sql.SQLException; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@ -54,7 +56,7 @@ import java.util.Set; /** * @author Stefan Winkler */ -public abstract class AbstractBasicListTableMapping implements IListMapping3, IMappingConstants +public abstract class AbstractBasicListTableMapping implements IListMapping4, IMappingConstants { private IMappingStrategy mappingStrategy; @@ -84,6 +86,17 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM return feature; } + public IDBTable getTable() + { + Iterator iterator = getDBTables().iterator(); + if (iterator.hasNext()) + { + return iterator.next(); + } + + return null; + } + public void addSimpleChunkWhere(IDBStoreAccessor accessor, CDOID cdoid, StringBuilder builder, int index) { builder.append(LIST_IDX); @@ -444,12 +457,12 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM private void optimizeListIndexes() { /* - * This is an optimization which reduces the amount of modifications on the database to maintain list indexes. For the - * optimization, we let go of the assumption that indexes are zero-based. Instead, we work with an offset at the - * database level which can change with every change to the list (e.g. if the second element is removed from a list with - * 1000 elements, instead of shifting down indexes 2 to 1000 by 1, we shift up index 0 by 1 and have now a list with - * indexes starting at 1 instead of 0. This optimization is applied by modifying the list of Manipulations, which can be - * seen as the database modification plan. + * This is an optimization which reduces the amount of modifications on the database to maintain list indexes. For + * the optimization, we let go of the assumption that indexes are zero-based. Instead, we work with an offset at + * the database level which can change with every change to the list (e.g. if the second element is removed from a + * list with 1000 elements, instead of shifting down indexes 2 to 1000 by 1, we shift up index 0 by 1 and have now + * a list with indexes starting at 1 instead of 0. This optimization is applied by modifying the list of + * Manipulations, which can be seen as the database modification plan. */ // First, get the current offset. @@ -613,8 +626,8 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM if (manipulation.is(MOVE)) { /* - * Step 2: MOVE all elements e (by e.srcIndex) which have e.is(MOVE) to tmpIndex (-1, -2, -3, -4, ...) and store - * tmpIndex in e.tempIndex + * Step 2: MOVE all elements e (by e.srcIndex) which have e.is(MOVE) to tmpIndex (-1, -2, -3, -4, ...) and + * store tmpIndex in e.tempIndex */ manipulation.tmpIndex = getNextTmpIndex(); dbMove(idHandler, manipulation.srcIndex, manipulation.tmpIndex, manipulation.srcIndex); @@ -634,8 +647,8 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM if (manipulation.is(MOVE)) { /* - * Step 4: MOVE all elements e have e.is(MOVE) from e.tempIdx to e.dstIndex (because we have moved them before, moveStmt - * is always initialized + * Step 4: MOVE all elements e have e.is(MOVE) from e.tempIdx to e.dstIndex (because we have moved them + * before, moveStmt is always initialized */ dbMove(idHandler, manipulation.tmpIndex, manipulation.dstIndex, manipulation.srcIndex); @@ -682,16 +695,16 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM protected void writeShifts(IIDHandler idHandler) throws SQLException { /* - * Step 3: shift all elements which have to be shifted up or down because of add, remove or move of other elements to - * their proper position. This has to be done in two phases to avoid collisions, as the index has to be unique and shift - * up operations have to be executed in top to bottom order. + * Step 3: shift all elements which have to be shifted up or down because of add, remove or move of other elements + * to their proper position. This has to be done in two phases to avoid collisions, as the index has to be unique + * and shift up operations have to be executed in top to bottom order. */ LinkedList shiftOperations = new LinkedList(); /* - * If a necessary shift is detected (source and destination indices differ), firstIndex is set to the current index and - * currentOffset is set to the offset of the shift operation. When a new offset is detected or the range is interrupted, - * we record the range and start a new one if needed. + * If a necessary shift is detected (source and destination indices differ), firstIndex is set to the current + * index and currentOffset is set to the offset of the shift operation. When a new offset is detected or the range + * is interrupted, we record the range and start a new one if needed. */ int rangeStartIndex = NO_INDEX; int rangeOffset = 0; @@ -701,15 +714,16 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM for (Manipulation manipulation : manipulations) { /* - * Shift applies only to elements which are not moved, inserted or deleted (i.e. only plain SET and NONE are affected) + * Shift applies only to elements which are not moved, inserted or deleted (i.e. only plain SET and NONE are + * affected) */ if (manipulation.types == NONE || manipulation.types == SET) { int elementOffset = manipulation.dstIndex - manipulation.srcIndex; /* - * First make sure if we have to close a previous range. This is the case, if the current element's offset differs from - * the rangeOffset and a range is open. + * First make sure if we have to close a previous range. This is the case, if the current element's offset + * differs from the rangeOffset and a range is open. */ if (elementOffset != rangeOffset && rangeStartIndex != NO_INDEX) { @@ -722,8 +736,9 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM } /* - * At this point, either a range is open, which means that the current element also fits in the range (i.e. the offsets - * match) or no range is open. In the latter case, we have to open one if the current element's offset is not 0. + * At this point, either a range is open, which means that the current element also fits in the range (i.e. + * the offsets match) or no range is open. In the latter case, we have to open one if the current element's + * offset is not 0. */ if (elementOffset != 0 && rangeStartIndex == NO_INDEX) { @@ -755,8 +770,8 @@ public abstract class AbstractBasicListTableMapping implements IListMapping3, IM } /* - * Now process the operations. Move down operations can be performed directly, move up operations need to be performed - * later in the reverse direction + * Now process the operations. Move down operations can be performed directly, move up operations need to be + * performed later in the reverse direction */ ListIterator operationIt = shiftOperations.listIterator(); writeShiftsDown(idHandler, operationIt); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java index d91023c222..5c6c9c7ac0 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java @@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; import org.eclipse.emf.cdo.server.IStoreAccessor.QueryXRefsContext; import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk; +import org.eclipse.emf.cdo.server.StoreThreadLocal; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader; @@ -30,6 +31,7 @@ import org.eclipse.emf.cdo.server.db.IMetaDataManager; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.net4j.db.DBException; @@ -41,6 +43,7 @@ import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability; import org.eclipse.net4j.db.ddl.IDBField; import org.eclipse.net4j.db.ddl.IDBIndex; import org.eclipse.net4j.db.ddl.IDBIndex.Type; +import org.eclipse.net4j.db.ddl.IDBSchema; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.util.ImplementationError; import org.eclipse.net4j.util.collection.MoveableList; @@ -107,7 +110,14 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa { super(mappingStrategy, eClass, feature); initDBTypes(); - initTable(); + + IDBStoreAccessor accessor = null; + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) + { + accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + } + + initTable(accessor); initSQLStrings(); } @@ -123,36 +133,21 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa return ITypeMapping.Registry.INSTANCE; } - private void initTable() + public void setTable(IDBTable table) + { + this.table = table; + } + + public void initTable(IDBStoreAccessor accessor) { String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); - DBType idType = getMappingStrategy().getStore().getIDHandler().getDBType(); - int idLength = getMappingStrategy().getStore().getIDColumnLength(); IDBDatabase database = getMappingStrategy().getStore().getDatabase(); table = database.getSchema().getTable(tableName); if (table == null) { - table = database.getSchemaTransaction().getWorkingCopy().addTable(tableName); - - IDBIndex index = table.addIndexEmpty(Type.NON_UNIQUE); - for (FieldInfo fieldInfo : getKeyFields()) - { - IDBField field = table.addField(fieldInfo.getName(), fieldInfo.getType(), fieldInfo.getPrecision()); - index.addIndexField(field); - } - - // Add field for list index - table.addField(FEATUREMAP_IDX, DBType.INTEGER); - - // Add field for FeatureMap tag (MetaID for Feature in CDO registry) - table.addField(FEATUREMAP_TAG, idType, idLength); - - // Create columns for all DBTypes - initTypeColumns(true); - - table.addIndex(Type.NON_UNIQUE, FEATUREMAP_IDX); - table.addIndex(Type.NON_UNIQUE, FEATUREMAP_TAG); + IDBSchema workingCopy = database.getSchemaTransaction().getWorkingCopy(); + table = createTable(workingCopy, tableName); } else { @@ -160,6 +155,33 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa } } + public IDBTable createTable(IDBSchema schema, String tableName) + { + IDBTable table = schema.addTable(tableName); + + IDBIndex index = table.addIndexEmpty(Type.NON_UNIQUE); + for (FieldInfo fieldInfo : getKeyFields()) + { + IDBField field = table.addField(fieldInfo.getName(), fieldInfo.getType(), fieldInfo.getPrecision()); + index.addIndexField(field); + } + + // Add field for list index + table.addField(FEATUREMAP_IDX, DBType.INTEGER); + + // Add field for FeatureMap tag (MetaID for Feature in CDO registry) + DBType idType = getMappingStrategy().getStore().getIDHandler().getDBType(); + int idLength = getMappingStrategy().getStore().getIDColumnLength(); + table.addField(FEATUREMAP_TAG, idType, idLength); + + // Create columns for all DBTypes + initTypeColumns(true); + + table.addIndex(Type.NON_UNIQUE, FEATUREMAP_IDX); + table.addIndex(Type.NON_UNIQUE, FEATUREMAP_TAG); + return table; + } + private void initTypeColumns(boolean create) { for (DBType type : getDBTypes()) @@ -284,7 +306,8 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa return dbTypes; } - protected final IDBTable getTable() + @Override + public final IDBTable getTable() { return table; } @@ -591,7 +614,8 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa public final boolean queryXRefs(IDBStoreAccessor accessor, String mainTableName, String mainTableWhere, QueryXRefsContext context, String idString) { /* - * must never be called (a feature map is not associated with an EReference feature, so XRefs are nor supported here) + * must never be called (a feature map is not associated with an EReference feature, so XRefs are nor supported + * here) */ throw new ImplementationError("Should never be called!"); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java index fbd69b3ee6..0f01db5c7f 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java @@ -36,7 +36,8 @@ import org.eclipse.emf.cdo.server.StoreThreadLocal; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IIDHandler; -import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; +import org.eclipse.emf.cdo.server.db.mapping.IClassMapping2; +import org.eclipse.emf.cdo.server.db.mapping.IFeatureMapping; import org.eclipse.emf.cdo.server.db.mapping.IListMapping; import org.eclipse.emf.cdo.server.db.mapping.IListMapping3; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; @@ -71,7 +72,6 @@ import org.eclipse.net4j.util.om.trace.ContextTracer; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.FeatureMapUtil; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -80,7 +80,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -91,7 +90,7 @@ import java.util.Set; * @author Eike Stepper * @since 2.0 */ -public abstract class AbstractHorizontalClassMapping implements IClassMapping, IMappingConstants, IDeactivateable +public abstract class AbstractHorizontalClassMapping implements IClassMapping2, IMappingConstants, IDeactivateable { protected static final int UNSET_LIST = -1; @@ -120,123 +119,97 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I this.mappingStrategy = mappingStrategy; this.eClass = eClass; - IDBStoreAccessor accessor = null; - if (AbstractHorizontalMappingStrategy.isEagerTableCreation(mappingStrategy)) + if (!AbstractMappingStrategy.isSkipMappingInitialization()) { - accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + IDBStoreAccessor accessor = null; + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) + { + accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + } + + initTable(accessor); } + } - initTable(accessor); + public void setTable(IDBTable table) + { + this.table = table; } - protected void initTable(IDBStoreAccessor accessor) + public void loadTable() { - IDBStore store = mappingStrategy.getStore(); - IDBDatabase database = store.getDatabase(); - String tableName = mappingStrategy.getTableName(eClass); + valueMappings = null; + listMappings = null; + listSizeFields = null; + unsettableFields = null; - table = database.getSchema().getTable(tableName); - if (table == null) + EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getClassInfo(eClass).getAllPersistentFeatures(); + List unsettableFeatures = new ArrayList(); + + for (EStructuralFeature feature : allPersistentFeatures) { - if (accessor != null) + String fieldName = mappingStrategy.getFieldName(feature); + if (feature.isMany()) { - IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction(); - - try + IListMapping listMapping = createListMapping(feature); + if (listMapping != null) { - DBType idType = store.getIDHandler().getDBType(); - int idLength = store.getIDColumnLength(); - - IDBSchema workingCopy = schemaTransaction.getWorkingCopy(); - IDBTable table = workingCopy.addTable(tableName); - table.addField(ATTRIBUTES_ID, idType, idLength, true); - table.addField(ATTRIBUTES_VERSION, DBType.INTEGER, true); - - IDBField branchField = addBranchField(table); - - table.addField(ATTRIBUTES_CREATED, DBType.BIGINT, true); - table.addField(ATTRIBUTES_REVISED, DBType.BIGINT, true); - table.addField(ATTRIBUTES_RESOURCE, idType, idLength, true); - addContainerField(table, idType, idLength); - table.addField(ATTRIBUTES_FEATURE, DBType.INTEGER, true); - - IDBIndex primaryKey = table.addIndex(IDBIndex.Type.PRIMARY_KEY, ATTRIBUTES_ID, ATTRIBUTES_VERSION); - if (branchField != null) + if (listMapping instanceof IListMapping3) { - primaryKey.addIndexField(branchField); + ((IListMapping3)listMapping).setClassMapping(this); } - table.addIndex(IDBIndex.Type.NON_UNIQUE, ATTRIBUTES_REVISED); + addListMapping(listMapping); - EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getClassInfo(eClass).getAllPersistentFeatures(); - Map valueMappings = new HashMap(); - List unsettableFeatures = new ArrayList(); - - for (EStructuralFeature feature : allPersistentFeatures) - { - String fieldName = mappingStrategy.getFieldName(feature); - if (feature.isMany()) - { - IListMapping mapping = createListMapping(feature); - if (mapping != null) - { - // Add field for list sizes. - table.addField(fieldName, DBType.INTEGER); - } - } - else - { - ITypeMapping valueMapping = mappingStrategy.createValueMapping(feature); - valueMapping.createDBField(table, fieldName); - valueMappings.put(feature, valueMapping); - - Set forceIndexes = AbstractMappingStrategy.getForceIndexes(mappingStrategy); - if (CDOFeatureType.matchesCombination(feature, forceIndexes)) - { - IDBField field = table.getField(fieldName); - if (!table.hasIndexFor(field)) - { - IDBIndex index = table.addIndex(IDBIndex.Type.NON_UNIQUE, field); - DBUtil.setOptional(index, true); // Creation might fail for unsupported column type! - } - } - - if (feature.isUnsettable()) - { - unsettableFeatures.add(feature); - } - } - } + IDBField listSizeField = table.getField(fieldName); + addListSizeFiled(feature, listSizeField); + } + } + else + { + ITypeMapping valueMapping = mappingStrategy.createValueMapping(feature); + valueMapping.setDBField(table, fieldName); + addValueMapping(valueMapping); - // Add unsettable fields to end of table. - for (EStructuralFeature feature : unsettableFeatures) - { - String fieldName = mappingStrategy.getUnsettableFieldName(feature); - table.addField(fieldName, DBType.BOOLEAN); - } + if (feature.isUnsettable()) + { + unsettableFeatures.add(feature); + } + } + } - // Create optional feature indices. - for (List features : DBIndexAnnotation.getIndices(eClass, allPersistentFeatures)) - { - int size = features.size(); - IDBField[] fields = new IDBField[size]; + // Register unsettable fields. + if (!unsettableFeatures.isEmpty()) + { + unsettableFields = new LinkedHashMap(); + for (EStructuralFeature feature : unsettableFeatures) + { + String fieldName = mappingStrategy.getUnsettableFieldName(feature); + IDBField field = table.getField(fieldName); + unsettableFields.put(feature, field); + } + } - for (int i = 0; i < size; i++) - { - EStructuralFeature feature = features.get(i); + ensureValueAndListMappings(); + } - ITypeMapping valueMapping = valueMappings.get(feature); - IDBField field = valueMapping.getField(); - fields[i] = field; - } + public void initTable(IDBStoreAccessor accessor) + { + IDBStore store = mappingStrategy.getStore(); + IDBDatabase database = store.getDatabase(); + String tableName = mappingStrategy.getTableName(eClass); - if (!table.hasIndexFor(fields)) - { - IDBIndex index = table.addIndex(IDBIndex.Type.NON_UNIQUE, fields); - DBUtil.setOptional(index, true); // Creation might fail for unsupported column type! - } - } + table = database.getSchema().getTable(tableName); + if (table == null) + { + if (accessor != null) + { + IDBSchemaTransaction schemaTransaction = database.openSchemaTransaction(); + try + { + IDBSchema workingCopy = schemaTransaction.getWorkingCopy(); + table = createTable(workingCopy, tableName); schemaTransaction.commit(); } finally @@ -250,99 +223,236 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I } else { - valueMappings = null; - listMappings = null; - listSizeFields = null; - unsettableFields = null; + loadTable(); + initSQLStrings(); + } + } + + public IDBTable createTable(IDBSchema schema, String tableName) + { + IDBStore store = mappingStrategy.getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); - EStructuralFeature[] allPersistentFeatures = CDOModelUtil.getClassInfo(eClass).getAllPersistentFeatures(); - List unsettableFeatures = new ArrayList(); + IDBTable table = schema.addTable(tableName); + table.addField(ATTRIBUTES_ID, idType, idLength, true); + table.addField(ATTRIBUTES_VERSION, DBType.INTEGER, true); - for (EStructuralFeature feature : allPersistentFeatures) - { - String fieldName = mappingStrategy.getFieldName(feature); - if (feature.isMany()) - { - IListMapping mapping = createListMapping(feature); - if (mapping != null) - { - if (mapping instanceof IListMapping3) - { - ((IListMapping3)mapping).setClassMapping(this); - } + IDBField branchField = addBranchField(table); - if (listMappings == null) - { - listMappings = new ArrayList(); - } + table.addField(ATTRIBUTES_CREATED, DBType.BIGINT, true); + table.addField(ATTRIBUTES_REVISED, DBType.BIGINT, true); + table.addField(ATTRIBUTES_RESOURCE, idType, idLength, true); + addContainerField(table, idType, idLength); + table.addField(ATTRIBUTES_FEATURE, DBType.INTEGER, true); + + IDBIndex primaryKey = table.addIndex(IDBIndex.Type.PRIMARY_KEY, ATTRIBUTES_ID, ATTRIBUTES_VERSION); + if (branchField != null) + { + primaryKey.addIndexField(branchField); + } - listMappings.add(mapping); + table.addIndex(IDBIndex.Type.NON_UNIQUE, ATTRIBUTES_REVISED); - IDBField listSizeField = table.getField(fieldName); + createFeatureMappings(table, true, CDOModelUtil.getClassInfo(eClass).getAllPersistentFeatures()); + ensureValueAndListMappings(); + return table; + } - if (listSizeFields == null) - { - listSizeFields = new LinkedHashMap(); - } + public IFeatureMapping[] createFeatureMappings(IDBTable table, boolean updateClassMapping, EStructuralFeature... features) + { + List result = new ArrayList(); + Map unsettableFields = new LinkedHashMap(); - listSizeFields.put(feature, listSizeField); - } - } - else + for (EStructuralFeature feature : features) + { + String fieldName = mappingStrategy.getFieldName(feature); + if (feature.isMany()) + { + IListMapping listMapping = createListMapping(feature); + if (listMapping != null) { - ITypeMapping mapping = mappingStrategy.createValueMapping(feature); - mapping.setDBField(table, fieldName); + result.add(listMapping); - if (valueMappings == null) + if (updateClassMapping) { - valueMappings = new ArrayList(); + addListMapping(listMapping); } - valueMappings.add(mapping); + // Add field for list sizes. + IDBField listSizeField = table.addField(fieldName, DBType.INTEGER); - if (feature.isUnsettable()) + if (updateClassMapping) { - unsettableFeatures.add(feature); + addListSizeFiled(feature, listSizeField); } } } - - // Register unsettable fields. - if (!unsettableFeatures.isEmpty()) + else { - unsettableFields = new LinkedHashMap(); - for (EStructuralFeature feature : unsettableFeatures) + ITypeMapping valueMapping = mappingStrategy.createValueMapping(feature); + valueMapping.createDBField(table, fieldName); + result.add(valueMapping); + + if (updateClassMapping) + { + addValueMapping(valueMapping); + } + + IDBField field = table.getField(fieldName); + + Set forceIndexes = AbstractMappingStrategy.getForceIndexes(mappingStrategy); + if (CDOFeatureType.matchesCombination(feature, forceIndexes)) + { + if (!table.hasIndexFor(field)) + { + IDBIndex index = table.addIndex(IDBIndex.Type.NON_UNIQUE, field); + DBUtil.setOptional(index, true); // Creation might fail for unsupported column type! + } + } + + if (feature.isUnsettable()) { - String fieldName = mappingStrategy.getUnsettableFieldName(feature); - IDBField field = table.getField(fieldName); unsettableFields.put(feature, field); } } + } - if (valueMappings == null) + // Add unsettable fields to end of table. + if (!unsettableFields.isEmpty()) + { + for (EStructuralFeature feature : unsettableFields.keySet()) { - valueMappings = Collections.emptyList(); + String fieldName = mappingStrategy.getUnsettableFieldName(feature); + table.addField(fieldName, DBType.BOOLEAN); } - if (listMappings == null) + if (updateClassMapping) { - listMappings = Collections.emptyList(); + this.unsettableFields = unsettableFields; } + } - initSQLStrings(); + // Create optional feature indices. + for (List indexedFeatures : DBIndexAnnotation.getIndices(eClass, features)) + { + int size = indexedFeatures.size(); + IDBField[] fields = new IDBField[size]; + + for (int i = 0; i < size; i++) + { + EStructuralFeature feature = indexedFeatures.get(i); + + ITypeMapping valueMapping = getValueMapping(feature); + fields[i] = valueMapping.getField(); + } + + if (!table.hasIndexFor(fields)) + { + IDBIndex index = table.addIndex(IDBIndex.Type.NON_UNIQUE, fields); + DBUtil.setOptional(index, true); // Creation might fail for unsupported column type! + } } + + return result.toArray(new IFeatureMapping[result.size()]); } - private IListMapping createListMapping(EStructuralFeature feature) + public IFeatureMapping[] getFeatureMappings() + { + List featureMappings = new ArrayList(); + + if (valueMappings != null) + { + featureMappings.addAll(valueMappings); + } + + if (listMappings != null) + { + featureMappings.addAll(listMappings); + } + + return featureMappings.toArray(new IFeatureMapping[featureMappings.size()]); + } + + public IFeatureMapping getFeatureMapping(EStructuralFeature feature) { - if (FeatureMapUtil.isFeatureMap(feature)) + if (feature.isMany()) { - return mappingStrategy.createFeatureMapMapping(eClass, feature); + return getFeatureMapping(feature, listMappings); } + return getFeatureMapping(feature, valueMappings); + } + + private IFeatureMapping getFeatureMapping(EStructuralFeature feature, List featureMappings) + { + if (featureMappings != null) + { + for (IFeatureMapping featureMapping : featureMappings) + { + if (featureMapping.getFeature() == feature) + { + return featureMapping; + } + } + } + + return null; + } + + private void addValueMapping(ITypeMapping mapping) + { + if (valueMappings == null) + { + valueMappings = new ArrayList(); + } + + valueMappings.add(mapping); + } + + private void addListMapping(IListMapping mapping) + { + if (listMappings == null) + { + listMappings = new ArrayList(); + } + + listMappings.add(mapping); + } + + private void addListSizeFiled(EStructuralFeature feature, IDBField field) + { + if (listSizeFields == null) + { + listSizeFields = new LinkedHashMap(); + } + + listSizeFields.put(feature, field); + } + + private IListMapping createListMapping(EStructuralFeature feature) + { + // if (FeatureMapUtil.isFeatureMap(feature)) + // { + // return mappingStrategy.createFeatureMapMapping(eClass, feature); + // } + return mappingStrategy.createListMapping(eClass, feature); } + private void ensureValueAndListMappings() + { + if (valueMappings == null) + { + valueMappings = Collections.emptyList(); + } + + if (listMappings == null) + { + listMappings = Collections.emptyList(); + } + } + protected void initSQLStrings() { // ----------- Select all revisions (for handleRevisions) --- @@ -528,12 +638,12 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I return eClass; } - protected final Map getUnsettableFields() + public final Map getUnsettableFields() { return unsettableFields; } - protected final Map getListSizeFields() + public final Map getListSizeFields() { return listSizeFields; } @@ -563,15 +673,18 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I public final IListMapping getListMapping(EStructuralFeature feature) { - for (IListMapping mapping : listMappings) + if (listMappings != null) { - if (mapping.getFeature() == feature) + for (IListMapping mapping : listMappings) { - return mapping; + if (mapping.getFeature() == feature) + { + return mapping; + } } } - throw new IllegalArgumentException("List mapping for feature " + feature + " does not exist"); //$NON-NLS-1$ //$NON-NLS-2$ + return null; } protected final IDBTable getTable() @@ -1019,6 +1132,11 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I if (ref.isMany()) { IListMapping listMapping = getListMapping(ref); + if (listMapping == null) + { + return true; + } + String where = getListXRefsWhere(context); boolean more = listMapping.queryXRefs(accessor, tableName, where, context, idString); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java index f29dc96e26..7916d5dc01 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java @@ -359,9 +359,9 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS } @Override - protected boolean isMapped(EClass eClass) + public boolean isMapped(EClass eClass) { - return !eClass.isAbstract() && !eClass.isInterface(); + return !eClass.isAbstract() && !eClass.isInterface() && super.isMapped(eClass); } @Override diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java index 28b23aeadd..041325671f 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java @@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.server.db.IIDHandler; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.net4j.db.DBException; @@ -88,22 +89,29 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap { super(mappingStrategy, eClass, feature); - IDBStoreAccessor accessor = null; - if (AbstractHorizontalMappingStrategy.isEagerTableCreation(mappingStrategy)) + if (!AbstractMappingStrategy.isSkipMappingInitialization()) { - accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + IDBStoreAccessor accessor = null; + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) + { + accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + } + + initTable(accessor); } + } - initTable(accessor); + public void setTable(IDBTable table) + { + this.table = table; } - protected void initTable(IDBStoreAccessor accessor) + public void initTable(IDBStoreAccessor accessor) { IMappingStrategy mappingStrategy = getMappingStrategy(); EStructuralFeature feature = getFeature(); String tableName = mappingStrategy.getTableName(getContainingClass(), feature); - typeMapping = mappingStrategy.createValueMapping(feature); IDBDatabase database = mappingStrategy.getStore().getDatabase(); table = database.getSchema().getTable(tableName); @@ -116,32 +124,7 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap try { IDBSchema workingCopy = schemaTransaction.getWorkingCopy(); - IDBTable table = workingCopy.addTable(tableName); - - IDBIndex primaryKey = table.addIndexEmpty(Type.PRIMARY_KEY); - for (FieldInfo info : getKeyFields()) - { - IDBField field = table.addField(info.getName(), info.getType(), info.getPrecision(), true); - primaryKey.addIndexField(field); - } - - // Add field for list index. - IDBField listIndexField = table.addField(LIST_IDX, DBType.INTEGER, true); - primaryKey.addIndexField(listIndexField); - - // Add field for value. - typeMapping.createDBField(table, LIST_VALUE); - - if (needsIndexOnValueField(feature)) - { - IDBField field = table.getField(LIST_VALUE); - - if (!table.hasIndexFor(field)) - { - IDBIndex index = table.addIndex(IDBIndex.Type.NON_UNIQUE, field); - DBUtil.setOptional(index, true); // Creation might fail for unsupported column type! - } - } + createTable(workingCopy, tableName); schemaTransaction.commit(); } @@ -156,11 +139,46 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap } else { + typeMapping = mappingStrategy.createValueMapping(feature); typeMapping.setDBField(table, LIST_VALUE); initSQLStrings(); } } + public IDBTable createTable(IDBSchema schema, String tableName) + { + IDBTable table = schema.addTable(tableName); + + IDBIndex primaryKey = table.addIndexEmpty(Type.PRIMARY_KEY); + for (FieldInfo info : getKeyFields()) + { + IDBField field = table.addField(info.getName(), info.getType(), info.getPrecision(), true); + primaryKey.addIndexField(field); + } + + // Add field for list index. + IDBField listIndexField = table.addField(LIST_IDX, DBType.INTEGER, true); + primaryKey.addIndexField(listIndexField); + + // Add field for value. + EStructuralFeature feature = getFeature(); + typeMapping = getMappingStrategy().createValueMapping(feature); + typeMapping.createDBField(table, LIST_VALUE); + + if (needsIndexOnValueField(feature)) + { + IDBField field = table.getField(LIST_VALUE); + + if (!table.hasIndexFor(field)) + { + IDBIndex index = table.addIndex(IDBIndex.Type.NON_UNIQUE, field); + DBUtil.setOptional(index, true); // Creation might fail for unsupported column type! + } + } + + return table; + } + protected void initSQLStrings() { String tableName = table.getName(); @@ -245,12 +263,13 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap return Collections.singleton(table); } - protected final IDBTable getTable() + @Override + public final IDBTable getTable() { return table; } - protected final ITypeMapping getTypeMapping() + public final ITypeMapping getTypeMapping() { return typeMapping; } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java index 4825a7d290..8ec86c5071 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java @@ -36,6 +36,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; import org.eclipse.emf.cdo.server.IRepository; import org.eclipse.emf.cdo.server.IStoreAccessor.QueryXRefsContext; import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk; +import org.eclipse.emf.cdo.server.StoreThreadLocal; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader; @@ -44,6 +45,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.net4j.db.DBException; @@ -53,6 +55,7 @@ import org.eclipse.net4j.db.IDBDatabase; import org.eclipse.net4j.db.IDBPreparedStatement; import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability; import org.eclipse.net4j.db.ddl.IDBIndex.Type; +import org.eclipse.net4j.db.ddl.IDBSchema; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.util.ImplementationError; import org.eclipse.net4j.util.collection.MoveableList; @@ -141,7 +144,14 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl { super(mappingStrategy, eClass, feature); initDBTypes(); - initTable(); + + IDBStoreAccessor accessor = null; + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) + { + accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + } + + initTable(accessor); initSQLStrings(); } @@ -152,7 +162,12 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl dbTypes = new ArrayList(registry.getDefaultFeatureMapDBTypes()); } - private void initTable() + public void setTable(IDBTable table) + { + this.table = table; + } + + public void initTable(IDBStoreAccessor accessor) { String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); IDBStore store = getMappingStrategy().getStore(); @@ -185,6 +200,11 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl } } + public IDBTable createTable(IDBSchema schema, String tableName) + { + throw new UnsupportedOperationException(); + } + private void initTypeColumns(boolean create) { for (DBType type : getDBTypes()) @@ -367,7 +387,8 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl return Collections.singleton(table); } - protected final IDBTable getTable() + @Override + public final IDBTable getTable() { return table; } @@ -700,8 +721,8 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl CDOBranch main = getMappingStrategy().getStore().getRepository().getBranchManager().getMainBranch(); // get revision from cache to find out version number - CDORevision revision = getMappingStrategy().getStore().getRepository().getRevisionManager().getRevision(id, main.getHead(), /* chunksize = */0, - CDORevision.DEPTH_NONE, true); + CDORevision revision = getMappingStrategy().getStore().getRepository().getRevisionManager().getRevision(id, main.getHead(), + /* chunksize = */0, CDORevision.DEPTH_NONE, true); // set cdo_revision_removed for all list items (so we have no NULL values) clearList(accessor, id, revision.getVersion(), FINAL_VERSION); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java index 8a27cfa925..4f385ce213 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java @@ -43,6 +43,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IListMappingUnitSupport; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.spi.server.InternalRepository; @@ -128,7 +129,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi super(mappingStrategy, eClass, feature); IDBStoreAccessor accessor = null; - if (AbstractHorizontalMappingStrategy.isEagerTableCreation(mappingStrategy)) + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) { accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); } @@ -136,14 +137,14 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi initTable(accessor); } - private void initTable(IDBStoreAccessor accessor) + public void setTable(IDBTable table) { - String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); - typeMapping = getMappingStrategy().createValueMapping(getFeature()); + this.table = table; + } - IDBStore store = getMappingStrategy().getStore(); - DBType idType = store.getIDHandler().getDBType(); - int idLength = store.getIDColumnLength(); + public void initTable(IDBStoreAccessor accessor) + { + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); IDBDatabase database = getMappingStrategy().getStore().getDatabase(); table = database.getSchema().getTable(tableName); @@ -155,19 +156,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi try { - IDBSchema workingCopy = schemaTransaction.getWorkingCopy(); - IDBTable table = workingCopy.addTable(tableName); - - table.addField(LIST_REVISION_ID, idType, idLength, true); - table.addField(LIST_REVISION_VERSION_ADDED, DBType.INTEGER); - table.addField(LIST_REVISION_VERSION_REMOVED, DBType.INTEGER); - table.addField(LIST_IDX, DBType.INTEGER, true); - - // TODO think about indexes - table.addIndex(Type.NON_UNIQUE, LIST_REVISION_ID, LIST_REVISION_VERSION_ADDED, LIST_REVISION_VERSION_REMOVED, LIST_IDX); - - typeMapping.createDBField(table, LIST_VALUE); - + table = createTable(schemaTransaction.getWorkingCopy(), tableName); schemaTransaction.commit(); } finally @@ -181,11 +170,32 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi } else { + typeMapping = getMappingStrategy().createValueMapping(getFeature()); typeMapping.setDBField(table, LIST_VALUE); initSQLStrings(); } } + public IDBTable createTable(IDBSchema schema, String tableName) + { + IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + + IDBTable table = schema.addTable(tableName); + table.addField(LIST_REVISION_ID, idType, idLength, true); + table.addField(LIST_REVISION_VERSION_ADDED, DBType.INTEGER); + table.addField(LIST_REVISION_VERSION_REMOVED, DBType.INTEGER); + table.addField(LIST_IDX, DBType.INTEGER, true); + + // TODO think about indexes + table.addIndex(Type.NON_UNIQUE, LIST_REVISION_ID, LIST_REVISION_VERSION_ADDED, LIST_REVISION_VERSION_REMOVED, LIST_IDX); + + typeMapping = getMappingStrategy().createValueMapping(getFeature()); + typeMapping.createDBField(table, LIST_VALUE); + return table; + } + private void initSQLStrings() { String tableName = getTable().getName(); @@ -332,7 +342,8 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi return Collections.singleton(table); } - protected final IDBTable getTable() + @Override + public final IDBTable getTable() { return table; } @@ -599,8 +610,8 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi CDOBranch main = getMappingStrategy().getStore().getRepository().getBranchManager().getMainBranch(); // get revision from cache to find out version number - CDORevision revision = getMappingStrategy().getStore().getRepository().getRevisionManager().getRevision(id, main.getHead(), /* chunksize = */0, - CDORevision.DEPTH_NONE, true); + CDORevision revision = getMappingStrategy().getStore().getRepository().getRevisionManager().getRevision(id, main.getHead(), + /* chunksize = */0, CDORevision.DEPTH_NONE, true); // set cdo_revision_removed for all list items (so we have no NULL values) clearList(accessor, id, revision.getVersion(), FINAL_VERSION); diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java index 5db1697cf3..65858dacc0 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java @@ -32,6 +32,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; import org.eclipse.emf.cdo.server.IStoreAccessor.QueryXRefsContext; import org.eclipse.emf.cdo.server.IStoreChunkReader; import org.eclipse.emf.cdo.server.IStoreChunkReader.Chunk; +import org.eclipse.emf.cdo.server.StoreThreadLocal; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IDBStoreChunkReader; @@ -40,6 +41,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; import org.eclipse.emf.cdo.spi.server.InternalRepository; @@ -51,6 +53,7 @@ import org.eclipse.net4j.db.IDBDatabase; import org.eclipse.net4j.db.IDBPreparedStatement; import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability; import org.eclipse.net4j.db.ddl.IDBIndex.Type; +import org.eclipse.net4j.db.ddl.IDBSchema; import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.util.ImplementationError; import org.eclipse.net4j.util.collection.MoveableList; @@ -137,7 +140,14 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList { super(mappingStrategy, eClass, feature); initDBTypes(); - initTable(); + + IDBStoreAccessor accessor = null; + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) + { + accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); + } + + initTable(accessor); initSQLStrings(); } @@ -148,18 +158,24 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList dbTypes = new ArrayList(registry.getDefaultFeatureMapDBTypes()); } - private void initTable() + public void setTable(IDBTable table) + { + this.table = table; + } + + public void initTable(IDBStoreAccessor accessor) { String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); IDBStore store = getMappingStrategy().getStore(); DBType idType = store.getIDHandler().getDBType(); int idLength = store.getIDColumnLength(); - IDBDatabase database = getMappingStrategy().getStore().getDatabase(); + IDBDatabase database = store.getDatabase(); table = database.getSchema().getTable(tableName); if (table == null) { - table = database.getSchemaTransaction().getWorkingCopy().addTable(tableName); + IDBSchema workingCopy = database.getSchemaTransaction().getWorkingCopy(); + table = workingCopy.addTable(tableName); table.addField(FEATUREMAP_REVISION_ID, idType, idLength); table.addField(LIST_REVISION_BRANCH, DBType.INTEGER); table.addField(FEATUREMAP_VERSION_ADDED, DBType.INTEGER); @@ -186,6 +202,11 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList } } + public IDBTable createTable(IDBSchema schema, String tableName) + { + throw new UnsupportedOperationException(); + } + private void initTypeColumns(boolean create) { for (DBType type : getDBTypes()) @@ -372,7 +393,8 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList return dbTypes; } - protected final IDBTable getTable() + @Override + public final IDBTable getTable() { return table; } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java index 8aa6f61f7f..8af5b7bc95 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java @@ -42,6 +42,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IListMappingDeltaSupport; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.server.internal.db.bundle.OM; +import org.eclipse.emf.cdo.server.internal.db.mapping.AbstractMappingStrategy; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; import org.eclipse.emf.cdo.spi.server.InternalRepository; @@ -125,7 +126,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM super(mappingStrategy, eClass, feature); IDBStoreAccessor accessor = null; - if (AbstractHorizontalMappingStrategy.isEagerTableCreation(mappingStrategy)) + if (AbstractMappingStrategy.isEagerTableCreation(mappingStrategy)) { accessor = (IDBStoreAccessor)StoreThreadLocal.getAccessor(); } @@ -133,14 +134,14 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM initTable(accessor); } - private void initTable(IDBStoreAccessor accessor) + public void setTable(IDBTable table) { - String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); - typeMapping = getMappingStrategy().createValueMapping(getFeature()); + this.table = table; + } - IDBStore store = getMappingStrategy().getStore(); - DBType idType = store.getIDHandler().getDBType(); - int idLength = store.getIDColumnLength(); + public void initTable(IDBStoreAccessor accessor) + { + String tableName = getMappingStrategy().getTableName(getContainingClass(), getFeature()); IDBDatabase database = getMappingStrategy().getStore().getDatabase(); table = database.getSchema().getTable(tableName); @@ -153,18 +154,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM try { IDBSchema workingCopy = schemaTransaction.getWorkingCopy(); - IDBTable table = workingCopy.addTable(tableName); - table.addField(LIST_REVISION_ID, idType, idLength, true); - table.addField(LIST_REVISION_BRANCH, DBType.INTEGER, true); - table.addField(LIST_REVISION_VERSION_ADDED, DBType.INTEGER); - table.addField(LIST_REVISION_VERSION_REMOVED, DBType.INTEGER); - table.addField(LIST_IDX, DBType.INTEGER, true); - - // TODO think about indexes - table.addIndex(Type.NON_UNIQUE, LIST_REVISION_ID, LIST_REVISION_BRANCH, LIST_REVISION_VERSION_ADDED, LIST_REVISION_VERSION_REMOVED, LIST_IDX); - - typeMapping.createDBField(table, LIST_VALUE); - + table = createTable(workingCopy, tableName); schemaTransaction.commit(); } finally @@ -178,11 +168,33 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM } else { + typeMapping = getMappingStrategy().createValueMapping(getFeature()); typeMapping.setDBField(table, LIST_VALUE); initSQLStrings(); } } + public IDBTable createTable(IDBSchema schema, String tableName) + { + IDBStore store = getMappingStrategy().getStore(); + DBType idType = store.getIDHandler().getDBType(); + int idLength = store.getIDColumnLength(); + + IDBTable table = schema.addTable(tableName); + table.addField(LIST_REVISION_ID, idType, idLength, true); + table.addField(LIST_REVISION_BRANCH, DBType.INTEGER, true); + table.addField(LIST_REVISION_VERSION_ADDED, DBType.INTEGER); + table.addField(LIST_REVISION_VERSION_REMOVED, DBType.INTEGER); + table.addField(LIST_IDX, DBType.INTEGER, true); + + // TODO think about indexes + table.addIndex(Type.NON_UNIQUE, LIST_REVISION_ID, LIST_REVISION_BRANCH, LIST_REVISION_VERSION_ADDED, LIST_REVISION_VERSION_REMOVED, LIST_IDX); + + typeMapping = getMappingStrategy().createValueMapping(getFeature()); + typeMapping.createDBField(table, LIST_VALUE); + return table; + } + private void initSQLStrings() { String tableName = getTable().getName(); @@ -312,7 +324,8 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM return Collections.singleton(table); } - protected final IDBTable getTable() + @Override + public final IDBTable getTable() { return table; } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java index 453b6c2920..ac4e7d2a81 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/DelegatingObjectTypeMapper.java @@ -10,12 +10,14 @@ */ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClassifierRef; import org.eclipse.emf.cdo.common.protocol.CDODataInput; import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IIDHandler; +import org.eclipse.emf.cdo.server.db.IMetaDataManager; import org.eclipse.emf.cdo.server.internal.db.IObjectTypeMapper; import org.eclipse.net4j.util.lifecycle.LifecycleUtil; @@ -71,6 +73,16 @@ public abstract class DelegatingObjectTypeMapper extends AbstractObjectTypeMappe return delegate.putObjectType(accessor, timeStamp, id, type); } + public int changeObjectType(IDBStoreAccessor accessor, EClass oldType, EClass newType) + { + IMetaDataManager metaDataManager = getMetaDataManager(); + CDOID oldClassID = metaDataManager.getMetaID(oldType, CDOBranchPoint.UNSPECIFIED_DATE); + CDOID newClassID = metaDataManager.getMetaID(newType, CDOBranchPoint.UNSPECIFIED_DATE); + doChangeObjectType(accessor, oldClassID, newClassID); + + return delegate.changeObjectType(accessor, oldType, newType); + } + public boolean removeObjectType(IDBStoreAccessor accessor, CDOID id) { doRemoveObjectType(accessor, id); @@ -125,5 +137,7 @@ public abstract class DelegatingObjectTypeMapper extends AbstractObjectTypeMappe protected abstract boolean doPutObjectType(IDBStoreAccessor accessor, CDOID id, CDOID type); + protected abstract void doChangeObjectType(IDBStoreAccessor accessor, CDOID oldType, CDOID newType); + protected abstract boolean doRemoveObjectType(IDBStoreAccessor accessor, CDOID id); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java index 25d4309151..5589d8a460 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java @@ -961,7 +961,10 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping delta.applyTo(newRevision); IListMappingDeltaSupport listMapping = (IListMappingDeltaSupport)getListMapping(delta.getFeature()); - listMapping.processDelta(accessor, id, branchId, oldVersion, oldVersion + 1, created, delta); + if (listMapping != null) + { + listMapping.processDelta(accessor, id, branchId, oldVersion, oldVersion + 1, created, delta); + } } public void visit(CDOContainerFeatureDelta delta) diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java index 449da9a94a..84eecf8d45 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategy.java @@ -42,8 +42,7 @@ public class HorizontalAuditMappingStrategy extends AbstractHorizontalMappingStr return false; } - @Override - protected IClassMapping doCreateClassMapping(EClass eClass) + public IClassMapping createClassMapping(EClass eClass) { return new HorizontalAuditClassMapping(this, eClass); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java index cb7330b329..9bb7a6fe91 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditMappingStrategyWithRanges.java @@ -35,7 +35,7 @@ public class HorizontalAuditMappingStrategyWithRanges extends HorizontalAuditMap } @Override - protected IClassMapping doCreateClassMapping(EClass eClass) + public IClassMapping createClassMapping(EClass eClass) { return new HorizontalAuditClassMapping(this, eClass); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java index 0d7287c44f..af4cc79805 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java @@ -1042,7 +1042,10 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp delta.applyTo(newRevision); IListMappingDeltaSupport listMapping = (IListMappingDeltaSupport)getListMapping(delta.getFeature()); - listMapping.processDelta(accessor, id, targetBranch.getID(), oldVersion, newVersion, created, delta); + if (listMapping != null) + { + listMapping.processDelta(accessor, id, targetBranch.getID(), oldVersion, newVersion, created, delta); + } } public void visit(CDOContainerFeatureDelta delta) diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java index fab24dc878..41c17414bc 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java @@ -56,8 +56,7 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin return false; } - @Override - protected IClassMapping doCreateClassMapping(EClass eClass) + public IClassMapping createClassMapping(EClass eClass) { return new HorizontalBranchingClassMapping(this, eClass); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java index 4879b8ec9e..e3f36e9175 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java @@ -66,7 +66,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran } @Override - protected IClassMapping doCreateClassMapping(EClass eClass) + public IClassMapping createClassMapping(EClass eClass) { return new HorizontalBranchingClassMapping(this, eClass); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java index bb3dbd3f9c..f3d70ec43c 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java @@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; import org.eclipse.emf.cdo.common.branch.CDOBranch; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClassifierRef; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; import org.eclipse.emf.cdo.common.protocol.CDODataInput; import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.common.revision.CDORevisionHandler; @@ -25,6 +26,8 @@ import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.mapping.IClassMapping; import org.eclipse.emf.cdo.server.db.mapping.IListMapping; import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy; +import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy3; +import org.eclipse.emf.cdo.server.db.mapping.INamingStrategy; import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping; import org.eclipse.emf.cdo.spi.common.commit.CDOChangeSetSegment; import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; @@ -42,13 +45,14 @@ import org.eclipse.emf.ecore.EStructuralFeature; import java.io.IOException; import java.sql.Connection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; /** * @author Eike Stepper */ -public class HorizontalMappingStrategy extends Lifecycle implements IMappingStrategy +public class HorizontalMappingStrategy extends Lifecycle implements IMappingStrategy3 { private Map properties; @@ -230,6 +234,41 @@ public class HorizontalMappingStrategy extends Lifecycle implements IMappingStra return delegate.getListJoin(attrTable, listTable); } + public INamingStrategy getNamingStrategy() + { + return ((IMappingStrategy3)delegate).getNamingStrategy(); + } + + public void setNamingStrategy(INamingStrategy namingStrategy) + { + ((IMappingStrategy3)delegate).setNamingStrategy(namingStrategy); + } + + public String getUnsettableFieldName(EStructuralFeature feature) + { + return ((IMappingStrategy3)delegate).getUnsettableFieldName(feature); + } + + public boolean isMapped(EClass eClass) + { + return ((IMappingStrategy3)delegate).isMapped(eClass); + } + + public List getMappedClasses(CDOPackageUnit[] packageUnits) + { + return ((IMappingStrategy3)delegate).getMappedClasses(packageUnits); + } + + public IClassMapping createClassMapping(EClass eClass) + { + return ((IMappingStrategy3)delegate).createClassMapping(eClass); + } + + public void clearClassMappings() + { + ((IMappingStrategy3)delegate).clearClassMappings(); + } + @Override protected void doActivate() throws Exception { diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java index 88f115837d..a4de6f791e 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java @@ -592,7 +592,10 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi try { IListMappingDeltaSupport listMapping = (IListMappingDeltaSupport)getListMapping(feature); - listMapping.processDelta(accessor, id, branchId, oldVersion, oldVersion + 1, created, delta); + if (listMapping != null) + { + listMapping.processDelta(accessor, id, branchId, oldVersion, oldVersion + 1, created, delta); + } } catch (NewListSizeResult result) { diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java index 0b489f46e9..4a4aa63a68 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditMappingStrategy.java @@ -63,8 +63,7 @@ public class HorizontalNonAuditMappingStrategy extends AbstractHorizontalMapping return new NonAuditFeatureMapTableMapping(this, containingClass, feature); } - @Override - protected IClassMapping doCreateClassMapping(EClass eClass) + public IClassMapping createClassMapping(EClass eClass) { return new HorizontalNonAuditClassMapping(this, eClass); } diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java index ded575c320..e27bb4ff1d 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeCache.java @@ -48,6 +48,12 @@ public class ObjectTypeCache extends DelegatingObjectTypeMapper return memoryCache.put(id, type) == null; } + @Override + protected void doChangeObjectType(IDBStoreAccessor accessor, CDOID oldType, CDOID newType) + { + memoryCache.clear(); + } + @Override protected boolean doRemoveObjectType(IDBStoreAccessor accessor, CDOID id) { diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java index 53e2ce347b..513b3d9984 100644 --- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java +++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java @@ -13,6 +13,7 @@ */ package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClassifierRef; import org.eclipse.emf.cdo.common.protocol.CDODataInput; @@ -20,6 +21,7 @@ import org.eclipse.emf.cdo.common.protocol.CDODataOutput; import org.eclipse.emf.cdo.server.db.IDBStore; import org.eclipse.emf.cdo.server.db.IDBStoreAccessor; import org.eclipse.emf.cdo.server.db.IIDHandler; +import org.eclipse.emf.cdo.server.db.IMetaDataManager; import org.eclipse.emf.cdo.server.internal.db.CDODBSchema; import org.eclipse.emf.cdo.spi.server.InternalRepository; @@ -55,6 +57,8 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappin private String sqlInsert; + private String sqlUpdate; + private String sqlSelect; public ObjectTypeTable() @@ -142,6 +146,35 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappin } } + public int changeObjectType(IDBStoreAccessor accessor, EClass oldType, EClass newType) + { + IDBStore store = getMappingStrategy().getStore(); + IIDHandler idHandler = store.getIDHandler(); + IMetaDataManager metaDataManager = getMetaDataManager(); + IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdate, ReuseProbability.HIGH); + + try + { + idHandler.setCDOID(stmt, 1, metaDataManager.getMetaID(newType, CDOBranchPoint.UNSPECIFIED_DATE)); + idHandler.setCDOID(stmt, 2, metaDataManager.getMetaID(oldType, CDOBranchPoint.UNSPECIFIED_DATE)); + + if (DBUtil.isTracerEnabled()) + { + DBUtil.trace(stmt.toString()); + } + + return stmt.executeUpdate(); + } + catch (SQLException ex) + { + throw new DBException(ex); + } + finally + { + DBUtil.close(stmt); + } + } + public final boolean removeObjectType(IDBStoreAccessor accessor, CDOID id) { IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler(); @@ -242,6 +275,7 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappin sqlSelect = "SELECT " + ATTRIBUTES_CLASS + " FROM " + table + " WHERE " + ATTRIBUTES_ID + "=?"; sqlInsert = "INSERT INTO " + table + "(" + ATTRIBUTES_ID + "," + ATTRIBUTES_CLASS + "," + ATTRIBUTES_CREATED + ") VALUES (?, ?, ?)"; + sqlUpdate = "UPDATE " + table + " SET " + ATTRIBUTES_CLASS + "=? WHERE " + ATTRIBUTES_CLASS + "=?"; sqlDelete = "DELETE FROM " + table + " WHERE " + ATTRIBUTES_ID + "=?"; } diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.classpath b/plugins/org.eclipse.emf.cdo.server.evolution/.classpath new file mode 100644 index 0000000000..64c5e31b7a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.options b/plugins/org.eclipse.emf.cdo.server.evolution/.options new file mode 100644 index 0000000000..3dfb22963b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.options @@ -0,0 +1,3 @@ +# Debugging and tracing options + +org.eclipse.emf.cdo.server.evolution/debug = true diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.project b/plugins/org.eclipse.emf.cdo.server.evolution/.project new file mode 100644 index 0000000000..af1a9445d4 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.project @@ -0,0 +1,58 @@ + + + org.eclipse.emf.cdo.server.evolution + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + + + org.eclipse.oomph.version.VersionBuilder + + + check.maven.pom + true + + + ignore.lower.bound.dependency.ranges + true + + + release.path + /org.eclipse.emf.cdo.releng/versions/release.xml + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature + org.eclipse.oomph.version.VersionNature + + + + 1396938000000 + + 10 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-true-false-target + + + + diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..1213de898a --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Mon Jul 04 12:52:06 CEST 2011 +eclipse.preferences.version=1 + diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..07533b5536 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,394 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.ucls,doc-files/,package.html,package-info.java +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.doc.comment.support=enabled +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning +org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled +org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning +org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=return_tag +org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled +org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=warning +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled +org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH,LOW,LOW,LOW,LOW,LOW +org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,PERF,MEM,POLISH,@generated NOT,@ADDED +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=2 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=160 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=2 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.launching.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000000..556ed07a3c --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,3 @@ +#Fri Sep 02 05:38:34 CEST 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..222aec0421 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,119 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=true +cleanup.format_source_code_changes_only=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=false +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=true +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=true +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_EMFT +cleanup_settings_version=2 +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_EMFT +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=ex +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=org.eclipse.emf.cdo;org.eclipse.emf.internal.cdo;org.eclipse.net4j;org.eclipse.internal.net4j;org.eclipse.emf;org.eclipse;com;org;javax;java; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.staticondemandthreshold=99 +org.eclipse.jdt.ui.text.custom_code_templates=