svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.api / src / main / java / org / gvsig / fmap / dal / SQLBuilder.java @ 43739
History | View | Annotate | Download (13.6 KB)
1 |
package org.gvsig.fmap.dal; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
import org.cresques.cts.IProjection; |
5 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
6 |
|
7 |
public interface SQLBuilder extends ExpressionBuilder { |
8 |
|
9 |
public enum Privilege { |
10 |
SELECT, |
11 |
INSERT, |
12 |
UPDATE, |
13 |
DELETE, |
14 |
TRUNCATE, |
15 |
REFERENCE, |
16 |
TRIGGER, |
17 |
ALL |
18 |
}; |
19 |
|
20 |
public interface Statement extends Visitable { |
21 |
|
22 |
} |
23 |
|
24 |
public interface SQLConfig extends Config { |
25 |
public final static String default_schema = "default_schema"; |
26 |
|
27 |
public final static String allowAutomaticValues = "allowAutomaticValues"; |
28 |
|
29 |
public final static String ST_ExtentAggregate = "ST_ExtentAggregate"; |
30 |
public final static String ST_UnionAggregate = "ST_UnionAggregate"; |
31 |
public final static String count = "count"; |
32 |
public final static String count_distinct = "count_distinct"; |
33 |
|
34 |
public final static String type_boolean = "type_boolean"; |
35 |
public final static String type_byte = "type_byte"; |
36 |
public final static String type_bytearray = "type_bytearray"; |
37 |
public final static String type_geometry = "type_geometry"; |
38 |
public final static String type_char = "type_char"; |
39 |
public final static String type_date = "type_date"; |
40 |
public final static String type_double = "type_double"; |
41 |
public final static String type_numeric_p = "type_numeric_p"; |
42 |
public final static String type_numeric_ps = "type_numeric_ps"; |
43 |
public final static String type_bigdecimal = "type_bigdecimal"; |
44 |
public final static String type_float = "type_float"; |
45 |
public final static String type_int = "type_int"; |
46 |
public final static String type_long = "type_long"; |
47 |
public final static String type_string = "type_string"; |
48 |
public final static String type_string_p = "type_string_p"; |
49 |
public final static String type_time = "type_time"; |
50 |
public final static String type_timestamp = "type_timestamp"; |
51 |
public final static String type_version = "type_version"; |
52 |
public final static String type_URI = "type_URI"; |
53 |
public final static String type_URL = "type_URL"; |
54 |
public final static String type_FILE = "type_FILE"; |
55 |
public final static String type_FOLDER = "type_FOLDER"; |
56 |
|
57 |
public final static String DELETE_FROM_table_WHERE_expresion = "DELETE_FROM_table_WHERE_expresion"; |
58 |
public final static String DELETE_FROM_table = "DELETE_FROM_table"; |
59 |
public final static String INSERT_INTO_table_columns_VALUES_values = "INSERT_INTO_table_columns_VALUES_values"; |
60 |
public final static String UPDATE_TABLE_STATISTICS_table = "UPDATE_TABLE_STATISTICS_table"; |
61 |
public final static String DROP_TABLE_table = "DROP_TABLE_table"; |
62 |
public final static String DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table = "DELETE_GEOMETRY_COLUMN_FROM_TABLE_schema_table"; |
63 |
public final static String DELETE_GEOMETRY_COLUMN_FROM_TABLE_table = "DELETE_GEOMETRY_COLUMN_FROM_TABLE_table"; |
64 |
public final static String UPDATE_table_SET_columnsAndValues_WHERE_expresion = "UPDATE_table_SET_columnsAndValues_WHERE_expresion"; |
65 |
public final static String UPDATE_table_SET_columnsAndValues = "UPDATE_table_SET_columnsAndValues"; |
66 |
public final static String GRANT_privileges_ON_table_TO_role = "GRANT_privileges_ON_table_TO_role"; |
67 |
// public final static String CREATE_INDEX_name_ON_table_column = "CREATE_INDEX_name_ON_table_column";
|
68 |
// public final static String CREATE_INDEX_name_ON_table_USING_GIST_column = "CREATE_INDEX_name_ON_table_USING_GIST_column";
|
69 |
|
70 |
} |
71 |
|
72 |
public interface TableNameBuilder extends Visitable { |
73 |
public TableNameBuilder database(String name); |
74 |
public TableNameBuilder schema(String name); |
75 |
public TableNameBuilder name(String name); |
76 |
public String getDatabase(); |
77 |
public String getSchema(); |
78 |
public String getName(); |
79 |
public boolean has_database(); |
80 |
public boolean has_schema(); |
81 |
} |
82 |
|
83 |
public interface ColumnDescriptorBuilder { |
84 |
public String getName(); |
85 |
public int getType(); |
86 |
public int getSize(); |
87 |
public int getPrecision(); |
88 |
public boolean isPrimaryKey(); |
89 |
public boolean isIndexed(); |
90 |
public boolean isAutomatic(); |
91 |
boolean allowNulls();
|
92 |
public Object getDefaultValue(); |
93 |
public int getGeometryType(); |
94 |
public int getGeometrySubtype(); |
95 |
public Object getGeometrySRSId(); |
96 |
public boolean isGeometry(); |
97 |
|
98 |
public void setName(String name); |
99 |
public void setType(int type); |
100 |
public void setSize(int size); |
101 |
public void setPrecision(int precision); |
102 |
public void setIsPrimaryKey(boolean isPk); |
103 |
public void setIsAutomatic(boolean isAutomatic); |
104 |
public void setAllowNulls(boolean allowNulls); |
105 |
public void setDefaultValue(Object defaultValue); |
106 |
public void setGeometryType(int geom_type); |
107 |
public void setGeometrySubtype(int geom_subtype); |
108 |
public void setGeometrySRSId(Object geom_srsid); |
109 |
} |
110 |
|
111 |
public interface CountBuilder extends Value { |
112 |
public CountBuilder all();
|
113 |
public CountBuilder column(Value value);
|
114 |
public CountBuilder distinct();
|
115 |
} |
116 |
|
117 |
public interface SelectColumnBuilder extends Visitable { |
118 |
public SelectColumnBuilder name(String name); |
119 |
public SelectColumnBuilder value(Value value);
|
120 |
public SelectColumnBuilder as(String alias); |
121 |
public SelectColumnBuilder as_geometry();
|
122 |
public SelectColumnBuilder all();
|
123 |
public String getName(); |
124 |
public String getAlias(); |
125 |
public String getValue(); |
126 |
} |
127 |
|
128 |
public interface InsertColumnBuilder extends Visitable { |
129 |
public InsertColumnBuilder name(String name); |
130 |
public InsertColumnBuilder with_value(Value value);
|
131 |
public String getName(); |
132 |
public Value getValue();
|
133 |
} |
134 |
|
135 |
public interface UpdateColumnBuilder extends InsertColumnBuilder { |
136 |
@Override
|
137 |
public UpdateColumnBuilder name(String name); |
138 |
@Override
|
139 |
public UpdateColumnBuilder with_value(Value value);
|
140 |
@Override
|
141 |
public String getName(); |
142 |
@Override
|
143 |
public Value getValue();
|
144 |
} |
145 |
|
146 |
public interface FromBuilder extends Visitable { |
147 |
public TableNameBuilder table();
|
148 |
public FromBuilder subquery(String subquery); |
149 |
public FromBuilder custom(String passthrough); |
150 |
} |
151 |
|
152 |
public interface OrderByBuilder extends Visitable { |
153 |
public OrderByBuilder column(String name); |
154 |
public OrderByBuilder ascending(boolean asc); |
155 |
public OrderByBuilder ascending();
|
156 |
public OrderByBuilder descending();
|
157 |
public OrderByBuilder custom(String order); |
158 |
} |
159 |
|
160 |
public interface SelectBuilder extends Statement { |
161 |
public SelectColumnBuilder column();
|
162 |
public FromBuilder from();
|
163 |
public ExpressionBuilder where();
|
164 |
public OrderByBuilder order_by();
|
165 |
public SelectBuilder distinct();
|
166 |
public SelectBuilder limit(long limit); |
167 |
|
168 |
/**
|
169 |
* Specifies an offset to be applied to the SQL statement.
|
170 |
* Only an offset can be applied if an order has been specified.
|
171 |
* Otherwise an IllegalStateException exception will be thrown when
|
172 |
* constructing the SQL statement invoking the toString method.
|
173 |
*
|
174 |
* @param offset
|
175 |
* @return this SelectBuilder
|
176 |
*/
|
177 |
public SelectBuilder offset(long offset); |
178 |
|
179 |
public boolean has_column(String name); |
180 |
public boolean has_where(); |
181 |
public boolean has_from(); |
182 |
public boolean has_order_by(); |
183 |
public boolean has_limit(); |
184 |
public boolean has_offset(); |
185 |
|
186 |
/**
|
187 |
* Constructs the SQL statement.
|
188 |
* If the values associated with the SQL statement are not valid
|
189 |
* an IllegalStateException exception is thrown.
|
190 |
*
|
191 |
* @return the SQL select statement.
|
192 |
* @throws IllegalStateException if the values of select statement are not valids.
|
193 |
*/
|
194 |
@Override
|
195 |
public String toString(); |
196 |
|
197 |
} |
198 |
|
199 |
public interface UpdateBuilder extends Statement { |
200 |
public TableNameBuilder table();
|
201 |
public UpdateColumnBuilder column();
|
202 |
public ExpressionBuilder where();
|
203 |
public boolean has_where(); |
204 |
} |
205 |
|
206 |
public interface InsertBuilder extends Statement { |
207 |
public TableNameBuilder table();
|
208 |
public InsertColumnBuilder column();
|
209 |
} |
210 |
|
211 |
public interface DeleteBuilder extends Statement { |
212 |
public TableNameBuilder table();
|
213 |
public ExpressionBuilder where();
|
214 |
public boolean has_where(); |
215 |
} |
216 |
|
217 |
public interface AlterTableBuilder extends Statement { |
218 |
public TableNameBuilder table();
|
219 |
public AlterTableBuilder drop_column(String columnName); |
220 |
public AlterTableBuilder add_column(FeatureAttributeDescriptor fad);
|
221 |
public AlterTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
222 |
public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls); |
223 |
public AlterTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls); |
224 |
public AlterTableBuilder alter_column(FeatureAttributeDescriptor fad);
|
225 |
public AlterTableBuilder alter_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
226 |
public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls); |
227 |
public AlterTableBuilder alter_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls); |
228 |
public AlterTableBuilder rename_column(String source, String target); |
229 |
public boolean isEmpty(); |
230 |
public List<String> toStrings(); |
231 |
} |
232 |
|
233 |
public interface CreateTableBuilder extends Statement { |
234 |
public TableNameBuilder table();
|
235 |
public CreateTableBuilder add_column(FeatureAttributeDescriptor fad);
|
236 |
public CreateTableBuilder add_column(String columnName, int type, int type_p, int type_s, boolean isPk, boolean isIndexed, boolean allowNulls, boolean isAutomatic, Object defaultValue); |
237 |
public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, IProjection proj, boolean isIndexed, boolean allowNulls); |
238 |
public CreateTableBuilder add_geometry_column(String columnName, int geom_type, int geom_subtype, Object srsdbcode, boolean isIndexed, boolean allowNulls); |
239 |
public ColumnDescriptor getColumnDescriptor(String columnName); |
240 |
public List<String> toStrings(); |
241 |
} |
242 |
|
243 |
public interface UpdateTableStatisticsBuilder extends Statement { |
244 |
public TableNameBuilder table();
|
245 |
public List<String> toStrings(); |
246 |
} |
247 |
|
248 |
public interface GrantRoleBuilder { |
249 |
public GrantRoleBuilder privilege(Privilege privilege);
|
250 |
public GrantRoleBuilder select();
|
251 |
public GrantRoleBuilder insert();
|
252 |
public GrantRoleBuilder delete();
|
253 |
public GrantRoleBuilder truncate();
|
254 |
public GrantRoleBuilder reference();
|
255 |
public GrantRoleBuilder update();
|
256 |
public GrantRoleBuilder trigger();
|
257 |
public GrantRoleBuilder all();
|
258 |
} |
259 |
|
260 |
public interface GrantBuilder extends Statement { |
261 |
public TableNameBuilder table();
|
262 |
public GrantRoleBuilder role(String name); |
263 |
public List<String> toStrings(); |
264 |
} |
265 |
|
266 |
public interface DropTableBuilder extends Statement { |
267 |
public TableNameBuilder table();
|
268 |
public List<String> toStrings(); |
269 |
} |
270 |
|
271 |
public interface CreateIndexBuilder extends Statement { |
272 |
public CreateIndexBuilder if_not_exist();
|
273 |
public CreateIndexBuilder unique();
|
274 |
public CreateIndexBuilder name(String name); |
275 |
public CreateIndexBuilder spatial();
|
276 |
public CreateIndexBuilder column(String name); |
277 |
public TableNameBuilder table();
|
278 |
public List<String> toStrings(); |
279 |
} |
280 |
|
281 |
public String default_schema(); |
282 |
|
283 |
public boolean supportSchemas(); |
284 |
|
285 |
@Deprecated
|
286 |
public String sqltype(int dataType, int p, int s); |
287 |
|
288 |
public String sqltype(int dataType, int p, int s, int geomType, int geomSubtype); |
289 |
|
290 |
public Object sqlgeometrytype(int type, int subtype); |
291 |
|
292 |
public Object sqlgeometrydimension(int type, int subtype); |
293 |
|
294 |
public SelectBuilder select();
|
295 |
|
296 |
public UpdateBuilder update();
|
297 |
|
298 |
public InsertBuilder insert();
|
299 |
|
300 |
public DeleteBuilder delete();
|
301 |
|
302 |
public AlterTableBuilder alter_table();
|
303 |
|
304 |
public CreateTableBuilder create_table();
|
305 |
|
306 |
public CreateIndexBuilder create_index();
|
307 |
|
308 |
public GrantBuilder grant();
|
309 |
|
310 |
public DropTableBuilder drop_table();
|
311 |
|
312 |
public UpdateTableStatisticsBuilder update_table_statistics();
|
313 |
|
314 |
public CountBuilder count();
|
315 |
|
316 |
public Function ST_ExtentAggregate(Value geom);
|
317 |
|
318 |
public Function ST_UnionAggregate(Value geom);
|
319 |
|
320 |
} |