diff options
Diffstat (limited to 'tests')
19 files changed, 1215 insertions, 20 deletions
diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/.classpath b/tests/org.eclipse.emf.teneo.hibernate.test/.classpath index 1fa3e6803..751c8f2e5 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/.classpath +++ b/tests/org.eclipse.emf.teneo.hibernate.test/.classpath @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> + <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_a_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_a_o_hibernate.hbm.xml index 340a2e491..a6e99c4fb 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_a_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_a_o_hibernate.hbm.xml @@ -48,6 +48,13 @@ <property name="birthPlace" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> <column not-null="true" unique="false" name="`birthplace`"/> </property> + <property name="double" lazy="false" insert="true" update="true" not-null="true" unique="false"> + <column not-null="true" unique="false" name="`double`"/> + <type name="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType"> + <param name="epackage">http://www.elver.org/samples/emf/hibernate/usertype</param> + <param name="edatatype">myDoubleType</param> + </type> + </property> </class> <class name="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" discriminator-value="Address" table="`address`"> <meta attribute="eclassName">Address</meta> @@ -67,6 +74,24 @@ <column not-null="false" unique="false" name="`address_person_e_id`"/> </many-to-one> </class> + <class name="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl" entity-name="City" abstract="false" lazy="false" discriminator-value="City" table="`city`"> + <meta attribute="eclassName">City</meta> + <meta attribute="epackage">http://www.elver.org/samples/emf/hibernate/usertype</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + <generator class="assigned"/> + </id> + <discriminator column="`dtype`" type="string"/> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + <property name="size" lazy="false" not-null="false" insert="true" update="true" unique="false"> + <column not-null="false" unique="false" name="`size`"/> + <type name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType"> + <param name="enumClass">org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize</param> + </type> + </property> + </class> <query name="getPersonByBirthPlace2"><![CDATA[select p from Person p where p.birthPlace=?]]></query> <query name="getPersonByBirthPlace"><![CDATA[select p from Person p where p.birthPlace=?]]></query> </hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_e_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_e_o_hibernate.hbm.xml index a5efabd89..746e45a94 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_e_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_e_o_hibernate.hbm.xml @@ -47,6 +47,13 @@ <property name="birthPlace" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> <column not-null="true" unique="false" name="`birthplace`"/> </property> + <property name="double" lazy="false" insert="true" update="true" not-null="true" unique="false"> + <column not-null="true" unique="false" name="`double`"/> + <type name="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType"> + <param name="epackage">http://www.elver.org/samples/emf/hibernate/usertype</param> + <param name="edatatype">myDoubleType</param> + </type> + </property> </class> <class name="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" table="`address`"> <meta attribute="eclassName">Address</meta> @@ -65,6 +72,23 @@ <column not-null="false" unique="false" name="`address_person_e_id`"/> </many-to-one> </class> + <class name="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl" entity-name="City" abstract="false" lazy="false" table="`city`"> + <meta attribute="eclassName">City</meta> + <meta attribute="epackage">http://www.elver.org/samples/emf/hibernate/usertype</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + <generator class="assigned"/> + </id> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + <property name="size" lazy="false" not-null="false" insert="true" update="true" unique="false"> + <column not-null="false" unique="false" name="`size`"/> + <type name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType"> + <param name="enumClass">org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize</param> + </type> + </property> + </class> <query name="getPersonByBirthPlace2"><![CDATA[select p from Person p where p.birthPlace=?]]></query> <query name="getPersonByBirthPlace"><![CDATA[select p from Person p where p.birthPlace=?]]></query> </hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_s_o_hibernate.hbm.xml b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_s_o_hibernate.hbm.xml index a5efabd89..746e45a94 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_s_o_hibernate.hbm.xml +++ b/tests/org.eclipse.emf.teneo.hibernate.test/hbm/org.eclipse.emf.teneo.hibernate.test.emf.annotations/UserTypeAction_mysql_s_o_hibernate.hbm.xml @@ -47,6 +47,13 @@ <property name="birthPlace" lazy="false" insert="true" update="true" not-null="true" unique="false" type="java.lang.String"> <column not-null="true" unique="false" name="`birthplace`"/> </property> + <property name="double" lazy="false" insert="true" update="true" not-null="true" unique="false"> + <column not-null="true" unique="false" name="`double`"/> + <type name="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType"> + <param name="epackage">http://www.elver.org/samples/emf/hibernate/usertype</param> + <param name="edatatype">myDoubleType</param> + </type> + </property> </class> <class name="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.AddressImpl" entity-name="Address" abstract="false" lazy="false" table="`address`"> <meta attribute="eclassName">Address</meta> @@ -65,6 +72,23 @@ <column not-null="false" unique="false" name="`address_person_e_id`"/> </many-to-one> </class> + <class name="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl" entity-name="City" abstract="false" lazy="false" table="`city`"> + <meta attribute="eclassName">City</meta> + <meta attribute="epackage">http://www.elver.org/samples/emf/hibernate/usertype</meta> + <id name="id" type="long" unsaved-value="0"> + <column not-null="true" unique="true" name="`id`"/> + <generator class="assigned"/> + </id> + <version name="e_version" column="e_version" access="org.eclipse.emf.teneo.hibernate.mapping.property.VersionPropertyHandler"> + <meta attribute="syntheticVersion">true</meta> + </version> + <property name="size" lazy="false" not-null="false" insert="true" update="true" unique="false"> + <column not-null="false" unique="false" name="`size`"/> + <type name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType"> + <param name="enumClass">org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize</param> + </type> + </property> + </class> <query name="getPersonByBirthPlace2"><![CDATA[select p from Person p where p.birthPlace=?]]></query> <query name="getPersonByBirthPlace"><![CDATA[select p from Person p where p.birthPlace=?]]></query> </hibernate-mapping>
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java index f94b1d578..8f6125d9e 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/AllTests.java @@ -55,13 +55,14 @@ import org.eclipse.emf.teneo.test.emf.annotations.VariousAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.82 $ + * @version $Revision: 1.83 $ */ public class AllTests { public static Test suite() { TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.emf.annotations", HibernateTestbed.instance().getConfigurations()); + suite.addTestSuite(UserTypeAction.class); suite.addTestSuite(JoinColumnsTest.class); suite.addTestSuite(LobAction.class); suite.addTestSuite(VariousAction.class); @@ -73,7 +74,6 @@ public class AllTests { suite.addTestSuite(SecondarytableHibernateAction.class); suite.addTestSuite(HbSequenceIdAction.class); - suite.addTestSuite(UserTypeAction.class); suite.addTestSuite(HibernateAction.class); suite.addTestSuite(OverrideSecondaryAction.class); diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/UserTypeAction.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/UserTypeAction.java index cfc286fb9..e22a65e19 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/UserTypeAction.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/emf/annotations/UserTypeAction.java @@ -8,7 +8,7 @@ * http://www.eclipse.org/legal/epl-v10.html
* </copyright>
*
- * $Id: UserTypeAction.java,v 1.11 2008/05/27 07:42:33 mtaal Exp $
+ * $Id: UserTypeAction.java,v 1.12 2009/06/11 04:59:10 mtaal Exp $
*/
package org.eclipse.emf.teneo.hibernate.test.emf.annotations;
@@ -18,9 +18,13 @@ import java.sql.ResultSet; import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
+import java.util.Properties;
+import org.eclipse.emf.teneo.PersistenceOptions;
import org.eclipse.emf.teneo.hibernate.test.stores.HibernateTestStore;
import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Address;
+import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City;
+import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize;
import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name;
import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person;
import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber;
@@ -33,7 +37,7 @@ import org.hibernate.Query; /**
* Test
*
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
@SuppressWarnings("unchecked")
public class UserTypeAction extends AbstractTestAction {
@@ -47,17 +51,53 @@ public class UserTypeAction extends AbstractTestAction { }
@Override
+ public Properties getExtraConfigurationProperties() {
+ final Properties props = new Properties();
+ props.setProperty(PersistenceOptions.HANDLE_UNSET_AS_NULL, "true");
+ return props;
+ }
+
+ @Override
public void doAction(TestStore store) {
storePerson(store);
testPerson(store);
testDatabase(store);
removePerson(store);
+
+ {
+ final City c = UsertypeFactory.eINSTANCE.createCity();
+ assertTrue(c.getSize() != null);
+ assertTrue(!c.isSetSize());
+ c.setId(105);
+ store.beginTransaction();
+ store.store(c);
+ store.commitTransaction();
+ }
+ {
+ final City c = store.getObject(City.class);
+ assertTrue(c.getSize() != null);
+ assertTrue(!c.isSetSize());
+ assertEquals(105, c.getId());
+ c.setSize(CitySize.MEDIUM_LITERAL);
+ assertTrue(c.isSetSize());
+ store.beginTransaction();
+ store.store(c);
+ store.commitTransaction();
+ assertTrue(c.isSetSize());
+ }
+ {
+ final City c = store.getObject(City.class);
+ assertEquals(105, c.getId());
+ assertEquals(CitySize.MEDIUM_LITERAL, c.getSize());
+ assertTrue(c.isSetSize());
+ }
}
private void storePerson(TestStore store) {
store.beginTransaction();
Person person = UsertypeFactory.eINSTANCE.createPerson();
person.setName(NAME);
+ person.setDouble(new Double(5));
UsaPhoneNumber up1 = new UsaPhoneNumber(100, 200, 300);
UsaPhoneNumber up2 = new UsaPhoneNumber(400, 500, 600);
UsaPhoneNumber up3 = new UsaPhoneNumber(700, 800, 900);
diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/City.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/City.java new file mode 100644 index 000000000..bdaa46e1b --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/City.java @@ -0,0 +1,114 @@ +/** + * <copyright> + * </copyright> + * + * $Id: City.java,v 1.2 2009/06/11 04:59:10 mtaal Exp $ + */ +package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; + +import org.eclipse.emf.ecore.EObject; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>City</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getId <em>Id</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getSize <em>Size</em>}</li> + * </ul> + * </p> + * + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getCity() + * @model + * @generated + */ +public interface City extends EObject { + /** + * Returns the value of the '<em><b>Id</b></em>' attribute. + * The default value is <code>"0"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Id</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Id</em>' attribute. + * @see #setId(long) + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getCity_Id() + * @model default="0" id="true" + * annotation="teneo.jpa value='@GeneratedValue(strategy=\"ASSIGNED\")'" + * @generated + */ + long getId(); + + /** + * Sets the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getId <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Id</em>' attribute. + * @see #getId() + * @generated + */ + void setId(long value); + + /** + * Returns the value of the '<em><b>Size</b></em>' attribute. + * The default value is <code>"MEDIUM"</code>. + * The literals are from the enumeration {@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Size</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Size</em>' attribute. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize + * @see #isSetSize() + * @see #unsetSize() + * @see #setSize(CitySize) + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getCity_Size() + * @model default="MEDIUM" unsettable="true" + * @generated + */ + CitySize getSize(); + + /** + * Sets the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getSize <em>Size</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Size</em>' attribute. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize + * @see #isSetSize() + * @see #unsetSize() + * @see #getSize() + * @generated + */ + void setSize(CitySize value); + + /** + * Unsets the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getSize <em>Size</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetSize() + * @see #getSize() + * @see #setSize(CitySize) + * @generated + */ + void unsetSize(); + + /** + * Returns whether the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getSize <em>Size</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Size</em>' attribute is set. + * @see #unsetSize() + * @see #getSize() + * @see #setSize(CitySize) + * @generated + */ + boolean isSetSize(); + +} // City diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/CitySize.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/CitySize.java new file mode 100644 index 000000000..27e6d5f80 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/CitySize.java @@ -0,0 +1,178 @@ +/** + * <copyright> + * </copyright> + * + * $Id: CitySize.java,v 1.2 2009/06/11 04:59:10 mtaal Exp $ + */ +package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.common.util.AbstractEnumerator; + +/** + * <!-- begin-user-doc --> + * A representation of the literals of the enumeration '<em><b>City Size</b></em>', + * and utility methods for working with them. + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getCitySize() + * @model + * @generated + */ +public final class CitySize extends AbstractEnumerator { + /** + * The '<em><b>SMALL</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>SMALL</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #SMALL_LITERAL + * @model + * @generated + * @ordered + */ + public static final int SMALL = 0; + + /** + * The '<em><b>MEDIUM</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>MEDIUM</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #MEDIUM_LITERAL + * @model + * @generated + * @ordered + */ + public static final int MEDIUM = 1; + + /** + * The '<em><b>LARGE</b></em>' literal value. + * <!-- begin-user-doc --> + * <p> + * If the meaning of '<em><b>LARGE</b></em>' literal object isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @see #LARGE_LITERAL + * @model + * @generated + * @ordered + */ + public static final int LARGE = 2; + + /** + * The '<em><b>SMALL</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #SMALL + * @generated + * @ordered + */ + public static final CitySize SMALL_LITERAL = new CitySize(SMALL, "SMALL", "SMALL"); + + /** + * The '<em><b>MEDIUM</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #MEDIUM + * @generated + * @ordered + */ + public static final CitySize MEDIUM_LITERAL = new CitySize(MEDIUM, "MEDIUM", "MEDIUM"); + + /** + * The '<em><b>LARGE</b></em>' literal object. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #LARGE + * @generated + * @ordered + */ + public static final CitySize LARGE_LITERAL = new CitySize(LARGE, "LARGE", "LARGE"); + + /** + * An array of all the '<em><b>City Size</b></em>' enumerators. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static final CitySize[] VALUES_ARRAY = + new CitySize[] { + SMALL_LITERAL, + MEDIUM_LITERAL, + LARGE_LITERAL, + }; + + /** + * A public read-only list of all the '<em><b>City Size</b></em>' enumerators. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the '<em><b>City Size</b></em>' literal with the specified literal value. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static CitySize get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + CitySize result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the '<em><b>City Size</b></em>' literal with the specified name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static CitySize getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + CitySize result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the '<em><b>City Size</b></em>' literal with the specified integer value. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static CitySize get(int value) { + switch (value) { + case SMALL: return SMALL_LITERAL; + case MEDIUM: return MEDIUM_LITERAL; + case LARGE: return LARGE_LITERAL; + } + return null; + } + + /** + * Only this class can construct instances. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private CitySize(int value, String name, String literal) { + super(value, name, literal); + } + +} //CitySize diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/Person.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/Person.java index c6fdfd20e..c1769ef99 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/Person.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/Person.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: Person.java,v 1.7 2008/08/26 21:20:34 mtaal Exp $ + * $Id: Person.java,v 1.8 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; @@ -24,6 +24,7 @@ import org.eclipse.emf.ecore.EObject; * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getEmergencyContact <em>Emergency Contact</em>}</li> * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getAddresses <em>Addresses</em>}</li> * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getBirthPlace <em>Birth Place</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getDouble <em>Double</em>}</li> * </ul> * </p> * @@ -175,4 +176,32 @@ public interface Person extends EObject { */ void setBirthPlace(String value); + /** + * Returns the value of the '<em><b>Double</b></em>' attribute. + * The default value is <code>"0"</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Double</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Double</em>' attribute. + * @see #setDouble(Double) + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getPerson_Double() + * @model default="0" unique="false" dataType="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.myDoubleType" required="true" + * extendedMetaData="kind='element' name='intArray'" + * @generated + */ + Double getDouble(); + + /** + * Sets the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getDouble <em>Double</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Double</em>' attribute. + * @see #getDouble() + * @generated + */ + void setDouble(Double value); + } // Person
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypeFactory.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypeFactory.java index d27b02174..a979fcd33 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypeFactory.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypeFactory.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: UsertypeFactory.java,v 1.4 2007/03/04 21:18:27 mtaal Exp $ + * $Id: UsertypeFactory.java,v 1.5 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; @@ -44,6 +44,15 @@ public interface UsertypeFactory extends EFactory { Address createAddress(); /** + * Returns a new object of class '<em>City</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>City</em>'. + * @generated + */ + City createCity(); + + /** * Returns the package supported by this factory. * <!-- begin-user-doc --> * <!-- end-user-doc --> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypePackage.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypePackage.java index 0d8e7e56d..6d3fe6b0f 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypePackage.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsertypePackage.java @@ -2,13 +2,14 @@ * <copyright> * </copyright> * - * $Id: UsertypePackage.java,v 1.9 2008/03/30 20:54:58 mtaal Exp $ + * $Id: UsertypePackage.java,v 1.10 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; @@ -126,13 +127,22 @@ public interface UsertypePackage extends EPackage { int PERSON__BIRTH_PLACE = 5; /** + * The feature id for the '<em><b>Double</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERSON__DOUBLE = 6; + + /** * The number of structural features of the '<em>Person</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - int PERSON_FEATURE_COUNT = 6; + int PERSON_FEATURE_COUNT = 7; /** * The meta object id for the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.AddressImpl <em>Address</em>}' class. @@ -172,6 +182,53 @@ public interface UsertypePackage extends EPackage { int ADDRESS_FEATURE_COUNT = 2; /** + * The meta object id for the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl <em>City</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getCity() + * @generated + */ + int CITY = 2; + + /** + * The feature id for the '<em><b>Id</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CITY__ID = 0; + + /** + * The feature id for the '<em><b>Size</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CITY__SIZE = 1; + + /** + * The number of structural features of the '<em>City</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CITY_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize <em>City Size</em>}' enum. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getCitySize() + * @generated + */ + int CITY_SIZE = 3; + + /** * The meta object id for the '<em>Name</em>' data type. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -179,7 +236,7 @@ public interface UsertypePackage extends EPackage { * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getName_() * @generated */ - int NAME = 2; + int NAME = 4; /** @@ -190,7 +247,7 @@ public interface UsertypePackage extends EPackage { * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getPhoneNumber() * @generated */ - int PHONE_NUMBER = 3; + int PHONE_NUMBER = 5; /** @@ -200,7 +257,18 @@ public interface UsertypePackage extends EPackage { * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getIntArray() * @generated */ - int INT_ARRAY = 4; + int INT_ARRAY = 6; + + + /** + * The meta object id for the '<em>my Double Type</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Double + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getmyDoubleType() + * @generated + */ + int MY_DOUBLE_TYPE = 7; /** @@ -280,6 +348,17 @@ public interface UsertypePackage extends EPackage { EAttribute getPerson_BirthPlace(); /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getDouble <em>Double</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Double</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getDouble() + * @see #getPerson() + * @generated + */ + EAttribute getPerson_Double(); + + /** * Returns the meta object for class '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Address <em>Address</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -312,6 +391,48 @@ public interface UsertypePackage extends EPackage { EReference getAddress_Person(); /** + * Returns the meta object for class '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City <em>City</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>City</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City + * @generated + */ + EClass getCity(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getId <em>Id</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Id</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getId() + * @see #getCity() + * @generated + */ + EAttribute getCity_Id(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getSize <em>Size</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Size</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City#getSize() + * @see #getCity() + * @generated + */ + EAttribute getCity_Size(); + + /** + * Returns the meta object for enum '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize <em>City Size</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for enum '<em>City Size</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize + * @generated + */ + EEnum getCitySize(); + + /** * Returns the meta object for data type '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name <em>Name</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -348,6 +469,19 @@ public interface UsertypePackage extends EPackage { EDataType getIntArray(); /** + * Returns the meta object for data type '{@link java.lang.Double <em>my Double Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>my Double Type</em>'. + * @see java.lang.Double + * @model instanceClass="java.lang.Double" + * extendedMetaData="name='IntArray'" + * annotation="teneo.jpa appinfo='\n\t\t\t\t\t\t@Type(type=\"org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType\", parameters={@Parameter(name=\"epackage\" value=\"http://www.elver.org/samples/emf/hibernate/usertype\"), @Parameter(name=\"edatatype\", value=\"myDoubleType\")})\n\t\t\t\t\t'" + * @generated + */ + EDataType getmyDoubleType(); + + /** * Returns the factory that creates the instances of the model. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -428,6 +562,14 @@ public interface UsertypePackage extends EPackage { EAttribute PERSON__BIRTH_PLACE = eINSTANCE.getPerson_BirthPlace(); /** + * The meta object literal for the '<em><b>Double</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PERSON__DOUBLE = eINSTANCE.getPerson_Double(); + + /** * The meta object literal for the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.AddressImpl <em>Address</em>}' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -454,6 +596,42 @@ public interface UsertypePackage extends EPackage { EReference ADDRESS__PERSON = eINSTANCE.getAddress_Person(); /** + * The meta object literal for the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl <em>City</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getCity() + * @generated + */ + EClass CITY = eINSTANCE.getCity(); + + /** + * The meta object literal for the '<em><b>Id</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute CITY__ID = eINSTANCE.getCity_Id(); + + /** + * The meta object literal for the '<em><b>Size</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute CITY__SIZE = eINSTANCE.getCity_Size(); + + /** + * The meta object literal for the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize <em>City Size</em>}' enum. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getCitySize() + * @generated + */ + EEnum CITY_SIZE = eINSTANCE.getCitySize(); + + /** * The meta object literal for the '<em>Name</em>' data type. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -482,6 +660,16 @@ public interface UsertypePackage extends EPackage { */ EDataType INT_ARRAY = eINSTANCE.getIntArray(); + /** + * The meta object literal for the '<em>my Double Type</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Double + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getmyDoubleType() + * @generated + */ + EDataType MY_DOUBLE_TYPE = eINSTANCE.getmyDoubleType(); + } } //UsertypePackage diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/CityImpl.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/CityImpl.java new file mode 100644 index 000000000..222f1da82 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/CityImpl.java @@ -0,0 +1,250 @@ +/** + * <copyright> + * </copyright> + * + * $Id: CityImpl.java,v 1.2 2009/06/11 04:59:10 mtaal Exp $ + */ +package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; + +import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City; +import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize; +import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>City</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl#getId <em>Id</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.CityImpl#getSize <em>Size</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class CityImpl extends EObjectImpl implements City { + /** + * The default value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected static final long ID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getId() <em>Id</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getId() + * @generated + * @ordered + */ + protected long id = ID_EDEFAULT; + + /** + * The default value of the '{@link #getSize() <em>Size</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSize() + * @generated + * @ordered + */ + protected static final CitySize SIZE_EDEFAULT = CitySize.MEDIUM_LITERAL; + + /** + * The cached value of the '{@link #getSize() <em>Size</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSize() + * @generated + * @ordered + */ + protected CitySize size = SIZE_EDEFAULT; + + /** + * This is true if the Size attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean sizeESet; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected CityImpl() { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() { + return UsertypePackage.Literals.CITY; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public long getId() { + return id; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setId(long newId) { + long oldId = id; + id = newId; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, UsertypePackage.CITY__ID, oldId, id)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public CitySize getSize() { + return size; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSize(CitySize newSize) { + CitySize oldSize = size; + size = newSize == null ? SIZE_EDEFAULT : newSize; + boolean oldSizeESet = sizeESet; + sizeESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, UsertypePackage.CITY__SIZE, oldSize, size, !oldSizeESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetSize() { + CitySize oldSize = size; + boolean oldSizeESet = sizeESet; + size = SIZE_EDEFAULT; + sizeESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, UsertypePackage.CITY__SIZE, oldSize, SIZE_EDEFAULT, oldSizeESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetSize() { + return sizeESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case UsertypePackage.CITY__ID: + return new Long(getId()); + case UsertypePackage.CITY__SIZE: + return getSize(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case UsertypePackage.CITY__ID: + setId(((Long)newValue).longValue()); + return; + case UsertypePackage.CITY__SIZE: + setSize((CitySize)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) { + switch (featureID) { + case UsertypePackage.CITY__ID: + setId(ID_EDEFAULT); + return; + case UsertypePackage.CITY__SIZE: + unsetSize(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) { + switch (featureID) { + case UsertypePackage.CITY__ID: + return id != ID_EDEFAULT; + case UsertypePackage.CITY__SIZE: + return isSetSize(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (id: "); + result.append(id); + result.append(", size: "); + if (sizeESet) result.append(size); else result.append("<unset>"); + result.append(')'); + return result.toString(); + } + +} //CityImpl diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/PersonImpl.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/PersonImpl.java index f464e514b..a675591b7 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/PersonImpl.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/PersonImpl.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: PersonImpl.java,v 1.9 2008/03/30 20:54:58 mtaal Exp $ + * $Id: PersonImpl.java,v 1.10 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; @@ -44,6 +44,7 @@ import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage; * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getEmergencyContact <em>Emergency Contact</em>}</li> * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getAddresses <em>Addresses</em>}</li> * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getBirthPlace <em>Birth Place</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getDouble <em>Double</em>}</li> * </ul> * </p> * @@ -151,6 +152,26 @@ public class PersonImpl extends EObjectImpl implements Person { protected String birthPlace = BIRTH_PLACE_EDEFAULT; /** + * The default value of the '{@link #getDouble() <em>Double</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDouble() + * @generated + * @ordered + */ + protected static final Double DOUBLE_EDEFAULT = new Double(0.0); + + /** + * The cached value of the '{@link #getDouble() <em>Double</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDouble() + * @generated + * @ordered + */ + protected Double double_ = DOUBLE_EDEFAULT; + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated @@ -281,6 +302,27 @@ public class PersonImpl extends EObjectImpl implements Person { * <!-- end-user-doc --> * @generated */ + public Double getDouble() { + return double_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setDouble(Double newDouble) { + Double oldDouble = double_; + double_ = newDouble; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, UsertypePackage.PERSON__DOUBLE, oldDouble, double_)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case UsertypePackage.PERSON__ADDRESSES: @@ -321,6 +363,8 @@ public class PersonImpl extends EObjectImpl implements Person { return getAddresses(); case UsertypePackage.PERSON__BIRTH_PLACE: return getBirthPlace(); + case UsertypePackage.PERSON__DOUBLE: + return getDouble(); } return super.eGet(featureID, resolve, coreType); } @@ -352,6 +396,9 @@ public class PersonImpl extends EObjectImpl implements Person { case UsertypePackage.PERSON__BIRTH_PLACE: setBirthPlace((String)newValue); return; + case UsertypePackage.PERSON__DOUBLE: + setDouble((Double)newValue); + return; } super.eSet(featureID, newValue); } @@ -381,6 +428,9 @@ public class PersonImpl extends EObjectImpl implements Person { case UsertypePackage.PERSON__BIRTH_PLACE: setBirthPlace(BIRTH_PLACE_EDEFAULT); return; + case UsertypePackage.PERSON__DOUBLE: + setDouble(DOUBLE_EDEFAULT); + return; } super.eUnset(featureID); } @@ -404,6 +454,8 @@ public class PersonImpl extends EObjectImpl implements Person { return addresses != null && !addresses.isEmpty(); case UsertypePackage.PERSON__BIRTH_PLACE: return BIRTH_PLACE_EDEFAULT == null ? birthPlace != null : !BIRTH_PLACE_EDEFAULT.equals(birthPlace); + case UsertypePackage.PERSON__DOUBLE: + return DOUBLE_EDEFAULT == null ? double_ != null : !DOUBLE_EDEFAULT.equals(double_); } return super.eIsSet(featureID); } @@ -427,6 +479,8 @@ public class PersonImpl extends EObjectImpl implements Person { result.append(emergencyContact); result.append(", birthPlace: "); result.append(birthPlace); + result.append(", double: "); + result.append(double_); result.append(')'); return result.toString(); } diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypeFactoryImpl.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypeFactoryImpl.java index bdc335730..7f46b24a3 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypeFactoryImpl.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypeFactoryImpl.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: UsertypeFactoryImpl.java,v 1.6 2007/03/04 21:18:27 mtaal Exp $ + * $Id: UsertypeFactoryImpl.java,v 1.7 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; @@ -62,6 +62,7 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory switch (eClass.getClassifierID()) { case UsertypePackage.PERSON: return createPerson(); case UsertypePackage.ADDRESS: return createAddress(); + case UsertypePackage.CITY: return createCity(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } @@ -74,12 +75,16 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory */ public Object createFromString(EDataType eDataType, String initialValue) { switch (eDataType.getClassifierID()) { + case UsertypePackage.CITY_SIZE: + return createCitySizeFromString(eDataType, initialValue); case UsertypePackage.NAME: return createNameFromString(eDataType, initialValue); case UsertypePackage.PHONE_NUMBER: return createPhoneNumberFromString(eDataType, initialValue); case UsertypePackage.INT_ARRAY: return createIntArrayFromString(eDataType, initialValue); + case UsertypePackage.MY_DOUBLE_TYPE: + return createmyDoubleTypeFromString(eDataType, initialValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -92,12 +97,16 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory */ public String convertToString(EDataType eDataType, Object instanceValue) { switch (eDataType.getClassifierID()) { + case UsertypePackage.CITY_SIZE: + return convertCitySizeToString(eDataType, instanceValue); case UsertypePackage.NAME: return convertNameToString(eDataType, instanceValue); case UsertypePackage.PHONE_NUMBER: return convertPhoneNumberToString(eDataType, instanceValue); case UsertypePackage.INT_ARRAY: return convertIntArrayToString(eDataType, instanceValue); + case UsertypePackage.MY_DOUBLE_TYPE: + return convertmyDoubleTypeToString(eDataType, instanceValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -128,6 +137,36 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory * <!-- end-user-doc --> * @generated */ + public City createCity() { + CityImpl city = new CityImpl(); + return city; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public CitySize createCitySizeFromString(EDataType eDataType, String initialValue) { + CitySize result = CitySize.get(initialValue); + if (result == null) throw new IllegalArgumentException("The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); + return result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertCitySizeToString(EDataType eDataType, Object instanceValue) { + return instanceValue == null ? null : instanceValue.toString(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public Name createNameFromString(EDataType eDataType, String initialValue) { return (Name)super.createFromString(eDataType, initialValue); } @@ -194,6 +233,24 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory * <!-- end-user-doc --> * @generated */ + public Double createmyDoubleTypeFromString(EDataType eDataType, String initialValue) { + return (Double)super.createFromString(eDataType, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertmyDoubleTypeToString(EDataType eDataType, Object instanceValue) { + return super.convertToString(eDataType, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public UsertypePackage getUsertypePackage() { return (UsertypePackage)getEPackage(); } diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypePackageImpl.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypePackageImpl.java index 268d3d6c5..d16cc127b 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypePackageImpl.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/impl/UsertypePackageImpl.java @@ -2,19 +2,22 @@ * <copyright> * </copyright> * - * $Id: UsertypePackageImpl.java,v 1.10 2008/08/26 21:20:34 mtaal Exp $ + * $Id: UsertypePackageImpl.java,v 1.11 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EEnum; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.impl.EPackageImpl; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Address; +import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City; +import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.CitySize; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber; @@ -47,6 +50,20 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage * <!-- end-user-doc --> * @generated */ + private EClass cityEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EEnum citySizeEEnum = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ private EDataType nameEDataType = null; /** @@ -64,6 +81,13 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage private EDataType intArrayEDataType = null; /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType myDoubleTypeEDataType = null; + + /** * Creates an instance of the model <b>Package</b>, registered with * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package * package URI value. @@ -199,6 +223,15 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage * <!-- end-user-doc --> * @generated */ + public EAttribute getPerson_Double() { + return (EAttribute)personEClass.getEStructuralFeatures().get(6); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public EClass getAddress() { return addressEClass; } @@ -226,6 +259,42 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage * <!-- end-user-doc --> * @generated */ + public EClass getCity() { + return cityEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getCity_Id() { + return (EAttribute)cityEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getCity_Size() { + return (EAttribute)cityEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EEnum getCitySize() { + return citySizeEEnum; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public EDataType getName_() { return nameEDataType; } @@ -253,6 +322,15 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage * <!-- end-user-doc --> * @generated */ + public EDataType getmyDoubleType() { + return myDoubleTypeEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public UsertypeFactory getUsertypeFactory() { return (UsertypeFactory)getEFactoryInstance(); } @@ -283,15 +361,24 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage createEAttribute(personEClass, PERSON__EMERGENCY_CONTACT); createEReference(personEClass, PERSON__ADDRESSES); createEAttribute(personEClass, PERSON__BIRTH_PLACE); + createEAttribute(personEClass, PERSON__DOUBLE); addressEClass = createEClass(ADDRESS); createEAttribute(addressEClass, ADDRESS__ADDRESS_INFO); createEReference(addressEClass, ADDRESS__PERSON); + cityEClass = createEClass(CITY); + createEAttribute(cityEClass, CITY__ID); + createEAttribute(cityEClass, CITY__SIZE); + + // Create enums + citySizeEEnum = createEEnum(CITY_SIZE); + // Create data types nameEDataType = createEDataType(NAME); phoneNumberEDataType = createEDataType(PHONE_NUMBER); intArrayEDataType = createEDataType(INT_ARRAY); + myDoubleTypeEDataType = createEDataType(MY_DOUBLE_TYPE); } /** @@ -327,15 +414,27 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage initEAttribute(getPerson_EmergencyContact(), this.getPhoneNumber(), "emergencyContact", "", 0, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getPerson_Addresses(), this.getAddress(), this.getAddress_Person(), "addresses", null, 0, -1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPerson_BirthPlace(), ecorePackage.getEString(), "birthPlace", null, 1, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPerson_Double(), this.getmyDoubleType(), "double", "0", 1, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(addressEClass, Address.class, "Address", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getAddress_AddressInfo(), ecorePackage.getEString(), "addressInfo", null, 1, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEReference(getAddress_Person(), this.getPerson(), this.getPerson_Addresses(), "person", null, 0, 1, Address.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEClass(cityEClass, City.class, "City", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getCity_Id(), ecorePackage.getELong(), "id", "0", 0, 1, City.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getCity_Size(), this.getCitySize(), "size", "MEDIUM", 0, 1, City.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Initialize enums and add enum literals + initEEnum(citySizeEEnum, CitySize.class, "CitySize"); + addEEnumLiteral(citySizeEEnum, CitySize.SMALL_LITERAL); + addEEnumLiteral(citySizeEEnum, CitySize.MEDIUM_LITERAL); + addEEnumLiteral(citySizeEEnum, CitySize.LARGE_LITERAL); + // Initialize data types initEDataType(nameEDataType, Name.class, "Name", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); initEDataType(phoneNumberEDataType, UsaPhoneNumber.class, "PhoneNumber", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); initEDataType(intArrayEDataType, int[].class, "IntArray", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(myDoubleTypeEDataType, Double.class, "myDoubleType", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); // Create resource createResource(eNS_URI); @@ -368,7 +467,7 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage source, new String[] { "appinfo", "@NamedQuery(name=\"getPersonByBirthPlace\" query=\"select p from Person p where p.birthPlace=?\")\n@HbEntity(dynamicInsert=true, dynamicUpdate=true, mutable=true, selectBeforeUpdate=true, persister=\"org.hibernate.persister.entity.SingleTableEntityPersister\", optimisticLock=VERSION, polymorphism=EXPLICIT)" - }); + }); } /** @@ -390,13 +489,25 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage source, new String[] { "appinfo", "@OnDelete(action=OnDeleteAction.CASCADE)\n@OneToMany(indexed=false, unique=true)" - }); + }); addAnnotation (intArrayEDataType, source, new String[] { "appinfo", "\n\t\t\t\t\t\t@TypeDef(name=\"intArrayType\" typeClass=\"org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType\", parameters={@Parameter(name=\"epackage\" value=\"http://www.elver.org/samples/emf/hibernate/usertype\"), @Parameter(name=\"edatatype\", value=\"IntArray\")})\n\t\t\t\t\t" + }); + addAnnotation + (myDoubleTypeEDataType, + source, + new String[] { + "appinfo", "\n\t\t\t\t\t\t@Type(type=\"org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType\", parameters={@Parameter(name=\"epackage\" value=\"http://www.elver.org/samples/emf/hibernate/usertype\"), @Parameter(name=\"edatatype\", value=\"myDoubleType\")})\n\t\t\t\t\t" }); + addAnnotation + (getCity_Id(), + source, + new String[] { + "value", "@GeneratedValue(strategy=\"ASSIGNED\")" + }); } /** @@ -435,6 +546,13 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage "name", "intArray" }); addAnnotation + (getPerson_Double(), + source, + new String[] { + "kind", "element", + "name", "intArray" + }); + addAnnotation (intArrayEDataType, source, new String[] { @@ -453,7 +571,13 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage new String[] { "kind", "element", "name", "name" - }); + }); + addAnnotation + (myDoubleTypeEDataType, + source, + new String[] { + "name", "IntArray" + }); } } //UsertypePackageImpl diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/UserType.genmodel b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/UserType.genmodel index 75abee14f..3ee6fb71d 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/UserType.genmodel +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/UserType.genmodel @@ -6,9 +6,15 @@ <foreignModel>usertype.ecore</foreignModel> <genPackages prefix="Usertype" basePackage="org.eclipse.emf.teneo.samples.emf.hibernate" resource="XML" disposableProviderFactory="true" ecorePackage="usertype.ecore#/"> + <genEnums typeSafeEnumCompatible="false" ecoreEnum="usertype.ecore#//CitySize"> + <genEnumLiterals ecoreEnumLiteral="usertype.ecore#//CitySize/SMALL"/> + <genEnumLiterals ecoreEnumLiteral="usertype.ecore#//CitySize/MEDIUM"/> + <genEnumLiterals ecoreEnumLiteral="usertype.ecore#//CitySize/LARGE"/> + </genEnums> <genDataTypes ecoreDataType="usertype.ecore#//Name"/> <genDataTypes ecoreDataType="usertype.ecore#//PhoneNumber"/> <genDataTypes ecoreDataType="usertype.ecore#//IntArray"/> + <genDataTypes ecoreDataType="usertype.ecore#//myDoubleType"/> <genClasses ecoreClass="usertype.ecore#//Person"> <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/name"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/numbers"/> @@ -16,10 +22,15 @@ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/emergencyContact"/> <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference usertype.ecore#//Person/addresses"/> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/birthPlace"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/double"/> </genClasses> <genClasses ecoreClass="usertype.ecore#//Address"> <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Address/addressInfo"/> <genFeatures notify="false" createChild="false" propertySortChoices="true" ecoreFeature="ecore:EReference usertype.ecore#//Address/person"/> </genClasses> + <genClasses ecoreClass="usertype.ecore#//City"> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//City/id"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//City/size"/> + </genClasses> </genPackages> </genmodel:GenModel> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/usertype.ecore b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/usertype.ecore index 1daf1010b..f942b141b 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/usertype.ecore +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/usertype.ecore @@ -48,6 +48,13 @@ </eStructuralFeatures> <eStructuralFeatures xsi:type="ecore:EAttribute" name="birthPlace" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="double" unique="false" + lowerBound="1" eType="#//myDoubleType" defaultValueLiteral="0"> + <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> + <details key="kind" value="element"/> + <details key="name" value="intArray"/> + </eAnnotations> + </eStructuralFeatures> </eClassifiers> <eClassifiers xsi:type="ecore:EDataType" name="PhoneNumber" instanceClassName="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber"/> <eClassifiers xsi:type="ecore:EDataType" name="IntArray" instanceClassName="int[]"> @@ -73,4 +80,27 @@ <eStructuralFeatures xsi:type="ecore:EReference" name="person" eType="#//Person" eOpposite="#//Person/addresses"/> </eClassifiers> + <eClassifiers xsi:type="ecore:EDataType" name="myDoubleType" instanceClassName="java.lang.Double"> + <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> + <details key="name" value="IntArray"/> + </eAnnotations> + <eAnnotations source="teneo.jpa"> + <details key="appinfo" value="
						@Type(type="org.eclipse.emf.teneo.hibernate.mapping.DefaultToStringUserType", parameters={@Parameter(name="epackage" value="http://www.elver.org/samples/emf/hibernate/usertype"), @Parameter(name="edatatype", value="myDoubleType")})
					"/> + </eAnnotations> + </eClassifiers> + <eClassifiers xsi:type="ecore:EClass" name="City"> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong" + defaultValueLiteral="0" iD="true"> + <eAnnotations source="teneo.jpa"> + <details key="value" value="@GeneratedValue(strategy="ASSIGNED")"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="size" eType="#//CitySize" + defaultValueLiteral="MEDIUM" unsettable="true"/> + </eClassifiers> + <eClassifiers xsi:type="ecore:EEnum" name="CitySize"> + <eLiterals name="SMALL"/> + <eLiterals name="MEDIUM" value="1"/> + <eLiterals name="LARGE" value="2"/> + </eClassifiers> </ecore:EPackage> diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeAdapterFactory.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeAdapterFactory.java index b789d9288..fc82d55b3 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeAdapterFactory.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeAdapterFactory.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: UsertypeAdapterFactory.java,v 1.5 2008/03/30 20:54:58 mtaal Exp $ + * $Id: UsertypeAdapterFactory.java,v 1.6 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.util; @@ -76,6 +76,9 @@ public class UsertypeAdapterFactory extends AdapterFactoryImpl { public Object caseAddress(Address object) { return createAddressAdapter(); } + public Object caseCity(City object) { + return createCityAdapter(); + } public Object defaultCase(EObject object) { return createEObjectAdapter(); } @@ -123,6 +126,20 @@ public class UsertypeAdapterFactory extends AdapterFactoryImpl { } /** + * Creates a new adapter for an object of class '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City <em>City</em>}'. + * <!-- begin-user-doc --> + * 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. + * <!-- end-user-doc --> + * @return the new adapter. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.City + * @generated + */ + public Adapter createCityAdapter() { + return null; + } + + /** * Creates a new adapter for the default case. * <!-- begin-user-doc --> * This default implementation returns null. diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeSwitch.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeSwitch.java index e4125a5f0..e7f9e9c81 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeSwitch.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/util/UsertypeSwitch.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: UsertypeSwitch.java,v 1.5 2008/03/30 20:54:58 mtaal Exp $ + * $Id: UsertypeSwitch.java,v 1.6 2009/06/11 04:59:10 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.util; @@ -99,6 +99,12 @@ public class UsertypeSwitch { if (result == null) result = defaultCase(theEObject); return result; } + case UsertypePackage.CITY: { + City city = (City)theEObject; + Object result = caseCity(city); + if (result == null) result = defaultCase(theEObject); + return result; + } default: return defaultCase(theEObject); } } @@ -134,6 +140,21 @@ public class UsertypeSwitch { } /** + * Returns the result of interpreting the object as an instance of '<em>City</em>'. + * <!-- begin-user-doc --> + * This implementation returns null; + * returning a non-null result will terminate the switch. + * <!-- end-user-doc --> + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of '<em>City</em>'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public Object caseCity(City object) { + return null; + } + + /** * Returns the result of interpreting the object as an instance of '<em>EObject</em>'. * <!-- begin-user-doc --> * This implementation returns null; |