blob: ea8a5dab5c2abc220b9aceaf1febac7fee6ffdea (
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
|
/***************************************************************************
* Copyright (c) 2004 - 2008 Eike Stepper, Germany.
* 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:
* Eike Stepper - initial API and implementation
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
import org.eclipse.emf.cdo.internal.protocol.model.InternalCDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.server.db.IClassMapping;
import org.eclipse.net4j.util.ImplementationError;
/**
* @author Eike Stepper
*/
public final class ClassServerInfo extends ServerInfo
{
public static final int CDO_OBJECT_CLASS_DBID = -1;
public static final int CDO_RESOURCE_CLASS_DBID = -2;
private IClassMapping classMapping;
private ClassServerInfo(int id)
{
super(id);
}
public static ClassServerInfo setDBID(CDOClass cdoClass, int id)
{
ClassServerInfo serverInfo = new ClassServerInfo(id);
((InternalCDOClass)cdoClass).setServerInfo(serverInfo);
return serverInfo;
}
/**
* Should only be called from {@link MappingStrategy#getClassMapping(CDOClass)}.
*/
public static IClassMapping getClassMapping(CDOClass cdoClass)
{
ClassServerInfo serverInfo = getServerInfo(cdoClass);
return serverInfo == null ? null : serverInfo.classMapping;
}
public static void setClassMapping(CDOClass cdoClass, IClassMapping classMapping)
{
ClassServerInfo serverInfo = getServerInfo(cdoClass);
if (serverInfo == null)
{
throw new ImplementationError("No serverInfo for class " + cdoClass);
}
serverInfo.classMapping = classMapping;
}
protected static ClassServerInfo getServerInfo(CDOClass cdoClass)
{
ClassServerInfo serverInfo = (ClassServerInfo)cdoClass.getServerInfo();
if (serverInfo == null)
{
if (cdoClass.isRoot())
{
serverInfo = setDBID(cdoClass, CDO_OBJECT_CLASS_DBID);
}
else if (cdoClass.isResource())
{
serverInfo = setDBID(cdoClass, CDO_RESOURCE_CLASS_DBID);
}
}
return serverInfo;
}
}
|