Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: eddcfefdf20c10da0a52285dc3d7531dcbb5ae9a (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
 * Copyright (c) 2008-2012, 2015 Eike Stepper (Berlin, 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 - copied from CDORevisionPropertyHandler and adapted
 *    Eike Stepper - maintenance
 */
package org.eclipse.emf.cdo.server.internal.hibernate.tuplizer;

import org.eclipse.emf.cdo.server.internal.hibernate.bundle.OM;

import org.eclipse.net4j.util.om.trace.ContextTracer;

import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.teneo.PersistenceOptions;

/**
 * @author Martin Taal
 */
public abstract class CDOPropertyHandler
{
  private final ContextTracer tracer = new ContextTracer(OM.DEBUG, this.getClass());

  private CDORevisionTuplizer tuplizer;

  private EStructuralFeature feature;

  private boolean virtualProperty;

  private PersistenceOptions persistenceOptions;

  public CDOPropertyHandler(CDORevisionTuplizer tuplizer, String propertyName)
  {
    this.tuplizer = tuplizer;
    feature = tuplizer.getEClass().getEStructuralFeature(propertyName);
    if (getTracer().isEnabled())
    {
      getTracer()
          .trace("Created " + this.getClass().getName() + " for eClass/feature: " + tuplizer.getEClass().getName() + "." //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
              + propertyName);
    }

    if (feature == null)
    {
      if (isVirtualPropertyAllowed())
      {
        virtualProperty = true;
        if (getTracer().isEnabled())
        {
          getTracer().trace("This is a virtual property"); //$NON-NLS-1$
        }
      }
      else
      {
        throw new IllegalStateException("Feature not found: " + propertyName); //$NON-NLS-1$
      }
    }
  }

  protected ContextTracer getTracer()
  {
    return tracer;
  }

  public CDORevisionTuplizer getTuplizer()
  {
    return tuplizer;
  }

  public EStructuralFeature getEStructuralFeature()
  {
    return feature;
  }

  protected boolean isVirtualPropertyAllowed()
  {
    return false;
  }

  /**
   * @return the virtualProperty
   */
  public boolean isVirtualProperty()
  {
    return virtualProperty;
  }

  public PersistenceOptions getPersistenceOptions()
  {
    return persistenceOptions;
  }

  public void setPersistenceOptions(PersistenceOptions persistenceOptions)
  {
    this.persistenceOptions = persistenceOptions;
  }
}

Back to the top