kmoore | 5231fb9 | 2011-02-06 02:13:04 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2008, 2009 Oracle. All rights reserved. |
| 3 | * This program and the accompanying materials are made available under the |
| 4 | * terms of the Eclipse Public License v1.0, which accompanies this distribution |
| 5 | * and is available at http://www.eclipse.org/legal/epl-v10.html. |
| 6 | * |
| 7 | * Contributors: |
| 8 | * Oracle - initial API and implementation |
| 9 | ******************************************************************************/ |
| 10 | package org.eclipse.jpt.jpa.eclipselink.core.internal.context.orm; |
| 11 | |
| 12 | import org.eclipse.emf.ecore.EFactory; |
| 13 | import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMapping; |
| 14 | import org.eclipse.jpt.jpa.core.context.orm.OrmAttributeMappingDefinition; |
| 15 | import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentAttribute; |
| 16 | import org.eclipse.jpt.jpa.core.context.orm.OrmXmlContextNodeFactory; |
| 17 | import org.eclipse.jpt.jpa.core.resource.orm.XmlAttributeMapping; |
| 18 | import org.eclipse.jpt.jpa.core.resource.xml.EmfTools; |
| 19 | import org.eclipse.jpt.jpa.eclipselink.core.EclipseLinkMappingKeys; |
| 20 | import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.EclipseLinkOrmPackage; |
| 21 | import org.eclipse.jpt.jpa.eclipselink.core.resource.orm.XmlBasicMap; |
| 22 | |
| 23 | public class OrmEclipseLinkBasicMapMappingDefinition |
| 24 | implements OrmAttributeMappingDefinition |
| 25 | { |
| 26 | // singleton |
| 27 | private static final OrmEclipseLinkBasicMapMappingDefinition INSTANCE = |
| 28 | new OrmEclipseLinkBasicMapMappingDefinition(); |
| 29 | |
| 30 | |
| 31 | /** |
| 32 | * Return the singleton |
| 33 | */ |
| 34 | public static OrmAttributeMappingDefinition instance() { |
| 35 | return INSTANCE; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Ensforce singleton usage |
| 41 | */ |
| 42 | private OrmEclipseLinkBasicMapMappingDefinition() { |
| 43 | super(); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | public String getKey() { |
| 48 | return EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY; |
| 49 | } |
| 50 | |
| 51 | public XmlAttributeMapping buildResourceMapping(EFactory factory) { |
| 52 | return EmfTools.create( |
| 53 | factory, |
| 54 | EclipseLinkOrmPackage.eINSTANCE.getXmlBasicMap(), |
| 55 | XmlBasicMap.class); |
| 56 | } |
| 57 | |
| 58 | public OrmAttributeMapping buildContextMapping( |
| 59 | OrmPersistentAttribute parent, |
| 60 | XmlAttributeMapping resourceMapping, |
| 61 | OrmXmlContextNodeFactory factory) { |
| 62 | return ((EclipseLinkOrmXmlContextNodeFactory) factory). |
| 63 | buildOrmEclipseLinkBasicMapMapping(parent, (XmlBasicMap) resourceMapping); |
| 64 | } |
| 65 | } |