Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3723123d2897bbf4ea31cee73cba3a5699cae76e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Copyright (c) 2010-2012, 2015 Eike Stepper (Loehne, Germany) and others.
 * All rights 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 - initial API and implementation
 *    Eike Stepper - maintenance
 */
package org.eclipse.emf.cdo.server.hibernate.teneo;

import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.teneo.annotations.pamodel.PAnnotatedEAttribute;
import org.eclipse.emf.teneo.hibernate.mapper.BasicMapper;
import org.eclipse.emf.teneo.hibernate.mapper.HbMapperConstants;
import org.eclipse.emf.teneo.simpledom.Element;

/**
 * Extends enum mapping with parameters for epackage and eclass. This will be solved in the next build of Teneo.
 *
 * @author <a href="mtaal@elver.org">Martin Taal</a>
 * @since 3.0
 */
public class CDOBasicMapper extends BasicMapper
{
  public CDOBasicMapper()
  {
  }

  @Override
  protected void setType(PAnnotatedEAttribute paAttribute, Element propElement)
  {
    super.setType(paAttribute, propElement);
    if (paAttribute.getEnumerated() != null)
    {
      final Element typeElement = propElement.element("type"); //$NON-NLS-1$
      for (Element element : typeElement.getChildren())
      {
        if (element.getName().equals(HbMapperConstants.ECLASSIFIER_PARAM))
        {
          // it has been done already
          return;
        }
      }

      // add the type elements
      final EAttribute eAttribute = paAttribute.getModelEAttribute();
      typeElement.addElement("param").addAttribute("name", HbMapperConstants.ECLASSIFIER_PARAM).addText( //$NON-NLS-1$ //$NON-NLS-2$
          eAttribute.getEAttributeType().getName());
      typeElement.addElement("param").addAttribute("name", HbMapperConstants.EPACKAGE_PARAM).addText( //$NON-NLS-1$//$NON-NLS-2$
          eAttribute.getEAttributeType().getEPackage().getNsURI());
    }
  }
}

Back to the top