diff --git a/bundles/specmate-migration-test/bnd.bnd b/bundles/specmate-migration-test/bnd.bnd index d7381cd08..215962aa7 100644 --- a/bundles/specmate-migration-test/bnd.bnd +++ b/bundles/specmate-migration-test/bnd.bnd @@ -1,7 +1,8 @@ Bundle-Version: 0.0.0.${tstamp} Test-Cases: \ com.specmate.migration.test.AddAttributeTest,\ - com.specmate.migration.test.AddSeveralAttributesTest + com.specmate.migration.test.AddSeveralAttributesTest,\ + com.specmate.migration.test.AddObjectTest -buildpath: \ org.eclipse.emf,\ org.eclipse.emf.cdo,\ diff --git a/bundles/specmate-migration-test/models/objectadded.ecore b/bundles/specmate-migration-test/models/objectadded.ecore new file mode 100644 index 000000000..7426e13ad --- /dev/null +++ b/bundles/specmate-migration-test/models/objectadded.ecore @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/specmate-migration-test/models/objectadded.genmodel b/bundles/specmate-migration-test/models/objectadded.genmodel new file mode 100644 index 000000000..76a677024 --- /dev/null +++ b/bundles/specmate-migration-test/models/objectadded.genmodel @@ -0,0 +1,33 @@ + + + objectadded.ecore + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/AddObjectTest.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/AddObjectTest.java new file mode 100644 index 000000000..31cc6e036 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/AddObjectTest.java @@ -0,0 +1,82 @@ +package com.specmate.migration.test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.junit.Test; + +import com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactFactory; +import com.specmate.migration.test.objectadded.testmodel.artefact.Diagram; +import com.specmate.migration.test.objectadded.testmodel.artefact.Document; +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; +import com.specmate.migration.test.objectadded.testmodel.base.Folder; +import com.specmate.model.support.util.SpecmateEcoreUtil; +import com.specmate.persistency.ITransaction; + +public class AddObjectTest extends MigrationTestBase { + + public AddObjectTest() throws Exception { + super("addobjecttest"); + } + + @Test + public void testNeedsMigration() throws Exception { + activatePersistency(); + assertFalse(migratorService.needsMigration()); + configureTestModel(BasePackage.class.getName()); + assertTrue(migratorService.needsMigration()); + deactivatePersistency(); + } + + @Test + public void doMigration() throws Exception { + checkMigrationPreconditions(); + configureTestModel(BasePackage.class.getName()); + migratorService.doMigration(); + checkMigrationPostconditions(); + } + + private void checkMigrationPostconditions() throws Exception { + activatePersistency(); + + ITransaction transaction = persistencyService.openTransaction(); + Resource resource = transaction.getResource(); + EObject root = SpecmateEcoreUtil.getEObjectWithId("root", resource.getContents()); + assertNotNull(root); + + assertTrue(root instanceof Folder); + Folder rootFolder = (Folder) root; + + EObject diagram = SpecmateEcoreUtil.getEObjectWithId("d0", rootFolder.eContents()); + assertNotNull(diagram); + assertTrue(diagram instanceof Diagram); + + Diagram d1 = ArtefactFactory.eINSTANCE.createDiagram(); + d1.setId("d1"); + + // Test that we can save the new object type + Document doc0 = ArtefactFactory.eINSTANCE.createDocument(); + doc0.setId("doc0"); + doc0.setLength(12); + doc0.setOwner("Pelle"); + doc0.getContents().add(d1); + + rootFolder.getContents().add(doc0); + transaction.commit(); + + // Test that we can also retrieve the new object type + EObject document = SpecmateEcoreUtil.getEObjectWithId("doc0", rootFolder.eContents()); + assertNotNull(document); + assertTrue(document instanceof Document); + doc0 = (Document) document; + + diagram = SpecmateEcoreUtil.getEObjectWithId("d1", doc0.eContents()); + assertNotNull(diagram); + assertTrue(diagram instanceof Diagram); + + deactivatePersistency(); + } +} diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/MigrationTestBase.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/MigrationTestBase.java index 9d73a078b..728b19c15 100644 --- a/bundles/specmate-migration-test/src/com/specmate/migration/test/MigrationTestBase.java +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/MigrationTestBase.java @@ -23,8 +23,8 @@ import com.specmate.migration.test.baseline.testmodel.artefact.Diagram; import com.specmate.migration.test.baseline.testmodel.base.BaseFactory; import com.specmate.migration.test.baseline.testmodel.base.BasePackage; -import com.specmate.migration.test.support.AttributeAddedMigrator; import com.specmate.migration.test.support.ServiceController; +import com.specmate.migration.test.support.TestMigratorImpl; import com.specmate.migration.test.support.TestModelProviderImpl; import com.specmate.model.support.util.SpecmateEcoreUtil; import com.specmate.persistency.IPackageProvider; @@ -60,8 +60,8 @@ public MigrationTestBase(String dbname) throws Exception { private void configureMigrator() throws IOException { Dictionary properties = new Hashtable<>(); - properties.put(AttributeAddedMigrator.KEY_MIGRATOR_TEST, this.getClass().getName()); - configurationAdmin.getConfiguration(AttributeAddedMigrator.PID).update(properties); + properties.put(TestMigratorImpl.KEY_MIGRATOR_TEST, this.getClass().getName()); + configurationAdmin.getConfiguration(TestMigratorImpl.PID).update(properties); } protected void configureTestModel(String basePackageClassName) throws IOException { diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/ArtefactFactory.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/ArtefactFactory.java new file mode 100644 index 000000000..18f4e97fe --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/ArtefactFactory.java @@ -0,0 +1,51 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage + * @generated + */ +public interface ArtefactFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ArtefactFactory eINSTANCE = com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactFactoryImpl.init(); + + /** + * Returns a new object of class 'Diagram'. + * + * + * @return a new object of class 'Diagram'. + * @generated + */ + Diagram createDiagram(); + + /** + * Returns a new object of class 'Document'. + * + * + * @return a new object of class 'Document'. + * @generated + */ + Document createDocument(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + ArtefactPackage getArtefactPackage(); + +} //ArtefactFactory diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/ArtefactPackage.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/ArtefactPackage.java new file mode 100644 index 000000000..bd4ee553e --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/ArtefactPackage.java @@ -0,0 +1,292 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact; + +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactFactory + * @model kind="package" + * @generated + */ +public interface ArtefactPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "artefact"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://specmate.com/1/testmodel/artefact"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "com.specmate.testmodel.artefact"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + ArtefactPackage eINSTANCE = com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactPackageImpl.init(); + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DiagramImpl Diagram}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.DiagramImpl + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactPackageImpl#getDiagram() + * @generated + */ + int DIAGRAM = 0; + + /** + * The feature id for the 'Tested' attribute. + * + * + * @generated + * @ordered + */ + int DIAGRAM__TESTED = BasePackage.IMODIFIABLE__TESTED; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int DIAGRAM__ID = BasePackage.IMODIFIABLE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Contents' containment reference list. + * + * + * @generated + * @ordered + */ + int DIAGRAM__CONTENTS = BasePackage.IMODIFIABLE_FEATURE_COUNT + 1; + + /** + * The number of structural features of the 'Diagram' class. + * + * + * @generated + * @ordered + */ + int DIAGRAM_FEATURE_COUNT = BasePackage.IMODIFIABLE_FEATURE_COUNT + 2; + + /** + * The number of operations of the 'Diagram' class. + * + * + * @generated + * @ordered + */ + int DIAGRAM_OPERATION_COUNT = BasePackage.IMODIFIABLE_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl Document}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactPackageImpl#getDocument() + * @generated + */ + int DOCUMENT = 1; + + /** + * The feature id for the 'Tested' attribute. + * + * + * @generated + * @ordered + */ + int DOCUMENT__TESTED = BasePackage.IMODIFIABLE__TESTED; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int DOCUMENT__ID = BasePackage.IMODIFIABLE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Contents' containment reference list. + * + * + * @generated + * @ordered + */ + int DOCUMENT__CONTENTS = BasePackage.IMODIFIABLE_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Length' attribute. + * + * + * @generated + * @ordered + */ + int DOCUMENT__LENGTH = BasePackage.IMODIFIABLE_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Owner' attribute. + * + * + * @generated + * @ordered + */ + int DOCUMENT__OWNER = BasePackage.IMODIFIABLE_FEATURE_COUNT + 3; + + /** + * The number of structural features of the 'Document' class. + * + * + * @generated + * @ordered + */ + int DOCUMENT_FEATURE_COUNT = BasePackage.IMODIFIABLE_FEATURE_COUNT + 4; + + /** + * The number of operations of the 'Document' class. + * + * + * @generated + * @ordered + */ + int DOCUMENT_OPERATION_COUNT = BasePackage.IMODIFIABLE_OPERATION_COUNT + 0; + + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Diagram Diagram}'. + * + * + * @return the meta object for class 'Diagram'. + * @see com.specmate.migration.test.objectadded.testmodel.artefact.Diagram + * @generated + */ + EClass getDiagram(); + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Document Document}'. + * + * + * @return the meta object for class 'Document'. + * @see com.specmate.migration.test.objectadded.testmodel.artefact.Document + * @generated + */ + EClass getDocument(); + + /** + * Returns the meta object for the attribute '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Document#getLength Length}'. + * + * + * @return the meta object for the attribute 'Length'. + * @see com.specmate.migration.test.objectadded.testmodel.artefact.Document#getLength() + * @see #getDocument() + * @generated + */ + EAttribute getDocument_Length(); + + /** + * Returns the meta object for the attribute '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Document#getOwner Owner}'. + * + * + * @return the meta object for the attribute 'Owner'. + * @see com.specmate.migration.test.objectadded.testmodel.artefact.Document#getOwner() + * @see #getDocument() + * @generated + */ + EAttribute getDocument_Owner(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + ArtefactFactory getArtefactFactory(); + + /** + * + * Defines literals for the meta objects that represent + * + * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DiagramImpl Diagram}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.DiagramImpl + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactPackageImpl#getDiagram() + * @generated + */ + EClass DIAGRAM = eINSTANCE.getDiagram(); + + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl Document}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl + * @see com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactPackageImpl#getDocument() + * @generated + */ + EClass DOCUMENT = eINSTANCE.getDocument(); + + /** + * The meta object literal for the 'Length' attribute feature. + * + * + * @generated + */ + EAttribute DOCUMENT__LENGTH = eINSTANCE.getDocument_Length(); + + /** + * The meta object literal for the 'Owner' attribute feature. + * + * + * @generated + */ + EAttribute DOCUMENT__OWNER = eINSTANCE.getDocument_Owner(); + + } + +} //ArtefactPackage diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/Diagram.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/Diagram.java new file mode 100644 index 000000000..5e8fdb704 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/Diagram.java @@ -0,0 +1,19 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact; + +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IModifiable; + +/** + * + * A representation of the model object 'Diagram'. + * + * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage#getDiagram() + * @model + * @generated + */ +public interface Diagram extends IModifiable, IContainer { +} // Diagram diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/Document.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/Document.java new file mode 100644 index 000000000..6d21671c2 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/Document.java @@ -0,0 +1,78 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact; + +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IModifiable; + +/** + * + * A representation of the model object 'Document'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage#getDocument() + * @model + * @generated + */ +public interface Document extends IModifiable, IContainer { + /** + * Returns the value of the 'Length' attribute. + * + *

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

+ * + * @return the value of the 'Length' attribute. + * @see #setLength(long) + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage#getDocument_Length() + * @model + * @generated + */ + long getLength(); + + /** + * Sets the value of the '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Document#getLength Length}' attribute. + * + * + * @param value the new value of the 'Length' attribute. + * @see #getLength() + * @generated + */ + void setLength(long value); + + /** + * Returns the value of the 'Owner' attribute. + * + *

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

+ * + * @return the value of the 'Owner' attribute. + * @see #setOwner(String) + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage#getDocument_Owner() + * @model + * @generated + */ + String getOwner(); + + /** + * Sets the value of the '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Document#getOwner Owner}' attribute. + * + * + * @param value the new value of the 'Owner' attribute. + * @see #getOwner() + * @generated + */ + void setOwner(String value); + +} // Document diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/ArtefactFactoryImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/ArtefactFactoryImpl.java new file mode 100644 index 000000000..fd46d62cd --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/ArtefactFactoryImpl.java @@ -0,0 +1,106 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact.impl; + +import com.specmate.migration.test.objectadded.testmodel.artefact.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class ArtefactFactoryImpl extends EFactoryImpl implements ArtefactFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static ArtefactFactory init() { + try { + ArtefactFactory theArtefactFactory = (ArtefactFactory)EPackage.Registry.INSTANCE.getEFactory(ArtefactPackage.eNS_URI); + if (theArtefactFactory != null) { + return theArtefactFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new ArtefactFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ArtefactFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case ArtefactPackage.DIAGRAM: return createDiagram(); + case ArtefactPackage.DOCUMENT: return createDocument(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Diagram createDiagram() { + DiagramImpl diagram = new DiagramImpl(); + return diagram; + } + + /** + * + * + * @generated + */ + public Document createDocument() { + DocumentImpl document = new DocumentImpl(); + return document; + } + + /** + * + * + * @generated + */ + public ArtefactPackage getArtefactPackage() { + return (ArtefactPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static ArtefactPackage getPackage() { + return ArtefactPackage.eINSTANCE; + } + +} //ArtefactFactoryImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/ArtefactPackageImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/ArtefactPackageImpl.java new file mode 100644 index 000000000..72d0d9931 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/ArtefactPackageImpl.java @@ -0,0 +1,225 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact.impl; + +import com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactFactory; +import com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage; +import com.specmate.migration.test.objectadded.testmodel.artefact.Diagram; +import com.specmate.migration.test.objectadded.testmodel.artefact.Document; + +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; + +import com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class ArtefactPackageImpl extends EPackageImpl implements ArtefactPackage { + /** + * + * + * @generated + */ + private EClass diagramEClass = null; + + /** + * + * + * @generated + */ + private EClass documentEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage#eNS_URI + * @see #init() + * @generated + */ + private ArtefactPackageImpl() { + super(eNS_URI, ArtefactFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link ArtefactPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ArtefactPackage init() { + if (isInited) return (ArtefactPackage)EPackage.Registry.INSTANCE.getEPackage(ArtefactPackage.eNS_URI); + + // Obtain or create and register package + ArtefactPackageImpl theArtefactPackage = (ArtefactPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof ArtefactPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new ArtefactPackageImpl()); + + isInited = true; + + // Obtain or create and register interdependencies + BasePackageImpl theBasePackage = (BasePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI) instanceof BasePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI) : BasePackage.eINSTANCE); + + // Create package meta-data objects + theArtefactPackage.createPackageContents(); + theBasePackage.createPackageContents(); + + // Initialize created meta-data + theArtefactPackage.initializePackageContents(); + theBasePackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theArtefactPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(ArtefactPackage.eNS_URI, theArtefactPackage); + return theArtefactPackage; + } + + /** + * + * + * @generated + */ + public EClass getDiagram() { + return diagramEClass; + } + + /** + * + * + * @generated + */ + public EClass getDocument() { + return documentEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getDocument_Length() { + return (EAttribute)documentEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getDocument_Owner() { + return (EAttribute)documentEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public ArtefactFactory getArtefactFactory() { + return (ArtefactFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + diagramEClass = createEClass(DIAGRAM); + + documentEClass = createEClass(DOCUMENT); + createEAttribute(documentEClass, DOCUMENT__LENGTH); + createEAttribute(documentEClass, DOCUMENT__OWNER); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + BasePackage theBasePackage = (BasePackage)EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + diagramEClass.getESuperTypes().add(theBasePackage.getIModifiable()); + diagramEClass.getESuperTypes().add(theBasePackage.getIContainer()); + documentEClass.getESuperTypes().add(theBasePackage.getIModifiable()); + documentEClass.getESuperTypes().add(theBasePackage.getIContainer()); + + // Initialize classes, features, and operations; add parameters + initEClass(diagramEClass, Diagram.class, "Diagram", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(documentEClass, Document.class, "Document", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDocument_Length(), ecorePackage.getELong(), "length", null, 0, 1, Document.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDocument_Owner(), ecorePackage.getEString(), "owner", null, 0, 1, Document.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //ArtefactPackageImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/DiagramImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/DiagramImpl.java new file mode 100644 index 000000000..66759d7fd --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/DiagramImpl.java @@ -0,0 +1,285 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact.impl; + +import com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage; +import com.specmate.migration.test.objectadded.testmodel.artefact.Diagram; + +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IContentElement; +import com.specmate.migration.test.objectadded.testmodel.base.IID; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Diagram'. + * + *

+ * The following features are implemented: + *

+ * + * + * @generated + */ +public class DiagramImpl extends MinimalEObjectImpl.Container implements Diagram { + /** + * The default value of the '{@link #isTested() Tested}' attribute. + * + * + * @see #isTested() + * @generated + * @ordered + */ + protected static final boolean TESTED_EDEFAULT = false; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = null; + + /** + * + * + * @generated + */ + protected DiagramImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ArtefactPackage.Literals.DIAGRAM; + } + + /** + * + * + * @generated + */ + @Override + protected int eStaticFeatureCount() { + return 0; + } + + /** + * + * + * @generated + */ + public boolean isTested() { + return (Boolean)eDynamicGet(ArtefactPackage.DIAGRAM__TESTED, BasePackage.Literals.ITESTABLE__TESTED, true, true); + } + + /** + * + * + * @generated + */ + public void setTested(boolean newTested) { + eDynamicSet(ArtefactPackage.DIAGRAM__TESTED, BasePackage.Literals.ITESTABLE__TESTED, newTested); + } + + /** + * + * + * @generated + */ + public String getId() { + return (String)eDynamicGet(ArtefactPackage.DIAGRAM__ID, BasePackage.Literals.IID__ID, true, true); + } + + /** + * + * + * @generated + */ + public void setId(String newId) { + eDynamicSet(ArtefactPackage.DIAGRAM__ID, BasePackage.Literals.IID__ID, newId); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + public EList getContents() { + return (EList)eDynamicGet(ArtefactPackage.DIAGRAM__CONTENTS, BasePackage.Literals.ICONTAINER__CONTENTS, true, true); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ArtefactPackage.DIAGRAM__CONTENTS: + return ((InternalEList)getContents()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ArtefactPackage.DIAGRAM__TESTED: + return isTested(); + case ArtefactPackage.DIAGRAM__ID: + return getId(); + case ArtefactPackage.DIAGRAM__CONTENTS: + return getContents(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ArtefactPackage.DIAGRAM__TESTED: + setTested((Boolean)newValue); + return; + case ArtefactPackage.DIAGRAM__ID: + setId((String)newValue); + return; + case ArtefactPackage.DIAGRAM__CONTENTS: + getContents().clear(); + getContents().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ArtefactPackage.DIAGRAM__TESTED: + setTested(TESTED_EDEFAULT); + return; + case ArtefactPackage.DIAGRAM__ID: + setId(ID_EDEFAULT); + return; + case ArtefactPackage.DIAGRAM__CONTENTS: + getContents().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ArtefactPackage.DIAGRAM__TESTED: + return isTested() != TESTED_EDEFAULT; + case ArtefactPackage.DIAGRAM__ID: + return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId()); + case ArtefactPackage.DIAGRAM__CONTENTS: + return !getContents().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == IID.class) { + switch (derivedFeatureID) { + case ArtefactPackage.DIAGRAM__ID: return BasePackage.IID__ID; + default: return -1; + } + } + if (baseClass == IContentElement.class) { + switch (derivedFeatureID) { + default: return -1; + } + } + if (baseClass == IContainer.class) { + switch (derivedFeatureID) { + case ArtefactPackage.DIAGRAM__CONTENTS: return BasePackage.ICONTAINER__CONTENTS; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == IID.class) { + switch (baseFeatureID) { + case BasePackage.IID__ID: return ArtefactPackage.DIAGRAM__ID; + default: return -1; + } + } + if (baseClass == IContentElement.class) { + switch (baseFeatureID) { + default: return -1; + } + } + if (baseClass == IContainer.class) { + switch (baseFeatureID) { + case BasePackage.ICONTAINER__CONTENTS: return ArtefactPackage.DIAGRAM__CONTENTS; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + +} //DiagramImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/DocumentImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/DocumentImpl.java new file mode 100644 index 000000000..677ea0f83 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/impl/DocumentImpl.java @@ -0,0 +1,363 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact.impl; + +import com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage; +import com.specmate.migration.test.objectadded.testmodel.artefact.Document; + +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IContentElement; +import com.specmate.migration.test.objectadded.testmodel.base.IID; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Document'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl#isTested Tested}
  • + *
  • {@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl#getId Id}
  • + *
  • {@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl#getContents Contents}
  • + *
  • {@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl#getLength Length}
  • + *
  • {@link com.specmate.migration.test.objectadded.testmodel.artefact.impl.DocumentImpl#getOwner Owner}
  • + *
+ * + * @generated + */ +public class DocumentImpl extends MinimalEObjectImpl.Container implements Document { + /** + * The default value of the '{@link #isTested() Tested}' attribute. + * + * + * @see #isTested() + * @generated + * @ordered + */ + protected static final boolean TESTED_EDEFAULT = false; + + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = null; + + /** + * The default value of the '{@link #getLength() Length}' attribute. + * + * + * @see #getLength() + * @generated + * @ordered + */ + protected static final long LENGTH_EDEFAULT = 0L; + + /** + * The default value of the '{@link #getOwner() Owner}' attribute. + * + * + * @see #getOwner() + * @generated + * @ordered + */ + protected static final String OWNER_EDEFAULT = null; + + /** + * + * + * @generated + */ + protected DocumentImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return ArtefactPackage.Literals.DOCUMENT; + } + + /** + * + * + * @generated + */ + @Override + protected int eStaticFeatureCount() { + return 0; + } + + /** + * + * + * @generated + */ + public boolean isTested() { + return (Boolean)eDynamicGet(ArtefactPackage.DOCUMENT__TESTED, BasePackage.Literals.ITESTABLE__TESTED, true, true); + } + + /** + * + * + * @generated + */ + public void setTested(boolean newTested) { + eDynamicSet(ArtefactPackage.DOCUMENT__TESTED, BasePackage.Literals.ITESTABLE__TESTED, newTested); + } + + /** + * + * + * @generated + */ + public String getId() { + return (String)eDynamicGet(ArtefactPackage.DOCUMENT__ID, BasePackage.Literals.IID__ID, true, true); + } + + /** + * + * + * @generated + */ + public void setId(String newId) { + eDynamicSet(ArtefactPackage.DOCUMENT__ID, BasePackage.Literals.IID__ID, newId); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + public EList getContents() { + return (EList)eDynamicGet(ArtefactPackage.DOCUMENT__CONTENTS, BasePackage.Literals.ICONTAINER__CONTENTS, true, true); + } + + /** + * + * + * @generated + */ + public long getLength() { + return (Long)eDynamicGet(ArtefactPackage.DOCUMENT__LENGTH, ArtefactPackage.Literals.DOCUMENT__LENGTH, true, true); + } + + /** + * + * + * @generated + */ + public void setLength(long newLength) { + eDynamicSet(ArtefactPackage.DOCUMENT__LENGTH, ArtefactPackage.Literals.DOCUMENT__LENGTH, newLength); + } + + /** + * + * + * @generated + */ + public String getOwner() { + return (String)eDynamicGet(ArtefactPackage.DOCUMENT__OWNER, ArtefactPackage.Literals.DOCUMENT__OWNER, true, true); + } + + /** + * + * + * @generated + */ + public void setOwner(String newOwner) { + eDynamicSet(ArtefactPackage.DOCUMENT__OWNER, ArtefactPackage.Literals.DOCUMENT__OWNER, newOwner); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case ArtefactPackage.DOCUMENT__CONTENTS: + return ((InternalEList)getContents()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case ArtefactPackage.DOCUMENT__TESTED: + return isTested(); + case ArtefactPackage.DOCUMENT__ID: + return getId(); + case ArtefactPackage.DOCUMENT__CONTENTS: + return getContents(); + case ArtefactPackage.DOCUMENT__LENGTH: + return getLength(); + case ArtefactPackage.DOCUMENT__OWNER: + return getOwner(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case ArtefactPackage.DOCUMENT__TESTED: + setTested((Boolean)newValue); + return; + case ArtefactPackage.DOCUMENT__ID: + setId((String)newValue); + return; + case ArtefactPackage.DOCUMENT__CONTENTS: + getContents().clear(); + getContents().addAll((Collection)newValue); + return; + case ArtefactPackage.DOCUMENT__LENGTH: + setLength((Long)newValue); + return; + case ArtefactPackage.DOCUMENT__OWNER: + setOwner((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case ArtefactPackage.DOCUMENT__TESTED: + setTested(TESTED_EDEFAULT); + return; + case ArtefactPackage.DOCUMENT__ID: + setId(ID_EDEFAULT); + return; + case ArtefactPackage.DOCUMENT__CONTENTS: + getContents().clear(); + return; + case ArtefactPackage.DOCUMENT__LENGTH: + setLength(LENGTH_EDEFAULT); + return; + case ArtefactPackage.DOCUMENT__OWNER: + setOwner(OWNER_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case ArtefactPackage.DOCUMENT__TESTED: + return isTested() != TESTED_EDEFAULT; + case ArtefactPackage.DOCUMENT__ID: + return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId()); + case ArtefactPackage.DOCUMENT__CONTENTS: + return !getContents().isEmpty(); + case ArtefactPackage.DOCUMENT__LENGTH: + return getLength() != LENGTH_EDEFAULT; + case ArtefactPackage.DOCUMENT__OWNER: + return OWNER_EDEFAULT == null ? getOwner() != null : !OWNER_EDEFAULT.equals(getOwner()); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { + if (baseClass == IID.class) { + switch (derivedFeatureID) { + case ArtefactPackage.DOCUMENT__ID: return BasePackage.IID__ID; + default: return -1; + } + } + if (baseClass == IContentElement.class) { + switch (derivedFeatureID) { + default: return -1; + } + } + if (baseClass == IContainer.class) { + switch (derivedFeatureID) { + case ArtefactPackage.DOCUMENT__CONTENTS: return BasePackage.ICONTAINER__CONTENTS; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + @Override + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { + if (baseClass == IID.class) { + switch (baseFeatureID) { + case BasePackage.IID__ID: return ArtefactPackage.DOCUMENT__ID; + default: return -1; + } + } + if (baseClass == IContentElement.class) { + switch (baseFeatureID) { + default: return -1; + } + } + if (baseClass == IContainer.class) { + switch (baseFeatureID) { + case BasePackage.ICONTAINER__CONTENTS: return ArtefactPackage.DOCUMENT__CONTENTS; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + +} //DocumentImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/util/ArtefactAdapterFactory.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/util/ArtefactAdapterFactory.java new file mode 100644 index 000000000..c7f06bcfa --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/util/ArtefactAdapterFactory.java @@ -0,0 +1,234 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact.util; + +import com.specmate.migration.test.objectadded.testmodel.artefact.*; + +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IContentElement; +import com.specmate.migration.test.objectadded.testmodel.base.IID; +import com.specmate.migration.test.objectadded.testmodel.base.IModifiable; +import com.specmate.migration.test.objectadded.testmodel.base.ITestable; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage + * @generated + */ +public class ArtefactAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static ArtefactPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public ArtefactAdapterFactory() { + if (modelPackage == null) { + modelPackage = ArtefactPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected ArtefactSwitch modelSwitch = + new ArtefactSwitch() { + @Override + public Adapter caseDiagram(Diagram object) { + return createDiagramAdapter(); + } + @Override + public Adapter caseDocument(Document object) { + return createDocumentAdapter(); + } + @Override + public Adapter caseITestable(ITestable object) { + return createITestableAdapter(); + } + @Override + public Adapter caseIModifiable(IModifiable object) { + return createIModifiableAdapter(); + } + @Override + public Adapter caseIID(IID object) { + return createIIDAdapter(); + } + @Override + public Adapter caseIContentElement(IContentElement object) { + return createIContentElementAdapter(); + } + @Override + public Adapter caseIContainer(IContainer object) { + return createIContainerAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Diagram Diagram}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.artefact.Diagram + * @generated + */ + public Adapter createDiagramAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.artefact.Document Document}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.artefact.Document + * @generated + */ + public Adapter createDocumentAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable ITestable}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.ITestable + * @generated + */ + public Adapter createITestableAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IModifiable IModifiable}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IModifiable + * @generated + */ + public Adapter createIModifiableAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IID IID}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IID + * @generated + */ + public Adapter createIIDAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IContentElement IContent Element}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContentElement + * @generated + */ + public Adapter createIContentElementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IContainer IContainer}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContainer + * @generated + */ + public Adapter createIContainerAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //ArtefactAdapterFactory diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/util/ArtefactSwitch.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/util/ArtefactSwitch.java new file mode 100644 index 000000000..d07479677 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/artefact/util/ArtefactSwitch.java @@ -0,0 +1,222 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.artefact.util; + +import com.specmate.migration.test.objectadded.testmodel.artefact.*; + +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IContentElement; +import com.specmate.migration.test.objectadded.testmodel.base.IID; +import com.specmate.migration.test.objectadded.testmodel.base.IModifiable; +import com.specmate.migration.test.objectadded.testmodel.base.ITestable; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage + * @generated + */ +public class ArtefactSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static ArtefactPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public ArtefactSwitch() { + if (modelPackage == null) { + modelPackage = ArtefactPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case ArtefactPackage.DIAGRAM: { + Diagram diagram = (Diagram)theEObject; + T result = caseDiagram(diagram); + if (result == null) result = caseIModifiable(diagram); + if (result == null) result = caseIContainer(diagram); + if (result == null) result = caseITestable(diagram); + if (result == null) result = caseIContentElement(diagram); + if (result == null) result = caseIID(diagram); + if (result == null) result = defaultCase(theEObject); + return result; + } + case ArtefactPackage.DOCUMENT: { + Document document = (Document)theEObject; + T result = caseDocument(document); + if (result == null) result = caseIModifiable(document); + if (result == null) result = caseIContainer(document); + if (result == null) result = caseITestable(document); + if (result == null) result = caseIContentElement(document); + if (result == null) result = caseIID(document); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Diagram'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Diagram'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseDiagram(Diagram object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Document'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Document'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseDocument(Document object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'ITestable'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'ITestable'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseITestable(ITestable object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IModifiable'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IModifiable'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIModifiable(IModifiable object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IID'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IID'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIID(IID object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IContent Element'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IContent Element'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIContentElement(IContentElement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IContainer'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IContainer'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIContainer(IContainer object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //ArtefactSwitch diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/BaseFactory.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/BaseFactory.java new file mode 100644 index 000000000..0f93f63ed --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/BaseFactory.java @@ -0,0 +1,42 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage + * @generated + */ +public interface BaseFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + BaseFactory eINSTANCE = com.specmate.migration.test.objectadded.testmodel.base.impl.BaseFactoryImpl.init(); + + /** + * Returns a new object of class 'Folder'. + * + * + * @return a new object of class 'Folder'. + * @generated + */ + Folder createFolder(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + BasePackage getBasePackage(); + +} //BaseFactory diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/BasePackage.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/BasePackage.java new file mode 100644 index 000000000..abe7f9a04 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/BasePackage.java @@ -0,0 +1,502 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see com.specmate.migration.test.objectadded.testmodel.base.BaseFactory + * @model kind="package" + * @generated + */ +public interface BasePackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "base"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://specmate.com/1/testmodel/base"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "com.specmate.testmodel.base"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + BasePackage eINSTANCE = com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl.init(); + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IID IID}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IID + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIID() + * @generated + */ + int IID = 0; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int IID__ID = 0; + + /** + * The number of structural features of the 'IID' class. + * + * + * @generated + * @ordered + */ + int IID_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'IID' class. + * + * + * @generated + * @ordered + */ + int IID_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IContentElement IContent Element}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IContentElement + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIContentElement() + * @generated + */ + int ICONTENT_ELEMENT = 1; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int ICONTENT_ELEMENT__ID = IID__ID; + + /** + * The number of structural features of the 'IContent Element' class. + * + * + * @generated + * @ordered + */ + int ICONTENT_ELEMENT_FEATURE_COUNT = IID_FEATURE_COUNT + 0; + + /** + * The number of operations of the 'IContent Element' class. + * + * + * @generated + * @ordered + */ + int ICONTENT_ELEMENT_OPERATION_COUNT = IID_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IContainer IContainer}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IContainer + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIContainer() + * @generated + */ + int ICONTAINER = 2; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int ICONTAINER__ID = ICONTENT_ELEMENT__ID; + + /** + * The feature id for the 'Contents' containment reference list. + * + * + * @generated + * @ordered + */ + int ICONTAINER__CONTENTS = ICONTENT_ELEMENT_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'IContainer' class. + * + * + * @generated + * @ordered + */ + int ICONTAINER_FEATURE_COUNT = ICONTENT_ELEMENT_FEATURE_COUNT + 1; + + /** + * The number of operations of the 'IContainer' class. + * + * + * @generated + * @ordered + */ + int ICONTAINER_OPERATION_COUNT = ICONTENT_ELEMENT_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.base.impl.FolderImpl Folder}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.FolderImpl + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getFolder() + * @generated + */ + int FOLDER = 3; + + /** + * The feature id for the 'Id' attribute. + * + * + * @generated + * @ordered + */ + int FOLDER__ID = ICONTAINER__ID; + + /** + * The feature id for the 'Contents' containment reference list. + * + * + * @generated + * @ordered + */ + int FOLDER__CONTENTS = ICONTAINER__CONTENTS; + + /** + * The number of structural features of the 'Folder' class. + * + * + * @generated + * @ordered + */ + int FOLDER_FEATURE_COUNT = ICONTAINER_FEATURE_COUNT + 0; + + /** + * The number of operations of the 'Folder' class. + * + * + * @generated + * @ordered + */ + int FOLDER_OPERATION_COUNT = ICONTAINER_OPERATION_COUNT + 0; + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable ITestable}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.ITestable + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getITestable() + * @generated + */ + int ITESTABLE = 4; + + /** + * The feature id for the 'Tested' attribute. + * + * + * @generated + * @ordered + */ + int ITESTABLE__TESTED = 0; + + /** + * The number of structural features of the 'ITestable' class. + * + * + * @generated + * @ordered + */ + int ITESTABLE_FEATURE_COUNT = 1; + + /** + * The number of operations of the 'ITestable' class. + * + * + * @generated + * @ordered + */ + int ITESTABLE_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IModifiable IModifiable}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IModifiable + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIModifiable() + * @generated + */ + int IMODIFIABLE = 5; + + /** + * The feature id for the 'Tested' attribute. + * + * + * @generated + * @ordered + */ + int IMODIFIABLE__TESTED = ITESTABLE__TESTED; + + /** + * The number of structural features of the 'IModifiable' class. + * + * + * @generated + * @ordered + */ + int IMODIFIABLE_FEATURE_COUNT = ITESTABLE_FEATURE_COUNT + 0; + + /** + * The number of operations of the 'IModifiable' class. + * + * + * @generated + * @ordered + */ + int IMODIFIABLE_OPERATION_COUNT = ITESTABLE_OPERATION_COUNT + 0; + + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.base.IID IID}'. + * + * + * @return the meta object for class 'IID'. + * @see com.specmate.migration.test.objectadded.testmodel.base.IID + * @generated + */ + EClass getIID(); + + /** + * Returns the meta object for the attribute '{@link com.specmate.migration.test.objectadded.testmodel.base.IID#getId Id}'. + * + * + * @return the meta object for the attribute 'Id'. + * @see com.specmate.migration.test.objectadded.testmodel.base.IID#getId() + * @see #getIID() + * @generated + */ + EAttribute getIID_Id(); + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.base.IContentElement IContent Element}'. + * + * + * @return the meta object for class 'IContent Element'. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContentElement + * @generated + */ + EClass getIContentElement(); + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.base.IContainer IContainer}'. + * + * + * @return the meta object for class 'IContainer'. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContainer + * @generated + */ + EClass getIContainer(); + + /** + * Returns the meta object for the containment reference list '{@link com.specmate.migration.test.objectadded.testmodel.base.IContainer#getContents Contents}'. + * + * + * @return the meta object for the containment reference list 'Contents'. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContainer#getContents() + * @see #getIContainer() + * @generated + */ + EReference getIContainer_Contents(); + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.base.Folder Folder}'. + * + * + * @return the meta object for class 'Folder'. + * @see com.specmate.migration.test.objectadded.testmodel.base.Folder + * @generated + */ + EClass getFolder(); + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable ITestable}'. + * + * + * @return the meta object for class 'ITestable'. + * @see com.specmate.migration.test.objectadded.testmodel.base.ITestable + * @generated + */ + EClass getITestable(); + + /** + * Returns the meta object for the attribute '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable#isTested Tested}'. + * + * + * @return the meta object for the attribute 'Tested'. + * @see com.specmate.migration.test.objectadded.testmodel.base.ITestable#isTested() + * @see #getITestable() + * @generated + */ + EAttribute getITestable_Tested(); + + /** + * Returns the meta object for class '{@link com.specmate.migration.test.objectadded.testmodel.base.IModifiable IModifiable}'. + * + * + * @return the meta object for class 'IModifiable'. + * @see com.specmate.migration.test.objectadded.testmodel.base.IModifiable + * @generated + */ + EClass getIModifiable(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + BaseFactory getBaseFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IID IID}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IID + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIID() + * @generated + */ + EClass IID = eINSTANCE.getIID(); + + /** + * The meta object literal for the 'Id' attribute feature. + * + * + * @generated + */ + EAttribute IID__ID = eINSTANCE.getIID_Id(); + + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IContentElement IContent Element}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IContentElement + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIContentElement() + * @generated + */ + EClass ICONTENT_ELEMENT = eINSTANCE.getIContentElement(); + + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IContainer IContainer}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IContainer + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIContainer() + * @generated + */ + EClass ICONTAINER = eINSTANCE.getIContainer(); + + /** + * The meta object literal for the 'Contents' containment reference list feature. + * + * + * @generated + */ + EReference ICONTAINER__CONTENTS = eINSTANCE.getIContainer_Contents(); + + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.base.impl.FolderImpl Folder}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.FolderImpl + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getFolder() + * @generated + */ + EClass FOLDER = eINSTANCE.getFolder(); + + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable ITestable}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.ITestable + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getITestable() + * @generated + */ + EClass ITESTABLE = eINSTANCE.getITestable(); + + /** + * The meta object literal for the 'Tested' attribute feature. + * + * + * @generated + */ + EAttribute ITESTABLE__TESTED = eINSTANCE.getITestable_Tested(); + + /** + * The meta object literal for the '{@link com.specmate.migration.test.objectadded.testmodel.base.IModifiable IModifiable}' class. + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.IModifiable + * @see com.specmate.migration.test.objectadded.testmodel.base.impl.BasePackageImpl#getIModifiable() + * @generated + */ + EClass IMODIFIABLE = eINSTANCE.getIModifiable(); + + } + +} //BasePackage diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/Folder.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/Folder.java new file mode 100644 index 000000000..ae9b3c3e8 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/Folder.java @@ -0,0 +1,17 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + + +/** + * + * A representation of the model object 'Folder'. + * + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getFolder() + * @model + * @generated + */ +public interface Folder extends IContainer { +} // Folder diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IContainer.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IContainer.java new file mode 100644 index 000000000..902bd7212 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IContainer.java @@ -0,0 +1,40 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + +import org.eclipse.emf.common.util.EList; + +/** + * + * A representation of the model object 'IContainer'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.migration.test.objectadded.testmodel.base.IContainer#getContents Contents}
  • + *
+ * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getIContainer() + * @model interface="true" abstract="true" + * @generated + */ +public interface IContainer extends IContentElement { + /** + * Returns the value of the 'Contents' containment reference list. + * The list contents are of type {@link com.specmate.migration.test.objectadded.testmodel.base.IContentElement}. + * + *

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

+ * + * @return the value of the 'Contents' containment reference list. + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getIContainer_Contents() + * @model containment="true" + * @generated + */ + EList getContents(); + +} // IContainer diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IContentElement.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IContentElement.java new file mode 100644 index 000000000..8f953bf78 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IContentElement.java @@ -0,0 +1,17 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + + +/** + * + * A representation of the model object 'IContent Element'. + * + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getIContentElement() + * @model interface="true" abstract="true" + * @generated + */ +public interface IContentElement extends IID { +} // IContentElement diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IID.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IID.java new file mode 100644 index 000000000..bbeae0d3a --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IID.java @@ -0,0 +1,50 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'IID'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.migration.test.objectadded.testmodel.base.IID#getId Id}
  • + *
+ * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getIID() + * @model interface="true" abstract="true" + * @generated + */ +public interface IID extends EObject { + /** + * Returns the value of the 'Id' attribute. + * + *

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

+ * + * @return the value of the 'Id' attribute. + * @see #setId(String) + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getIID_Id() + * @model + * @generated + */ + String getId(); + + /** + * Sets the value of the '{@link com.specmate.migration.test.objectadded.testmodel.base.IID#getId Id}' attribute. + * + * + * @param value the new value of the 'Id' attribute. + * @see #getId() + * @generated + */ + void setId(String value); + +} // IID diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IModifiable.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IModifiable.java new file mode 100644 index 000000000..a779ffe8c --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/IModifiable.java @@ -0,0 +1,17 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + + +/** + * + * A representation of the model object 'IModifiable'. + * + * + * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getIModifiable() + * @model interface="true" abstract="true" + * @generated + */ +public interface IModifiable extends ITestable { +} // IModifiable diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/ITestable.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/ITestable.java new file mode 100644 index 000000000..0ff891a44 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/ITestable.java @@ -0,0 +1,50 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'ITestable'. + * + * + *

+ * The following features are supported: + *

+ *
    + *
  • {@link com.specmate.migration.test.objectadded.testmodel.base.ITestable#isTested Tested}
  • + *
+ * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getITestable() + * @model interface="true" abstract="true" + * @generated + */ +public interface ITestable extends EObject { + /** + * Returns the value of the 'Tested' attribute. + * + *

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

+ * + * @return the value of the 'Tested' attribute. + * @see #setTested(boolean) + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#getITestable_Tested() + * @model + * @generated + */ + boolean isTested(); + + /** + * Sets the value of the '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable#isTested Tested}' attribute. + * + * + * @param value the new value of the 'Tested' attribute. + * @see #isTested() + * @generated + */ + void setTested(boolean value); + +} // ITestable diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/BaseFactoryImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/BaseFactoryImpl.java new file mode 100644 index 000000000..c8c44db32 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/BaseFactoryImpl.java @@ -0,0 +1,95 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base.impl; + +import com.specmate.migration.test.objectadded.testmodel.base.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class BaseFactoryImpl extends EFactoryImpl implements BaseFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static BaseFactory init() { + try { + BaseFactory theBaseFactory = (BaseFactory)EPackage.Registry.INSTANCE.getEFactory(BasePackage.eNS_URI); + if (theBaseFactory != null) { + return theBaseFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new BaseFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public BaseFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case BasePackage.FOLDER: return createFolder(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Folder createFolder() { + FolderImpl folder = new FolderImpl(); + return folder; + } + + /** + * + * + * @generated + */ + public BasePackage getBasePackage() { + return (BasePackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static BasePackage getPackage() { + return BasePackage.eINSTANCE; + } + +} //BaseFactoryImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/BasePackageImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/BasePackageImpl.java new file mode 100644 index 000000000..c71fe0c79 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/BasePackageImpl.java @@ -0,0 +1,317 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base.impl; + +import com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage; + +import com.specmate.migration.test.objectadded.testmodel.artefact.impl.ArtefactPackageImpl; + +import com.specmate.migration.test.objectadded.testmodel.base.BaseFactory; +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; +import com.specmate.migration.test.objectadded.testmodel.base.Folder; +import com.specmate.migration.test.objectadded.testmodel.base.IContainer; +import com.specmate.migration.test.objectadded.testmodel.base.IContentElement; +import com.specmate.migration.test.objectadded.testmodel.base.IModifiable; +import com.specmate.migration.test.objectadded.testmodel.base.ITestable; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class BasePackageImpl extends EPackageImpl implements BasePackage { + /** + * + * + * @generated + */ + private EClass iidEClass = null; + + /** + * + * + * @generated + */ + private EClass iContentElementEClass = null; + + /** + * + * + * @generated + */ + private EClass iContainerEClass = null; + + /** + * + * + * @generated + */ + private EClass folderEClass = null; + + /** + * + * + * @generated + */ + private EClass iTestableEClass = null; + + /** + * + * + * @generated + */ + private EClass iModifiableEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage#eNS_URI + * @see #init() + * @generated + */ + private BasePackageImpl() { + super(eNS_URI, BaseFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link BasePackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static BasePackage init() { + if (isInited) return (BasePackage)EPackage.Registry.INSTANCE.getEPackage(BasePackage.eNS_URI); + + // Obtain or create and register package + BasePackageImpl theBasePackage = (BasePackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof BasePackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new BasePackageImpl()); + + isInited = true; + + // Obtain or create and register interdependencies + ArtefactPackageImpl theArtefactPackage = (ArtefactPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(ArtefactPackage.eNS_URI) instanceof ArtefactPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(ArtefactPackage.eNS_URI) : ArtefactPackage.eINSTANCE); + + // Create package meta-data objects + theBasePackage.createPackageContents(); + theArtefactPackage.createPackageContents(); + + // Initialize created meta-data + theBasePackage.initializePackageContents(); + theArtefactPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theBasePackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(BasePackage.eNS_URI, theBasePackage); + return theBasePackage; + } + + /** + * + * + * @generated + */ + public EClass getIID() { + return iidEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getIID_Id() { + return (EAttribute)iidEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getIContentElement() { + return iContentElementEClass; + } + + /** + * + * + * @generated + */ + public EClass getIContainer() { + return iContainerEClass; + } + + /** + * + * + * @generated + */ + public EReference getIContainer_Contents() { + return (EReference)iContainerEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getFolder() { + return folderEClass; + } + + /** + * + * + * @generated + */ + public EClass getITestable() { + return iTestableEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getITestable_Tested() { + return (EAttribute)iTestableEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getIModifiable() { + return iModifiableEClass; + } + + /** + * + * + * @generated + */ + public BaseFactory getBaseFactory() { + return (BaseFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + iidEClass = createEClass(IID); + createEAttribute(iidEClass, IID__ID); + + iContentElementEClass = createEClass(ICONTENT_ELEMENT); + + iContainerEClass = createEClass(ICONTAINER); + createEReference(iContainerEClass, ICONTAINER__CONTENTS); + + folderEClass = createEClass(FOLDER); + + iTestableEClass = createEClass(ITESTABLE); + createEAttribute(iTestableEClass, ITESTABLE__TESTED); + + iModifiableEClass = createEClass(IMODIFIABLE); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + iContentElementEClass.getESuperTypes().add(this.getIID()); + iContainerEClass.getESuperTypes().add(this.getIContentElement()); + folderEClass.getESuperTypes().add(this.getIContainer()); + iModifiableEClass.getESuperTypes().add(this.getITestable()); + + // Initialize classes, features, and operations; add parameters + initEClass(iidEClass, com.specmate.migration.test.objectadded.testmodel.base.IID.class, "IID", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getIID_Id(), ecorePackage.getEString(), "id", null, 0, 1, com.specmate.migration.test.objectadded.testmodel.base.IID.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(iContentElementEClass, IContentElement.class, "IContentElement", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(iContainerEClass, IContainer.class, "IContainer", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getIContainer_Contents(), this.getIContentElement(), null, "contents", null, 0, -1, IContainer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(folderEClass, Folder.class, "Folder", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(iTestableEClass, ITestable.class, "ITestable", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getITestable_Tested(), ecorePackage.getEBoolean(), "tested", null, 0, 1, ITestable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(iModifiableEClass, IModifiable.class, "IModifiable", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + } + +} //BasePackageImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/FolderImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/FolderImpl.java new file mode 100644 index 000000000..25a4cbfa6 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/impl/FolderImpl.java @@ -0,0 +1,188 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base.impl; + +import com.specmate.migration.test.objectadded.testmodel.base.BasePackage; +import com.specmate.migration.test.objectadded.testmodel.base.Folder; +import com.specmate.migration.test.objectadded.testmodel.base.IContentElement; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Folder'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link com.specmate.migration.test.objectadded.testmodel.base.impl.FolderImpl#getId Id}
  • + *
  • {@link com.specmate.migration.test.objectadded.testmodel.base.impl.FolderImpl#getContents Contents}
  • + *
+ * + * @generated + */ +public class FolderImpl extends MinimalEObjectImpl.Container implements Folder { + /** + * The default value of the '{@link #getId() Id}' attribute. + * + * + * @see #getId() + * @generated + * @ordered + */ + protected static final String ID_EDEFAULT = null; + + /** + * + * + * @generated + */ + protected FolderImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return BasePackage.Literals.FOLDER; + } + + /** + * + * + * @generated + */ + @Override + protected int eStaticFeatureCount() { + return 0; + } + + /** + * + * + * @generated + */ + public String getId() { + return (String)eDynamicGet(BasePackage.FOLDER__ID, BasePackage.Literals.IID__ID, true, true); + } + + /** + * + * + * @generated + */ + public void setId(String newId) { + eDynamicSet(BasePackage.FOLDER__ID, BasePackage.Literals.IID__ID, newId); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + public EList getContents() { + return (EList)eDynamicGet(BasePackage.FOLDER__CONTENTS, BasePackage.Literals.ICONTAINER__CONTENTS, true, true); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case BasePackage.FOLDER__CONTENTS: + return ((InternalEList)getContents()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case BasePackage.FOLDER__ID: + return getId(); + case BasePackage.FOLDER__CONTENTS: + return getContents(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case BasePackage.FOLDER__ID: + setId((String)newValue); + return; + case BasePackage.FOLDER__CONTENTS: + getContents().clear(); + getContents().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case BasePackage.FOLDER__ID: + setId(ID_EDEFAULT); + return; + case BasePackage.FOLDER__CONTENTS: + getContents().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case BasePackage.FOLDER__ID: + return ID_EDEFAULT == null ? getId() != null : !ID_EDEFAULT.equals(getId()); + case BasePackage.FOLDER__CONTENTS: + return !getContents().isEmpty(); + } + return super.eIsSet(featureID); + } + +} //FolderImpl diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/util/BaseAdapterFactory.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/util/BaseAdapterFactory.java new file mode 100644 index 000000000..480117a79 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/util/BaseAdapterFactory.java @@ -0,0 +1,210 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base.util; + +import com.specmate.migration.test.objectadded.testmodel.base.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage + * @generated + */ +public class BaseAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static BasePackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public BaseAdapterFactory() { + if (modelPackage == null) { + modelPackage = BasePackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected BaseSwitch modelSwitch = + new BaseSwitch() { + @Override + public Adapter caseIID(IID object) { + return createIIDAdapter(); + } + @Override + public Adapter caseIContentElement(IContentElement object) { + return createIContentElementAdapter(); + } + @Override + public Adapter caseIContainer(IContainer object) { + return createIContainerAdapter(); + } + @Override + public Adapter caseFolder(Folder object) { + return createFolderAdapter(); + } + @Override + public Adapter caseITestable(ITestable object) { + return createITestableAdapter(); + } + @Override + public Adapter caseIModifiable(IModifiable object) { + return createIModifiableAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IID IID}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IID + * @generated + */ + public Adapter createIIDAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IContentElement IContent Element}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContentElement + * @generated + */ + public Adapter createIContentElementAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IContainer IContainer}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IContainer + * @generated + */ + public Adapter createIContainerAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.Folder Folder}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.Folder + * @generated + */ + public Adapter createFolderAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.ITestable ITestable}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.ITestable + * @generated + */ + public Adapter createITestableAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link com.specmate.migration.test.objectadded.testmodel.base.IModifiable IModifiable}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see com.specmate.migration.test.objectadded.testmodel.base.IModifiable + * @generated + */ + public Adapter createIModifiableAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //BaseAdapterFactory diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/util/BaseSwitch.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/util/BaseSwitch.java new file mode 100644 index 000000000..abc51f760 --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/objectadded/testmodel/base/util/BaseSwitch.java @@ -0,0 +1,222 @@ +/** + */ +package com.specmate.migration.test.objectadded.testmodel.base.util; + +import com.specmate.migration.test.objectadded.testmodel.base.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see com.specmate.migration.test.objectadded.testmodel.base.BasePackage + * @generated + */ +public class BaseSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static BasePackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public BaseSwitch() { + if (modelPackage == null) { + modelPackage = BasePackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case BasePackage.IID: { + IID iid = (IID)theEObject; + T result = caseIID(iid); + if (result == null) result = defaultCase(theEObject); + return result; + } + case BasePackage.ICONTENT_ELEMENT: { + IContentElement iContentElement = (IContentElement)theEObject; + T result = caseIContentElement(iContentElement); + if (result == null) result = caseIID(iContentElement); + if (result == null) result = defaultCase(theEObject); + return result; + } + case BasePackage.ICONTAINER: { + IContainer iContainer = (IContainer)theEObject; + T result = caseIContainer(iContainer); + if (result == null) result = caseIContentElement(iContainer); + if (result == null) result = caseIID(iContainer); + if (result == null) result = defaultCase(theEObject); + return result; + } + case BasePackage.FOLDER: { + Folder folder = (Folder)theEObject; + T result = caseFolder(folder); + if (result == null) result = caseIContainer(folder); + if (result == null) result = caseIContentElement(folder); + if (result == null) result = caseIID(folder); + if (result == null) result = defaultCase(theEObject); + return result; + } + case BasePackage.ITESTABLE: { + ITestable iTestable = (ITestable)theEObject; + T result = caseITestable(iTestable); + if (result == null) result = defaultCase(theEObject); + return result; + } + case BasePackage.IMODIFIABLE: { + IModifiable iModifiable = (IModifiable)theEObject; + T result = caseIModifiable(iModifiable); + if (result == null) result = caseITestable(iModifiable); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'IID'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IID'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIID(IID object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IContent Element'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IContent Element'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIContentElement(IContentElement object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IContainer'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IContainer'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIContainer(IContainer object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Folder'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Folder'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseFolder(Folder object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'ITestable'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'ITestable'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseITestable(ITestable object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'IModifiable'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'IModifiable'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseIModifiable(IModifiable object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //BaseSwitch diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/support/AttributeAddedMigrator.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/support/AttributeAddedMigrator.java deleted file mode 100644 index e002cc0cb..000000000 --- a/bundles/specmate-migration-test/src/com/specmate/migration/test/support/AttributeAddedMigrator.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.specmate.migration.test.support; - -import java.io.IOException; -import java.sql.Connection; -import java.util.Dictionary; - -import org.junit.Assert; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.osgi.service.cm.ConfigurationAdmin; -import org.osgi.service.component.annotations.Component; -import org.osgi.util.tracker.ServiceTracker; - -import com.specmate.common.SpecmateException; -import com.specmate.migration.api.IMigrator; -import com.specmate.migration.basemigrators.AttributeAddedBaseMigrator; -import com.specmate.migration.test.AddAttributeTest; -import com.specmate.migration.test.AddSeveralAttributesTest; - -@Component(property = "sourceVersion=0") -public class AttributeAddedMigrator extends AttributeAddedBaseMigrator implements IMigrator { - public static final String PID = "com.specmate.migration.text.support.AttributeAddedMigrator"; - public static final String KEY_MIGRATOR_TEST = "testcase"; - - @Override - public String getSourceVersion() { - return "0"; - } - - @Override - public String getTargetVersion() { - return "1"; - } - - @Override - public void migrate(Connection connection) throws SpecmateException { - this.connection = connection; - BundleContext context = FrameworkUtil.getBundle(AttributeAddedMigrator.class).getBundleContext(); - try { - ConfigurationAdmin ca = getConfigurationAdmin(context); - Dictionary props = ca.getConfiguration(PID).getProperties(); - String testcase = (String) props.get(KEY_MIGRATOR_TEST); - if (testcase.equals(AddAttributeTest.class.getName())) { - migrateAttributeAdded(); - } else if (testcase.equals(AddSeveralAttributesTest.class.getName())) { - migrateSeveralAttributesAdded(); - } - } catch (InterruptedException | IOException e) { - throw new SpecmateException(e.getMessage()); - } - } - - private void migrateAttributeAdded() throws SpecmateException { - migrateNewStringAttribute("folder", "name", ""); - migrateNewStringAttribute("diagram", "name", null); - } - - private void migrateSeveralAttributesAdded() throws SpecmateException { - migrateNewStringAttribute("folder", "name", ""); - migrateNewStringAttribute("diagram", "name", null); - migrateNewBooleanAttribute("diagram", "linked", false); - migrateNewDoubleAttribute("diagram", "length", null); - migrateNewIntegerAttribute("diagram", "amount", -1); - migrateNewIntegerAttribute("diagram", "intamount", -1); - migrateNewDoubleAttribute("diagram", "doublelength", 0.0); - migrateNewBooleanAttribute("diagram", "booleanlinked", false); - } - - private ConfigurationAdmin getConfigurationAdmin(BundleContext context) throws InterruptedException { - ServiceTracker configurationAdminTracker = - new ServiceTracker<>(context, ConfigurationAdmin.class.getName(), null); - - configurationAdminTracker.open(); - ConfigurationAdmin configurationAdmin = configurationAdminTracker.waitForService(10000); - Assert.assertNotNull(configurationAdmin); - return configurationAdmin; - } - -} diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestMigratorImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestMigratorImpl.java new file mode 100644 index 000000000..16b46f6df --- /dev/null +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestMigratorImpl.java @@ -0,0 +1,103 @@ +package com.specmate.migration.test.support; + +import java.io.IOException; +import java.sql.Connection; +import java.util.ArrayList; +import java.util.Dictionary; +import java.util.List; + +import org.junit.Assert; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.component.annotations.Component; +import org.osgi.util.tracker.ServiceTracker; + +import com.specmate.common.SpecmateException; +import com.specmate.migration.api.IMigrator; +import com.specmate.migration.h2.AttributeAddedtoSQLMapper; +import com.specmate.migration.h2.ObjectAddedtoSQLMapper; +import com.specmate.migration.test.AddAttributeTest; +import com.specmate.migration.test.AddObjectTest; +import com.specmate.migration.test.AddSeveralAttributesTest; + +@Component(property = "sourceVersion=0") +public class TestMigratorImpl implements IMigrator { + public static final String PID = "com.specmate.migration.test.support.TestMigratorImpl"; + public static final String KEY_MIGRATOR_TEST = "testcase"; + + @Override + public String getSourceVersion() { + return "0"; + } + + @Override + public String getTargetVersion() { + return "1"; + } + + @Override + public void migrate(Connection connection) throws SpecmateException { + BundleContext context = FrameworkUtil.getBundle(TestMigratorImpl.class).getBundleContext(); + try { + ConfigurationAdmin ca = getConfigurationAdmin(context); + Dictionary props = ca.getConfiguration(PID).getProperties(); + String testcase = (String) props.get(KEY_MIGRATOR_TEST); + if (testcase.equals(AddAttributeTest.class.getName())) { + migrateAttributeAdded(connection); + } else if (testcase.equals(AddSeveralAttributesTest.class.getName())) { + migrateSeveralAttributesAdded(connection); + } else if (testcase.equals(AddObjectTest.class.getName())) { + migrateObjectAdded(connection); + } + + } catch (InterruptedException | IOException e) { + throw new SpecmateException(e.getMessage()); + } + } + + private void migrateAttributeAdded(Connection connection) throws SpecmateException { + AttributeAddedtoSQLMapper aAdded = new AttributeAddedtoSQLMapper(connection); + aAdded.migrateNewStringAttribute("folder", "name", ""); + aAdded.migrateNewStringAttribute("diagram", "name", null); + } + + private void migrateSeveralAttributesAdded(Connection connection) throws SpecmateException { + AttributeAddedtoSQLMapper aAdded = new AttributeAddedtoSQLMapper(connection); + aAdded.migrateNewStringAttribute("folder", "name", ""); + aAdded.migrateNewStringAttribute("diagram", "name", null); + aAdded.migrateNewBooleanAttribute("diagram", "linked", false); + aAdded.migrateNewDoubleAttribute("diagram", "length", null); + aAdded.migrateNewIntegerAttribute("diagram", "amount", -1); + aAdded.migrateNewIntegerAttribute("diagram", "intamount", -1); + aAdded.migrateNewDoubleAttribute("diagram", "doublelength", 0.0); + aAdded.migrateNewBooleanAttribute("diagram", "booleanlinked", false); + } + + private void migrateObjectAdded(Connection connection) throws SpecmateException { + String objectName = "Document"; + List attributeNames = new ArrayList<>(); + attributeNames.add("length"); + attributeNames.add("owner"); + + ObjectAddedtoSQLMapper oAdded = new ObjectAddedtoSQLMapper(connection); + oAdded.newObject(objectName, attributeNames, "testmodel/artefact", getTargetVersion()); + + AttributeAddedtoSQLMapper aAdded = new AttributeAddedtoSQLMapper(connection); + aAdded.migrateNewStringAttribute(objectName, "id", ""); + aAdded.migrateNewBooleanAttribute(objectName, "tested", false); + aAdded.migrateNewLongAttribute(objectName, "length", null); + aAdded.migrateNewStringAttribute(objectName, "owner", null); + aAdded.migrateNewReference(objectName, "contents"); + } + + private ConfigurationAdmin getConfigurationAdmin(BundleContext context) throws InterruptedException { + ServiceTracker configurationAdminTracker = + new ServiceTracker<>(context, ConfigurationAdmin.class.getName(), null); + + configurationAdminTracker.open(); + ConfigurationAdmin configurationAdmin = configurationAdminTracker.waitForService(10000); + Assert.assertNotNull(configurationAdmin); + return configurationAdmin; + } +} diff --git a/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestModelProviderImpl.java b/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestModelProviderImpl.java index ee686a671..6e8ae8f3e 100644 --- a/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestModelProviderImpl.java +++ b/bundles/specmate-migration-test/src/com/specmate/migration/test/support/TestModelProviderImpl.java @@ -25,7 +25,7 @@ public class TestModelProviderImpl implements IPackageProvider { @Override public Collection getPackages() { - BundleContext context = FrameworkUtil.getBundle(AttributeAddedMigrator.class).getBundleContext(); + BundleContext context = FrameworkUtil.getBundle(TestMigratorImpl.class).getBundleContext(); try { ConfigurationAdmin ca = getConfigurationAdmin(context); Dictionary props = ca.getConfiguration(PID).getProperties(); @@ -39,6 +39,8 @@ public Collection getPackages() { return getAttributeAddedPackages(); } else if (modelName.equals(com.specmate.migration.test.severalattributesadded.testmodel.base.BasePackage.class.getName())) { return getSeveralAttributesAddedPackages(); + } else if (modelName.equals(com.specmate.migration.test.objectadded.testmodel.base.BasePackage.class.getName())) { + return getObjectAddedPackages(); } } catch (InterruptedException | IOException e) { e.printStackTrace(); @@ -62,6 +64,11 @@ private Collection getSeveralAttributesAddedPackages() { com.specmate.migration.test.severalattributesadded.testmodel.artefact.ArtefactPackage.eINSTANCE); } + private Collection getObjectAddedPackages() { + return Arrays.asList(com.specmate.migration.test.objectadded.testmodel.base.BasePackage.eINSTANCE, + com.specmate.migration.test.objectadded.testmodel.artefact.ArtefactPackage.eINSTANCE); + } + private ConfigurationAdmin getConfigurationAdmin(BundleContext context) throws InterruptedException { ServiceTracker configurationAdminTracker = new ServiceTracker<>(context, ConfigurationAdmin.class.getName(), null); diff --git a/bundles/specmate-migration/bnd.bnd b/bundles/specmate-migration/bnd.bnd index 341ae8bd0..63223e076 100644 --- a/bundles/specmate-migration/bnd.bnd +++ b/bundles/specmate-migration/bnd.bnd @@ -61,4 +61,4 @@ Bundle-Version: 0.0.0.${tstamp} Private-Package: com.specmate.migration.internal.services Export-Package: \ com.specmate.migration.api,\ - com.specmate.migration.basemigrators \ No newline at end of file + com.specmate.migration.h2 \ No newline at end of file diff --git a/bundles/specmate-migration/src/com/specmate/migration/basemigrators/AttributeAddedBaseMigrator.java b/bundles/specmate-migration/src/com/specmate/migration/basemigrators/AttributeAddedBaseMigrator.java deleted file mode 100644 index ceabf2048..000000000 --- a/bundles/specmate-migration/src/com/specmate/migration/basemigrators/AttributeAddedBaseMigrator.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.specmate.migration.basemigrators; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; - -import com.specmate.common.SpecmateException; - -public abstract class AttributeAddedBaseMigrator { - protected Connection connection; - - public int migrateNewStringAttribute(String table, String attributeName, String defaultValue) throws SpecmateException { - String alterString = "ALTER TABLE " + table + - " ADD COLUMN " + attributeName + - " VARCHAR(32672)"; - - if(defaultValue != null) { - alterString += " DEFAULT '" + defaultValue + "'"; - } - - return alterDB(alterString, table, attributeName, defaultValue); - } - - public int migrateNewBooleanAttribute(String table, String attributeName, Boolean defaultValue) throws SpecmateException { - String alterString = "ALTER TABLE " + table + - " ADD COLUMN " + attributeName + - " BOOLEAN"; - - if(defaultValue != null) { - alterString += " DEFAULT " + defaultValue; - } - - return alterDB(alterString, table, attributeName, defaultValue); - } - - public int migrateNewIntegerAttribute(String table, String attributeName, Integer defaultValue) throws SpecmateException { - String alterString = "ALTER TABLE " + table + - " ADD COLUMN " + attributeName + - " INTEGER"; - - if(defaultValue != null) { - alterString += " DEFAULT " + defaultValue.intValue(); - } - - return alterDB(alterString, table, attributeName, defaultValue); - } - - public int migrateNewDoubleAttribute(String table, String attributeName, Double defaultValue) throws SpecmateException { - String alterString = "ALTER TABLE " + table + - " ADD COLUMN " + attributeName + - " DOUBLE"; - - if(defaultValue != null) { - alterString += " DEFAULT " + defaultValue; - } - - return alterDB(alterString, table, attributeName, defaultValue); - } - - private int alterDB(String alterString, String table, String attributeName, Object defaultValue) throws SpecmateException { - String failmsg = "Migration: Could not add column " + attributeName + " to table " + table + "."; - PreparedStatement alterStmt = null; - PreparedStatement updateStmt = null; - int affectedRows = 0; - - String updateString = null; - if(defaultValue != null) { - updateString = "UPDATE " + table + - " SET " + attributeName + - " = DEFAULT"; - } - - try { - connection.setAutoCommit(false); - - alterStmt = connection.prepareStatement(alterString); - alterStmt.execute(); - if(updateString != null) { - updateStmt = connection.prepareStatement(updateString); - affectedRows = updateStmt.executeUpdate(); - } - - connection.commit(); - } catch (SQLException e) { - try { - connection.rollback(); - } catch (SQLException f) { - throw new SpecmateException(failmsg + e.getMessage() + f.getMessage()); - } - - throw new SpecmateException(failmsg + e.getMessage()); - } finally { - try { - if(alterStmt != null) { - alterStmt.close(); - } - if(updateStmt != null) { - updateStmt.close(); - } - - connection.setAutoCommit(true); - } catch (SQLException e) { - throw new SpecmateException(failmsg); - } - } - - return affectedRows; - } -} diff --git a/bundles/specmate-migration/src/com/specmate/migration/h2/AttributeAddedtoSQLMapper.java b/bundles/specmate-migration/src/com/specmate/migration/h2/AttributeAddedtoSQLMapper.java new file mode 100644 index 000000000..11afe5d75 --- /dev/null +++ b/bundles/specmate-migration/src/com/specmate/migration/h2/AttributeAddedtoSQLMapper.java @@ -0,0 +1,114 @@ +package com.specmate.migration.h2; + +import java.sql.Connection; +import java.util.ArrayList; +import java.util.List; + +import com.specmate.common.SpecmateException; + +public class AttributeAddedtoSQLMapper { + protected Connection connection; + + public AttributeAddedtoSQLMapper(Connection connection) { + this.connection = connection; + } + + public void migrateNewStringAttribute(String tableName, String attributeName, String defaultValue) throws SpecmateException { + String alterString = "ALTER TABLE " + tableName + + " ADD COLUMN " + attributeName + + " VARCHAR(32672)"; + + if (defaultValue != null) { + alterString += " DEFAULT '" + defaultValue + "'"; + } + + alterDB(alterString, tableName, attributeName, defaultValue); + } + + public void migrateNewBooleanAttribute(String tableName, String attributeName, Boolean defaultValue) throws SpecmateException { + String alterString = "ALTER TABLE " + tableName + + " ADD COLUMN " + attributeName + + " BOOLEAN"; + + if (defaultValue != null) { + alterString += " DEFAULT " + defaultValue; + } + + alterDB(alterString, tableName, attributeName, defaultValue); + } + + public void migrateNewIntegerAttribute(String tableName, String attributeName, Integer defaultValue) throws SpecmateException { + String alterString = "ALTER TABLE " + tableName + + " ADD COLUMN " + attributeName + + " INTEGER"; + + if (defaultValue != null) { + alterString += " DEFAULT " + defaultValue.intValue(); + } + + alterDB(alterString, tableName, attributeName, defaultValue); + } + + public void migrateNewDoubleAttribute(String tableName, String attributeName, Double defaultValue) throws SpecmateException { + String alterString = "ALTER TABLE " + tableName + + " ADD COLUMN " + attributeName + + " DOUBLE"; + + if (defaultValue != null) { + alterString += " DEFAULT " + defaultValue; + } + + alterDB(alterString, tableName, attributeName, defaultValue); + } + + public void migrateNewLongAttribute(String tableName, String attributeName, Long defaultValue) throws SpecmateException { + String alterString = "ALTER TABLE " + tableName + + " ADD COLUMN " + attributeName + + " BIGINT"; + + if (defaultValue != null) { + alterString += " DEFAULT " + defaultValue; + } + + alterDB(alterString, tableName, attributeName, defaultValue); + } + + public void migrateNewReference(String tableName, String attributeName) throws SpecmateException { + String failmsg = "Migration: Could not add column " + attributeName + " to table " + tableName + "."; + String tableNameList = tableName + "_" + attributeName + "_LIST"; + List queries = new ArrayList<>(); + queries.add("ALTER TABLE " + tableName + + " ADD COLUMN " + attributeName + + " INTEGER"); + + queries.add("CREATE TABLE " + tableNameList + " (" + + "CDO_SOURCE BIGINT NOT NULL, " + + "CDO_VERSION INTEGER NOT NULL, " + + "CDO_IDX INTEGER NOT NULL, " + + "CDO_VALUE BIGINT)"); + + queries.add("CREATE UNIQUE INDEX " + + SQLUtil.createRandomIdentifier("PRIMARY_KEY_" + tableNameList) + + " ON " + tableNameList + " (CDO_SOURCE ASC, CDO_VERSION ASC, CDO_IDX ASC)"); + + queries.add("ALTER TABLE " + tableNameList + " ADD CONSTRAINT " + + SQLUtil.createRandomIdentifier("CONSTRAINT_" + tableNameList) + + " PRIMARY KEY (CDO_SOURCE, CDO_VERSION, CDO_IDX)"); + + SQLUtil.executeStatements(queries, connection, failmsg); + } + + private void alterDB(String alterString, String tableName, String attributeName, Object defaultValue) throws SpecmateException { + String failmsg = "Migration: Could not add column " + attributeName + " to table " + tableName + "."; + List queries = new ArrayList<>(); + queries.add(alterString); + + if (defaultValue != null) { + queries.add("UPDATE " + tableName + + " SET " + attributeName + + " = DEFAULT"); + } + + SQLUtil.executeStatements(queries, connection, failmsg); + } +} \ No newline at end of file diff --git a/bundles/specmate-migration/src/com/specmate/migration/h2/ObjectAddedtoSQLMapper.java b/bundles/specmate-migration/src/com/specmate/migration/h2/ObjectAddedtoSQLMapper.java new file mode 100644 index 000000000..f09f14361 --- /dev/null +++ b/bundles/specmate-migration/src/com/specmate/migration/h2/ObjectAddedtoSQLMapper.java @@ -0,0 +1,82 @@ +package com.specmate.migration.h2; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.specmate.common.SpecmateException; + +public class ObjectAddedtoSQLMapper { + protected Connection connection; + + public ObjectAddedtoSQLMapper(Connection connection) { + this.connection = connection; + } + + /* + * L64 + */ + public void newObject(String tableName, List attributeNames, String packageName, String version) throws SpecmateException { + String failmsg = "Migration: Could not add table " + tableName + "."; + List queries = new ArrayList<>(); + + queries.add("CREATE TABLE " + tableName + "(" + + "CDO_ID BIGINT NOT NULL, " + + "CDO_VERSION INTEGER NOT NULL, " + + "CDO_CREATED BIGINT NOT NULL, " + + "CDO_REVISED BIGINT NOT NULL, " + + "CDO_RESOURCE BIGINT NOT NULL, " + + "CDO_CONTAINER BIGINT NOT NULL, " + + "CDO_FEATURE INTEGER NOT NULL)"); + + queries.add("CREATE UNIQUE INDEX " + + SQLUtil.createRandomIdentifier("PRIMARY_KEY_" + tableName) + + " ON " + tableName + " (CDO_ID ASC, CDO_VERSION ASC)"); + + queries.add("CREATE INDEX " + + SQLUtil.createRandomIdentifier("INDEX_" + tableName) + + " ON " + tableName + " (CDO_REVISED ASC)"); + + queries.add("ALTER TABLE " + tableName + " ADD CONSTRAINT " + + SQLUtil.createRandomIdentifier("CONSTRAINT_" + tableName) + + " PRIMARY KEY (CDO_ID, CDO_VERSION)"); + + queries.addAll(getExtRefQueries(tableName, attributeNames, packageName, version)); + SQLUtil.executeStatements(queries, connection, failmsg); + } + + private List getExtRefQueries(String tableName, List attributeNames, String packageName, String version) throws SpecmateException { + int id = 0; + try { + PreparedStatement st = SQLUtil.executeStatement("SELECT id FROM CDO_EXTERNAL_REFS ORDER BY ID ASC LIMIT 1;", connection); + ResultSet result = st.getResultSet(); + if (result.next()) { + id = result.getInt(1); + } + } catch (SQLException e) { + throw new SpecmateException("Migration: Could not get retrieve id. " + e.getMessage()); + } + + List queries = new ArrayList<>(); + String baseUri = "http://specmate.com/" + version + "/" + packageName + "#//" + tableName; + id = id - 1; + queries.add(getExtRefQuery(baseUri, id)); + for (String name : attributeNames) { + String attributeUri = baseUri + "/" + name; + id = id - 1; + queries.add(getExtRefQuery(attributeUri, id)); + } + + return queries; + } + + private String getExtRefQuery(String uri, int id) { + Date now = new Date(); + return "INSERT INTO CDO_EXTERNAL_REFS (ID, URI, COMMITTIME) " + + "VALUES (" + id + ", '" + uri + "', " + now.getTime() + ")"; + } +} diff --git a/bundles/specmate-migration/src/com/specmate/migration/h2/SQLUtil.java b/bundles/specmate-migration/src/com/specmate/migration/h2/SQLUtil.java new file mode 100644 index 000000000..f2e50daab --- /dev/null +++ b/bundles/specmate-migration/src/com/specmate/migration/h2/SQLUtil.java @@ -0,0 +1,63 @@ +package com.specmate.migration.h2; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; + +import com.specmate.common.SpecmateException; + +public class SQLUtil { + public static PreparedStatement executeStatement(String sql, Connection connection) throws SQLException { + PreparedStatement stmt = connection.prepareStatement(sql); + stmt.execute(); + return stmt; + } + + public static void executeStatements(List queries, Connection connection, String failmsg) throws SpecmateException { + List statements = new ArrayList<>(); + + try { + connection.setAutoCommit(false); + for (String query : queries) { + statements.add(executeStatement(query, connection)); + } + connection.commit(); + } catch (SQLException e) { + try { + connection.rollback(); + } catch (SQLException f) { + throw new SpecmateException(failmsg + " " + e.getMessage() + " " + f.getMessage()); + } + + throw new SpecmateException(failmsg + " " + e.getMessage()); + } finally { + try { + closePreparedStatements(statements); + connection.setAutoCommit(true); + } catch (SQLException e) { + throw new SpecmateException(failmsg + " " + e.getMessage()); + } + } + } + + public static String createRandomIdentifier(String prefix) { + Date now = new Date(); + return prefix + "_" + now.getTime() + "_" + ThreadLocalRandom.current().nextInt(0, Integer.MAX_VALUE); + } + + public static void closePreparedStatement(PreparedStatement stmt) throws SQLException { + if (stmt != null) { + stmt.close(); + } + } + + public static void closePreparedStatements(List statements) throws SQLException { + for(PreparedStatement stmt : statements) { + closePreparedStatement(stmt); + } + } +} diff --git a/bundles/specmate-migration/src/com/specmate/migration/basemigrators/package-info.java b/bundles/specmate-migration/src/com/specmate/migration/h2/package-info.java similarity index 51% rename from bundles/specmate-migration/src/com/specmate/migration/basemigrators/package-info.java rename to bundles/specmate-migration/src/com/specmate/migration/h2/package-info.java index e17988cdb..8440d334d 100644 --- a/bundles/specmate-migration/src/com/specmate/migration/basemigrators/package-info.java +++ b/bundles/specmate-migration/src/com/specmate/migration/h2/package-info.java @@ -1,2 +1,2 @@ @org.osgi.annotation.versioning.Version("1.0.0") -package com.specmate.migration.basemigrators; +package com.specmate.migration.h2; diff --git a/web/webpack/webpack.common.js b/web/webpack/webpack.common.js index a25b6ecd2..e1627387b 100644 --- a/web/webpack/webpack.common.js +++ b/web/webpack/webpack.common.js @@ -1,4 +1,4 @@ -const SPECMATE_VERSION = '0.1-alpha.2' +const SPECMATE_VERSION = '0.1-alpha.3' const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); @@ -118,4 +118,4 @@ module.exports = { copyUnmodified: true }]) ] -}; \ No newline at end of file +};