summaryrefslogtreecommitdiffstats
blob: 7b0ceef1c9209df89ed8fdc52befc4d4a3f6c740 (plain)
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/***************************************************************************
 * Copyright (c) 2004, 2005, 2006 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.impl;


public interface SQLConstants
{
  //--------------------------------------------------------------------
  public static final String SYSTEM_TABLE = "CDO_SYSTEM";

  public static final String SYSTEM_SID_COLUMN = "SID";

  public static final String SYSTEM_STARTED_COLUMN = "STARTED";

  //--------------------------------------------------------------------
  public static final String PACKAGE_TABLE = "CDO_PACKAGE";

  public static final String PACKAGE_PID_COLUMN = "PID";

  public static final String PACKAGE_NAME_COLUMN = "NAME";

  //--------------------------------------------------------------------
  public static final String CLASS_TABLE = "CDO_CLASS";

  public static final String CLASS_CID_COLUMN = "CID";

  public static final String CLASS_NAME_COLUMN = "NAME";

  public static final String CLASS_PARENTNAME_COLUMN = "PARENT" + CLASS_NAME_COLUMN;

  public static final String CLASS_TABLENAME_COLUMN = "TABLENAME";

  public static final String CLASS_PID_COLUMN = PACKAGE_PID_COLUMN;

  //--------------------------------------------------------------------
  public static final String ATTRIBUTE_TABLE = "CDO_ATTRIBUTE";

  public static final String ATTRIBUTE_NAME_COLUMN = "NAME";

  public static final String ATTRIBUTE_FEATUREID_COLUMN = "FEATUREID";

  public static final String ATTRIBUTE_DATATYPE_COLUMN = "DATATYPE";

  public static final String ATTRIBUTE_COLUMNNAME_COLUMN = "COLUMNNAME";

  public static final String ATTRIBUTE_COLUMNTYPE_COLUMN = "COLUMNTYPE";

  public static final String ATTRIBUTE_CID_COLUMN = CLASS_CID_COLUMN;

  //--------------------------------------------------------------------
  public static final String OBJECT_TABLE = "CDO_OBJECT";

  public static final String OBJECT_OID_COLUMN = "OID";

  public static final String OBJECT_OCA_COLUMN = "OCA";

  public static final String OBJECT_CID_COLUMN = CLASS_CID_COLUMN;

  //--------------------------------------------------------------------
  public static final String RESOURCE_TABLE = "CDO_RESOURCE";

  public static final String RESOURCE_RID_COLUMN = "RID";

  public static final String RESOURCE_PATH_COLUMN = "PATH";

  //--------------------------------------------------------------------
  public static final String CONTENT_TABLE = "CDO_CONTENT";

  public static final String CONTENT_OID_COLUMN = OBJECT_OID_COLUMN;

  //--------------------------------------------------------------------
  public static final String REFERENCE_TABLE = "CDO_REFERENCE";

  public static final String REFERENCE_OID_COLUMN = "SOURCE" + OBJECT_OID_COLUMN;

  public static final String REFERENCE_FEATUREID_COLUMN = "FEATUREID";

  public static final String REFERENCE_CONTENT_COLUMN = "CONTENT";

  public static final String REFERENCE_ORDINAL_COLUMN = "ORDINAL";

  public static final String REFERENCE_TARGET_COLUMN = "TARGET" + OBJECT_OID_COLUMN;

  //--------------------------------------------------------------------
  public static final String USER_OID_COLUMN = "CDO_" + OBJECT_OID_COLUMN;

  //--------------------------------------------------------------------
  public static final String SELECT_PACKAGES = "SELECT " + PACKAGE_PID_COLUMN + ", "
      + PACKAGE_NAME_COLUMN + " FROM " + PACKAGE_TABLE;

  public static final String SELECT_CLASSES = "SELECT " + CLASS_CID_COLUMN + ", "
      + CLASS_NAME_COLUMN + ", " + CLASS_PARENTNAME_COLUMN + ", " + CLASS_TABLENAME_COLUMN
      + " FROM " + CLASS_TABLE + " WHERE " + CLASS_PID_COLUMN + "=?";

  public static final String SELECT_ATTRIBUTES = "SELECT " + ATTRIBUTE_NAME_COLUMN + ", "
      + ATTRIBUTE_FEATUREID_COLUMN + ", " + ATTRIBUTE_DATATYPE_COLUMN + ", "
      + ATTRIBUTE_COLUMNNAME_COLUMN + ", " + ATTRIBUTE_COLUMNTYPE_COLUMN + " FROM "
      + ATTRIBUTE_TABLE + " WHERE " + ATTRIBUTE_CID_COLUMN + "=?";

  public static final String INSERT_PACKAGE = "INSERT INTO " + PACKAGE_TABLE + " VALUES (?, ?)";

  public static final String INSERT_CLASS = "INSERT INTO " + CLASS_TABLE
      + " VALUES (?, ?, ?, ?, ?)";

  public static final String INSERT_ATTRIBUTE = "INSERT INTO " + ATTRIBUTE_TABLE
      + " VALUES (?, ?, ?, ?, ?, ?)";

  public static final String SELECT_MAX_PID = "SELECT MAX(" + PACKAGE_PID_COLUMN + ") FROM "
      + PACKAGE_TABLE;

  public static final String SELECT_MAX_CID = "SELECT MAX(" + CLASS_CID_COLUMN + ") FROM "
      + CLASS_TABLE;

  public static final String SELECT_MAX_RID = "SELECT MAX(" + RESOURCE_RID_COLUMN + ") FROM "
      + RESOURCE_TABLE;

  public static final String SELECT_MAX_OID_FRAGMENT = "SELECT MAX(" + OBJECT_OID_COLUMN
      + ") FROM " + OBJECT_TABLE + " WHERE " + OBJECT_OID_COLUMN + " BETWEEN ? AND ?";

  public static final String SELECT_CID_OF_OBJECT = "SELECT " + OBJECT_CID_COLUMN + " FROM "
      + OBJECT_TABLE + " WHERE " + OBJECT_OID_COLUMN + "=?";

  public static final String SELECT_CONTAINER_OF_OBJECT = "SELECT " + REFERENCE_TABLE + "."
      + REFERENCE_OID_COLUMN + ", " + OBJECT_TABLE + "." + OBJECT_CID_COLUMN + " FROM "
      + REFERENCE_TABLE + ", " + OBJECT_TABLE + " WHERE " + REFERENCE_TABLE + "."
      + REFERENCE_TARGET_COLUMN + "=? AND " + REFERENCE_TABLE + "." + REFERENCE_CONTENT_COLUMN
      + "=? AND " + REFERENCE_TABLE + "." + REFERENCE_OID_COLUMN + "=" + OBJECT_TABLE + "."
      + OBJECT_OID_COLUMN;

  public static final String SELECT_XREFS_OF_OBJECT = "SELECT " + REFERENCE_TABLE + "."
      + REFERENCE_OID_COLUMN + ", " + REFERENCE_TABLE + "." + REFERENCE_FEATUREID_COLUMN + ", "
      + OBJECT_TABLE + "." + OBJECT_CID_COLUMN + " FROM " + REFERENCE_TABLE + ", " + OBJECT_TABLE
      + " WHERE " + REFERENCE_TABLE + "." + REFERENCE_TARGET_COLUMN + "=? AND " + REFERENCE_TABLE
      + "." + REFERENCE_CONTENT_COLUMN + "=FALSE AND " + REFERENCE_TABLE + "."
      + REFERENCE_OID_COLUMN + "=" + OBJECT_TABLE + "." + OBJECT_OID_COLUMN;

  public static final String SELECT_ALL_RESOURCES = "SELECT " + RESOURCE_RID_COLUMN + ", "
      + RESOURCE_PATH_COLUMN + " FROM " + RESOURCE_TABLE;

  public static final String SELECT_RID_OF_RESOURCE = "SELECT " + RESOURCE_RID_COLUMN + " FROM "
      + RESOURCE_TABLE + " WHERE " + RESOURCE_PATH_COLUMN + "=?";

  public static final String SELECT_PATH_OF_RESOURCE = "SELECT " + RESOURCE_PATH_COLUMN + " FROM "
      + RESOURCE_TABLE + " WHERE " + RESOURCE_RID_COLUMN + "=?";

  public static final String SELECT_COLLECTION_COUNT = "SELECT COUNT(" + REFERENCE_OID_COLUMN
      + ") FROM " + REFERENCE_TABLE + " WHERE " + REFERENCE_OID_COLUMN + "=? AND "
      + REFERENCE_FEATUREID_COLUMN + "=?";

  public static final String INSERT_RESOURCE = "INSERT INTO " + RESOURCE_TABLE + " VALUES (?, ?)";

  public static final String INSERT_REFERENCE = "INSERT INTO " + REFERENCE_TABLE
      + " VALUES (?, ?, ?, ?, ?)";

  public static final String REMOVE_REFERENCES = "DELETE FROM " + REFERENCE_TABLE + " WHERE "
      + REFERENCE_OID_COLUMN + "=?";

  public static final String REMOVE_REFERENCE = "DELETE FROM " + REFERENCE_TABLE + " WHERE "
      + REFERENCE_OID_COLUMN + "=? AND " + REFERENCE_FEATUREID_COLUMN + "=? AND "
      + REFERENCE_ORDINAL_COLUMN + "=?";

  public static final String MOVE_REFERENCE_ABSOLUTE = "UPDATE " + REFERENCE_TABLE + " SET "
      + REFERENCE_ORDINAL_COLUMN + "=? WHERE " + REFERENCE_OID_COLUMN + "=? AND "
      + REFERENCE_FEATUREID_COLUMN + "=? AND " + REFERENCE_ORDINAL_COLUMN + "=?";

  public static final String MOVE_REFERENCES_RELATIVE = "UPDATE " + REFERENCE_TABLE + " SET "
      + REFERENCE_ORDINAL_COLUMN + "=" + REFERENCE_ORDINAL_COLUMN + "+? WHERE "
      + REFERENCE_OID_COLUMN + "=? AND " + REFERENCE_FEATUREID_COLUMN + "=? AND "
      + REFERENCE_ORDINAL_COLUMN + " BETWEEN ? AND ?";

  public static final String TRANSMIT_REFERENCES = "SELECT "
      + (REFERENCE_TABLE + "." + REFERENCE_FEATUREID_COLUMN) + ", "
      + (REFERENCE_TABLE + "." + REFERENCE_TARGET_COLUMN) + ", "
      + (OBJECT_TABLE + "." + OBJECT_CID_COLUMN) + " FROM " + REFERENCE_TABLE + ", " + OBJECT_TABLE
      + " WHERE " + (REFERENCE_TABLE + "." + REFERENCE_OID_COLUMN) + "=? AND "
      + (REFERENCE_TABLE + "." + REFERENCE_TARGET_COLUMN) + "="
      + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + " ORDER BY "
      + (REFERENCE_TABLE + "." + REFERENCE_FEATUREID_COLUMN) + ", "
      + (REFERENCE_TABLE + "." + REFERENCE_ORDINAL_COLUMN);

  public static final String INSERT_OBJECT = "INSERT INTO " + OBJECT_TABLE + " VALUES (?, 1, ?)";

  public static final String INSERT_CONTENT = "INSERT INTO " + CONTENT_TABLE + " VALUES (?)";

  public static final String REMOVE_CONTENT = "DELETE FROM " + CONTENT_TABLE + " WHERE "
      + CONTENT_OID_COLUMN + "=?";

  public static final String TRANSMIT_CONTENT = "SELECT "
      + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + ", " + (OBJECT_TABLE + "." + OBJECT_OCA_COLUMN)
      + ", " + (OBJECT_TABLE + "." + OBJECT_CID_COLUMN) + " FROM " + CONTENT_TABLE + ", "
      + OBJECT_TABLE + " WHERE " + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + "="
      + (CONTENT_TABLE + "." + CONTENT_OID_COLUMN) + " AND "
      + (OBJECT_TABLE + "." + OBJECT_OID_COLUMN) + " BETWEEN ? AND ?";

  public static final String TRANSMIT_OBJECT = "SELECT " + OBJECT_OCA_COLUMN + ", "
      + OBJECT_CID_COLUMN + " FROM " + OBJECT_TABLE + " WHERE " + OBJECT_OID_COLUMN + "=?";

  public static final String DO_OPTIMISTIC_CONTROL = "UPDATE " + OBJECT_TABLE + " SET "
      + OBJECT_OCA_COLUMN + "=" + OBJECT_OCA_COLUMN + "+1 WHERE " + OBJECT_OID_COLUMN + "=?"
      + " AND " + OBJECT_OCA_COLUMN + "=?";
}