diff options
author | mtaal | 2011-03-17 09:21:35 +0000 |
---|---|---|
committer | mtaal | 2011-03-17 09:21:35 +0000 |
commit | 1fbe287ce98c0868c860fd40af39c89961e0c6aa (patch) | |
tree | 40822db5ca71d1c061db7f318a224016ec6a22c6 | |
parent | 1992c50bb410ca71234834d43ac67fa0a8da7a38 (diff) | |
download | org.eclipse.emf.teneo-1fbe287ce98c0868c860fd40af39c89961e0c6aa.tar.gz org.eclipse.emf.teneo-1fbe287ce98c0868c860fd40af39c89961e0c6aa.tar.xz org.eclipse.emf.teneo-1fbe287ce98c0868c860fd40af39c89961e0c6aa.zip |
[321765]
2 files changed, 53 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractMapper.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractMapper.java index 5d370494e..37f536660 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractMapper.java +++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/AbstractMapper.java @@ -3,7 +3,7 @@ * reserved. This program and the accompanying materials are made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal Brian - * Vetter </copyright> $Id: AbstractMapper.java,v 1.54 2011/02/21 06:39:57 mtaal Exp $ + * Vetter </copyright> $Id: AbstractMapper.java,v 1.55 2011/03/17 09:21:35 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapper; @@ -311,6 +311,10 @@ public abstract class AbstractMapper { || (paAttribute.getTemporal() != null && paAttribute .getTemporal().getValue().getValue() == TemporalType.TIMESTAMP_VALUE)) { return getEDateTimeClass(paAttribute); + } else if (EcoreDataTypes.INSTANCE.isETime(eDataType) + || (paAttribute.getTemporal() != null && paAttribute + .getTemporal().getValue().getValue() == TemporalType.TIME_VALUE)) { + return getETimeClass(paAttribute); } else if (EcoreDataTypes.INSTANCE.isEDuration(eDataType)) { return hbmContext.getDurationType(); } else if (EcoreDataTypes.INSTANCE.isEDate(eDataType, getHbmContext() @@ -443,6 +447,44 @@ public abstract class AbstractMapper { } /* + * @return The name of the java class needed to map the time type + */ + public String getETimeClass(PAnnotatedEAttribute paAttribute) { + final EDataType eDataType = paAttribute.getModelEAttribute() + .getEAttributeType(); + + if (XMLTypePackage.eINSTANCE.getTime().equals(eDataType)) { + return getHbmContext().getXSDTimeUserType(); + } + + if (paAttribute.getTemporal() != null) { + final TemporalType tt = paAttribute.getTemporal().getValue(); + return hbType(tt); + } + + // bugzilla 277546 + if (eDataType.getInstanceClass() != null + && Timestamp.class.isAssignableFrom(eDataType + .getInstanceClass())) { + return eDataType.getInstanceClass().getName(); + } + + if (EcoreDataTypes.INSTANCE.isETime(eDataType)) { + // EMF returns an XSD Date type as an Object instance. go figure. + // note that I would prefer to use the class instance to get the + // name + // but for other reasons I do not want to have references to the + // org.eclipse.emf.teneo.hibernate plugin. + return getHbmContext().getXSDTimeUserType(); + } + + // TODO: should it not use the eDataType.getInstanceClass()? Hmm if the + // user + // really wants a different mapping he/she should use maybe a usertype?? + return Timestamp.class.getName(); + } + + /* * @return The name of the java class needed to map the datetime/timestamp * type */ diff --git a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java index 676f1c173..10ace36ac 100644 --- a/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java +++ b/plugins/org.eclipse.emf.teneo.hibernate.mapper/src/org/eclipse/emf/teneo/hibernate/mapper/MappingContext.java @@ -3,7 +3,7 @@ * reserved. This program and the accompanying materials are made available under the terms of the * Eclipse Public License v1.0 which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal - * </copyright> $Id: MappingContext.java,v 1.37 2011/02/21 06:39:57 mtaal Exp $ + * </copyright> $Id: MappingContext.java,v 1.38 2011/03/17 09:21:35 mtaal Exp $ */ package org.eclipse.emf.teneo.hibernate.mapper; @@ -46,7 +46,7 @@ import org.eclipse.emf.teneo.simpledom.Element; * Maps a basic attribute with many=true, e.g. list of simpletypes. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.37 $ + * @version $Revision: 1.38 $ */ public class MappingContext extends AbstractProcessingContext implements ExtensionPoint, ExtensionInitializable, ExtensionManagerAware { @@ -667,6 +667,14 @@ public class MappingContext extends AbstractProcessingContext implements // --- JJH } + /** Returns the usertype used to handle the xsd time */ + public String getXSDTimeUserType() { + // --- JJH + return persistenceOptions.getUserXSDTime(); + // return "org.eclipse.emf.teneo.hibernate.mapping.XSDDateTime"; + // --- JJH + } + /** Returns the usertype used to handle the xsd datetime */ public String getXSDDateTimeUserType() { // --- JJH |