diff options
Diffstat (limited to 'tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate')
9 files changed, 607 insertions, 35 deletions
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 7b5ed8af3..cfcc37258 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,10 +2,12 @@ * <copyright> * </copyright> * - * $Id: Person.java,v 1.3 2006/09/07 08:10:02 mtaal Exp $ + * $Id: Person.java,v 1.4 2006/11/13 14:52:45 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; +import org.eclipse.emf.common.util.EList; + import org.eclipse.emf.ecore.EObject; /** @@ -17,6 +19,9 @@ import org.eclipse.emf.ecore.EObject; * The following features are supported: * <ul> * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getName <em>Name</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getNumbers <em>Numbers</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getPhoneNumbers <em>Phone Numbers</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getEmergencyContact <em>Emergency Contact</em>}</li> * </ul> * </p> * @@ -52,4 +57,74 @@ public interface Person extends EObject { */ void setName(Name value); + /** + * Returns the value of the '<em><b>Numbers</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Numbers</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Numbers</em>' attribute. + * @see #setNumbers(int[]) + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getPerson_Numbers() + * @model unique="false" dataType="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.IntArray" required="true" + * extendedMetaData="kind='element' name='intArray'" + * @generated + */ + int[] getNumbers(); + + /** + * Sets the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getNumbers <em>Numbers</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Numbers</em>' attribute. + * @see #getNumbers() + * @generated + */ + void setNumbers(int[] value); + + /** + * Returns the value of the '<em><b>Phone Numbers</b></em>' attribute list. + * The list contents are of type {@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Phone Numbers</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Phone Numbers</em>' attribute list. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getPerson_PhoneNumbers() + * @model type="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber" dataType="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.PhoneNumber" upper="100" + * @generated + */ + EList getPhoneNumbers(); + + /** + * Returns the value of the '<em><b>Emergency Contact</b></em>' attribute. + * The default value is <code>""</code>. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Emergency Contact</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Emergency Contact</em>' attribute. + * @see #setEmergencyContact(UsaPhoneNumber) + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage#getPerson_EmergencyContact() + * @model default="" dataType="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.PhoneNumber" + * @generated + */ + UsaPhoneNumber getEmergencyContact(); + + /** + * Sets the value of the '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getEmergencyContact <em>Emergency Contact</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Emergency Contact</em>' attribute. + * @see #getEmergencyContact() + * @generated + */ + void setEmergencyContact(UsaPhoneNumber 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/UsaPhoneNumber.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsaPhoneNumber.java new file mode 100644 index 000000000..c453e3339 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/UsaPhoneNumber.java @@ -0,0 +1,50 @@ +package org.eclipse.emf.teneo.samples.emf.hibernate.usertype;
+
+
+/**
+ * Trivial example implementation of a specific type.
+ */
+public class UsaPhoneNumber {
+
+ private int num1;
+ private int num2;
+ private int num3;
+
+ public UsaPhoneNumber(int num1, int num2, int num3) {
+ this.num1 = num1;
+ this.num2 = num2;
+ this.num3 = num3;
+ }
+
+ public UsaPhoneNumber(String numbers) {
+ String[] nums = numbers.split("_");
+ num1 = Integer.parseInt(nums[0]);
+ num2 = Integer.parseInt(nums[1]);
+ num3 = Integer.parseInt(nums[2]);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (!(obj instanceof UsaPhoneNumber)) {
+ return false;
+ }
+ UsaPhoneNumber up = (UsaPhoneNumber)obj;
+ return up.num1 == num1 && up.num2 == num2 && up.num3 == num3;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ return num1 + num2 + num3;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return num1 + "_" + num2 + "_" + num3;
+ }
+}
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 7ad7f95e6..9ae77c6af 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,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: UsertypePackage.java,v 1.6 2006/09/07 22:26:49 mtaal Exp $ + * $Id: UsertypePackage.java,v 1.7 2006/11/13 14:52:45 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype; @@ -79,13 +79,40 @@ public interface UsertypePackage extends EPackage { int PERSON__NAME = 0; /** + * The feature id for the '<em><b>Numbers</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERSON__NUMBERS = 1; + + /** + * The feature id for the '<em><b>Phone Numbers</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERSON__PHONE_NUMBERS = 2; + + /** + * The feature id for the '<em><b>Emergency Contact</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PERSON__EMERGENCY_CONTACT = 3; + + /** * The number of structural features of the '<em>Person</em>' class. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated * @ordered */ - int PERSON_FEATURE_COUNT = 1; + int PERSON_FEATURE_COUNT = 4; /** * The meta object id for the '<em>Name</em>' data type. @@ -99,6 +126,27 @@ public interface UsertypePackage extends EPackage { /** + * The meta object id for the '<em>Phone Number</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getPhoneNumber() + * @generated + */ + int PHONE_NUMBER = 2; + + + /** + * The meta object id for the '<em>Int Array</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getIntArray() + * @generated + */ + int INT_ARRAY = 3; + + + /** * Returns the meta object for class '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person <em>Person</em>}'. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -120,19 +168,75 @@ public interface UsertypePackage extends EPackage { EAttribute getPerson_Name(); /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getNumbers <em>Numbers</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Numbers</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getNumbers() + * @see #getPerson() + * @generated + */ + EAttribute getPerson_Numbers(); + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getPhoneNumbers <em>Phone Numbers</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Phone Numbers</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getPhoneNumbers() + * @see #getPerson() + * @generated + */ + EAttribute getPerson_PhoneNumbers(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getEmergencyContact <em>Emergency Contact</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Emergency Contact</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Person#getEmergencyContact() + * @see #getPerson() + * @generated + */ + EAttribute getPerson_EmergencyContact(); + + /** * 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 --> * @return the meta object for data type '<em>Name</em>'. * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name * @model instanceClass="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name" - * annotation="teneo.jpa appinfo='\n\t\t\t\t\t\t@Type(type=\"org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType\")\n\t\t\t\t\t\t@Columns({@Column(name=\"first_name\"), @Column(name=\"last_name\")})\n\t\t\t\t\t'" + * annotation="teneo.jpa appinfo='\n\t\t\t\t\t\t@TypeDef(name=\"nameType\" typeClass=\"org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType\")\n\t\t\t\t\t\t@Columns({@Column(name=\"first_name\"), @Column(name=\"last_name\")})\n\t\t\t\t\t'" * extendedMetaData="name='Name'" * @generated */ EDataType getName_(); /** + * Returns the meta object for data type '{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber <em>Phone Number</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Phone Number</em>'. + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber + * @model instanceClass="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber" + * @generated + */ + EDataType getPhoneNumber(); + + /** + * Returns the meta object for data type '<em>Int Array</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Int Array</em>'. + * @model instanceClass="int[]" + * extendedMetaData="name='IntArray'" + * annotation="teneo.jpa 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'" + * @generated + */ + EDataType getIntArray(); + + /** * Returns the factory that creates the instances of the model. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -173,6 +277,30 @@ public interface UsertypePackage extends EPackage { EAttribute PERSON__NAME = eINSTANCE.getPerson_Name(); /** + * The meta object literal for the '<em><b>Numbers</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PERSON__NUMBERS = eINSTANCE.getPerson_Numbers(); + + /** + * The meta object literal for the '<em><b>Phone Numbers</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PERSON__PHONE_NUMBERS = eINSTANCE.getPerson_PhoneNumbers(); + + /** + * The meta object literal for the '<em><b>Emergency Contact</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + EAttribute PERSON__EMERGENCY_CONTACT = eINSTANCE.getPerson_EmergencyContact(); + + /** * The meta object literal for the '<em>Name</em>' data type. * <!-- begin-user-doc --> * <!-- end-user-doc --> @@ -182,6 +310,25 @@ public interface UsertypePackage extends EPackage { */ EDataType NAME = eINSTANCE.getName_(); + /** + * The meta object literal for the '<em>Phone Number</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsaPhoneNumber + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getPhoneNumber() + * @generated + */ + EDataType PHONE_NUMBER = eINSTANCE.getPhoneNumber(); + + /** + * The meta object literal for the '<em>Int Array</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.UsertypePackageImpl#getIntArray() + * @generated + */ + EDataType INT_ARRAY = eINSTANCE.getIntArray(); + } } //UsertypePackage 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 2a74d92ae..09c2cced6 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,19 +2,27 @@ * <copyright> * </copyright> * - * $Id: PersonImpl.java,v 1.6 2006/09/07 22:26:49 mtaal Exp $ + * $Id: PersonImpl.java,v 1.7 2006/11/13 14:52:45 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; +import java.util.Collection; + import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; + import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; + 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; +import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypeFactory; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage; /** @@ -25,6 +33,9 @@ import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage; * The following features are implemented: * <ul> * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getName <em>Name</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getNumbers <em>Numbers</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getPhoneNumbers <em>Phone Numbers</em>}</li> + * <li>{@link org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl.PersonImpl#getEmergencyContact <em>Emergency Contact</em>}</li> * </ul> * </p> * @@ -52,6 +63,56 @@ public class PersonImpl extends EObjectImpl implements Person { protected Name name = NAME_EDEFAULT; /** + * The default value of the '{@link #getNumbers() <em>Numbers</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getNumbers() + * @generated + * @ordered + */ + protected static final int[] NUMBERS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNumbers() <em>Numbers</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getNumbers() + * @generated + * @ordered + */ + protected int[] numbers = NUMBERS_EDEFAULT; + + /** + * The cached value of the '{@link #getPhoneNumbers() <em>Phone Numbers</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPhoneNumbers() + * @generated + * @ordered + */ + protected EList phoneNumbers = null; + + /** + * The default value of the '{@link #getEmergencyContact() <em>Emergency Contact</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getEmergencyContact() + * @generatedNOT + * @ordered + */ + protected static final UsaPhoneNumber EMERGENCY_CONTACT_EDEFAULT = (UsaPhoneNumber)UsertypeFactory.eINSTANCE.createFromString(UsertypePackage.eINSTANCE.getPhoneNumber(), "000_000_000"); + + /** + * The cached value of the '{@link #getEmergencyContact() <em>Emergency Contact</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getEmergencyContact() + * @generated + * @ordered + */ + protected UsaPhoneNumber emergencyContact = EMERGENCY_CONTACT_EDEFAULT; + + /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated @@ -95,10 +156,70 @@ public class PersonImpl extends EObjectImpl implements Person { * <!-- end-user-doc --> * @generated */ + public int[] getNumbers() { + return numbers; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setNumbers(int[] newNumbers) { + int[] oldNumbers = numbers; + numbers = newNumbers; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, UsertypePackage.PERSON__NUMBERS, oldNumbers, numbers)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EList getPhoneNumbers() { + if (phoneNumbers == null) { + phoneNumbers = new EDataTypeUniqueEList(UsaPhoneNumber.class, this, UsertypePackage.PERSON__PHONE_NUMBERS); + } + return phoneNumbers; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public UsaPhoneNumber getEmergencyContact() { + return emergencyContact; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setEmergencyContact(UsaPhoneNumber newEmergencyContact) { + UsaPhoneNumber oldEmergencyContact = emergencyContact; + emergencyContact = newEmergencyContact; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, UsertypePackage.PERSON__EMERGENCY_CONTACT, oldEmergencyContact, emergencyContact)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case UsertypePackage.PERSON__NAME: return getName(); + case UsertypePackage.PERSON__NUMBERS: + return getNumbers(); + case UsertypePackage.PERSON__PHONE_NUMBERS: + return getPhoneNumbers(); + case UsertypePackage.PERSON__EMERGENCY_CONTACT: + return getEmergencyContact(); } return super.eGet(featureID, resolve, coreType); } @@ -113,6 +234,16 @@ public class PersonImpl extends EObjectImpl implements Person { case UsertypePackage.PERSON__NAME: setName((Name)newValue); return; + case UsertypePackage.PERSON__NUMBERS: + setNumbers((int[])newValue); + return; + case UsertypePackage.PERSON__PHONE_NUMBERS: + getPhoneNumbers().clear(); + getPhoneNumbers().addAll((Collection)newValue); + return; + case UsertypePackage.PERSON__EMERGENCY_CONTACT: + setEmergencyContact((UsaPhoneNumber)newValue); + return; } super.eSet(featureID, newValue); } @@ -127,6 +258,15 @@ public class PersonImpl extends EObjectImpl implements Person { case UsertypePackage.PERSON__NAME: setName(NAME_EDEFAULT); return; + case UsertypePackage.PERSON__NUMBERS: + setNumbers(NUMBERS_EDEFAULT); + return; + case UsertypePackage.PERSON__PHONE_NUMBERS: + getPhoneNumbers().clear(); + return; + case UsertypePackage.PERSON__EMERGENCY_CONTACT: + setEmergencyContact(EMERGENCY_CONTACT_EDEFAULT); + return; } super.eUnset(featureID); } @@ -140,6 +280,12 @@ public class PersonImpl extends EObjectImpl implements Person { switch (featureID) { case UsertypePackage.PERSON__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case UsertypePackage.PERSON__NUMBERS: + return NUMBERS_EDEFAULT == null ? numbers != null : !NUMBERS_EDEFAULT.equals(numbers); + case UsertypePackage.PERSON__PHONE_NUMBERS: + return phoneNumbers != null && !phoneNumbers.isEmpty(); + case UsertypePackage.PERSON__EMERGENCY_CONTACT: + return EMERGENCY_CONTACT_EDEFAULT == null ? emergencyContact != null : !EMERGENCY_CONTACT_EDEFAULT.equals(emergencyContact); } return super.eIsSet(featureID); } @@ -155,6 +301,12 @@ public class PersonImpl extends EObjectImpl implements Person { StringBuffer result = new StringBuffer(super.toString()); result.append(" (name: "); result.append(name); + result.append(", numbers: "); + result.append(numbers); + result.append(", phoneNumbers: "); + result.append(phoneNumbers); + result.append(", emergencyContact: "); + result.append(emergencyContact); 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 1f8a4a750..1ad77c1ec 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.4 2006/09/07 08:18:01 mtaal Exp $ + * $Id: UsertypeFactoryImpl.java,v 1.5 2006/11/13 14:52:45 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; @@ -75,6 +75,10 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory switch (eDataType.getClassifierID()) { case UsertypePackage.NAME: return createNameFromString(eDataType, initialValue); + case UsertypePackage.PHONE_NUMBER: + return createPhoneNumberFromString(eDataType, initialValue); + case UsertypePackage.INT_ARRAY: + return createIntArrayFromString(eDataType, initialValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -89,6 +93,10 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory switch (eDataType.getClassifierID()) { case UsertypePackage.NAME: return convertNameToString(eDataType, instanceValue); + case UsertypePackage.PHONE_NUMBER: + return convertPhoneNumberToString(eDataType, instanceValue); + case UsertypePackage.INT_ARRAY: + return convertIntArrayToString(eDataType, instanceValue); default: throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); } @@ -127,6 +135,54 @@ public class UsertypeFactoryImpl extends EFactoryImpl implements UsertypeFactory * <!-- end-user-doc --> * @generated */ + public UsaPhoneNumber createPhoneNumberFromString(EDataType eDataType, String initialValue) { + return (UsaPhoneNumber)super.createFromString(eDataType, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertPhoneNumberToString(EDataType eDataType, Object instanceValue) { + return super.convertToString(eDataType, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generatedNOT + */ + public int[] createIntArrayFromString(EDataType eDataType, String initialValue) { + if (initialValue == null) return null; + final String[] vals = initialValue.split("_"); + final int[] result = new int[vals.length]; + for (int i = 0; i < vals.length; i++) { + result[i] = Integer.parseInt(vals[i]); + } + return result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generatedNOT + */ + public String convertIntArrayToString(EDataType eDataType, Object instanceValue) { + final int[] vals = (int[])instanceValue; + final StringBuffer result = new StringBuffer(); + for (int i = 0; i < vals.length; i++) { + if (i > 0) result.append("_"); + result.append(vals[i] + ""); + } + return result.toString(); + } + + /** + * <!-- 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 ceaabe7ac..7dfa1e0a4 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,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: UsertypePackageImpl.java,v 1.6 2006/09/07 22:26:49 mtaal Exp $ + * $Id: UsertypePackageImpl.java,v 1.7 2006/11/13 14:52:45 mtaal Exp $ */ package org.eclipse.emf.teneo.samples.emf.hibernate.usertype.impl; @@ -15,6 +15,7 @@ import org.eclipse.emf.ecore.impl.EPackageImpl; 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; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypeFactory; import org.eclipse.emf.teneo.samples.emf.hibernate.usertype.UsertypePackage; @@ -40,6 +41,20 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage private EDataType nameEDataType = null; /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType phoneNumberEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType intArrayEDataType = 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. @@ -130,6 +145,33 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage * <!-- end-user-doc --> * @generated */ + public EAttribute getPerson_Numbers() { + return (EAttribute)personEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getPerson_PhoneNumbers() { + return (EAttribute)personEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getPerson_EmergencyContact() { + return (EAttribute)personEClass.getEStructuralFeatures().get(3); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public EDataType getName_() { return nameEDataType; } @@ -139,6 +181,24 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage * <!-- end-user-doc --> * @generated */ + public EDataType getPhoneNumber() { + return phoneNumberEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getIntArray() { + return intArrayEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ public UsertypeFactory getUsertypeFactory() { return (UsertypeFactory)getEFactoryInstance(); } @@ -164,9 +224,14 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage // Create classes and their features personEClass = createEClass(PERSON); createEAttribute(personEClass, PERSON__NAME); + createEAttribute(personEClass, PERSON__NUMBERS); + createEAttribute(personEClass, PERSON__PHONE_NUMBERS); + createEAttribute(personEClass, PERSON__EMERGENCY_CONTACT); // Create data types nameEDataType = createEDataType(NAME); + phoneNumberEDataType = createEDataType(PHONE_NUMBER); + intArrayEDataType = createEDataType(INT_ARRAY); } /** @@ -197,9 +262,14 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage // Initialize classes and features; add operations and parameters initEClass(personEClass, Person.class, "Person", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); initEAttribute(getPerson_Name(), this.getName_(), "name", null, 1, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPerson_Numbers(), this.getIntArray(), "numbers", null, 1, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPerson_PhoneNumbers(), this.getPhoneNumber(), "phoneNumbers", null, 0, 100, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + 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); // 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); // Create resource createResource(eNS_URI); @@ -223,8 +293,14 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage (nameEDataType, source, new String[] { - "appinfo", "\n\t\t\t\t\t\t@Type(type=\"org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType\")\n\t\t\t\t\t\t@Columns({@Column(name=\"first_name\"), @Column(name=\"last_name\")})\n\t\t\t\t\t" - }); + "appinfo", "\n\t\t\t\t\t\t@TypeDef(name=\"nameType\" typeClass=\"org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType\")\n\t\t\t\t\t\t@Columns({@Column(name=\"first_name\"), @Column(name=\"last_name\")})\n\t\t\t\t\t" + }); + 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" + }); } /** @@ -254,7 +330,20 @@ public class UsertypePackageImpl extends EPackageImpl implements UsertypePackage new String[] { "kind", "element", "name", "name" - }); + }); + addAnnotation + (getPerson_Numbers(), + source, + new String[] { + "kind", "element", + "name", "intArray" + }); + addAnnotation + (intArrayEDataType, + 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 30f84fcbb..82f7612e2 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 @@ -2,13 +2,18 @@ <genmodel:GenModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.teneo.hibernate.test/src" - modelPluginID="org.eclipse.emf.teneo.hibernate.test" modelName="UserType" importerID="org.eclipse.xsd.ecore.importer"> - <foreignModel>UserType.xsd</foreignModel> + modelPluginID="org.eclipse.emf.teneo.hibernate.test" modelName="UserType" importerID="org.eclipse.emf.importer.ecore"> + <foreignModel>usertype.ecore</foreignModel> <genPackages prefix="Usertype" basePackage="org.eclipse.emf.teneo.samples.emf.hibernate" resource="XML" disposableProviderFactory="true" ecorePackage="usertype.ecore#/"> <genDataTypes ecoreDataType="usertype.ecore#//Name"/> + <genDataTypes ecoreDataType="usertype.ecore#//PhoneNumber"/> + <genDataTypes ecoreDataType="usertype.ecore#//IntArray"/> <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"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/phoneNumbers"/> + <genFeatures createChild="false" ecoreFeature="ecore:EAttribute usertype.ecore#//Person/emergencyContact"/> </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.xsd b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/UserType.xsd deleted file mode 100644 index c53c91a5b..000000000 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/UserType.xsd +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.elver.org/samples/emf/hibernate/usertype"
- xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:this="http://www.elver.org/samples/emf/hibernate/usertype">
-
- <xsd:simpleType name="Name" ecore:instanceClass="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name">
- <xsd:annotation>
- <xsd:appinfo source="teneo.jpa"> - @Type(type="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType") - @Columns({@Column(name="first_name"), @Column(name="last_name")}) - </xsd:appinfo>
- </xsd:annotation>
- <xsd:restriction/>
- </xsd:simpleType>
-
- <xsd:complexType name="Person">
- <xsd:sequence>
- <xsd:element name="name" type="this:Name">
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
-
-</xsd:schema>
\ 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/model/usertype.ecore b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/samples/emf/hibernate/usertype/model/usertype.ecore index 75e8b81d2..35657d061 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 @@ -5,7 +5,7 @@ nsURI="http://www.elver.org/samples/emf/hibernate/usertype" nsPrefix="usertype"> <eClassifiers xsi:type="ecore:EDataType" name="Name" instanceClassName="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.Name"> <eAnnotations source="teneo.jpa"> - <details key="appinfo" value="
						@Type(type="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType")
						@Columns({@Column(name="first_name"), @Column(name="last_name")})
					"/> + <details key="appinfo" value="
						@TypeDef(name="nameType" typeClass="org.eclipse.emf.teneo.samples.emf.hibernate.usertype.NameType")
						@Columns({@Column(name="first_name"), @Column(name="last_name")})
					"/> </eAnnotations> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> <details key="name" value="Name"/> @@ -23,5 +23,25 @@ <details key="name" value="name"/> </eAnnotations> </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="numbers" unique="false" + lowerBound="1" eType="#//IntArray"> + <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> + <details key="kind" value="element"/> + <details key="name" value="intArray"/> + </eAnnotations> + </eStructuralFeatures> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="phoneNumbers" upperBound="100" + eType="#//PhoneNumber"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="emergencyContact" eType="#//PhoneNumber" + defaultValueLiteral=""/> + </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[]"> + <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> + <details key="name" value="IntArray"/> + </eAnnotations> + <eAnnotations source="teneo.jpa"> + <details key="appinfo" value="
						@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")})
					"/> + </eAnnotations> </eClassifiers> </ecore:EPackage> |