Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 89ad3124391241bfe3b6f7d395a2736ac80caf38 (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright (c) 2010-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:
 *    Simon McDuff - initial API and implementation
 *    Ibrahim Sallam - code refactoring for CDO 3.0
 */
package org.eclipse.emf.cdo.server.internal.objectivity.mapper;

import org.eclipse.emf.cdo.server.internal.objectivity.db.ObjyObject;

import org.eclipse.emf.ecore.EStructuralFeature;

import com.objy.as.app.Class_Object;
import com.objy.as.app.Proposed_Class;
import com.objy.as.app.d_Attribute;

import java.util.ArrayList;

// TODO - verify the need for this, and perhaps extend the implementation to the
//        colletion of mappers.
public class MultipleTypeMapper extends BasicTypeMapper implements IManyTypeMapper
{
  ArrayList<IManyTypeMapper> mapperList = new ArrayList<IManyTypeMapper>();

  public void add(IManyTypeMapper attributeBridge)
  {
    mapperList.add(attributeBridge);
  }

  // @Override
  public boolean createSchema(Proposed_Class proposedClasses, EStructuralFeature feature)
  {
    boolean result = true;
    for (IManyTypeMapper manyMapper : mapperList)
    {
      result &= manyMapper.createSchema(proposedClasses, feature);
    }
    return result;
  }

  // @Override
  public Object getValue(ObjyObject class_Object, EStructuralFeature feature, int index)
  {
    return mapperList.get(0).getValue(class_Object, feature, index);
  }

  // @Override
  public void initialize(Class_Object class_Object, EStructuralFeature feature)
  {
    for (ITypeMapper manyMapper : mapperList)
    {
      manyMapper.initialize(class_Object, feature);
    }
  }

  // @Override
  public void modifySchema(Proposed_Class proposedooClass, EStructuralFeature feature)
  {
    for (IManyTypeMapper manyMapper : mapperList)
    {
      manyMapper.modifySchema(proposedooClass, feature);
    }
  }

  // @Override
  public void setValue(ObjyObject class_Object, EStructuralFeature feature, int index, Object newValue)
  {
    mapperList.get(0).setValue(class_Object, feature, index, newValue);
  }

  // @Override
  public boolean validate(d_Attribute ooAttribute, EStructuralFeature feature)
  {

    boolean result = true;
    for (ITypeMapper manyMapper : mapperList)
    {
      result &= manyMapper.validate(ooAttribute, feature);
    }
    return result;

  }

  // @Override
  public void add(ObjyObject classObject, EStructuralFeature feature, int index, Object value)
  {
    for (IManyTypeMapper manyMapper : mapperList)
    {
      manyMapper.add(classObject, feature, index, value);
    }

  }

  public void addAll(ObjyObject classObject, EStructuralFeature feature, int index, Object[] value)
  {
    for (IManyTypeMapper manyMapper : mapperList)
    {
      manyMapper.addAll(classObject, feature, index, value);
    }
  }

  // @Override
  public int size(ObjyObject classObject, EStructuralFeature feature)
  {
    // TODO Auto-generated method stub
    return mapperList.get(0).size(classObject, feature);
  }

  // @Override
  public void clear(ObjyObject classObject, EStructuralFeature feature)
  {
    for (IManyTypeMapper manyMapper : mapperList)
    {
      manyMapper.clear(classObject, feature);
    }

  }

  // @Override
  public Object remove(ObjyObject objyObject, EStructuralFeature feature, int index)
  {
    Object returnValue = null;
    int i = 0;
    for (IManyTypeMapper manyMapper : mapperList)
    {
      Object object = manyMapper.remove(objyObject, feature, index);
      if (i == 0)
      {
        returnValue = object;
      }
    }
    return returnValue;
  }

  public void delete(ObjyObject objyObject, EStructuralFeature feature)
  {
  }

  public Object[] getAll(ObjyObject objyObject, EStructuralFeature feature, int index, int chunkSize)
  {
    return mapperList.get(0).getAll(objyObject, feature, index, chunkSize);
  }

  public void setAll(ObjyObject objyObject, EStructuralFeature feature, int index, Object[] newValues)
  {
    mapperList.get(0).setAll(objyObject, feature, index, newValues);
  }

  public void move(ObjyObject objyObject, EStructuralFeature feature, int targetIndex, int sourceIndex)
  {
    mapperList.get(0).move(objyObject, feature, targetIndex, sourceIndex);
  }

}

Back to the top