diff options
Diffstat (limited to 'plugins')
125 files changed, 6730 insertions, 924 deletions
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); } @@ -163,6 +164,20 @@ public class EvolutionItemProvider extends ModelSetItemProvider } /** + * This adds a property descriptor for the Initial Release feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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. * <!-- begin-user-doc --> * <!-- end-user-doc --> 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<EPackage> 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 @@ <eOperations name="getPreviousRelease" eType="#//Release"/> <eOperations name="getRootPackages" upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EPackage"/> <eOperations name="getAllPackages" upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EPackage"/> + <eOperations name="getPackage" eType="ecore:EClass ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EPackage"> + <eParameters name="nsURI" eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> + </eOperations> <eOperations name="containsElement" eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EBoolean"> <eParameters name="modelElement" eType="ecore:EClass ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EModelElement"/> </eOperations> @@ -45,6 +48,11 @@ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> <details key="constraints" value="ModelLoaded IDs_Exist NamespaceReflectsChange"/> </eAnnotations> + <eOperations name="ensureIDs" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + <eOperations name="getPackage" eType="ecore:EClass ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EPackage"> + <eParameters name="nsURI" eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> + </eOperations> + <eOperations name="save"/> <eStructuralFeatures xsi:type="ecore:EReference" name="evolution" lowerBound="1" eType="#//Evolution" eOpposite="#//Evolution/models"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="uRI" eType="#//URI"> @@ -69,9 +77,18 @@ <eAnnotations source="http://www.eclipse.org/emf/2002/Ecore"> <details key="constraints" value="NotEmpty PackagesUnique NoMissingPackages IDsUnique"/> </eAnnotations> + <eOperations name="ensureIDs" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + <eOperations name="getModel" eType="#//Model"> + <eParameters name="nsURI" eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EString"/> + </eOperations> + <eOperations name="addModel" eType="#//Model"> + <eParameters name="uri" eType="#//URI"/> + </eOperations> <eOperations name="getRelease" eType="#//Release"> <eParameters name="version" eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt"/> </eOperations> + <eOperations name="createRelease" eType="#//Release"/> + <eOperations name="save"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="useEcorePackage" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" defaultValueLiteral="true"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="useEresourcePackage" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> @@ -93,6 +110,8 @@ eType="#//Release" containment="true" eOpposite="#//Release/evolution"/> <eStructuralFeatures xsi:type="ecore:EReference" name="orderedReleases" upperBound="-1" eType="#//Release" changeable="false" volatile="true" transient="true" derived="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="initialRelease" eType="#//Release" + changeable="false" volatile="true" transient="true" derived="true"/> <eStructuralFeatures xsi:type="ecore:EReference" name="latestRelease" eType="#//Release" changeable="false" volatile="true" transient="true" derived="true"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="nextReleaseVersion" eType="ecore:EDataType ../../org.eclipse.emf.ecore/model/Ecore.ecore#//EInt" diff --git a/plugins/org.eclipse.emf.cdo.evolution/model/evolution.genmodel b/plugins/org.eclipse.emf.cdo.evolution/model/evolution.genmodel index ae03a8ab51..5f120aaab1 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/model/evolution.genmodel +++ b/plugins/org.eclipse.emf.cdo.evolution/model/evolution.genmodel @@ -4,8 +4,8 @@ modelPluginID="org.eclipse.emf.cdo.evolution" modelName="Evolution" modelPluginClass="org.eclipse.emf.cdo.evolution.impl.EvolutionPlugin" rootExtendsInterface="org.eclipse.emf.cdo.CDOObject" rootExtendsClass="org.eclipse.emf.internal.cdo.CDOObjectImpl" testsDirectory="" importerID="org.eclipse.emf.importer.cdo" featureDelegation="Dynamic" - complianceLevel="5.0" copyrightFields="false" optimizedHasChildren="true" colorProviders="true" - fontProviders="true" usedGenPackages="../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore" + containmentProxies="true" complianceLevel="5.0" copyrightFields="false" optimizedHasChildren="true" + colorProviders="true" fontProviders="true" usedGenPackages="../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore" operationReflection="true" importOrganizing="true" decoration="Live" styleProviders="true" cleanup="true" autoResizeProperties="true" findAction="true" collapseAllAction="true"> <foreignModel>evolution.ecore</foreignModel> @@ -30,6 +30,9 @@ <genOperations ecoreOperation="evolution.ecore#//ModelSet/getPreviousRelease"/> <genOperations ecoreOperation="evolution.ecore#//ModelSet/getRootPackages"/> <genOperations ecoreOperation="evolution.ecore#//ModelSet/getAllPackages"/> + <genOperations ecoreOperation="evolution.ecore#//ModelSet/getPackage"> + <genParameters ecoreParameter="evolution.ecore#//ModelSet/getPackage/nsURI"/> + </genOperations> <genOperations ecoreOperation="evolution.ecore#//ModelSet/containsElement"> <genParameters ecoreParameter="evolution.ecore#//ModelSet/containsElement/modelElement"/> </genOperations> @@ -58,6 +61,11 @@ <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Model/allPackages"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Model/referencedPackages"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Model/missingPackages"/> + <genOperations ecoreOperation="evolution.ecore#//Model/ensureIDs"/> + <genOperations ecoreOperation="evolution.ecore#//Model/getPackage"> + <genParameters ecoreParameter="evolution.ecore#//Model/getPackage/nsURI"/> + </genOperations> + <genOperations ecoreOperation="evolution.ecore#//Model/save"/> </genClasses> <genClasses ecoreClass="evolution.ecore#//Evolution"> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute evolution.ecore#//Evolution/useEcorePackage"/> @@ -70,11 +78,21 @@ <genFeatures property="Readonly" notify="false" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Evolution/missingPackages"/> <genFeatures property="None" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Evolution/releases"/> <genFeatures property="Readonly" children="true" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Evolution/orderedReleases"/> + <genFeatures property="Readonly" notify="false" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Evolution/initialRelease"/> <genFeatures property="Readonly" notify="false" createChild="false" ecoreFeature="ecore:EReference evolution.ecore#//Evolution/latestRelease"/> <genFeatures property="Readonly" createChild="false" ecoreFeature="ecore:EAttribute evolution.ecore#//Evolution/nextReleaseVersion"/> + <genOperations ecoreOperation="evolution.ecore#//Evolution/ensureIDs"/> + <genOperations ecoreOperation="evolution.ecore#//Evolution/getModel"> + <genParameters ecoreParameter="evolution.ecore#//Evolution/getModel/nsURI"/> + </genOperations> + <genOperations ecoreOperation="evolution.ecore#//Evolution/addModel"> + <genParameters ecoreParameter="evolution.ecore#//Evolution/addModel/uri"/> + </genOperations> <genOperations ecoreOperation="evolution.ecore#//Evolution/getRelease"> <genParameters ecoreParameter="evolution.ecore#//Evolution/getRelease/version"/> </genOperations> + <genOperations ecoreOperation="evolution.ecore#//Evolution/createRelease"/> + <genOperations ecoreOperation="evolution.ecore#//Evolution/save"/> </genClasses> <genClasses ecoreClass="evolution.ecore#//Release"> <genFeatures property="None" notify="false" createChild="false" propertySortChoices="true" diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ChangeKind.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ChangeKind.java index d77d774386..1b16dad216 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ChangeKind.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/ChangeKind.java @@ -327,4 +327,17 @@ public enum ChangeKind implements Enumerator return literal; } + public int indexWithin(ChangeKind... changeKinds) + { + for (int i = 0; i < changeKinds.length; i++) + { + if (changeKinds[i] == this) + { + return i; + } + } + + return -1; + } + } // ChangeKind diff --git a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Evolution.java b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Evolution.java index 528cbb50d5..60116c48c0 100644 --- a/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Evolution.java +++ b/plugins/org.eclipse.emf.cdo.evolution/src/org/eclipse/emf/cdo/evolution/Evolution.java @@ -3,6 +3,7 @@ package org.eclipse.emf.cdo.evolution; import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EPackage; import java.util.Map; @@ -27,6 +28,7 @@ import java.util.Set; * <li>{@link org.eclipse.emf.cdo.evolution.Evolution#getMissingPackages <em>Missing Packages</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.Evolution#getReleases <em>Releases</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.Evolution#getOrderedReleases <em>Ordered Releases</em>}</li> + * <li>{@link org.eclipse.emf.cdo.evolution.Evolution#getInitialRelease <em>Initial Release</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.Evolution#getLatestRelease <em>Latest Release</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.Evolution#getNextReleaseVersion <em>Next Release Version</em>}</li> * </ul> @@ -50,7 +52,7 @@ public interface Evolution extends ModelSet * @return the value of the '<em>Models</em>' 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<Model> getModels(); @@ -208,7 +210,7 @@ public interface Evolution extends ModelSet * @return the value of the '<em>Releases</em>' 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<Release> getReleases(); @@ -230,6 +232,21 @@ public interface Evolution extends ModelSet EList<Release> getOrderedReleases(); /** + * Returns the value of the '<em><b>Initial Release</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Initial Release</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Initial Release</em>' 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 '<em><b>Latest Release</b></em>' reference. * <!-- begin-user-doc --> * <p> @@ -260,6 +277,30 @@ public interface Evolution extends ModelSet int getNextReleaseVersion(); /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + boolean ensureIDs(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + Model getModel(String nsURI); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model uriDataType="org.eclipse.emf.cdo.evolution.URI" + * @generated + */ + Model addModel(URI uri); + + /** * Returns the value of the '<em><b>Missing Packages</b></em>' reference list. * The list contents are of type {@link org.eclipse.emf.ecore.EPackage}. * <!-- begin-user-doc --> @@ -283,4 +324,20 @@ public interface Evolution extends ModelSet */ Release getRelease(int version); + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + Release createRelease(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 @@ -143,13 +143,22 @@ public interface EvolutionPackage extends EPackage int MODEL_SET___GET_ALL_PACKAGES = 4; /** + * The operation id for the '<em>Get Package</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int MODEL_SET___GET_PACKAGE__STRING = 5; + + /** * The operation id for the '<em>Contains Element</em>' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - int MODEL_SET___CONTAINS_ELEMENT__EMODELELEMENT = 5; + int MODEL_SET___CONTAINS_ELEMENT__EMODELELEMENT = 6; /** * The operation id for the '<em>Get Element</em>' 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 '<em>Get Element ID</em>' 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 '<em>Get Element ID</em>' 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 '<em>Compare</em>' 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 '<em>Get Migration</em>' 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 '<em>Model Set</em>' 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 <em>Model</em>}' class. @@ -289,13 +298,40 @@ public interface EvolutionPackage extends EPackage int MODEL_FEATURE_COUNT = 6; /** + * The operation id for the '<em>Ensure IDs</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int MODEL___ENSURE_IDS = 0; + + /** + * The operation id for the '<em>Get Package</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int MODEL___GET_PACKAGE__STRING = 1; + + /** + * The operation id for the '<em>Save</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int MODEL___SAVE = 2; + + /** * The number of operations of the '<em>Model</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - int MODEL_OPERATION_COUNT = 0; + int MODEL_OPERATION_COUNT = 3; /** * The feature id for the '<em><b>Change</b></em>' containment reference. @@ -406,13 +442,22 @@ public interface EvolutionPackage extends EPackage int EVOLUTION__ORDERED_RELEASES = MODEL_SET_FEATURE_COUNT + 9; /** + * The feature id for the '<em><b>Initial Release</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION__INITIAL_RELEASE = MODEL_SET_FEATURE_COUNT + 10; + + /** * The feature id for the '<em><b>Latest Release</b></em>' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @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 '<em><b>Next Release Version</b></em>' 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 '<em>Evolution</em>' 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 '<em>Get Evolution</em>' operation. @@ -478,6 +523,15 @@ public interface EvolutionPackage extends EPackage int EVOLUTION___GET_ALL_PACKAGES = MODEL_SET___GET_ALL_PACKAGES; /** + * The operation id for the '<em>Get Package</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION___GET_PACKAGE__STRING = MODEL_SET___GET_PACKAGE__STRING; + + /** * The operation id for the '<em>Contains Element</em>' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -532,13 +586,58 @@ public interface EvolutionPackage extends EPackage int EVOLUTION___GET_MIGRATION__STRING = MODEL_SET___GET_MIGRATION__STRING; /** + * The operation id for the '<em>Ensure IDs</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION___ENSURE_IDS = MODEL_SET_OPERATION_COUNT + 0; + + /** + * The operation id for the '<em>Get Model</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION___GET_MODEL__STRING = MODEL_SET_OPERATION_COUNT + 1; + + /** + * The operation id for the '<em>Add Model</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION___ADD_MODEL__URI = MODEL_SET_OPERATION_COUNT + 2; + + /** * The operation id for the '<em>Get Release</em>' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @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 '<em>Create Release</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION___CREATE_RELEASE = MODEL_SET_OPERATION_COUNT + 4; + + /** + * The operation id for the '<em>Save</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int EVOLUTION___SAVE = MODEL_SET_OPERATION_COUNT + 5; /** * The number of operations of the '<em>Evolution</em>' 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 <em>Release</em>}' class. @@ -695,6 +794,15 @@ public interface EvolutionPackage extends EPackage int RELEASE___GET_ALL_PACKAGES = MODEL_SET___GET_ALL_PACKAGES; /** + * The operation id for the '<em>Get Package</em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int RELEASE___GET_PACKAGE__STRING = MODEL_SET___GET_PACKAGE__STRING; + + /** * The operation id for the '<em>Contains Element</em>' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1433,6 +1541,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) <em>Get Package</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Get Package</em>' 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) <em>Contains Element</em>}' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1569,6 +1687,36 @@ public interface EvolutionPackage extends EPackage EReference getModel_MissingPackages(); /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Model#ensureIDs() <em>Ensure IDs</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Ensure IDs</em>' 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) <em>Get Package</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Get Package</em>' 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() <em>Save</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Save</em>' 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 <em>Evolution</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1678,6 +1826,17 @@ public interface EvolutionPackage extends EPackage EReference getEvolution_OrderedReleases(); /** + * Returns the meta object for the reference '{@link org.eclipse.emf.cdo.evolution.Evolution#getInitialRelease <em>Initial Release</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Initial Release</em>'. + * @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 <em>Latest Release</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1700,6 +1859,36 @@ public interface EvolutionPackage extends EPackage EAttribute getEvolution_NextReleaseVersion(); /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#ensureIDs() <em>Ensure IDs</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Ensure IDs</em>' 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) <em>Get Model</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Get Model</em>' 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) <em>Add Model</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Add Model</em>' 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 <em>Missing Packages</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -1721,6 +1910,26 @@ public interface EvolutionPackage extends EPackage EOperation getEvolution__GetRelease__int(); /** + * Returns the meta object for the '{@link org.eclipse.emf.cdo.evolution.Evolution#createRelease() <em>Create Release</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Create Release</em>' 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() <em>Save</em>}' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the '<em>Save</em>' 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 <em>Release</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -2215,6 +2424,14 @@ public interface EvolutionPackage extends EPackage EOperation MODEL_SET___GET_ALL_PACKAGES = eINSTANCE.getModelSet__GetAllPackages(); /** + * The meta object literal for the '<em><b>Get Package</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation MODEL_SET___GET_PACKAGE__STRING = eINSTANCE.getModelSet__GetPackage__String(); + + /** * The meta object literal for the '<em><b>Contains Element</b></em>' operation. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -2321,6 +2538,30 @@ public interface EvolutionPackage extends EPackage EReference MODEL__MISSING_PACKAGES = eINSTANCE.getModel_MissingPackages(); /** + * The meta object literal for the '<em><b>Ensure IDs</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation MODEL___ENSURE_IDS = eINSTANCE.getModel__EnsureIDs(); + + /** + * The meta object literal for the '<em><b>Get Package</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation MODEL___GET_PACKAGE__STRING = eINSTANCE.getModel__GetPackage__String(); + + /** + * The meta object literal for the '<em><b>Save</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation MODEL___SAVE = eINSTANCE.getModel__Save(); + + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl <em>Evolution</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -2403,6 +2644,14 @@ public interface EvolutionPackage extends EPackage EReference EVOLUTION__ORDERED_RELEASES = eINSTANCE.getEvolution_OrderedReleases(); /** + * The meta object literal for the '<em><b>Initial Release</b></em>' reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EReference EVOLUTION__INITIAL_RELEASE = eINSTANCE.getEvolution_InitialRelease(); + + /** * The meta object literal for the '<em><b>Latest Release</b></em>' reference feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -2419,6 +2668,30 @@ public interface EvolutionPackage extends EPackage EAttribute EVOLUTION__NEXT_RELEASE_VERSION = eINSTANCE.getEvolution_NextReleaseVersion(); /** + * The meta object literal for the '<em><b>Ensure IDs</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation EVOLUTION___ENSURE_IDS = eINSTANCE.getEvolution__EnsureIDs(); + + /** + * The meta object literal for the '<em><b>Get Model</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation EVOLUTION___GET_MODEL__STRING = eINSTANCE.getEvolution__GetModel__String(); + + /** + * The meta object literal for the '<em><b>Add Model</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation EVOLUTION___ADD_MODEL__URI = eINSTANCE.getEvolution__AddModel__URI(); + + /** * The meta object literal for the '<em><b>Missing Packages</b></em>' reference list feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -2435,6 +2708,22 @@ public interface EvolutionPackage extends EPackage EOperation EVOLUTION___GET_RELEASE__INT = eINSTANCE.getEvolution__GetRelease__int(); /** + * The meta object literal for the '<em><b>Create Release</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation EVOLUTION___CREATE_RELEASE = eINSTANCE.getEvolution__CreateRelease(); + + /** + * The meta object literal for the '<em><b>Save</b></em>' operation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EOperation EVOLUTION___SAVE = eINSTANCE.getEvolution__Save(); + + /** * The meta object literal for the '{@link org.eclipse.emf.cdo.evolution.impl.ReleaseImpl <em>Release</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> 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<EPackage> getMissingPackages(); + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + boolean ensureIDs(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ + EPackage getPackage(String nsURI); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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; /** * <!-- begin-user-doc --> @@ -67,7 +70,7 @@ public interface ModelSet extends CDOObject * @return the value of the '<em>Migrations</em>' 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<Migration> getMigrations(); @@ -118,6 +121,14 @@ public interface ModelSet extends CDOObject * @model * @generated */ + EPackage getPackage(String nsURI); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @model + * @generated + */ boolean containsElement(EModelElement modelElement); /** @@ -160,4 +171,10 @@ public interface ModelSet extends CDOObject */ Migration getMigration(String diagnosticID); + EList<ElementChange> getElementChanges(EClass elementType, ChangeKind... changeKinds); + + EList<PropertyChange> 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<Release> * <!-- end-user-doc --> * @return the value of the '<em>Root Packages</em>' containment reference list. * @see org.eclipse.emf.cdo.evolution.EvolutionPackage#getRelease_RootPackages() - * @model containment="true" + * @model containment="true" resolveProxies="true" * @generated */ EList<EPackage> 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; * <li>{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getMissingPackages <em>Missing Packages</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getReleases <em>Releases</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getOrderedReleases <em>Ordered Releases</em>}</li> + * <li>{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getInitialRelease <em>Initial Release</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getLatestRelease <em>Latest Release</em>}</li> * <li>{@link org.eclipse.emf.cdo.evolution.impl.EvolutionImpl#getNextReleaseVersion <em>Next Release Version</em>}</li> * </ul> @@ -328,6 +337,72 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution /** * <!-- begin-user-doc --> * <!-- end-user-doc --> + * @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<EPackage> 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; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void save() + { + try + { + eResource().save(null); + } + catch (IOException ex) + { + throw new IORuntimeException(ex); + } + + for (Model model : getModels()) + { + model.save(); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @@ -364,6 +439,33 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution * <!-- end-user-doc --> * @generated */ + public Release getInitialRelease() + { + Release initialRelease = basicGetInitialRelease(); + return initialRelease != null && ((EObject)initialRelease).eIsProxy() ? (Release)eResolveProxy((InternalEObject)initialRelease) : initialRelease; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Release basicGetInitialRelease() + { + EList<Release> orderedReleases = getOrderedReleases(); + if (orderedReleases.isEmpty()) + { + return null; + } + + return orderedReleases.get(orderedReleases.size() - 1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public Release getLatestRelease() { Release latestRelease = basicGetLatestRelease(); @@ -400,6 +502,54 @@ public class EvolutionImpl extends ModelSetImpl implements Evolution /** * <!-- begin-user-doc --> * <!-- end-user-doc --> + * @generated NOT + */ + public boolean ensureIDs() + { + boolean modified = false; + + for (Model model : getModels()) + { + modified |= model.ensureIDs(); + } + + return modified; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Model getModel(String nsURI) + { + for (Model model : getModels()) + { + EPackage ePackage = model.getPackage(nsURI); + if (ePackage != null) + { + return model; + } + } + + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Model addModel(URI uri) + { + Model model = EvolutionFactory.eINSTANCE.createModel(uri); + getModels().add(model); + return model; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> * @generated */ @SuppressWarnings("unchecked") @@ -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 * <!-- end-user-doc --> * @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 * <!-- end-user-doc --> * @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 * <!-- end-user-doc --> * @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 * <!-- end-user-doc --> * @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 * <!-- end-user-doc --> * @generated */ - public EOperation getModelSet__Compare__ModelSet() + public EOperation getModelSet__GetElementID__EModelElement_boolean() { return modelSetEClass.getEOperations().get(9); } @@ -336,7 +336,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * <!-- end-user-doc --> * @generated */ - public EOperation getModelSet__GetMigration__String() + public EOperation getModelSet__Compare__ModelSet() { return modelSetEClass.getEOperations().get(10); } @@ -346,6 +346,16 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * <!-- end-user-doc --> * @generated */ + public EOperation getModelSet__GetMigration__String() + { + return modelSetEClass.getEOperations().get(11); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public EClass getModel() { return modelEClass; @@ -416,6 +426,36 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * <!-- end-user-doc --> * @generated */ + public EOperation getModel__EnsureIDs() + { + return modelEClass.getEOperations().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getModel__GetPackage__String() + { + return modelEClass.getEOperations().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getModel__Save() + { + return modelEClass.getEOperations().get(2); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public EClass getEvolution() { return evolutionEClass; @@ -516,7 +556,7 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * <!-- end-user-doc --> * @generated */ - public EReference getEvolution_LatestRelease() + public EReference getEvolution_InitialRelease() { return (EReference)evolutionEClass.getEStructuralFeatures().get(10); } @@ -526,9 +566,49 @@ public class EvolutionPackageImpl extends EPackageImpl implements EvolutionPacka * <!-- end-user-doc --> * @generated */ + public EReference getEvolution_LatestRelease() + { + return (EReference)evolutionEClass.getEStructuralFeatures().get(11); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public EAttribute getEvolution_NextReleaseVersion() { - return (EAttribute)evolutionEClass.getEStructuralFeatures().get(11); + return (EAttribute)evolutionEClass.getEStructuralFeatures().get(12); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getEvolution__EnsureIDs() + { + return evolutionEClass.getEOperations().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getEvolution__GetModel__String() + { + return evolutionEClass.getEOperations().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EOperation getEvolution__CreateRelease() + { + return evolutionEClass.getEOperations().get(4); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 @@ -85,6 +85,16 @@ public abstract class MigrationImpl extends CDOObjectImpl implements Migration * <!-- end-user-doc --> * @generated */ + public ModelSet basicGetModelSet() + { + return (ModelSet)eDynamicGet(EvolutionPackage.MIGRATION__MODEL_SET, EvolutionPackage.Literals.MIGRATION__MODEL_SET, false, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public NotificationChain basicSetModelSet(ModelSet newModelSet, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newModelSet, EvolutionPackage.MIGRATION__MODEL_SET, msgs); @@ -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; @@ -109,6 +118,16 @@ public class ModelImpl extends CDOObjectImpl implements Model * <!-- end-user-doc --> * @generated */ + public Evolution basicGetEvolution() + { + return (Evolution)eDynamicGet(EvolutionPackage.MODEL__EVOLUTION, EvolutionPackage.Literals.MODEL__EVOLUTION, false, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public NotificationChain basicSetEvolution(Evolution newEvolution, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newEvolution, EvolutionPackage.MODEL__EVOLUTION, msgs); @@ -414,6 +433,64 @@ public class ModelImpl extends CDOObjectImpl implements Model /** * <!-- begin-user-doc --> * <!-- end-user-doc --> + * @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]; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public EPackage getPackage(String nsURI) + { + for (EPackage ePackage : getAllPackages()) + { + if (ObjectUtil.equals(ePackage.getNsURI(), nsURI)) + { + return ePackage; + } + } + + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void save() + { + try + { + eResource().save(null); + } + catch (IOException ex) + { + throw new IORuntimeException(ex); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> * @generated */ @Override @@ -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); } + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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; @@ -269,6 +274,24 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet * <!-- end-user-doc --> * @generated NOT */ + public EPackage getPackage(String nsURI) + { + for (EPackage ePackage : getAllPackages()) + { + if (ObjectUtil.equals(ePackage.getNsURI(), nsURI)) + { + return ePackage; + } + } + + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ public abstract boolean containsElement(EModelElement modelElement); /** @@ -372,6 +395,87 @@ public abstract class ModelSetImpl extends CDOObjectImpl implements ModelSet return null; } + public EList<ElementChange> getElementChanges(EClass elementType, ChangeKind... changeKinds) + { + ModelSetChange modelSetChange = getChange(); + + EList<ElementChange> result = new BasicEList<ElementChange>(); + collectElementChanges(result, modelSetChange, elementType, changeKinds); + return result; + } + + private void collectElementChanges(EList<ElementChange> 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<PropertyChange> getPropertyChanges(EStructuralFeature feature, ChangeKind... changeKinds) + { + ModelSetChange modelSetChange = getChange(); + + EList<PropertyChange> result = new BasicEList<PropertyChange>(); + collectPropertyChanges(result, modelSetChange, feature, changeKinds); + return result; + } + + private void collectPropertyChanges(EList<PropertyChange> 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; + } + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -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<EModelElement, ElementChange> 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 @@ -207,6 +207,16 @@ public class ReleaseImpl extends ModelSetImpl implements Release * <!-- end-user-doc --> * @generated */ + public Evolution basicGetEvolution() + { + return (Evolution)eDynamicGet(EvolutionPackage.RELEASE__EVOLUTION, EvolutionPackage.Literals.RELEASE__EVOLUTION, false, true); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public NotificationChain basicSetEvolution(Evolution newEvolution, NotificationChain msgs) { msgs = eBasicSetContainer((InternalEObject)newEvolution, EvolutionPackage.RELEASE__EVOLUTION, msgs); @@ -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 @@ <groupId>org.eclipse.emf.cdo</groupId> <artifactId>org.eclipse.emf.cdo.explorer.ui</artifactId> - <version>4.4.300-SNAPSHOT</version> + <version>4.4.400-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> 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<Object> 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 @@ <extension-point id="mappingStrategies" name="%extension-point.name" schema="schema/mappingStrategies.exsd"/> - <extension - point="org.eclipse.net4j.util.factories"> + <extension point="org.eclipse.net4j.util.factories"> + <factory + productGroup="org.eclipse.emf.cdo.server.browserPages" + type="dbmappings" + class="org.eclipse.emf.cdo.server.internal.db.DBMappingsPage$Factory"/> <factory - class="org.eclipse.emf.cdo.server.internal.db.DBBrowserPage$Factory" productGroup="org.eclipse.emf.cdo.server.browserPages" - type="db"> - </factory> + type="dbschema" + class="org.eclipse.emf.cdo.server.internal.db.DBSchemaPage$Factory"/> + <factory + productGroup="org.eclipse.emf.cdo.server.browserPages" + type="dbtables" + class="org.eclipse.emf.cdo.server.internal.db.DBTablesPage$Factory"/> </extension> <extension @@ -32,8 +38,7 @@ </storeFactory> </extension> - <extension - point="org.eclipse.emf.cdo.server.db.mappingStrategies"> + <extension point="org.eclipse.emf.cdo.server.db.mappingStrategies"> <mappingStrategy class="org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalMappingStrategy" type="horizontal"/> 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 @@ <groupId>org.eclipse.emf.cdo</groupId> <artifactId>org.eclipse.emf.cdo.server.db</artifactId> - <version>4.6.0-SNAPSHOT</version> + <version>4.7.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> 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 @@ -100,6 +100,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 */ public void rawExport(Connection connection, CDODataOutput out, long fromCommitTime, long toCommitTime) throws IOException; 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 <i>units</i>. + * + * @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<EStructuralFeature, IDBField> getUnsettableFields(); + + public Map<EStructuralFeature, IDBField> 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,16 +33,9 @@ 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. * * @return a collection of all tables of 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<EClass> 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: + * <code>element instanceof EClass || element instanceof EPackage</code>. + * @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<String, String> 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,14 +37,9 @@ 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. */ public IDBField getField(); 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/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<EClass, IClassMapping> classMappings = mappingStrategy.getClassMappings(mapAll); + + if (mappingStrategy instanceof IMappingStrategy3) + { + CDOPackageRegistry packageRegistry = store.getRepository().getPackageRegistry(); + CDOPackageUnit[] packageUnits = packageRegistry.getPackageUnits(); + + IMappingStrategy3 mappingStrategy3 = (IMappingStrategy3)mappingStrategy; + List<EClass> mappedClasses = mappingStrategy3.getMappedClasses(packageUnits); + + int countMapped = classMappings.size(); + int countMappable = mappedClasses.size(); + + out.print("Mappable classes: " + countMappable + "<br>\r\n"); + out.print("Mapped classes: " + countMapped + "<br>\r\n"); + out.print("Unmapped classes: " + (countMappable - countMapped)); + + if (countMapped < countMappable) + { + out.print(" " + browser.href("(map all)", getName(), "map", "all")); + } + + out.print("<br>\r\n"); + out.print("<br>\r\n"); + } + + List<String> qualifiedNames = new ArrayList<String>(); + Map<String, IClassMapping> byQualifiedName = new LinkedHashMap<String, IClassMapping>(); + for (Map.Entry<EClass, IClassMapping> 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("<table border=1>\r\n"); + out.print("<tr><th>Class</th><th>Table</th></tr/>\r\n"); + + for (String qualifiedName : qualifiedNames) + { + IClassMapping classMapping = byQualifiedName.get(qualifiedName); + List<IDBTable> tables = classMapping.getDBTables(); + + boolean mapped = tables.get(0) != null; + String fontPrefix = mapped ? "<b>" : "<font color=\"gray\">"; + String fontSuffix = mapped ? "</b>" : "</font>"; + + out.print("<tr><td valign=\"top\">"); + out.print(fontPrefix); + out.print(qualifiedName); + out.print(fontSuffix); + out.print("</td><td>"); + + boolean first = true; + for (IDBTable table : tables) + { + if (table != null) + { + if (first) + { + first = false; + } + else + { + out.print("<br/>"); + } + + out.print(DBTablesPage.tableHRef(browser, table)); + } + } + + out.print("</td></tr/>\r\n"); + } + + out.print("</table>\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<EModelElement, EModelElement> oldToRepositoryElements = new HashMap<EModelElement, EModelElement>(); + + private final Map<EModelElement, EModelElement> repositoryToOldElements = new HashMap<EModelElement, EModelElement>(); + + 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<EModelElement, EModelElement> newToOldElements = release.getChange().getNewToOldElements(); + + //////////////////////////////////////////////////////////////////////////////////////// + // Compute all new class mappings in a temporary schema. + //////////////////////////////////////////////////////////////////////////////////////// + + Map<EClass, IClassMapping2> newClassMappings = new HashMap<EClass, IClassMapping2>(); + 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<IDBTable> tablesToRemove = new HashSet<IDBTable>(); + + 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<IClassMapping2> addedClassMappings = new HashSet<IClassMapping2>(); + Map<CDOID, Pair<CDOID, ? extends EModelElement>> oldToNewMetaIDs = new HashMap<CDOID, Pair<CDOID, ? extends EModelElement>>(); + + 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<InternalCDOPackageUnit> repositoryPackageUnits = new ArrayList<InternalCDOPackageUnit>(); + + 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/DBBrowserPage.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBTablesPage.java index fe6b898f77..b0d38ef475 100644 --- 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/DBTablesPage.java @@ -17,6 +17,7 @@ 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; @@ -31,11 +32,15 @@ import java.util.List; * @author Eike Stepper * @since 4.0 */ -public class DBBrowserPage extends AbstractPage +public class DBTablesPage extends AbstractPage { - public DBBrowserPage() + private static final String PARAM_TABLE = "table"; + + private static final String NAME = "tables"; + + public DBTablesPage() { - super("tables", "DB Tables"); + super(NAME, "DB Tables"); } public boolean canDisplay(InternalRepository repository) @@ -84,7 +89,7 @@ public class DBBrowserPage extends AbstractPage */ protected String showTables(CDOServerBrowser browser, PrintStream pout, Connection connection, String repo) { - String table = browser.getParam("table"); + String table = browser.getParam(PARAM_TABLE); boolean used = browser.isParam("used"); boolean schema = browser.isParam("schema"); @@ -126,7 +131,7 @@ public class DBBrowserPage extends AbstractPage } else { - pout.print(browser.href(label, getName(), "table", tableName, "order", null, "direction", null)); + pout.print(browser.href(label, getName(), PARAM_TABLE, tableName, "order", null, "direction", null)); } if (rowCount > 0) @@ -235,21 +240,32 @@ public class DBBrowserPage extends AbstractPage } } + 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 = "db"; + public static final String TYPE = "dbtables"; public Factory() { super(PRODUCT_GROUP, TYPE); } - public DBBrowserPage create(String description) throws ProductCreationException + public DBTablesPage create(String description) throws ProductCreationException { - return new DBBrowserPage(); + 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<InternalCDOPackageUnit> readPackageUnits(Connection connection, long fromCommitTime, long toCommitTime, OMMonitor monitor) { - try + final Map<String, InternalCDOPackageUnit> packageUnits = new HashMap<String, InternalCDOPackageUnit>(); + 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<String, List<InternalCDOPackageInfo>> packageInfos = new HashMap<String, List<InternalCDOPackageInfo>>(); + 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<InternalCDOPackageUnit> rawImport(Connection connection, CDODataInput in, long fromCommitTime, long toCommitTime, OMMonitor monitor) - throws IOException - { - monitor.begin(3); + String unit = (String)values[0]; + List<InternalCDOPackageInfo> list = packageInfos.get(unit); + if (list == null) + { + list = new ArrayList<InternalCDOPackageInfo>(); + 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<String, InternalCDOPackageUnit> entry : packageUnits.entrySet()) + { + String id = entry.getKey(); + InternalCDOPackageUnit packageUnit = entry.getValue(); - private InternalCDOPackageRegistry getPackageRegistry() - { - return (InternalCDOPackageRegistry)store.getRepository().getPackageRegistry(); - } + List<InternalCDOPackageInfo> 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<InternalCDOPackageUnit> readPackageUnits(Connection connection, long fromCommitTime, long toCommitTime, OMMonitor monitor) + public final void deletePackageUnits(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor) { - final Map<String, InternalCDOPackageUnit> packageUnits = new HashMap<String, InternalCDOPackageUnit>(); - 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<String, List<InternalCDOPackageInfo>> packageInfos = new HashMap<String, List<InternalCDOPackageInfo>>(); - 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<InternalCDOPackageInfo> list = packageInfos.get(unit); - if (list == null) + if (stmt.execute()) { - list = new ArrayList<InternalCDOPackageInfo>(); - 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<String, InternalCDOPackageUnit> 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<InternalCDOPackageInfo> 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<InternalCDOPackageUnit> 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<Boolean> SKIP_MAPPING_INITIALIZATION = new ThreadLocal<Boolean>(); private IDBStore store; private Map<String, String> properties; + private INamingStrategy namingStrategy; + private ConcurrentMap<EClass, IClassMapping> 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<CDOFeatureType> getForceIndexes() @@ -297,167 +258,24 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp protected abstract Collection<EClass> 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<IClassMapping> mapPackageUnits(InternalCDOPackageUnit[] packageUnits, Connection connection, boolean unmap) - { - Set<IClassMapping> classMappings = new HashSet<IClassMapping>(); - - 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<IClassMapping> 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<IClassMapping> classMappings) + public List<EClass> getMappedClasses(CDOPackageUnit[] packageUnits) { - for (EClass eClass : eClasses) + List<EClass> result = new ArrayList<EClass>(); + + 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); } } } @@ -605,18 +413,13 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp public final Map<EClass, IClassMapping> getClassMappings(boolean createOnDemand) { - return doGetClassMappings(createOnDemand); - } - - public final Map<EClass, IClassMapping> doGetClassMappings(boolean createOnDemand) - { if (createOnDemand) { synchronized (classMappings) { 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) { @@ -679,8 +489,23 @@ public abstract class AbstractMappingStrategy extends Lifecycle implements IMapp 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<String, String> 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<IDBTable> 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<Shift> shiftOperations = new LinkedList<Shift>(); /* - * 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<Shift> 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<EStructuralFeature> unsettableFeatures = new ArrayList<EStructuralFeature>(); + + 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<EStructuralFeature, ITypeMapping> valueMappings = new HashMap<EStructuralFeature, ITypeMapping>(); - List<EStructuralFeature> unsettableFeatures = new ArrayList<EStructuralFeature>(); - - 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<CDOFeatureType> 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<EStructuralFeature> features : DBIndexAnnotation.getIndices(eClass, allPersistentFeatures)) - { - int size = features.size(); - IDBField[] fields = new IDBField[size]; + // Register unsettable fields. + if (!unsettableFeatures.isEmpty()) + { + unsettableFields = new LinkedHashMap<EStructuralFeature, IDBField>(); + 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<EStructuralFeature> unsettableFeatures = new ArrayList<EStructuralFeature>(); + 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<IListMapping>(); - } + 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<EStructuralFeature, IDBField>(); - } + public IFeatureMapping[] createFeatureMappings(IDBTable table, boolean updateClassMapping, EStructuralFeature... features) + { + List<IFeatureMapping> result = new ArrayList<IFeatureMapping>(); + Map<EStructuralFeature, IDBField> unsettableFields = new LinkedHashMap<EStructuralFeature, IDBField>(); - 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<ITypeMapping>(); + 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<EStructuralFeature, IDBField>(); - 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<CDOFeatureType> 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<EStructuralFeature> 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<IFeatureMapping> featureMappings = new ArrayList<IFeatureMapping>(); + + 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<? extends IFeatureMapping> 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<ITypeMapping>(); + } + + valueMappings.add(mapping); + } + + private void addListMapping(IListMapping mapping) + { + if (listMappings == null) + { + listMappings = new ArrayList<IListMapping>(); + } + + listMappings.add(mapping); + } + + private void addListSizeFiled(EStructuralFeature feature, IDBField field) + { + if (listSizeFields == null) + { + listSizeFields = new LinkedHashMap<EStructuralFeature, IDBField>(); + } + + 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<EStructuralFeature, IDBField> getUnsettableFields() + public final Map<EStructuralFeature, IDBField> getUnsettableFields() { return unsettableFields; } - protected final Map<EStructuralFeature, IDBField> getListSizeFields() + public final Map<EStructuralFeature, IDBField> 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<DBType>(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<DBType>(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<String, String> 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<EClass> 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 @@ -49,6 +49,12 @@ public class ObjectTypeCache extends DelegatingObjectTypeMapper } @Override + protected void doChangeObjectType(IDBStoreAccessor accessor, CDOID oldType, CDOID newType) + { + memoryCache.clear(); + } + + @Override protected boolean doRemoveObjectType(IDBStoreAccessor accessor, CDOID id) { return memoryCache.remove(id) != null; 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> 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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.emf.cdo.server.evolution</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.oomph.version.VersionBuilder</name> + <arguments> + <dictionary> + <key>check.maven.pom</key> + <value>true</value> + </dictionary> + <dictionary> + <key>ignore.lower.bound.dependency.ranges</key> + <value>true</value> + </dictionary> + <dictionary> + <key>release.path</key> + <value>/org.eclipse.emf.cdo.releng/versions/release.xml</value> + </dictionary> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + <nature>org.eclipse.oomph.version.VersionNature</nature> + </natures> + <filteredResources> + <filter> + <id>1396938000000</id> + <name></name> + <type>10</type> + <matcher> + <id>org.eclipse.ui.ide.multiFilter</id> + <arguments>1.0-projectRelativePath-matches-true-false-target</arguments> + </matcher> + </filter> + </filteredResources> +</projectDescription> 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=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment"/><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment"/><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment"/><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*\r\n * Copyright (c) 2004-2018 Eike Stepper (Loehne, Germany) and others.\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Eike Stepper - initial API and implementation\r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author Eike Stepper\r\n */</template><template autoinsert\="false" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment"/><template autoinsert\="false" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment"/><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment"/><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">${exception_var}.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> +sp_cleanup.add_default_serial_version_id=true +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=false +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=true +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=false +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=true +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=true +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=true +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=true +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=true +sp_cleanup.remove_unused_private_types=true +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_blocks=true +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_parentheses_in_expressions=true +sp_cleanup.use_this_for_non_static_field_access=true +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true +sp_cleanup.use_this_for_non_static_method_access=true +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.ltk.core.refactoring.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000000..864e30fe5d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,3 @@ +#Thu Feb 04 09:44:24 CET 2010 +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.tasks.ui.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000000..b050639a54 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,4 @@ +#Thu Feb 04 09:44:24 CET 2010 +eclipse.preferences.version=1 +project.repository.kind=bugzilla +project.repository.url=https\://bugs.eclipse.org/bugs diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.team.ui.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.team.ui.prefs new file mode 100644 index 0000000000..97c11e6725 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.mylyn.team.ui.prefs @@ -0,0 +1,3 @@ +#Thu Feb 04 09:44:24 CET 2010 +commit.comment.template=[${task.id}] ${task.description}\r\n\r\n${task.url} +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.api.tools.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 0000000000..0c17d59e45 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,95 @@ +#Thu Feb 04 09:44:24 CET 2010 +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Error +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_JAVADOC_TAG=Ignore +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Error +MISSING_EE_DESCRIPTIONS=Warning +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Ignore +automatically_removed_unused_problem_filters=Disabled +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Error +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.prefs b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..fe01bb701d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/.settings/org.eclipse.pde.prefs @@ -0,0 +1,31 @@ +#Thu Feb 04 09:44:24 CET 2010 +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=2 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=1 +compilers.p.missing-version-export-package=1 +compilers.p.missing-version-import-package=1 +compilers.p.missing-version-require-bundle=1 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=2 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.server.evolution/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..31c4348f68 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.emf.cdo.server.evolution;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Name: %pluginName +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.emf.cdo.server.internal.evolution.bundle.OM$Activator +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ClassPath: . +Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)";resolution:=optional, + org.eclipse.emf.cdo.server;bundle-version="[4.0.0,5.0.0)";visibility:=reexport, + org.eclipse.emf.cdo.evolution;bundle-version="[1.0.0,2.0.0)";visibility:=reexport +Export-Package: org.eclipse.emf.cdo.server.evolution;version="1.0.0", + org.eclipse.emf.cdo.server.internal.evolution.bundle;version="1.0.0";x-internal:=true, + org.eclipse.emf.cdo.server.spi.evolution;version="1.0.0" +Automatic-Module-Name: org.eclipse.emf.cdo.server.evolution diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/about.html b/plugins/org.eclipse.emf.cdo.server.evolution/about.html new file mode 100644 index 0000000000..d35d5aed64 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>June 5, 2007</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + +</body> +</html> diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/build.properties b/plugins/org.eclipse.emf.cdo.server.evolution/build.properties new file mode 100644 index 0000000000..6a3190d379 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/build.properties @@ -0,0 +1,26 @@ +# Copyright (c) 2016, 2017 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 + +# NLS_MESSAGEFORMAT_VAR + +bin.includes = .,\ + META-INF/,\ + plugin.properties,\ + .options,\ + about.html,\ + plugin.xml +jars.compile.order = . +source.. = src/ +output.. = bin/ +src.includes = about.html,\ + pom.xml + +doc.project = org.eclipse.emf.cdo.doc + +generateSourceReferences = true diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/plugin.properties b/plugins/org.eclipse.emf.cdo.server.evolution/plugin.properties new file mode 100644 index 0000000000..be50d74256 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/plugin.properties @@ -0,0 +1,11 @@ +# Copyright (c) 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 + +pluginName = CDO Model Repository Server Evolution Support +providerName = Eclipse Modeling Project diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/plugin.xml b/plugins/org.eclipse.emf.cdo.server.evolution/plugin.xml new file mode 100644 index 0000000000..d8d52cf5f0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/plugin.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<!-- + Copyright (c) 2007-2012 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 +--> + +<plugin> + + <extension point="org.eclipse.net4j.util.factories"> + <factory + class="org.eclipse.emf.cdo.server.internal.evolution.bundle.CDOMigrateCommand$Factory" + productGroup="org.eclipse.emf.cdo.server.commands" + type="migrate"/> + </extension> + +</plugin> diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/pom.xml b/plugins/org.eclipse.emf.cdo.server.evolution/pom.xml new file mode 100644 index 0000000000..746478c699 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/pom.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2017, 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 +--> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.emf.cdo</groupId> + <artifactId>org.eclipse.emf.cdo.plugins</artifactId> + <version>4.7.0-SNAPSHOT</version> + <relativePath>../../releng/org.eclipse.emf.cdo.releng.parent/plugins</relativePath> + </parent> + + <groupId>org.eclipse.emf.cdo</groupId> + <artifactId>org.eclipse.emf.cdo.server.evolution</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> + +</project> diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/Renamer.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/Renamer.java new file mode 100644 index 0000000000..d4a5862c9e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/Renamer.java @@ -0,0 +1,145 @@ +/* + * 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.evolution; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public abstract class Renamer implements Runnable +{ + private final Map<String, String> oldNames = new HashMap<String, String>(); + + private final Map<String, String> newNames = new HashMap<String, String>(); + + public Renamer() + { + } + + public Map<String, String> getOldNames() + { + return oldNames; + } + + public Map<String, String> getNewNames() + { + return newNames; + } + + public void addNames(String oldName, String newName) + { + if (oldName != null) + { + oldNames.put(oldName, newName); + } + + if (newName != null) + { + newNames.put(newName, oldName); + } + } + + public void run() + { + List<String> colliding = new ArrayList<String>(); + Set<String> newNames = new HashSet<String>(); + + for (Map.Entry<String, String> entry : oldNames.entrySet()) + { + String oldName = entry.getKey(); + String newName = entry.getValue(); + + if (newName != null && oldNames.containsKey(newName)) + { + if (oldNames.get(newName) == null) + { + throw new RuntimeException("Rename from " + oldName + " to " + newName + " is not possible"); + } + + colliding.add(oldName); + } + else + { + if (newName != null) + { + doRename(oldName, newName); + } + + newNames.add(newName); + } + } + + Map<String, String> tempNames = new LinkedHashMap<String, String>(); + int tempCounter = 0; + + while (!colliding.isEmpty()) + { + String oldName = colliding.remove(0); + String newName = oldNames.get(oldName); + + if (newNames.contains(newName) || colliding.contains(newName)) + { + String tempName = createTempName(++tempCounter); + tempNames.put(tempName, newName); + + doRename(oldName, tempName); + } + else + { + doRename(oldName, newName); + } + } + + for (Map.Entry<String, String> entry : tempNames.entrySet()) + { + String tempName = entry.getKey(); + String newName = entry.getValue(); + doRename(tempName, newName); + } + } + + protected abstract void doRename(String oldName, String newName); + + protected String createTempName(int id) + { + return getTempPrefix() + id; + } + + protected String getTempPrefix() + { + return "CDO_TMP_"; + } + + // public static void main(String[] args) + // { + // Renamer renamer = new Renamer() + // { + // @Override + // protected void doRename(String oldName, String newName) + // { + // System.out.println(oldName + " --> " + newName); + // } + // }; + // + // renamer.addNames("C", "X"); + // renamer.addNames("A", "B"); + // renamer.addNames("B", "A"); + // renamer.addNames("X", "M"); + // renamer.run(); + // } +} diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/package-info.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/package-info.java new file mode 100644 index 0000000000..ee0f9e6727 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/evolution/package-info.java @@ -0,0 +1,11 @@ +/* + * Copyright (c) 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 + */ + +/** + * Server concepts for dealing with Net4j-based repositories and fail-over infrastructure. + */ +package org.eclipse.emf.cdo.server.evolution; diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/CDOMigrateCommand.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/CDOMigrateCommand.java new file mode 100644 index 0000000000..e8a7464458 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/CDOMigrateCommand.java @@ -0,0 +1,80 @@ +/* + * 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.evolution.bundle; + +import org.eclipse.emf.cdo.server.IStoreAccessor; +import org.eclipse.emf.cdo.server.spi.evolution.AbstractMigrationContext; +import org.eclipse.emf.cdo.server.spi.evolution.EvolutionSupport; +import org.eclipse.emf.cdo.spi.server.CDOCommand; +import org.eclipse.emf.cdo.spi.server.InternalRepository; + +import org.eclipse.net4j.util.factory.ProductCreationException; +import org.eclipse.net4j.util.om.monitor.Monitor; + +import org.eclipse.emf.common.util.URI; + +/** + * @author Eike Stepper + */ +public class CDOMigrateCommand extends CDOCommand.WithAccessor +{ + public CDOMigrateCommand() + { + super("migrate", "migrate the contents of a repository to a new release of the models", + new CommandParameter[] { CDOCommand.parameter("evolution-uri"), CDOCommand.optional("release-version") }); + } + + @Override + public void execute(InternalRepository repository, IStoreAccessor accessor, String[] args) throws Exception + { + if (accessor instanceof EvolutionSupport) + { + EvolutionSupport evolutionSupport = (EvolutionSupport)accessor; + + URI evolutionURI = "reset".equals(args[0]) ? null : URI.createURI(args[0]); + int releaseVersion = args[1] == null ? AbstractMigrationContext.LATEST_RELEASE_VERSION : Integer.parseInt(args[1]); + + AbstractMigrationContext context = createMigrationContext(evolutionURI, releaseVersion); + context.migrate(evolutionSupport, new Monitor()); + } + else + { + println("The repository " + repository.getName() + " does not support model evolution"); + } + } + + protected AbstractMigrationContext createMigrationContext(URI evolutionURI, int releaseVersion) + { + return new AbstractMigrationContext(evolutionURI, releaseVersion) + { + public void log(Object msg) + { + println(msg); + } + }; + } + + /** + * @author Eike Stepper + */ + public static final class Factory extends org.eclipse.net4j.util.factory.Factory + { + public Factory() + { + super(CDOCommand.PRODUCT_GROUP, "migrate"); + } + + public CDOCommand.WithAccessor create(String description) throws ProductCreationException + { + return new CDOMigrateCommand(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/OM.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/OM.java new file mode 100644 index 0000000000..a40dffbbfd --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/internal/evolution/bundle/OM.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 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.evolution.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.server.evolution"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/AbstractMigrationContext.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/AbstractMigrationContext.java new file mode 100644 index 0000000000..12cec614d7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/AbstractMigrationContext.java @@ -0,0 +1,239 @@ +/* + * 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.spi.evolution; + +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.evolution.Evolution; +import org.eclipse.emf.cdo.evolution.Release; +import org.eclipse.emf.cdo.server.IStore; +import org.eclipse.emf.cdo.server.IStoreAccessor; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.net4j.util.collection.CollectionUtil; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public abstract class AbstractMigrationContext implements MigrationContext +{ + public static final int LATEST_RELEASE_VERSION = -1; + + private static final String PROP_RELEASE_VERSION = "org.eclipse.emf.cdo.server.evolution.releaseVersion"; + + private static final Set<String> PROPS = CollectionUtil.setOf(PROP_RELEASE_VERSION); + + private static final boolean ALWAYS_RESET = OMPlatform.INSTANCE.isProperty("org.eclipse.emf.cdo.server.evolution.AbstractMigrationContext.alwaysReset"); + + private final Evolution evolution; + + private final Release newRelease; + + /** + * + * @param evolutionURI the <code>URI</code> of the evolution resource, + * or <code>null</code> to request deletion of the migration properties + * from the {@link IStore store}. + * @param releaseVersion the version of the release to migrate to, or any value if the <code>evolutionURI</code> + * parameter is null. + */ + public AbstractMigrationContext(URI evolutionURI, int releaseVersion) + { + if (evolutionURI != null) + { + evolution = loadEvolution(evolutionURI); + + if (releaseVersion == LATEST_RELEASE_VERSION) + { + Release latestRelease = evolution.getLatestRelease(); + releaseVersion = latestRelease == null ? 0 : latestRelease.getVersion(); + } + + newRelease = evolution.getRelease(releaseVersion); + if (newRelease == null) + { + throw new IllegalArgumentException("Release v" + releaseVersion + " does not exist"); + } + + controlRootPackages(); + } + else + { + evolution = null; + newRelease = null; + } + } + + public AbstractMigrationContext(Release release) + { + newRelease = release; + + if (newRelease != null) + { + evolution = newRelease.getEvolution(); + controlRootPackages(); + } + else + { + evolution = null; + } + } + + public boolean migrate(EvolutionSupport evolutionSupport, OMMonitor monitor) + { + String repositoryName = evolutionSupport.getStore().getRepository().getName(); + + if (evolution == null) + { + deleteReleaseVersion(evolutionSupport); + log("Migration properties of " + repositoryName + " deleted"); + return true; + } + + if (ALWAYS_RESET) + { + deleteReleaseVersion(evolutionSupport); + } + + int oldVersion = readReleaseVersion(evolutionSupport); + + Release[] releases = computeReleases(oldVersion); + if (releases.length == 0) + { + log("Migration of " + repositoryName + " not needed"); + return false; + } + + monitor.begin(releases.length); + + try + { + InternalCDORevisionCache revisionCache = ((InternalCDORevisionManager)evolutionSupport.getStore().getRepository().getRevisionManager()).getCache(); + + for (Release toRelease : releases) + { + int toVersion = toRelease.getVersion(); + String msg = repositoryName + (oldVersion == 0 ? "" : " from release v" + oldVersion) + " to release v" + toVersion; + log("Migrating " + msg); + + evolutionSupport.migrateTo(toRelease, this, monitor.fork()); + revisionCache.clear(); + + writeReleaseVersion(evolutionSupport, toVersion); + log("Migrated " + msg); + log(""); + + oldVersion = toVersion; + } + + return true; + } + finally + { + monitor.done(); + } + } + + /** + * Moves each root package of the new release into its own resource with the {@link EPackage#getNsURI() nsURI}, + * such that {@link EcoreUtil#getURI(org.eclipse.emf.ecore.EObject) EcoreUtil.getURI(modelElement)} returns a + * URI that starts with the nsURI of the rootPackage. + */ + protected void controlRootPackages() + { + Resource releaseResource = newRelease.eResource(); + ResourceSet resourceSet = releaseResource.getResourceSet(); + + for (EPackage rootPackage : newRelease.getRootPackages()) + { + if (rootPackage.eResource() == releaseResource) + { + URI nsURI = URI.createURI(rootPackage.getNsURI()); + + Resource resource = resourceSet.createResource(nsURI); + resource.getContents().add(rootPackage); + } + } + } + + protected Evolution loadEvolution(URI evolutionURI) + { + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(); + Resource resource = resourceSet.getResource(evolutionURI, true); + Evolution evolution = (Evolution)resource.getContents().get(0); + + CDOView view = evolution.cdoView(); + if (view != null) + { + // TODO Create temp resource set? Copy models? + evolution = EcoreUtil.copy(evolution); + view.getSession().close(); + } + + return evolution; + } + + protected Release[] computeReleases(int oldVersion) + { + List<Release> releases = new ArrayList<Release>(); + Release oldRelease = oldVersion == 0 ? null : evolution.getRelease(oldVersion); + + for (Release fromRelease = oldRelease; oldVersion < newRelease.getVersion();) + { + Release toRelease = fromRelease == null ? evolution.getInitialRelease() : fromRelease.getNextRelease(); + releases.add(toRelease); + + fromRelease = toRelease; + oldVersion = fromRelease.getVersion(); + } + + return releases.toArray(new Release[releases.size()]); + } + + protected int readReleaseVersion(IStoreAccessor accessor) + { + IStore store = accessor.getStore(); + Map<String, String> properties = store.getPersistentProperties(PROPS); + + String currentVersion = properties.get(PROP_RELEASE_VERSION); + return currentVersion == null ? 0 : Integer.parseInt(currentVersion); + } + + protected void writeReleaseVersion(IStoreAccessor accessor, int releaseVersion) + { + Map<String, String> properties = new HashMap<String, String>(); + properties.put(PROP_RELEASE_VERSION, Integer.toString(releaseVersion)); + + IStore store = accessor.getStore(); + store.setPersistentProperties(properties); + } + + protected void deleteReleaseVersion(IStoreAccessor accessor) + { + IStore store = accessor.getStore(); + store.removePersistentProperties(PROPS); + } +} diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/EvolutionSupport.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/EvolutionSupport.java new file mode 100644 index 0000000000..698c3db0a7 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/EvolutionSupport.java @@ -0,0 +1,24 @@ +/* + * 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.spi.evolution; + +import org.eclipse.emf.cdo.evolution.Release; +import org.eclipse.emf.cdo.server.IStoreAccessor; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +/** + * @author Eike Stepper + */ +public interface EvolutionSupport extends IStoreAccessor +{ + public void migrateTo(Release release, MigrationContext context, OMMonitor monitor); +} diff --git a/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/MigrationContext.java b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/MigrationContext.java new file mode 100644 index 0000000000..c1a2b063c5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server.evolution/src/org/eclipse/emf/cdo/server/spi/evolution/MigrationContext.java @@ -0,0 +1,19 @@ +/* + * 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.spi.evolution; + +/** + * @author Eike Stepper + */ +public interface MigrationContext +{ + public void log(Object msg); +} diff --git a/plugins/org.eclipse.emf.cdo.server.product/CDOServer.launch b/plugins/org.eclipse.emf.cdo.server.product/CDOServer.launch index dba19e1e70..fe7c3cbcd7 100644 --- a/plugins/org.eclipse.emf.cdo.server.product/CDOServer.launch +++ b/plugins/org.eclipse.emf.cdo.server.product/CDOServer.launch @@ -32,8 +32,8 @@ <stringAttribute key="product" value="org.eclipse.platform.ide"/> <stringAttribute key="selectedPlugin" value="org.eclipse.emf.cdo"/> <stringAttribute key="selected_target_plugins" value="com.ibm.icu@default:default,com.mysql.jdbc@default:default,org.apache.derby@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.win32.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.console@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.osgi.compatibility.state@default:false,org.eclipse.osgi@-1:true,org.h2@default:default,org.hsqldb@default:default,org.postgresql@default:default"/> -<stringAttribute key="selected_workspace_plugins" value="org.eclipse.emf.cdo.common@default:default,org.eclipse.emf.cdo.ecore.retrofit@default:false,org.eclipse.emf.cdo.examples.company@default:default,org.eclipse.emf.cdo.expressions@default:default,org.eclipse.emf.cdo.net4j@default:default,org.eclipse.emf.cdo.security@default:default,org.eclipse.emf.cdo.server.admin@default:default,org.eclipse.emf.cdo.server.db@default:default,org.eclipse.emf.cdo.server.net4j@default:default,org.eclipse.emf.cdo.server.security@default:default,org.eclipse.emf.cdo.server@default:default,org.eclipse.emf.cdo@default:default,org.eclipse.net4j.db.derby@default:default,org.eclipse.net4j.db.h2@default:default,org.eclipse.net4j.db.hsqldb@default:default,org.eclipse.net4j.db.jdbc@default:default,org.eclipse.net4j.db.mysql@default:default,org.eclipse.net4j.db.postgresql@default:default,org.eclipse.net4j.db@default:default,org.eclipse.net4j.jvm@default:default,org.eclipse.net4j.tcp@default:default,org.eclipse.net4j.util@default:default,org.eclipse.net4j@default:default"/> -<booleanAttribute key="show_selected_only" value="true"/> +<stringAttribute key="selected_workspace_plugins" value="org.eclipse.emf.cdo.common@default:default,org.eclipse.emf.cdo.ecore.retrofit@default:false,org.eclipse.emf.cdo.evolution@default:default,org.eclipse.emf.cdo.examples.company@default:default,org.eclipse.emf.cdo.expressions@default:default,org.eclipse.emf.cdo.net4j@default:default,org.eclipse.emf.cdo.security@default:default,org.eclipse.emf.cdo.server.admin@default:default,org.eclipse.emf.cdo.server.db@default:default,org.eclipse.emf.cdo.server.evolution@default:default,org.eclipse.emf.cdo.server.net4j@default:default,org.eclipse.emf.cdo.server.security@default:default,org.eclipse.emf.cdo.server@default:default,org.eclipse.emf.cdo@default:default,org.eclipse.net4j.db.derby@default:default,org.eclipse.net4j.db.h2@default:default,org.eclipse.net4j.db.hsqldb@default:default,org.eclipse.net4j.db.jdbc@default:default,org.eclipse.net4j.db.mysql@default:default,org.eclipse.net4j.db.postgresql@default:default,org.eclipse.net4j.db@default:default,org.eclipse.net4j.jvm@default:default,org.eclipse.net4j.tcp@default:default,org.eclipse.net4j.util@default:default,org.eclipse.net4j@default:default"/> +<booleanAttribute key="show_selected_only" value="false"/> <stringAttribute key="templateConfig" value="${target_home}\configuration\config.ini"/> <booleanAttribute key="tracing" value="false"/> <mapAttribute key="tracingOptions"> diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java index 70cb7ba82a..1a3fe4a71b 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java @@ -2308,18 +2308,7 @@ public class Repository extends Container<Object> implements InternalRepository, try { - Collection<InternalCDOPackageUnit> packageUnits = reader.readPackageUnits(); - for (InternalCDOPackageUnit packageUnit : packageUnits) - { - packageRegistry.putPackageUnit(packageUnit); - - // Bug 521029: Initialize EPackages early from the main thread to avoid multi-threading issues. - // This could be made optional at some point. - for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos()) - { - packageInfo.getEPackage(true); // Trigger initialization. - } - } + readPackageUnits(reader, packageRegistry); } finally { @@ -2327,6 +2316,25 @@ public class Repository extends Container<Object> implements InternalRepository, } } + public static void readPackageUnits(IStoreAccessor reader, InternalCDOPackageRegistry packageRegistry) + { + Collection<InternalCDOPackageUnit> packageUnits = reader.readPackageUnits(); + for (InternalCDOPackageUnit packageUnit : packageUnits) + { + packageRegistry.putPackageUnit(packageUnit); + } + + // Bug 521029: Initialize EPackages early from the main thread to avoid multi-threading issues. + // This could be made optional at some point. + for (InternalCDOPackageUnit packageUnit : packageUnits) + { + for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos()) + { + packageInfo.getEPackage(true); // Trigger initialization. + } + } + } + protected void setPostActivateState() { setState(State.ONLINE); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java index 84bbe345c9..45292ecec6 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/bundle/CDOCommandProvider.java @@ -171,11 +171,27 @@ public class CDOCommandProvider implements CommandProvider } }; - private static final CDOCommand branches = new CDOCommand.WithRepository("branches", "dump the branches of a repository") + private static final CDOCommand properties = new CDOCommand.WithRepository("properties", "dump the persistent properties of a repository") { @Override public void execute(InternalRepository repository, String[] args) throws Exception { + Map<String, String> properties = repository.getStore().getPersistentProperties(null); + List<String> keys = new ArrayList<String>(properties.keySet()); + Collections.sort(keys); + + for (String key : keys) + { + println(key + " = " + properties.get(key)); + } + } + }; + + private static final CDOCommand branches = new CDOCommand.WithAccessor("branches", "dump the branches of a repository") + { + @Override + public void execute(InternalRepository repository, IStoreAccessor accessor, String[] args) throws Exception + { branches(repository.getBranchManager().getMainBranch(), ""); } @@ -247,7 +263,7 @@ public class CDOCommandProvider implements CommandProvider } }; - private static final CDOCommand deletelocks = new CDOCommand.WithAccessor("deletelocks", "delete a durable locking area of a repository", + private static final CDOCommand deleteLocks = new CDOCommand.WithAccessor("deletelocks", "delete a durable locking area of a repository", CDOCommand.parameter("area-id")) { @Override @@ -348,11 +364,12 @@ public class CDOCommandProvider implements CommandProvider addCommand(commands, stop); addCommand(commands, exportXML); addCommand(commands, importXML); + addCommand(commands, properties); addCommand(commands, branches); - addCommand(commands, deletelocks); - addCommand(commands, locks); addCommand(commands, packages); addCommand(commands, sessions); + addCommand(commands, locks); + addCommand(commands, deleteLocks); try { diff --git a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 ALL) with ServerBrowser.launch b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 ALL) with ServerBrowser.launch index bed44a829c..11e5075ba1 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 ALL) with ServerBrowser.launch +++ b/plugins/org.eclipse.emf.cdo.tests.db/CDO AllTests (H2 ALL) with ServerBrowser.launch @@ -16,5 +16,5 @@ <stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2All"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/> -<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx2G -Dorg.eclipse.net4j.util.om.trace.disable=true -Dorg.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.enableServerBrowser=true"/> +<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m -Xmx2G -Dorg.eclipse.net4j.util.om.trace.disable=true -Dorg.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.enableServerBrowser=true -Dorg.eclipse.emf.cdo.server.db.zipPackageBytes=true"/> </launchConfiguration> diff --git a/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF index fd6cbbf3f1..1b0cb3e820 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.tests.db/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.tests.db;singleton:=true -Bundle-Version: 4.0.700.qualifier +Bundle-Version: 4.0.800.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -27,12 +27,12 @@ Import-Package: com.mysql.jdbc.jdbc2.optional;version="[5.0.0,6.0.0)", org.hsqldb.jdbc;version="[2.0.0,3.0.0)", org.postgresql.ds;version="[9.0.0,10.0.0)", org.postgresql.ds.common;version="[9.0.0,10.0.0)" -Export-Package: org.eclipse.emf.cdo.tests.db;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all", - org.eclipse.emf.cdo.tests.db.bugzilla;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all", - org.eclipse.emf.cdo.tests.db.bundle;version="4.0.700";x-internal:=true, - org.eclipse.emf.cdo.tests.db.capabilities;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all", - org.eclipse.emf.cdo.tests.db.offline;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all", - org.eclipse.emf.cdo.tests.db.performance;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all", - org.eclipse.emf.cdo.tests.db.revisioncache;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all", - org.eclipse.emf.cdo.tests.db.verifier;version="4.0.700";x-friends:="org.eclipse.emf.cdo.tests.all" +Export-Package: org.eclipse.emf.cdo.tests.db;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all", + org.eclipse.emf.cdo.tests.db.bugzilla;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all", + org.eclipse.emf.cdo.tests.db.bundle;version="4.0.800";x-internal:=true, + org.eclipse.emf.cdo.tests.db.capabilities;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all", + org.eclipse.emf.cdo.tests.db.offline;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all", + org.eclipse.emf.cdo.tests.db.performance;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all", + org.eclipse.emf.cdo.tests.db.revisioncache;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all", + org.eclipse.emf.cdo.tests.db.verifier;version="4.0.800";x-friends:="org.eclipse.emf.cdo.tests.all" Automatic-Module-Name: org.eclipse.emf.cdo.tests.db diff --git a/plugins/org.eclipse.emf.cdo.tests.db/evolution/company1.evolution b/plugins/org.eclipse.emf.cdo.tests.db/evolution/company1.evolution new file mode 100644 index 0000000000..a30351348e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.db/evolution/company1.evolution @@ -0,0 +1,553 @@ +<?xml version="1.0" encoding="UTF-8"?> +<evolution:Evolution xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:evolution="http://www.eclipse.org/emf/CDO/evolution/1.0.0"> + <models uRI="platform:/resource/org.eclipse.emf.cdo.examples.company/model/company.ecore"/> + <models uRI="platform:/resource/org.eclipse.emf.cdo.examples.company/model/extended.ecore"/> + <releases version="1" date="2018-08-17T16:09:03.828+0200"> + <rootPackages name="extended" nsURI="http://www.eclipse.org/emf/CDO/examples/extended/1.0.0" nsPrefix="extended"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmEKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eClassifiers xsi:type="ecore:EClass" name="ExtendedCompany" eSuperTypes="//@releases.0/@rootPackages.1/Company"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmEaImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="employees" upperBound="-1" eType="//@releases.0/@rootPackages.0/Employee" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmEqImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Employee" eSuperTypes="//@releases.0/@rootPackages.1/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmE6ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="salary"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWgNIKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eStructuralFeatures> + </eClassifiers> + </rootPackages> + <rootPackages name="company" nsURI="http://www.eclipse.org/emf/CDO/examples/company/1.0.0" nsPrefix="company"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@hbGenericGenerators({@GenericGenerator(name="system-uuid", strategy = "org.eclipse.emf.cdo.examples.hibernate.server.CDOExampleUUIDHexGenerator")})"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatwKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eClassifiers xsi:type="ecore:EClass" name="Addressable" abstract="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatwaImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatwqImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="street"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatw6ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="city"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatxKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Company" eSuperTypes="//@releases.0/@rootPackages.1/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatxaImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1" eType="//@releases.0/@rootPackages.1/Category" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatxqImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="suppliers" upperBound="-1" eType="//@releases.0/@rootPackages.1/Supplier" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatx6ImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="customers" upperBound="-1" eType="//@releases.0/@rootPackages.1/Customer" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatyKImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" eType="//@releases.0/@rootPackages.1/PurchaseOrder" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatyaImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" eType="//@releases.0/@rootPackages.1/SalesOrder" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU0KImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Supplier" eSuperTypes="//@releases.0/@rootPackages.1/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU0aImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" eType="//@releases.0/@rootPackages.1/PurchaseOrder" eOpposite="//@releases.0/@rootPackages.1/PurchaseOrder/supplier"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU0qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="preferred" defaultValueLiteral="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU06ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Customer" eSuperTypes="//@releases.0/@rootPackages.1/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU1KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" eType="//@releases.0/@rootPackages.1/SalesOrder" eOpposite="//@releases.0/@rootPackages.1/SalesOrder/customer"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU1aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Order"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Entity(name="BaseOrder")"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU1qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1" eType="//@releases.0/@rootPackages.1/OrderDetail" containment="true" eOpposite="//@releases.0/@rootPackages.1/OrderDetail/order"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU16ImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="OrderDetail"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU2KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="order" lowerBound="1" eType="//@releases.0/@rootPackages.1/Order" eOpposite="//@releases.0/@rootPackages.1/Order/orderDetails"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU2aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="product" eType="//@releases.0/@rootPackages.1/Product" eOpposite="//@releases.0/@rootPackages.1/Product/orderDetails"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU2qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="price"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU26ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EFloat"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder" eSuperTypes="//@releases.0/@rootPackages.1/Order"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU3KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="date"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU3aImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EDate"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="supplier" lowerBound="1" eType="//@releases.0/@rootPackages.1/Supplier" eOpposite="//@releases.0/@rootPackages.1/Supplier/purchaseOrders"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU3qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="SalesOrder" eSuperTypes="//@releases.0/@rootPackages.1/Order"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU36ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU4KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="customer" lowerBound="1" eType="//@releases.0/@rootPackages.1/Customer" eOpposite="//@releases.0/@rootPackages.1/Customer/salesOrders"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU4aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Category"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU4qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Id @GeneratedValue(generator="system-uuid")"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU46ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1" eType="//@releases.0/@rootPackages.1/Category" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU5KImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="products" upperBound="-1" eType="//@releases.0/@rootPackages.1/Product" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU5aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Product"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU5qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Id"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU56ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1" eType="//@releases.0/@rootPackages.1/OrderDetail" eOpposite="//@releases.0/@rootPackages.1/OrderDetail/product"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU6KImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="vat" eType="//@releases.0/@rootPackages.1/VAT" defaultValueLiteral="vat15"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Basic(optional=false)
@Column(nullable=false)"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU6aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" transient="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU6qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="price"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU66ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EFloat"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EEnum" name="VAT"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU7KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eLiterals name="vat0"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU7aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eLiterals> + <eLiterals name="vat7" value="7"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU7qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eLiterals> + <eLiterals name="vat15" value="15"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU76ImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eLiterals> + </eClassifiers> + </rootPackages> + </releases> + <releases version="2" date="2018-09-16T11:38:02.913+0200"> + <rootPackages name="company" nsURI="http://www.eclipse.org/emf/CDO/examples/company/1.0.0" nsPrefix="company"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@hbGenericGenerators({@GenericGenerator(name="system-uuid", strategy = "org.eclipse.emf.cdo.examples.hibernate.server.CDOExampleUUIDHexGenerator")})"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatwKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eClassifiers xsi:type="ecore:EClass" name="Addressable" abstract="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatwaImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatwqImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="street"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatw6ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="city"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatxKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Company" eSuperTypes="//@releases.1/@rootPackages.0/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatxaImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1" eType="//@releases.1/@rootPackages.0/Category" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatxqImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="suppliers" upperBound="-1" eType="//@releases.1/@rootPackages.0/Supplier" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatx6ImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="customers" upperBound="-1" eType="//@releases.1/@rootPackages.0/Customer" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatyKImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" eType="//@releases.1/@rootPackages.0/PurchaseOrder" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEatyaImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" eType="//@releases.1/@rootPackages.0/SalesOrder" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU0KImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Supplier" eSuperTypes="//@releases.1/@rootPackages.0/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU0aImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" eType="//@releases.1/@rootPackages.0/PurchaseOrder" eOpposite="//@releases.1/@rootPackages.0/PurchaseOrder/supplier"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU0qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="preferred" defaultValueLiteral="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU06ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Customer" eSuperTypes="//@releases.1/@rootPackages.0/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU1KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" eType="//@releases.1/@rootPackages.0/SalesOrder" eOpposite="//@releases.1/@rootPackages.0/SalesOrder/customer"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU1aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Order"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Entity(name="BaseOrder")"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU1qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1" eType="//@releases.1/@rootPackages.0/OrderDetail" containment="true" eOpposite="//@releases.1/@rootPackages.0/OrderDetail/order"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU16ImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="OrderDetail"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU2KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="order" lowerBound="1" eType="//@releases.1/@rootPackages.0/Order" eOpposite="//@releases.1/@rootPackages.0/Order/orderDetails"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU2aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="product" eType="//@releases.1/@rootPackages.0/Product" eOpposite="//@releases.1/@rootPackages.0/Product/orderDetails"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU2qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="price"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU26ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EFloat"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder" eSuperTypes="//@releases.1/@rootPackages.0/Order"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU3KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="date"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU3aImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EDate"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="supplier" lowerBound="1" eType="//@releases.1/@rootPackages.0/Supplier" eOpposite="//@releases.1/@rootPackages.0/Supplier/purchaseOrders"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU3qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="SalesOrder" eSuperTypes="//@releases.1/@rootPackages.0/Order"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU36ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU4KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="customer" lowerBound="1" eType="//@releases.1/@rootPackages.0/Customer" eOpposite="//@releases.1/@rootPackages.0/Customer/salesOrders"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU4aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Category"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU4qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Id @GeneratedValue(generator="system-uuid")"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU46ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1" eType="//@releases.1/@rootPackages.0/Category" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU5KImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="products" upperBound="-1" eType="//@releases.1/@rootPackages.0/Product" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU5aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Product"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU5qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Id"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU56ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1" eType="//@releases.1/@rootPackages.0/OrderDetail" eOpposite="//@releases.1/@rootPackages.0/OrderDetail/product"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU6KImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="vat" eType="//@releases.1/@rootPackages.0/VAT" defaultValueLiteral="vat15"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Basic(optional=false)
@Column(nullable=false)"/> + </eAnnotations> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU6aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" transient="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU6qImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="price"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU66ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EFloat"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EEnum" name="VAT"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU7KImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eLiterals name="vat0"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU7aImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eLiterals> + <eLiterals name="vat7" value="7"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU7qImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eLiterals> + <eLiterals name="vat15" value="15"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_IEbU76ImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eLiterals> + </eClassifiers> + </rootPackages> + <rootPackages name="extended" nsURI="http://www.eclipse.org/emf/CDO/examples/extended/1.0.0/v2" nsPrefix="extended"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmEKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eClassifiers xsi:type="ecore:EClass" name="CompanyWithEmployees" eSuperTypes="//@releases.1/@rootPackages.0/Company"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmEaImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EReference" name="employees" upperBound="-1" eType="//@releases.1/@rootPackages.1/Employee" containment="true"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmEqImEeiVxYbQv5gQdw"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="code"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_c13uAKInEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EByte"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="salary"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="oldValue" value="_DWgNIKImEeiVxYbQv5gQdw"/> + <details key="value" value="_uqFJUKUCEeiGSu5PVxFtGQ"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eStructuralFeatures> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Employee" eSuperTypes="//@releases.1/@rootPackages.0/Addressable"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWfmE6ImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="salary"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="value" value="_DWgNIKImEeiVxYbQv5gQdw"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="salary2"> + <eAnnotations source="http://www.eclipse.org/CDO/evolution/ID"> + <details key="oldValue" value="_DWgNIKImEeiVxYbQv5gQdw"/> + <details key="value" value="_D1TTgKRLEeiiEtXzDT3l2w"/> + </eAnnotations> + <eType xsi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + </eStructuralFeatures> + </eClassifiers> + </rootPackages> + </releases> +</evolution:Evolution> diff --git a/plugins/org.eclipse.emf.cdo.tests.db/evolution/model1.ecore b/plugins/org.eclipse.emf.cdo.tests.db/evolution/model1.ecore new file mode 100644 index 0000000000..e839a2bd23 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.db/evolution/model1.ecore @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model1" nsURI="http://www.eclipse.org/EvolutionTest/model1" + nsPrefix="model1"> + <eClassifiers xsi:type="ecore:EClass" name="Address"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="street" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="city" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Company" eSuperTypes="#//Address"> + <eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1" + eType="#//Category" containment="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="suppliers" upperBound="-1" + eType="#//Supplier" containment="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="customers" upperBound="-1" + eType="#//Customer" containment="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" + eType="#//PurchaseOrder" containment="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" + eType="#//SalesOrder" containment="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Supplier" eSuperTypes="#//Address"> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" + eType="#//PurchaseOrder" eOpposite="#//PurchaseOrder/supplier"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="preferred" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean" + defaultValueLiteral="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Customer" eSuperTypes="#//Address"> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" + eType="#//SalesOrder" eOpposite="#//SalesOrder/customer"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderByProduct" upperBound="-1" + eType="#//ProductToOrder" containment="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Order" abstract="true"> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1" + eType="#//OrderDetail" containment="true" eOpposite="#//OrderDetail/order"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="OrderDetail"> + <eStructuralFeatures xsi:type="ecore:EReference" name="order" lowerBound="1" eType="#//Order" + eOpposite="#//Order/orderDetails"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="product" eType="#//Product1" + eOpposite="#//Product1/orderDetails"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="price" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFloat"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder" eSuperTypes="#//Order"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="date" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="supplier" lowerBound="1" + eType="#//Supplier" eOpposite="#//Supplier/purchaseOrders"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="salesOrders" upperBound="-1" + eType="#//SalesOrder" eOpposite="#//SalesOrder/purchaseOrders"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="SalesOrder" eSuperTypes="#//Order"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="customer" lowerBound="1" + eType="#//Customer" eOpposite="#//Customer/salesOrders"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="purchaseOrders" upperBound="-1" + eType="#//PurchaseOrder" eOpposite="#//PurchaseOrder/salesOrders"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Category"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="categories" upperBound="-1" + eType="#//Category" containment="true"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="products" upperBound="-1" + eType="#//Product1" containment="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="Product1"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@Id"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EReference" name="orderDetails" upperBound="-1" + eType="#//OrderDetail" eOpposite="#//OrderDetail/product"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="vat" eType="#//VAT" defaultValueLiteral="vat15"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="otherVATs" upperBound="-1" + eType="#//VAT" defaultValueLiteral="vat15"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="description" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString" + transient="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EEnum" name="VAT"> + <eLiterals name="vat0"/> + <eLiterals name="vat7" value="7"/> + <eLiterals name="vat15" value="15"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="OrderAddress" eSuperTypes="#//Address #//Order #//OrderDetail"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="testAttribute" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="ProductToOrder" instanceClassName="java.util.Map$Entry"> + <eStructuralFeatures xsi:type="ecore:EReference" name="key" eType="#//Product1"/> + <eStructuralFeatures xsi:type="ecore:EReference" name="value" eType="#//SalesOrder"/> + </eClassifiers> +</ecore:EPackage> diff --git a/plugins/org.eclipse.emf.cdo.tests.db/pom.xml b/plugins/org.eclipse.emf.cdo.tests.db/pom.xml index 47f318f5b7..18a141a86b 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/pom.xml +++ b/plugins/org.eclipse.emf.cdo.tests.db/pom.xml @@ -25,7 +25,7 @@ <groupId>org.eclipse.emf.cdo</groupId> <artifactId>org.eclipse.emf.cdo.tests.db</artifactId> - <version>4.0.700-SNAPSHOT</version> + <version>4.0.800-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> </project> diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java index 0d076140b6..ef99baea0c 100644 --- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java +++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/DBConfigs.java @@ -49,6 +49,7 @@ public abstract class DBConfigs extends AllConfigs testClasses.add(DBStoreTest.class); testClasses.add(CustomTypeMappingTest.class); testClasses.add(SQLQueryTest.class); + testClasses.add(EvolutionTest.class); super.initTestClasses(testClasses, scenario); testClasses.remove(MEMStoreQueryTest.class); diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/EvolutionTest.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/EvolutionTest.java new file mode 100644 index 0000000000..339e1389d2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/EvolutionTest.java @@ -0,0 +1,618 @@ +/* + * 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.tests.db; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.evolution.Evolution; +import org.eclipse.emf.cdo.evolution.EvolutionFactory; +import org.eclipse.emf.cdo.evolution.Model; +import org.eclipse.emf.cdo.evolution.Release; +import org.eclipse.emf.cdo.server.StoreThreadLocal; +import org.eclipse.emf.cdo.server.spi.evolution.AbstractMigrationContext; +import org.eclipse.emf.cdo.server.spi.evolution.EvolutionSupport; +import org.eclipse.emf.cdo.session.CDOSession; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.om.monitor.Monitor; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import java.io.File; + +/** + * @author Eike Stepper + */ +@CleanRepositoriesBefore(reason = "Needs clean package registry") +public class EvolutionTest extends AbstractCDOTest +{ + private Model createEvolution(String modelPath) + { + String modelName = URI.createFileURI(modelPath).trimFileExtension().lastSegment(); + String tempFolder = createTempFolder(getTestMethodName() + "-").toString(); + ResourceSet resourceSet = EMFUtil.newEcoreResourceSet(); + + Evolution evolution = EvolutionFactory.eINSTANCE.createEvolution(); + URI evolutionURI = URI.createFileURI(tempFolder).appendSegment(modelName + ".evolution"); + Resource evolutionResource = resourceSet.createResource(evolutionURI); + evolutionResource.getContents().add(evolution); + + File modelFile = new File(tempFolder, modelName + ".ecore"); + IOUtil.copyFile(new File(modelPath), modelFile); + URI modelURI = URI.createFileURI(modelFile.toString()); + Model model = evolution.addModel(modelURI); + + IOUtil.OUT().println("Evolution: " + evolutionURI.path()); + IOUtil.OUT().println("Model: " + modelURI.path()); + IOUtil.OUT().println(); + + evolution.ensureIDs(); + evolution.save(); + + return model; + } + + private void migrate(Release release) + { + AbstractMigrationContext context = new AbstractMigrationContext(release) + { + public void log(Object msg) + { + IOUtil.OUT().println(msg); + } + }; + + EvolutionSupport evolutionSupport = (EvolutionSupport)getRepository().getStore().getReader(null); + StoreThreadLocal.setAccessor(evolutionSupport); + + try + { + context.migrate(evolutionSupport, new Monitor()); + } + finally + { + StoreThreadLocal.release(); + } + } + + public void testInitialRelease() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + Release v1 = model.getEvolution().createRelease(); + migrate(v1); + + CDOSession session = openSession(); + + String nsURI = model.getRootPackage().getNsURI(); + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + EObject company = new SessionPackage(nsURI).create("Company"); + eSet(company, "name", "ESC"); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(company); + transaction.commit(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("res")); + EObject company2 = resource2.getContents().get(0); + assertEquals("ESC", eGet(company2, "name")); + } + + public void testAddClass() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + EPackage ePackage = model.getRootPackage(); + + EClass eClass = EcoreFactory.eINSTANCE.createEClass(); + eClass.setName("Employee"); + eClass.getESuperTypes().add((EClass)ePackage.getEClassifier("Address")); + + EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute(); + eAttribute.setName("salary"); + eAttribute.setEType(EcorePackage.Literals.EDOUBLE); + + ePackage.getEClassifiers().add(eClass); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + String nsURI = model.getRootPackage().getNsURI(); + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + EObject employee = new SessionPackage(nsURI).create("Employee"); + eSet(employee, "name", "Eike"); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(employee); + transaction.commit(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("res")); + EObject employee2 = resource2.getContents().get(0); + assertEquals("Eike", eGet(employee2, "name")); + } + + public void testRenameClass() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + EPackage ePackage = model.getRootPackage(); + EClass addressClass = (EClass)ePackage.getEClassifier("Address"); + addressClass.setName("Addressable"); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + String nsURI = model.getRootPackage().getNsURI(); + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + EObject addressable = new SessionPackage(nsURI).create("Addressable"); + eSet(addressable, "name", "Somebody"); + + EObject customer = new SessionPackage(nsURI).create("Customer"); + eSet(customer, "name", "Eike"); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(addressable); + resource.getContents().add(customer); + transaction.commit(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + CDOResource resource2 = transaction2.getOrCreateResource(getResourcePath("res")); + + EObject addressable2 = resource2.getContents().get(0); + assertEquals("Addressable", addressable2.eClass().getName()); + assertEquals("Somebody", eGet(addressable2, "name")); + + EObject customer2 = resource2.getContents().get(1); + assertEquals("Customer", customer2.eClass().getName()); + assertEquals("Eike", eGet(customer2, "name")); + session2.close(); + + ePackage = model.getRootPackage(); + addressClass = (EClass)ePackage.getEClassifier("Addressable"); + addressClass.setName("AddressableXXX"); + + Release v3 = evolution.createRelease(); + migrate(v3); + + CDOSession session3 = openSession(); + CDOTransaction transaction3 = session3.openTransaction(); + CDOResource resource3 = transaction3.getOrCreateResource(getResourcePath("res")); + + EObject addressable3 = resource3.getContents().get(0); + assertEquals("AddressableXXX", addressable3.eClass().getName()); + assertEquals("Somebody", eGet(addressable3, "name")); + + EObject customer3 = resource3.getContents().get(1); + assertEquals("Customer", customer3.eClass().getName()); + assertEquals("Eike", eGet(customer3, "name")); + session3.close(); + } + + public void testAddAttribute_SingleValued() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + String nsURI = model.getRootPackage().getNsURI(); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + CDOSession session0 = openSession(); + CDOTransaction transaction0 = session0.openTransaction(); + CDOResource resource0 = transaction0.getOrCreateResource(getResourcePath("res")); + EObject customer0 = new SessionPackage(nsURI).create("Customer"); + resource0.getContents().add(customer0); + transaction0.commit(); + session0.close(); + + EPackage ePackage = model.getRootPackage(); + EClass addressClass = (EClass)ePackage.getEClassifier("Address"); + + EAttribute zipCodeAttribute = EcoreFactory.eINSTANCE.createEAttribute(); + zipCodeAttribute.setName("zipCode"); + zipCodeAttribute.setEType(EcorePackage.Literals.EINT); + + addressClass.getEStructuralFeatures().add(zipCodeAttribute); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + EObject customer = new SessionPackage(nsURI).create("Customer"); + eSet(customer, "zipCode", 32584); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(customer); + transaction.commit(); + CDOID customerID = CDOUtil.getCDOObject(customer).cdoID(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + EObject customer2 = transaction2.getObject(customerID); + assertEquals(32584, eGet(customer2, "zipCode")); + } + + public void testAddAttribute_ManyValued() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + String nsURI = model.getRootPackage().getNsURI(); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + CDOSession session0 = openSession(); + CDOTransaction transaction0 = session0.openTransaction(); + CDOResource resource0 = transaction0.getOrCreateResource(getResourcePath("res")); + EObject customer0 = new SessionPackage(nsURI).create("Customer"); + resource0.getContents().add(customer0); + transaction0.commit(); + session0.close(); + + EPackage ePackage = model.getRootPackage(); + EClass addressClass = (EClass)ePackage.getEClassifier("Address"); + + EAttribute zipCodesAttribute = EcoreFactory.eINSTANCE.createEAttribute(); + zipCodesAttribute.setName("zipCodes"); + zipCodesAttribute.setEType(EcorePackage.Literals.EINT); + zipCodesAttribute.setUpperBound(-1); + + addressClass.getEStructuralFeatures().add(zipCodesAttribute); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + EObject customer = new SessionPackage(nsURI).create("Customer"); + eAdd(customer, "zipCodes", 32584); + eAdd(customer, "zipCodes", 10243); + eAdd(customer, "zipCodes", 10777); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(customer); + transaction.commit(); + CDOID customerID = CDOUtil.getCDOObject(customer).cdoID(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + EObject customer2 = transaction2.getObject(customerID); + assertEquals(32584, (int)(Integer)eGet(customer2, "zipCodes", 0)); + assertEquals(10243, (int)(Integer)eGet(customer2, "zipCodes", 1)); + assertEquals(10777, (int)(Integer)eGet(customer2, "zipCodes", 2)); + } + + public void testRenameAttribute_SingleValued() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + String nsURI = model.getRootPackage().getNsURI(); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + CDOSession session0 = openSession(); + CDOTransaction transaction0 = session0.openTransaction(); + CDOResource resource0 = transaction0.getOrCreateResource(getResourcePath("res")); + EObject customer0 = new SessionPackage(nsURI).create("Customer"); + resource0.getContents().add(customer0); + transaction0.commit(); + session0.close(); + + EPackage ePackage = model.getRootPackage(); + EClass addressClass = (EClass)ePackage.getEClassifier("Address"); + addressClass.getEStructuralFeature("city").setName("zipCodeAndCity"); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + EObject customer = new SessionPackage(nsURI).create("Customer"); + eSet(customer, "zipCodeAndCity", "32584 Loehne"); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(customer); + transaction.commit(); + CDOID customerID = CDOUtil.getCDOObject(customer).cdoID(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + EObject customer2 = transaction2.getObject(customerID); + assertEquals("32584 Loehne", eGet(customer2, "zipCodeAndCity")); + } + + public void testRenameAttribute_ManyValued() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + String nsURI = model.getRootPackage().getNsURI(); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + CDOSession session0 = openSession(); + CDOTransaction transaction0 = session0.openTransaction(); + CDOResource resource0 = transaction0.getOrCreateResource(getResourcePath("res")); + SessionPackage sessionPackage0 = new SessionPackage(nsURI); + EObject company0 = sessionPackage0.create("Company"); + resource0.getContents().add(company0); + eAdd(company0, "customers", sessionPackage0.create("Customer")); + transaction0.commit(); + session0.close(); + + EPackage ePackage = model.getRootPackage(); + EClass companyClass = (EClass)ePackage.getEClassifier("Company"); + companyClass.getEStructuralFeature("customers").setName("esteemedCustomers"); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + SessionPackage sessionPackage = new SessionPackage(nsURI); + EObject company = sessionPackage.create("Company"); + eAdd(company, "esteemedCustomers", sessionPackage.create("Customer")); + eAdd(company, "esteemedCustomers", sessionPackage.create("Customer")); + eAdd(company, "esteemedCustomers", sessionPackage.create("Customer")); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(company); + transaction.commit(); + CDOID companyID = CDOUtil.getCDOObject(company).cdoID(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + EObject company2 = transaction2.getObject(companyID); + EList<EObject> esteemedCustomers2 = eList(company2, "esteemedCustomers"); + assertEquals("Customer", esteemedCustomers2.get(0).eClass().getName()); + assertEquals("Customer", esteemedCustomers2.get(1).eClass().getName()); + assertEquals("Customer", esteemedCustomers2.get(2).eClass().getName()); + } + + public void testAddReference_SingleValued() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + String nsURI = model.getRootPackage().getNsURI(); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + CDOSession session0 = openSession(); + CDOTransaction transaction0 = session0.openTransaction(); + CDOResource resource0 = transaction0.getOrCreateResource(getResourcePath("res")); + EObject customer0 = new SessionPackage(nsURI).create("Customer"); + resource0.getContents().add(customer0); + transaction0.commit(); + session0.close(); + + EPackage ePackage = model.getRootPackage(); + EClass addressClass = (EClass)ePackage.getEClassifier("Address"); + + EReference siteReference = EcoreFactory.eINSTANCE.createEReference(); + siteReference.setName("site"); + siteReference.setEType(addressClass); + siteReference.setContainment(true); + + addressClass.getEStructuralFeatures().add(siteReference); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + SessionPackage sessionPackage = new SessionPackage(nsURI); + EObject customer = sessionPackage.create("Customer"); + eSet(customer, "site", sessionPackage.create("Customer")); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(customer); + transaction.commit(); + CDOID customerID = CDOUtil.getCDOObject(customer).cdoID(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + EObject customer2 = transaction2.getObject(customerID); + EObject site2 = eGet(customer2, "site"); + assertEquals("Customer", site2.eClass().getName()); + } + + public void testAddReference_ManyValued() throws Exception + { + // InternalRepository repository = getRepository(); + // IDBStore store = (IDBStore)repository.getStore(); + // IDBSchema schema = store.getDatabase().getSchema(); + // IMappingStrategy mappingStrategy = store.getMappingStrategy(); + + Model model = createEvolution("evolution/model1.ecore"); + String nsURI = model.getRootPackage().getNsURI(); + Evolution evolution = model.getEvolution(); + + Release v1 = evolution.createRelease(); + migrate(v1); + + CDOSession session0 = openSession(); + CDOTransaction transaction0 = session0.openTransaction(); + CDOResource resource0 = transaction0.getOrCreateResource(getResourcePath("res")); + EObject customer0 = new SessionPackage(nsURI).create("Customer"); + resource0.getContents().add(customer0); + transaction0.commit(); + session0.close(); + + EPackage ePackage = model.getRootPackage(); + EClass addressClass = (EClass)ePackage.getEClassifier("Address"); + + EReference sitesReference = EcoreFactory.eINSTANCE.createEReference(); + sitesReference.setName("sites"); + sitesReference.setEType(addressClass); + sitesReference.setContainment(true); + sitesReference.setUpperBound(-1); + + addressClass.getEStructuralFeatures().add(sitesReference); + + Release v2 = evolution.createRelease(); + migrate(v2); + + CDOSession session = openSession(); + + CDOPackageUnit packageUnit = session.getPackageRegistry().getPackageUnit(nsURI); + assertNotNull(packageUnit); + + SessionPackage sessionPackage = new SessionPackage(nsURI); + EObject customer = sessionPackage.create("Customer"); + eAdd(customer, "sites", sessionPackage.create("Customer")); + eAdd(customer, "sites", sessionPackage.create("Customer")); + eAdd(customer, "sites", sessionPackage.create("Customer")); + + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.getOrCreateResource(getResourcePath("res")); + resource.getContents().add(customer); + transaction.commit(); + CDOID customerID = CDOUtil.getCDOObject(customer).cdoID(); + session.close(); + + CDOSession session2 = openSession(); + CDOTransaction transaction2 = session2.openTransaction(); + EObject customer2 = transaction2.getObject(customerID); + assertEquals(3, eList(customer2, "sites").size()); + } + + public void _testNewPackageVersionWithSameNSURI() throws Exception + { + throw new UnsupportedOperationException(); + } + + public void _testNewTransientFeature() throws Exception + { + throw new UnsupportedOperationException(); + } + + public void _testAdditionalIndexes() throws Exception + { + throw new UnsupportedOperationException(); + } + + public void _testRenameUnsettableFeature() throws Exception + { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java index 9026b16fa6..ce14d922e8 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractCDOTest.java @@ -50,12 +50,16 @@ import org.eclipse.net4j.util.io.IOUtil; import org.eclipse.net4j.util.tests.AbstractOMTest; import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.spi.cdo.FSMUtil; import java.util.List; @@ -451,4 +455,84 @@ public abstract class AbstractCDOTest extends ConfigTest } } } + + protected static void eSet(EObject object, String featureName, Object value) + { + EStructuralFeature feature = object.eClass().getEStructuralFeature(featureName); + object.eSet(feature, value); + } + + @SuppressWarnings("unchecked") + protected static <T> T eGet(EObject object, String featureName) + { + EStructuralFeature feature = object.eClass().getEStructuralFeature(featureName); + return (T)object.eGet(feature); + } + + @SuppressWarnings("unchecked") + protected static <T> T eGet(EObject object, String featureName, int index) + { + EList<Object> list = eList(object, featureName); + return (T)list.get(index); + } + + @SuppressWarnings("unchecked") + protected static <T> EList<T> eList(EObject object, String featureName) + { + return (EList<T>)eGet(object, featureName); + } + + protected static void eAdd(EObject object, String featureName, int index, Object value) + { + EList<Object> list = eList(object, featureName); + list.add(index, value); + } + + protected static void eAdd(EObject object, String featureName, Object value) + { + EList<Object> list = eList(object, featureName); + list.add(value); + } + + protected static void eRemove(EObject object, String featureName, int index) + { + EList<Object> list = eList(object, featureName); + list.remove(index); + } + + protected static void eRemove(EObject object, String featureName, Object value) + { + EList<Object> list = eList(object, featureName); + list.remove(value); + } + + /** + * @author Eike Stepper + */ + protected class SessionPackage + { + private final EPackage ePackage; + + public SessionPackage(String nsURI, CDOSession session) + { + ePackage = session.getPackageRegistry().getEPackage(nsURI); + } + + public SessionPackage(String nsURI) + { + this(nsURI, getLatestSession()); + } + + public EPackage getEPackage() + { + return ePackage; + } + + @SuppressWarnings("unchecked") + public <T extends EObject> T create(String className) + { + EClass eClass = (EClass)ePackage.getEClassifier(className); + return (T)EcoreUtil.create(eClass); + } + } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java index 5a5c96a003..87903010c5 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/ISessionConfig.java @@ -49,4 +49,6 @@ public interface ISessionConfig extends IConfig public CDOSession openSession(String repositoryName); public CDOSession openSession(CDOSessionConfiguration configuration); + + public CDOSession getLatestSession(); } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java index 3582693697..683b1f97a7 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/ConfigTest.java @@ -411,6 +411,16 @@ public abstract class ConfigTest extends AbstractOMTest implements IConstants return openSession(); } + /** + * @category Session + */ + public CDOSession getLatestSession() + { + determineCodeLink(); + ISessionConfig sessionConfig = getSessionConfig(); + return sessionConfig.getLatestSession(); + } + // ///////////////////////////////////////////////////////////////////////// // //////////////////////// Model ////////////////////////////////////////// diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java index 6bf0e27140..bde796680a 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java @@ -53,6 +53,7 @@ import org.eclipse.emf.ecore.impl.EPackageImpl; import java.io.File; import java.util.Date; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Set; import java.util.concurrent.ExecutorService; @@ -194,12 +195,24 @@ public abstract class SessionConfig extends Config implements ISessionConfig return session; } + public CDOSession getLatestSession() + { + CDOSession latestSession = null; + + for (CDOSession session : sessions) + { + latestSession = session; + } + + return latestSession; + } + @Override public void setUp() throws Exception { super.setUp(); - sessions = new HashSet<CDOSession>(); + sessions = new LinkedHashSet<CDOSession>(); sessionListener = new LifecycleEventAdapter() { @Override diff --git a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF index a56d80f2d5..f14fd11d8d 100644 --- a/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.net4j.db/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.net4j.db;singleton:=true -Bundle-Version: 4.7.0.qualifier +Bundle-Version: 4.8.0.qualifier Bundle-Activator: org.eclipse.net4j.internal.db.bundle.OM$Activator Bundle-Vendor: %providerName Bundle-ClassPath: . @@ -11,17 +11,17 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)", org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, org.eclipse.net4j.db.jdbc;bundle-version="[4.0.0,5.0.0)" -Export-Package: org.eclipse.net4j.db;version="4.7.0", - org.eclipse.net4j.db.ddl;version="4.7.0", - org.eclipse.net4j.db.ddl.delta;version="4.7.0", - org.eclipse.net4j.db.dml;version="4.7.0", - org.eclipse.net4j.internal.db;version="4.7.0";x-internal:=true, - org.eclipse.net4j.internal.db.bundle;version="4.7.0";x-internal:=true, - org.eclipse.net4j.internal.db.ddl;version="4.7.0";x-friends:="org.eclipse.emf.cdo.server.db", - org.eclipse.net4j.internal.db.ddl.delta;version="4.7.0";x-internal:=true, - org.eclipse.net4j.internal.db.dml;version="4.7.0";x-internal:=true, - org.eclipse.net4j.spi.db;version="4.7.0", - org.eclipse.net4j.spi.db.ddl;version="4.7.0" +Export-Package: org.eclipse.net4j.db;version="4.8.0", + org.eclipse.net4j.db.ddl;version="4.8.0", + org.eclipse.net4j.db.ddl.delta;version="4.8.0", + org.eclipse.net4j.db.dml;version="4.8.0", + org.eclipse.net4j.internal.db;version="4.8.0";x-internal:=true, + org.eclipse.net4j.internal.db.bundle;version="4.8.0";x-internal:=true, + org.eclipse.net4j.internal.db.ddl;version="4.8.0";x-friends:="org.eclipse.emf.cdo.server.db", + org.eclipse.net4j.internal.db.ddl.delta;version="4.8.0";x-internal:=true, + org.eclipse.net4j.internal.db.dml;version="4.8.0";x-internal:=true, + org.eclipse.net4j.spi.db;version="4.8.0", + org.eclipse.net4j.spi.db.ddl;version="4.8.0" Bundle-ActivationPolicy: lazy Eclipse-BuddyPolicy: registered Automatic-Module-Name: org.eclipse.net4j.db diff --git a/plugins/org.eclipse.net4j.db/pom.xml b/plugins/org.eclipse.net4j.db/pom.xml index 3e6e6c972e..3938721b77 100644 --- a/plugins/org.eclipse.net4j.db/pom.xml +++ b/plugins/org.eclipse.net4j.db/pom.xml @@ -25,7 +25,7 @@ <groupId>org.eclipse.emf.cdo</groupId> <artifactId>org.eclipse.net4j.db</artifactId> - <version>4.7.0-SNAPSHOT</version> + <version>4.8.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java index 428c03d427..a7116cdc8d 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java @@ -154,4 +154,9 @@ public interface IDBAdapter * @since 4.2 */ public String sqlModifyField(IDBField field); + + /** + * @since 4.8 + */ + public String sqlRenameTable(String newName, String oldName); } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java index a91a10c8e8..a2add8a0a5 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBField.java @@ -52,4 +52,9 @@ public interface IDBField extends IDBSchemaElement, PositionProvider public String formatPrecision(); public String formatPrecisionAndScale(); + + /** + * @since 4.8 + */ + public boolean rename(String newName); } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java index 26b6a31005..72f1c67012 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBSchemaElement.java @@ -13,7 +13,7 @@ package org.eclipse.net4j.db.ddl; import org.eclipse.net4j.util.container.IContainer; /** - * Specifies a hierachical namespace for elements in a {@link IDBSchema DB schema}. + * Specifies a hierarchical namespace for elements in a {@link IDBSchema DB schema}. * * @author Eike Stepper * @noimplement This interface is not intended to be implemented by clients. diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBTable.java index 67543a536a..7e1a78b774 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBTable.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/ddl/IDBTable.java @@ -110,4 +110,9 @@ public interface IDBTable extends IDBSchemaElement public IDBIndex getPrimaryKeyIndex(); public String sqlInsert(); + + /** + * @since 4.8 + */ + public boolean rename(String newName); } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java index 5d494256ae..ea0b2d927f 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBField.java @@ -19,6 +19,7 @@ import org.eclipse.net4j.db.ddl.IDBTable; import org.eclipse.net4j.spi.db.ddl.InternalDBField; import org.eclipse.net4j.spi.db.ddl.InternalDBSchema; import org.eclipse.net4j.spi.db.ddl.InternalDBTable; +import org.eclipse.net4j.util.ObjectUtil; import java.io.IOException; import java.io.Writer; @@ -222,6 +223,21 @@ public class DBField extends DBSchemaElement implements InternalDBField return table.getName() + "." + getName(); //$NON-NLS-1$ } + public boolean rename(String newName) + { + String oldName = getName(); + if (!ObjectUtil.equals(newName, oldName)) + { + if (((InternalDBTable)table).renameField(this, newName)) + { + setName(newName); + return true; + } + } + + return false; + } + public void remove() { ((InternalDBTable)table).removeField(this); diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java index b312dfbbb7..f6364cb1b0 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchema.java @@ -214,6 +214,21 @@ public class DBSchema extends DBSchemaElement implements InternalDBSchema return table; } + public boolean renameTable(IDBTable table, String newName) + { + assertUnlocked(); + newName = name(newName); + + if (tables.containsKey(newName)) + { + return false; + } + + tables.remove(table.getName()); + tables.put(newName, table); + return true; + } + /** * @since 4.2 */ diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java index 722c71d57b..3c2a57ae71 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBSchemaElement.java @@ -168,14 +168,29 @@ public abstract class DBSchemaElement extends DBNamedElement implements Internal int level = schemaElementType.getLevel(); for (int i = 0; i < level; i++) { - writer.append(" "); + if (writer instanceof DumpFormat) + { + writer.append(((DumpFormat)writer).getIndent()); + } + else + { + writer.append(" "); + } } writer.append(schemaElementType.toString()); writer.append(" "); writer.append(getName()); dumpAdditionalProperties(writer); - writer.append(StringUtil.NL); + + if (writer instanceof DumpFormat) + { + writer.append(((DumpFormat)writer).getNewline()); + } + else + { + writer.append(StringUtil.NL); + } for (IDBSchemaElement element : getElements()) { diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java index 576132c64e..9110fc25fe 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DBTable.java @@ -22,6 +22,7 @@ import org.eclipse.net4j.db.ddl.SchemaElementNotFoundException; import org.eclipse.net4j.spi.db.ddl.InternalDBField; import org.eclipse.net4j.spi.db.ddl.InternalDBSchema; import org.eclipse.net4j.spi.db.ddl.InternalDBTable; +import org.eclipse.net4j.util.ObjectUtil; import java.util.ArrayList; import java.util.Iterator; @@ -137,6 +138,19 @@ public class DBTable extends DBSchemaElement implements InternalDBTable resetElements(); } + public boolean renameField(IDBField field, String newName) + { + assertUnlocked(); + newName = name(newName); + + if (getField(newName) != null) + { + return false; + } + + return true; + } + public IDBField getFieldSafe(String name) throws SchemaElementNotFoundException { IDBField field = getField(name); @@ -310,6 +324,21 @@ public class DBTable extends DBSchemaElement implements InternalDBTable return getName(); } + public boolean rename(String newName) + { + String oldName = getName(); + if (!ObjectUtil.equals(newName, oldName)) + { + if (((InternalDBSchema)schema).renameTable(this, newName)) + { + setName(newName); + return true; + } + } + + return false; + } + public void remove() { schema.removeTable(getName()); diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java index 519e035541..c4e808594c 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBField.java @@ -36,6 +36,11 @@ public final class DelegatingDBField extends DelegatingDBSchemaElement implement return this; } + public boolean rename(String newName) + { + return getDelegate().rename(newName); + } + public int getPosition() { return getDelegate().getPosition(); diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBSchema.java index 45b5c744d0..dfbca0f240 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBSchema.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBSchema.java @@ -80,6 +80,11 @@ public final class DelegatingDBSchema extends DelegatingDBSchemaElement implemen return wrap(getDelegate().removeTable(name)); } + public boolean renameTable(IDBTable table, String newName) + { + return getDelegate().renameTable(unwrap(table), newName); + } + public String createIndexName(IDBTable table, Type type, IDBField[] fields, int position) { return getDelegate().createIndexName(unwrap(table), type, fields, position); diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBTable.java index 243a329efd..c23fca75ea 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBTable.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/DelegatingDBTable.java @@ -69,6 +69,11 @@ public final class DelegatingDBTable extends DelegatingDBSchemaElement implement return wrap(getDelegate().getParent()); } + public boolean rename(String newName) + { + return getDelegate().rename(newName); + } + public IDBField addField(String name, DBType type) { return wrap(getDelegate().addField(name, type)); @@ -79,21 +84,11 @@ public final class DelegatingDBTable extends DelegatingDBSchemaElement implement return wrap(getDelegate().addField(name, type, notNull)); } - public void removeField(IDBField fieldToRemove) - { - getDelegate().removeField(unwrap(fieldToRemove)); - } - public IDBField addField(String name, DBType type, int precision) { return wrap(getDelegate().addField(name, type, precision)); } - public void removeIndex(IDBIndex indexToRemove) - { - getDelegate().removeIndex(unwrap(indexToRemove)); - } - public IDBField addField(String name, DBType type, int precision, boolean notNull) { return wrap(getDelegate().addField(name, type, precision, notNull)); @@ -109,6 +104,16 @@ public final class DelegatingDBTable extends DelegatingDBSchemaElement implement return wrap(getDelegate().addField(name, type, precision, scale, notNull)); } + public void removeField(IDBField fieldToRemove) + { + getDelegate().removeField(unwrap(fieldToRemove)); + } + + public boolean renameField(IDBField field, String newName) + { + return getDelegate().renameField(unwrap(field), newName); + } + public IDBField getFieldSafe(String name) throws SchemaElementNotFoundException { return wrap(getDelegate().getFieldSafe(name)); @@ -174,6 +179,11 @@ public final class DelegatingDBTable extends DelegatingDBSchemaElement implement return wrap(getDelegate().addIndexEmpty(type)); } + public void removeIndex(IDBIndex indexToRemove) + { + getDelegate().removeIndex(unwrap(indexToRemove)); + } + public IDBIndex getIndexSafe(String name) throws SchemaElementNotFoundException { return wrap(getDelegate().getIndexSafe(name)); diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java index 8cbccb2869..b78d11cbbc 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/ddl/delta/DBSchemaDelta.java @@ -188,7 +188,10 @@ public final class DBSchemaDelta extends DBDelta implements IDBSchemaDelta public void removed(IDBFieldDelta delta) { IDBField field = delta.getSchemaElement(schema); - field.remove(); + if (field != null) + { + field.remove(); + } } @Override @@ -212,7 +215,10 @@ public final class DBSchemaDelta extends DBDelta implements IDBSchemaDelta public void removed(IDBIndexDelta delta) { IDBIndex index = delta.getSchemaElement(schema); - index.remove(); + if (index != null) + { + index.remove(); + } } @Override @@ -237,7 +243,10 @@ public final class DBSchemaDelta extends DBDelta implements IDBSchemaDelta public void removed(IDBIndexFieldDelta delta) { IDBIndexField indexField = delta.getSchemaElement(schema); - indexField.remove(); + if (indexField != null) + { + indexField.remove(); + } } @Override diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java index 3be0858f09..b626243721 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/DBAdapter.java @@ -1181,6 +1181,11 @@ public abstract class DBAdapter implements IDBAdapter return "ALTER TABLE " + tableName + " ALTER COLUMN " + fieldName + " " + definition; } + public String sqlRenameTable(String newName, String oldName) + { + return "ALTER TABLE " + oldName + " RENAME TO " + newName; + } + /** * @since 4.2 */ diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java index 7203fe8f4e..5ee15948ca 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBNamedElement.java @@ -13,7 +13,12 @@ package org.eclipse.net4j.spi.db.ddl; import org.eclipse.net4j.db.ddl.IDBNamedElement; import java.io.IOException; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; /** * @since 4.2 @@ -30,4 +35,51 @@ public interface InternalDBNamedElement extends IDBNamedElement, InternalDBEleme public void dump(); public void dump(Writer writer) throws IOException; + + /** + * @author Eike Stepper + * @since 4.8 + */ + public interface DumpFormat + { + public CharSequence getNewline(); + + public CharSequence getIndent(); + + /** + * @author Eike Stepper + */ + public static class HTML extends OutputStreamWriter implements DumpFormat + { + public HTML(OutputStream out, Charset cs) + { + super(out, cs); + } + + public HTML(OutputStream out, CharsetEncoder enc) + { + super(out, enc); + } + + public HTML(OutputStream out, String charsetName) throws UnsupportedEncodingException + { + super(out, charsetName); + } + + public HTML(OutputStream out) + { + super(out); + } + + public CharSequence getNewline() + { + return "<br/>"; + } + + public CharSequence getIndent() + { + return " "; + } + } + } } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java index a3e2ec6a45..796d3a5455 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBSchema.java @@ -39,4 +39,9 @@ public interface InternalDBSchema extends IDBSchema, InternalDBSchemaElement public boolean unlock(); public void assertUnlocked() throws DBException; + + /** + * @since 4.8 + */ + public boolean renameTable(IDBTable table, String newName); } diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java index fab2bfdca8..98a3917955 100644 --- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java +++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/spi/db/ddl/InternalDBTable.java @@ -31,4 +31,9 @@ public interface InternalDBTable extends IDBTable, InternalDBSchemaElement public void removeField(IDBField fieldToRemove); public void removeIndex(IDBIndex indexToRemove); + + /** + * @since 4.8 + */ + public boolean renameField(IDBField field, String newName); } diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/CollectionUtil.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/CollectionUtil.java index 3787367671..a97af77f11 100644 --- a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/CollectionUtil.java +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/collection/CollectionUtil.java @@ -12,6 +12,7 @@ package org.eclipse.net4j.util.collection; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -33,6 +34,20 @@ public final class CollectionUtil /** * @since 3.9 */ + public static <T> Set<T> setOf(T... elements) + { + Set<T> set = new HashSet<T>(); + for (T element : elements) + { + set.add(element); + } + + return set; + } + + /** + * @since 3.9 + */ public static <K, V> Set<V> getSet(Map<K, Set<V>> map, K key) { Set<V> set = map.get(key); |