Revision 316
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/count.sql | ||
---|---|---|
1 |
|
|
2 |
-- Count SQL |
|
3 |
SELECT COUNT(*) FROM "public"."test"; |
|
4 |
|
|
5 |
-- Count SQL 1 |
|
6 |
SELECT COUNT(*) FROM "public"."test"; |
|
7 |
|
|
8 |
-- Count SQL 2 |
|
9 |
SELECT COUNT(*) FROM "dba"."test"; |
|
10 |
|
|
11 |
-- Count with group SQL |
|
12 |
SELECT COUNT(*) |
|
13 |
FROM ( |
|
14 |
SELECT COUNT(*) |
|
15 |
FROM "public"."test" |
|
16 |
GROUP BY "Long" |
|
17 |
) "_subquery_alias_" ; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/resultSetForSetProvider.sql | ||
---|---|---|
1 |
|
|
2 |
-- ResultSetForSetProvider SQL |
|
3 |
|
|
4 |
-- Simple |
|
5 |
SELECT |
|
6 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
7 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
8 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
9 |
FROM "public"."test"; |
|
10 |
|
|
11 |
-- Simple Group by |
|
12 |
SELECT MIN("test"."ID") "ID", MAX("test"."Byte") "Byte", NULL "Bool1", "Long", |
|
13 |
NULL "Timestamp", NULL "Date", NULL "Time", NULL "Bool2", |
|
14 |
NULL "String", NULL "Bool3", SUM("test"."Double") "Double", |
|
15 |
NULL "Bool4", NULL "Float", NULL "Bool5", NULL "Decimal", |
|
16 |
NULL "Geometry" |
|
17 |
FROM "public"."test" |
|
18 |
GROUP BY "test"."Long"; |
|
19 |
|
|
20 |
-- Subselect |
|
21 |
SELECT |
|
22 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
23 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
24 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL), |
|
25 |
CASE WHEN ( |
|
26 |
EXISTS(( |
|
27 |
SELECT * |
|
28 |
FROM ( |
|
29 |
SELECT "ISO_A2" |
|
30 |
FROM "countries" |
|
31 |
WHERE ( (( ("test"."String") = ("countries"."CONTINENT") )) AND (( ("countries"."LASTCENSUS") < (0) )) ) |
|
32 |
) a WHERE ROWNUM <= 1 |
|
33 |
)) |
|
34 |
) |
|
35 |
THEN (1) |
|
36 |
ELSE (0) |
|
37 |
END "EXISTS62a964cd7bc24f409b97c03b9170408d" |
|
38 |
FROM "public"."test" |
|
39 |
WHERE |
|
40 |
EXISTS(( |
|
41 |
SELECT * |
|
42 |
FROM ( |
|
43 |
SELECT "ISO_A2" |
|
44 |
FROM "countries" |
|
45 |
WHERE ( (( ("test"."String") = ("countries"."CONTINENT") )) AND (( ("countries"."LASTCENSUS") < (0) )) ) |
|
46 |
) a |
|
47 |
WHERE ROWNUM <= 1 |
|
48 |
)); |
|
49 |
|
|
50 |
-- Group and Subselect |
|
51 |
SELECT |
|
52 |
MIN("test"."ID") "ID", MAX("test"."Byte") "Byte", NULL "Bool1", "Long", |
|
53 |
NULL "Timestamp", NULL "Date", NULL "Time", NULL "Bool2", |
|
54 |
NULL "String", NULL "Bool3", SUM("test"."Double") "Double", |
|
55 |
NULL "Bool4", NULL "Float", NULL "Bool5", NULL "Decimal", |
|
56 |
NULL "Geometry" |
|
57 |
FROM "public"."test" |
|
58 |
WHERE |
|
59 |
EXISTS(( |
|
60 |
SELECT * |
|
61 |
FROM ( |
|
62 |
SELECT "ISO_A2" |
|
63 |
FROM "countries" |
|
64 |
WHERE ( |
|
65 |
(( ("test"."String") = ("countries"."CONTINENT") )) |
|
66 |
AND |
|
67 |
(( ("countries"."LASTCENSUS") < (0) )) |
|
68 |
) |
|
69 |
) a |
|
70 |
WHERE ROWNUM <= 1 |
|
71 |
)) |
|
72 |
GROUP BY "test"."Long"; |
|
73 |
|
|
74 |
|
|
75 |
-- Constant Column Primary Key |
|
76 |
SELECT |
|
77 |
"Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
78 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
79 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL), "ID" |
|
80 |
FROM "public"."test"; |
|
81 |
|
|
82 |
-- CLOB |
|
83 |
SELECT |
|
84 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
85 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
86 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
87 |
FROM "public"."test" |
|
88 |
WHERE dbms_lob.compare(("String"),('hola')) = 0; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/testCreateSource1_es.csv | ||
---|---|---|
1 |
ID__Integer__set__size=0__set__precision=10__set__scale=0__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=true__set__automatic=false__set__isTime=false__set__locale=es__set__order=0__set__roundMode=4;Byte__Byte__set__size=0__set__precision=3__set__scale=0__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=10__set__roundMode=4;Bool1__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=20__set__roundMode=4;Long__Long__set__size=0__set__precision=19__set__scale=0__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=30__set__roundMode=4;Timestamp__Timestamp__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=40__set__roundMode=4;Date__Date__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=50__set__roundMode=4;Time__Time__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=60__set__roundMode=4;Bool2__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=70__set__roundMode=4;String__String__set__size=30__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=80__set__roundMode=4;Bool3__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=90__set__roundMode=4;Double__Double__set__size=0__set__precision=16__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=100__set__roundMode=4;Bool4__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=110__set__roundMode=4;Float__Float__set__size=0__set__precision=8__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=120__set__roundMode=4;Bool5__Boolean__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=130__set__roundMode=4;Decimal__Decimal__set__size=0__set__precision=6__set__scale=3__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=140__set__roundMode=4;Geometry__Geometry__set__size=0__set__precision=-1__set__scale=-1__set__hidden=false__set__readOnly=false__set__allowNull=true__set__pk=false__set__automatic=false__set__isTime=false__set__locale=es__set__order=150__set__roundMode=4__set__srs=EPSG:25830__set__geomtype=Point@2D |
|
2 |
0;;;;;;;; ;;;;;true;; |
|
3 |
1;10;true;1000;29-dic-2019 12:13:14;29 de diciembre de 2019;12:13:14 CET;true;Yo yo1;false;1234554321;true;12321;true;456,123;POINT (-3.8945156972987958 42.01053743584765) |
|
4 |
2;20;true;2000;29-nov-2019 12:13:14;29 de noviembre de 2019;13:13:14 CET;true;Yo yo2;false;1210054321;true;10021;true;456,123;POINT (-2.1079618220646115 41.983079082675474) |
|
5 |
3;30;true;3000;29-oct-2019 12:13:14;29 de octubre de 2019;14:13:14 CET;true;Yo yo3;false;1210154321;true;10121;true;456,123;POINT (-2.57249737803327 41.35372113353277) |
|
6 |
4;40;true;4000;29-sep-2019 12:13:14;29 de septiembre de 2019;15:13:14 CET;true;Yo yo4;false;1210254321;true;10221;true;456,123;POINT (-4.061822048036304 41.35877680235475) |
|
7 |
5;50;true;5000;29-ago-2019 12:13:14;29 de agosto de 2019;16:13:14 CET;true;Yo yo5;false;1210354321;true;10321;true;456,123;POINT (-3.974317066986988 40.78701209315094) |
|
8 |
6;60;true;6000;29-jul-2019 12:13:14;29 de julio de 2019;17:13:14 CET;true;Yo yo6;false;1210454321;true;10421;true;456,123;POINT (-2.510509736717547 40.69847453392384) |
|
9 |
7;70;true;7000;29-jun-2019 12:13:14;29 de junio de 2019;18:13:14 CET;true;Yo yo7;false;1210554321;true;10521;true;456,123;POINT (-0.5317736981843011 40.66396082637622) |
|
10 |
8;80;true;8000;29-may-2019 12:13:14;29 de mayo de 2019;19:13:14 CET;true;Yo yo8;false;1210654321;true;10621;true;456,123;POINT (-0.3626917259170671 41.13652386601604) |
|
11 |
9;90;true;9000;29-abr-2019 12:13:14;29 de abril de 2019;20:13:14 CET;true;Yo yo9;false;1210754321;true;10721;true;456,123;POINT (-1.2461823078608523 41.84950010180092) |
|
12 |
10;;true;1001;29-dic-2019 12:13:14;29 de diciembre de 2019;12:13:14 CET;true;Yo yo1;false;1234554321;true;12321;true;456,123;POINT (-1.2145405488596532 41.22158511004416) |
|
13 |
11;22;;2003;29-nov-2019 12:13:14;29 de noviembre de 2019;13:13:14 CET;true;Yo yo 2;false;1210054321;true;10021;true;456,123;POINT (-0.7699089544899235 41.630581204431756) |
|
14 |
12;33;true;;29-sep-2019 12:13:14;29 de octubre de 2019;14:13:14 CET;true;Yo yo3;false;1210154321;true;10121;true;456,123;POINT (0.4821915816701051 41.75970939133133) |
|
15 |
13;41;true;4001;;29 de septiembre de 2019;15:13:14 CET;true;Yo yo4;false;1210254321;true;10221;true;456,123;POINT (0.7912661147227479 41.919324620992036) |
|
16 |
14;52;true;5002;29-ago-2019 12:13:14;;16:13:14 CET;true;Yo yo5;false;1210354321;true;10321;true;456,123;POINT (1.052534629531243 41.493736996249545) |
|
17 |
15;63;true;6003;29-jul-2019 12:13:14;29 de julio de 2019;;true;Yo yo6;false;1210454321;true;10421;true;456,123;POINT (0.8097002367335026 41.0899480235613) |
|
18 |
16;74;true;7004;29-jun-2019 12:13:14;29 de junio de 2019;18:13:14 CET;true; ;false;1210554321;true;10521;true;456,123;POINT (-0.4883960310112362 41.17597288081971) |
|
19 |
17;85;true;8005;29-may-2019 12:13:14;29 de mayo de 2019;19:13:14 CET;true;Yo yo8;false;;true;10621;true;456,123;POINT (-0.6439030698437881 40.89530766155764) |
|
20 |
18;96;true;9006;29-abr-2019 12:13:14;29 de abril de 2019;20:13:14 CET;true;Yo yo9;false;1210754321;true;;true;;POINT (-1.3061826868199504 40.72372835570524) |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/fetchFeatureProviderByReference.sql | ||
---|---|---|
1 |
|
|
2 |
-- fetchFeatureProviderByReference SQL |
|
3 |
SELECT |
|
4 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
5 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
6 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
7 |
FROM "public"."test" |
|
8 |
WHERE ( ("ID") = (?) ) AND ROWNUM <= 1; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/calculateEnvelope.sql | ||
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
-- Count SQL |
|
5 |
--SELECT NVL2((SDO_AGGR_MBR("Geometry")),(SDO_AGGR_MBR("Geometry")).Get_WKB(),NULL) |
|
6 |
--FROM "public"."test" |
|
7 |
--WHERE ( ("Geometry") IS NOT NULL ); |
|
8 |
|
|
9 |
SELECT NVL2((SDO_AGGR_MBR("Geometry")),(SDO_AGGR_MBR("Geometry")).Get_WKB(),NULL) |
|
10 |
FROM "public"."test" |
|
11 |
WHERE ( ("Geometry") IS NOT NULL ); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/testCreateSource_short.csv | ||
---|---|---|
1 |
Byte/Byte |
|
2 |
|
|
3 |
10 |
|
4 |
20 |
|
5 |
30 |
|
6 |
40 |
|
7 |
50 |
|
8 |
60 |
|
9 |
70 |
|
10 |
80 |
|
11 |
90 |
|
12 |
|
|
13 |
22 |
|
14 |
33 |
|
15 |
41 |
|
16 |
52 |
|
17 |
63 |
|
18 |
74 |
|
19 |
85 |
|
20 |
96 |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/testCreateSource1.csv | ||
---|---|---|
1 |
ID/Integer/set/pk=true;Byte/Byte;Bool1/Boolean;Long/Long;Timestamp/TimeStamp;Date/Date;Time/Time;Bool2/Boolean;String/String/set/size=30;Bool3/Boolean;Double/Double;Bool4/Boolean;Float/Float;Bool5/Boolean;Decimal/Decimal/set/precision=6/set/scale=3;Geometry/Geometry/set/geomtype=Point:2D/set/srs=EPSG:4326 |
|
2 |
0; ; ; ; ; ; ; ; ; ; ; ; ;T; ; |
|
3 |
1;10;T;1000;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123;POINT (-3.8945156972987958 42.01053743584765) |
|
4 |
2;20;T;2000;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123;POINT (-2.1079618220646115 41.983079082675474) |
|
5 |
3;30;T;3000;20191029121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123;POINT (-2.57249737803327 41.35372113353277) |
|
6 |
4;40;T;4000;20190929121314;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123;POINT (-4.061822048036304 41.35877680235475) |
|
7 |
5;50;T;5000;20190829121314;20190829;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123;POINT (-3.974317066986988 40.78701209315094) |
|
8 |
6;60;T;6000;20190729121314;20190729;171314;T;Yo yo6;F;12104.54321;T;104.21;T;456.123;POINT (-2.510509736717547 40.69847453392384) |
|
9 |
7;70;T;7000;20190629121314;20190629;181314;T;Yo yo7;F;12105.54321;T;105.21;T;456.123;POINT (-0.5317736981843011 40.66396082637622) |
|
10 |
8;80;T;8000;20190529121314;20190529;191314;T;Yo yo8;F;12106.54321;T;106.21;T;456.123;POINT (-0.3626917259170671 41.13652386601604) |
|
11 |
9;90;T;9000;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T;107.21;T;456.123;POINT (-1.2461823078608523 41.84950010180092) |
|
12 |
10;;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123;POINT (-1.2145405488596532 41.22158511004416) |
|
13 |
11;22; ;2002;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123;POINT (-0.7699089544899235 41.630581204431756) |
|
14 |
12;33;T; ;20190929121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123;POINT (0.4821915816701051 41.75970939133133) |
|
15 |
13;41;T;4001; ;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123;POINT (0.7912661147227479 41.919324620992036) |
|
16 |
14;52;T;5002;20190829121314; ;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123;POINT (1.052534629531243 41.493736996249545) |
|
17 |
15;63;T;6003;20190729121314;20190729; ;T;Yo yo6;F;12104.54321;T;104.21;T;456.123;POINT (0.8097002367335026 41.0899480235613) |
|
18 |
16;74;T;7004;20190629121314;20190629;181314;T; ;F;12105.54321;T;105.21;T;456.123;POINT (-0.4883960310112362 41.17597288081971) |
|
19 |
17;85;T;8005;20190529121314;20190529;191314;T;Yo yo8;F; ;T;106.21;T;456.123;POINT (-0.6439030698437881 40.89530766155764) |
|
20 |
18;96;T;9006;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T; ;T; ;POINT (-1.3061826868199504 40.72372835570524) |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/tableIsEmpty.sql | ||
---|---|---|
1 |
|
|
2 |
-- Table is empty |
|
3 |
SELECT * FROM "public"."test" WHERE ROWNUM <= 1; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/performChanges.sql | ||
---|---|---|
1 |
|
|
2 |
-- Insert SQL |
|
3 |
INSERT INTO "public"."test" ( |
|
4 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
5 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", |
|
6 |
"Decimal", "Geometry" |
|
7 |
) VALUES ( |
|
8 |
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NVL2((?),SDO_GEOMETRY((?), (?)),NULL) |
|
9 |
); |
|
10 |
|
|
11 |
-- Delete SQL |
|
12 |
DELETE FROM "public"."test" WHERE ( ("ID") = (?) ); |
|
13 |
|
|
14 |
-- Update SQL |
|
15 |
UPDATE "public"."test" |
|
16 |
SET |
|
17 |
"Byte" = ?, |
|
18 |
"Bool1" = ?, |
|
19 |
"Long" = ?, |
|
20 |
"Timestamp" = ?, |
|
21 |
"Date" = ?, |
|
22 |
"Time" = ?, |
|
23 |
"Bool2" = ?, |
|
24 |
"String" = ?, |
|
25 |
"Bool3" = ?, |
|
26 |
"Double" = ?, |
|
27 |
"Bool4" = ?, |
|
28 |
"Float" = ?, |
|
29 |
"Bool5" = ?, |
|
30 |
"Decimal" = ?, |
|
31 |
"Geometry" = NVL2((?),SDO_GEOMETRY((?), (?)),NULL) |
|
32 |
WHERE |
|
33 |
( ("ID") = (?) ); |
|
34 |
|
|
35 |
|
|
36 |
-- Update Table SQL |
|
37 |
ALTER TABLE "public"."test" ADD "Byte" NUMBER(3,0) DEFAULT NULL NULL; |
|
38 |
ALTER TABLE "public"."test" ADD "Bool1" CHAR(1) DEFAULT NULL NULL; |
|
39 |
ALTER TABLE "public"."test" ADD "Long" NUMBER(18,0) DEFAULT NULL NULL; |
|
40 |
ALTER TABLE "public"."test" ADD "Timestamp" TIMESTAMP DEFAULT NULL NULL; |
|
41 |
ALTER TABLE "public"."test" ADD "Date" DATE DEFAULT NULL NULL; |
|
42 |
ALTER TABLE "public"."test" ADD "Time" TIMESTAMP DEFAULT NULL NULL; |
|
43 |
ALTER TABLE "public"."test" ADD "Bool2" CHAR(1) DEFAULT NULL NULL; |
|
44 |
ALTER TABLE "public"."test" ADD "String" VARCHAR(30) DEFAULT NULL NULL; |
|
45 |
ALTER TABLE "public"."test" ADD "Bool3" CHAR(1) DEFAULT NULL NULL; |
|
46 |
ALTER TABLE "public"."test" ADD "Double" BINARY_DOUBLE DEFAULT NULL NULL; |
|
47 |
ALTER TABLE "public"."test" ADD "Bool4" CHAR(1) DEFAULT NULL NULL; |
|
48 |
ALTER TABLE "public"."test" ADD "Float" BINARY_FLOAT DEFAULT NULL NULL; |
|
49 |
ALTER TABLE "public"."test" ADD "Bool5" CHAR(1) DEFAULT NULL NULL; |
|
50 |
ALTER TABLE "public"."test" ADD "Decimal" NUMBER(6,3) DEFAULT NULL NULL; |
|
51 |
ALTER TABLE "public"."test" ADD "Geometry" SDO_GEOMETRY DEFAULT NULL NULL; |
|
52 |
|
|
53 |
|
|
54 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS |
|
55 |
WHERE F_TABLE_SCHEMA = 'public' |
|
56 |
AND F_TABLE_NAME = 'test' |
|
57 |
AND F_GEOMETRY_COLUMN = 'Geometry'; |
|
58 |
|
|
59 |
|
|
60 |
INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS ( |
|
61 |
F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) |
|
62 |
VALUES ('public', 'test', 'Geometry', 1001); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/updateTableStatistics.sql | ||
---|---|---|
1 |
|
|
2 |
-- UpdateTableStatistics SQL |
|
3 |
ANALYZE TABLE "public"."test" COMPUTE STATISTICS; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/append.sql | ||
---|---|---|
1 |
INSERT INTO "public"."test" ( |
|
2 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", |
|
3 |
"Bool2", "String", "Bool3", "Double", "Bool4", "Float", "Bool5", |
|
4 |
"Decimal", "Geometry" |
|
5 |
) VALUES ( |
|
6 |
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NVL2((?),SDO_GEOMETRY((?), (?)),NULL) ); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/fetchFeatureType.sql | ||
---|---|---|
1 |
|
|
2 |
-- FetchFeatureType first row SQL |
|
3 |
SELECT * FROM "public"."test" WHERE ROWNUM <= 1; |
|
4 |
|
|
5 |
SELECT "USER_TAB_COLS"."COLUMN_NAME", "ALL_CONSTRAINTS"."CONSTRAINT_TYPE" |
|
6 |
FROM USER_TAB_COLS |
|
7 |
JOIN ALL_CONS_COLUMNS on (ALL_CONS_COLUMNS.TABLE_NAME = USER_TAB_COLS.TABLE_NAME and ALL_CONS_COLUMNS.COLUMN_NAME = USER_TAB_COLS.COLUMN_NAME) |
|
8 |
LEFT JOIN ALL_CONSTRAINTS on ALL_CONSTRAINTS.CONSTRAINT_NAME = ALL_CONS_COLUMNS.CONSTRAINT_NAME |
|
9 |
WHERE ( |
|
10 |
(( ("USER_TAB_COLS"."TABLE_NAME") LIKE ('test') )) |
|
11 |
AND |
|
12 |
(( ("ALL_CONSTRAINTS"."CONSTRAINT_TYPE") = ('P') )) |
|
13 |
); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/createTable.sql | ||
---|---|---|
1 |
|
|
2 |
-- Se usa en TestCreateTable. |
|
3 |
-- Se corresponde con el fichero CSV "testCreateSource1.csv". |
|
4 |
|
|
5 |
CREATE TABLE "public"."TEST" ( |
|
6 |
"ID" NUMBER(9,0), |
|
7 |
"Byte" NUMBER(3,0) DEFAULT NULL, |
|
8 |
"Bool1" CHAR(1) DEFAULT NULL, |
|
9 |
"Long" NUMBER(18,0) DEFAULT NULL, |
|
10 |
"Timestamp" TIMESTAMP DEFAULT NULL, |
|
11 |
"Date" DATE DEFAULT NULL, |
|
12 |
"Time" TIMESTAMP DEFAULT NULL, |
|
13 |
"Bool2" CHAR(1) DEFAULT NULL, |
|
14 |
"String" VARCHAR(30) DEFAULT NULL, |
|
15 |
"Bool3" CHAR(1) DEFAULT NULL, |
|
16 |
"Double" BINARY_DOUBLE DEFAULT NULL, |
|
17 |
"Bool4" CHAR(1) DEFAULT NULL, |
|
18 |
"Float" BINARY_FLOAT DEFAULT NULL, |
|
19 |
"Bool5" CHAR(1) DEFAULT NULL, |
|
20 |
"Decimal" NUMBER(6,3) DEFAULT NULL, |
|
21 |
"GEOMETRY" SDO_GEOMETRY DEFAULT NULL |
|
22 |
); |
|
23 |
|
|
24 |
|
|
25 |
ALTER TABLE "public"."TEST" ADD PRIMARY KEY ("ID"); |
|
26 |
|
|
27 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS |
|
28 |
WHERE F_TABLE_SCHEMA = 'public' |
|
29 |
AND F_TABLE_NAME = 'TEST' |
|
30 |
AND F_GEOMETRY_COLUMN = 'GEOMETRY'; |
|
31 |
|
|
32 |
INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS ( |
|
33 |
F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) |
|
34 |
VALUES ('public', 'TEST', 'GEOMETRY', 1); |
|
35 |
|
|
36 |
-- Create table with CLOB |
|
37 |
|
|
38 |
CREATE TABLE "public"."TEST" ( |
|
39 |
"ID" NUMBER(9,0), |
|
40 |
"Byte" NUMBER(3,0) DEFAULT NULL, |
|
41 |
"Bool1" CHAR(1) DEFAULT NULL, |
|
42 |
"Long" NUMBER(18,0) DEFAULT NULL, |
|
43 |
"Timestamp" TIMESTAMP DEFAULT NULL, |
|
44 |
"Date" DATE DEFAULT NULL, |
|
45 |
"Time" TIMESTAMP DEFAULT NULL, |
|
46 |
"Bool2" CHAR(1) DEFAULT NULL, |
|
47 |
"String" CLOB DEFAULT NULL, |
|
48 |
"Bool3" CHAR(1) DEFAULT NULL, |
|
49 |
"Double" BINARY_DOUBLE DEFAULT NULL, |
|
50 |
"Bool4" CHAR(1) DEFAULT NULL, |
|
51 |
"Float" BINARY_FLOAT DEFAULT NULL, |
|
52 |
"Bool5" CHAR(1) DEFAULT NULL, |
|
53 |
"Decimal" NUMBER(6,3) DEFAULT NULL, |
|
54 |
"GEOMETRY" SDO_GEOMETRY DEFAULT NULL |
|
55 |
); |
|
56 |
|
|
57 |
ALTER TABLE "public"."TEST" ADD PRIMARY KEY ("ID"); |
|
58 |
|
|
59 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS |
|
60 |
WHERE F_TABLE_SCHEMA = 'public' |
|
61 |
AND F_TABLE_NAME = 'TEST' |
|
62 |
AND F_GEOMETRY_COLUMN = 'GEOMETRY'; |
|
63 |
|
|
64 |
INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS ( |
|
65 |
F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) |
|
66 |
VALUES ('public', 'TEST', 'GEOMETRY', 1); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/dropTable.sql | ||
---|---|---|
1 |
|
|
2 |
-- Drop table SQL |
|
3 |
DROP TABLE "public"."test"; |
|
4 |
|
|
5 |
DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS WHERE F_TABLE_SCHEMA = 'public' AND F_TABLE_NAME = 'test'; |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/org/gvsig/oracle/dal/date.sql | ||
---|---|---|
1 |
|
|
2 |
-- Date SQL |
|
3 |
|
|
4 |
SELECT |
|
5 |
"ID", "Byte", "Bool1", "Long", "Timestamp", "Date", "Time", "Bool2", |
|
6 |
"String", "Bool3", "Double", "Bool4", "Float", "Bool5", "Decimal", |
|
7 |
NVL2(("Geometry"),("Geometry").Get_WKB(),NULL) |
|
8 |
FROM "public"."test" |
|
9 |
WHERE ( |
|
10 |
(( |
|
11 |
(( ("Time") > (TIMESTAMP '1970-01-01 01:02:03') )) |
|
12 |
AND |
|
13 |
(( ("Time") < (TIMESTAMP '1970-01-01 20:52:55') )) |
|
14 |
)) |
|
15 |
OR |
|
16 |
(( |
|
17 |
(( ("Date") > (DATE '2019-02-17') )) |
|
18 |
AND |
|
19 |
(( ("Date") < (DATE '2020-02-23') )) |
|
20 |
)) |
|
21 |
); |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/resources/log4j.properties | ||
---|---|---|
1 |
log4j.rootLogger=INFO, stdout |
|
2 |
|
|
3 |
log4j.appender.stdout=org.apache.log4j.ConsoleAppender |
|
4 |
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout |
|
5 |
|
|
6 |
# Pattern to output the caller's file name and line number. |
|
7 |
log4j.appender.stdout.layout.ConversionPattern=%5p %r [%t] (%F:%L) - %m%n |
|
8 |
|
|
9 |
log4j.logger.org.gvsig.andami.plugins=INFO |
|
10 |
log4j.logger.org.gvsig.tools=INFO |
|
11 |
log4j.logger.org.gvsig.tools.dataTypes=INFO |
|
12 |
log4j.logger.org.gvsig.tools.library=INFO |
|
13 |
log4j.logger.org.gvsig.tools.persistence=INFO |
|
14 |
log4j.logger.org.gvsig.i18n.Messages=INFO |
|
15 |
log4j.logger.org.gvsig.installer.lib.impl.DefaultDependenciesCalculator=INFO |
|
16 |
# |
|
17 |
# JCRS |
|
18 |
log4j.logger.org.gvsig.crs=INFO |
|
19 |
log4j.logger.es.idr.teledeteccion.connection=INFO |
|
20 |
log4j.logger.org.geotools.referencing.operation.projection=INFO |
|
21 |
# |
|
22 |
# JDBC/BBDD |
|
23 |
# Core |
|
24 |
log4j.logger.org.gvsig.fmap.dal.store.jdbc=DEBUG |
|
25 |
log4j.logger.org.gvsig.fmap.dal.store.jdbc2=DEBUG |
|
26 |
log4j.logger.org.gvsig.fmap.dal.feature.spi=INFO |
|
27 |
# Data providers |
|
28 |
log4j.logger.org.gvsig.fmap.dal.store.h2=INFO |
|
29 |
log4j.logger.org.gvsig.postgresql.dal=INFO |
|
30 |
log4j.logger.org.gvsig.mssqlserver.dal=INFO |
|
31 |
log4j.logger.org.gvsig.mysql.dal=INFO |
|
32 |
log4j.logger.org.gvsig.spatialite.dal=INFO |
|
33 |
log4j.logger.org.gvsig.oracle.dal=DEBUG |
|
34 |
# Exoport providers |
|
35 |
log4j.logger.org.gvsig.exportto.swing.prov.jdbc=INFO |
|
36 |
log4j.logger.org.gvsig.exportto.swing.prov.h2=INFO |
|
37 |
# |
|
38 |
# shp/dbf driver |
|
39 |
log4j.logger.org.gvsig.fmap.dal.store.shp=INFO |
|
40 |
log4j.logger.org.gvsig.fmap.dal.store.dbf=INFO |
|
41 |
# |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/OracleSQLBuilderTest.java | ||
---|---|---|
1 |
package org.gvsig.oracle.dal; |
|
2 |
|
|
3 |
|
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.apache.commons.lang3.ArrayUtils; |
|
6 |
import org.cresques.cts.IProjection; |
|
7 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
|
8 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilder; |
|
9 |
import org.gvsig.expressionevaluator.GeometryExpressionBuilderHelper; |
|
10 |
import org.gvsig.fmap.crs.CRSFactory; |
|
11 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
12 |
import org.gvsig.fmap.dal.SQLBuilder.Privilege; |
|
13 |
import org.gvsig.fmap.dal.feature.spi.SQLBuilderBase; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.OperationsFactoryBase; |
|
16 |
import org.gvsig.fmap.geom.DataTypes; |
|
17 |
import org.gvsig.fmap.geom.Geometry; |
|
18 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
19 |
import org.gvsig.fmap.geom.GeometryManager; |
|
20 |
import org.gvsig.fmap.geom.primitive.Polygon; |
|
21 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
22 |
|
|
23 |
public class OracleSQLBuilderTest extends TestCase { |
|
24 |
|
|
25 |
public OracleSQLBuilderTest(String testName) { |
|
26 |
super(testName); |
|
27 |
} |
|
28 |
|
|
29 |
@Override |
|
30 |
protected void setUp() throws Exception { |
|
31 |
super.setUp(); |
|
32 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
33 |
} |
|
34 |
|
|
35 |
@Override |
|
36 |
protected void tearDown() throws Exception { |
|
37 |
super.tearDown(); |
|
38 |
} |
|
39 |
|
|
40 |
private SQLBuilder createSQLBuilder() { |
|
41 |
return new OracleSQLBuilder(TestUtils.getJDBCHelper()); |
|
42 |
} |
|
43 |
|
|
44 |
public void testCalculateEnvelopeOfColumn() throws Exception { |
|
45 |
|
|
46 |
TableReference table = new OperationsFactoryBase.DefaultTableReference("master","dbo","test1", null); |
|
47 |
String columnName = "geom"; |
|
48 |
|
|
49 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
50 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
51 |
|
|
52 |
sqlbuilder.select().column().value( |
|
53 |
expbuilder.as_geometry( |
|
54 |
expbuilder.ST_ExtentAggregate( |
|
55 |
expbuilder.column(columnName) |
|
56 |
) |
|
57 |
) |
|
58 |
); |
|
59 |
//sqlbuilder.select().group_by(expbuilder.column(columnName)); |
|
60 |
sqlbuilder.select().from().table() |
|
61 |
.database(table.getDatabase()) |
|
62 |
.schema(table.getSchema()) |
|
63 |
.name(table.getTable()); |
|
64 |
sqlbuilder.select().from().subquery(table.getSubquery()); |
|
65 |
|
|
66 |
sqlbuilder.select().where().set( |
|
67 |
expbuilder.not_is_null(expbuilder.column(columnName)) |
|
68 |
); |
|
69 |
|
|
70 |
System.out.println("# Test:: testCalculateEnvelopeOfColumn"); |
|
71 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
72 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
73 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
74 |
assertEquals( |
|
75 |
"SELECT NVL2((SDO_AGGR_MBR(\"geom\")),(SDO_AGGR_MBR(\"geom\")).Get_WKB(),NULL) FROM \"dbo\".\"test1\" WHERE ( (\"geom\") IS NOT NULL )", |
|
76 |
sqlbuilder.toString() |
|
77 |
); |
|
78 |
assertEquals( |
|
79 |
"[geom]", |
|
80 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
81 |
); |
|
82 |
assertEquals( |
|
83 |
"[]", |
|
84 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
85 |
); |
|
86 |
} |
|
87 |
|
|
88 |
public void testCalculateEnvelope() throws Exception { |
|
89 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
90 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
91 |
|
|
92 |
Polygon limit = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D); |
|
93 |
limit.addVertex(0, 0); |
|
94 |
limit.addVertex(0, 100); |
|
95 |
limit.addVertex(100, 100); |
|
96 |
limit.addVertex(100, 0); |
|
97 |
limit.addVertex(0, 0); |
|
98 |
|
|
99 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
100 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
101 |
|
|
102 |
sqlbuilder.select().column().value( |
|
103 |
expbuilder.as_geometry( |
|
104 |
expbuilder.ST_ExtentAggregate( |
|
105 |
expbuilder.column("the_geom") |
|
106 |
) |
|
107 |
) |
|
108 |
).as("envelope"); |
|
109 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
110 |
sqlbuilder.select().where().set( |
|
111 |
expbuilder.ST_Intersects( |
|
112 |
expbuilder.ST_Envelope( |
|
113 |
expbuilder.column("the_geom") |
|
114 |
), |
|
115 |
expbuilder.geometry(limit, proj) |
|
116 |
) |
|
117 |
); |
|
118 |
sqlbuilder.select().where().and( |
|
119 |
expbuilder.custom("x = 27") |
|
120 |
); |
|
121 |
|
|
122 |
System.out.println("# Test:: testCalculateEnvelope"); |
|
123 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
124 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
125 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
126 |
assertEquals( |
|
127 |
"SELECT NVL2((SDO_AGGR_MBR(\"the_geom\")),(SDO_AGGR_MBR(\"the_geom\")).Get_WKB(),NULL) \"envelope\" FROM \"dbo\".\"test1\" WHERE ( ((SDO_RELATE(SDO_GEOM.SDO_MBR(\"the_geom\"), SDO_GEOMETRY((TO_BLOB(HEXTORAW('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'))), (4326)), 'mask=ANYINTERACT') = 'TRUE')) AND (x = 27) )", |
|
128 |
sqlbuilder.toString() |
|
129 |
); |
|
130 |
assertEquals( |
|
131 |
"[the_geom]", |
|
132 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
133 |
); |
|
134 |
assertEquals( |
|
135 |
"[]", |
|
136 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
137 |
); |
|
138 |
} |
|
139 |
|
|
140 |
public void testCount() throws Exception { |
|
141 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
142 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
143 |
|
|
144 |
sqlbuilder.select().column().value(sqlbuilder.count().all()); |
|
145 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
146 |
sqlbuilder.select().from().subquery(null); |
|
147 |
sqlbuilder.select().where().set( expbuilder.custom("pp = 200")); |
|
148 |
|
|
149 |
System.out.println("# Test:: testCount"); |
|
150 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
151 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
152 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
153 |
|
|
154 |
//# Test:: testCount |
|
155 |
//# SQL:: SELECT COUNT(*) FROM "test1" WHERE pp = 200 |
|
156 |
//# Variables:: [] |
|
157 |
//# Parametros:: [] |
|
158 |
|
|
159 |
assertEquals( |
|
160 |
"SELECT COUNT(*) FROM \"dbo\".\"test1\" WHERE pp = 200", |
|
161 |
sqlbuilder.toString() |
|
162 |
); |
|
163 |
assertEquals( |
|
164 |
"[]", |
|
165 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
166 |
); |
|
167 |
assertEquals( |
|
168 |
"[]", |
|
169 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
170 |
); |
|
171 |
} |
|
172 |
|
|
173 |
public void testCreateTable() throws Exception { |
|
174 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
175 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
176 |
|
|
177 |
sqlbuilder.create_table().table().database("master").schema("dbo").name("test1"); |
|
178 |
sqlbuilder.create_table().add_column( |
|
179 |
"name", |
|
180 |
DataTypes.STRING, |
|
181 |
45, |
|
182 |
0, |
|
183 |
0, |
|
184 |
false, |
|
185 |
false, |
|
186 |
true, |
|
187 |
false, |
|
188 |
null |
|
189 |
); |
|
190 |
sqlbuilder.create_table().add_column( |
|
191 |
"id", |
|
192 |
DataTypes.INT, |
|
193 |
0, |
|
194 |
0, |
|
195 |
0, |
|
196 |
true, |
|
197 |
false, |
|
198 |
false, |
|
199 |
true, |
|
200 |
0 |
|
201 |
); |
|
202 |
sqlbuilder.create_table().add_column( |
|
203 |
"geom", |
|
204 |
DataTypes.GEOMETRY, |
|
205 |
0, |
|
206 |
0, |
|
207 |
0, |
|
208 |
false, |
|
209 |
false, |
|
210 |
true, |
|
211 |
false, |
|
212 |
null |
|
213 |
); |
|
214 |
|
|
215 |
|
|
216 |
// CREATE TABLE "test1" ("name" VARCHAR(45) DEFAULT NULL, "id" INTEGER PRIMARY KEY AUTO_INCREMENT DEFAULT '0' NOT NULL, "geom" GEOMETRY ); ALTER TABLE "test1" ADD CONSTRAINT IF NOT EXISTS "constraint_test1_geom_dim" CHECK ST_CoordDim("geom") = 2 |
|
217 |
System.out.println("# Test:: testCreateTable"); |
|
218 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
219 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
220 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
221 |
assertEquals( |
|
222 |
"CREATE TABLE \"dbo\".\"TEST1\" (\"name\" VARCHAR(45) DEFAULT NULL, \"id\" NUMBER(9,0), \"geom\" SDO_GEOMETRY DEFAULT NULL ); ALTER TABLE \"dbo\".\"TEST1\" ADD PRIMARY KEY (\"id\"); CREATE SEQUENCE \"GVSEQ_TEST1_ID\"; CREATE OR REPLACE TRIGGER \"GVSER_TEST1_ID\" BEFORE INSERT ON \"dbo\".\"TEST1\" FOR EACH ROW BEGIN SELECT \"GVSEQ_TEST1_ID\".NEXTVAL INTO :new.\"id\" FROM dual; END;; DELETE FROM MDSYS.OGIS_GEOMETRY_COLUMNS WHERE F_TABLE_SCHEMA = 'dbo' AND F_TABLE_NAME = 'TEST1' AND F_GEOMETRY_COLUMN = 'geom'; INSERT INTO MDSYS.OGIS_GEOMETRY_COLUMNS (F_TABLE_SCHEMA, F_TABLE_NAME, F_GEOMETRY_COLUMN, GEOMETRY_TYPE) VALUES ('dbo', 'TEST1', 'geom', 0)", |
|
223 |
sqlbuilder.toString() |
|
224 |
); |
|
225 |
assertEquals( |
|
226 |
"[]", |
|
227 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
228 |
); |
|
229 |
assertEquals( |
|
230 |
"[]", |
|
231 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
232 |
); |
|
233 |
} |
|
234 |
|
|
235 |
public void testDropTable() throws Exception { |
|
236 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
237 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
238 |
|
|
239 |
sqlbuilder.drop_table().table().database("master").schema("dbo").name("test1"); |
|
240 |
|
|
241 |
// DROP TABLE "test1" |
|
242 |
|
|
243 |
System.out.println("# Test:: testDropTable"); |
|
244 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
245 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
246 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
247 |
assertEquals( |
|
248 |
"DROP TABLE \"dbo\".\"test1\"", |
|
249 |
sqlbuilder.toString() |
|
250 |
); |
|
251 |
assertEquals( |
|
252 |
"[]", |
|
253 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
254 |
); |
|
255 |
assertEquals( |
|
256 |
"[]", |
|
257 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
258 |
); |
|
259 |
} |
|
260 |
|
|
261 |
public void testFetchFeatureProviderByReference() throws Exception { |
|
262 |
SQLBuilder sqlbuilder = new SQLBuilderBase(); |
|
263 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
264 |
|
|
265 |
String value = "yoyo"; |
|
266 |
sqlbuilder.select().column().name("name"); |
|
267 |
sqlbuilder.select().column().name("id"); |
|
268 |
sqlbuilder.select().column().name("geom").as_geometry(); |
|
269 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
270 |
sqlbuilder.select().where().set( |
|
271 |
expbuilder.eq( |
|
272 |
expbuilder.column("name"), |
|
273 |
expbuilder.parameter(value).as_constant() |
|
274 |
) |
|
275 |
); |
|
276 |
sqlbuilder.select().limit(1); |
|
277 |
|
|
278 |
// SELECT "name", "id", ST_AsBinary("geom") FROM "master"."dbo"."test1" WHERE ( ("name") = (?) ) LIMIT 1 |
|
279 |
|
|
280 |
System.out.println("# Test:: testFetchFeatureProviderByReference"); |
|
281 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
282 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
283 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
284 |
assertEquals( |
|
285 |
"SELECT \"name\", \"id\", ST_AsBinary(\"geom\") FROM \"master\".\"dbo\".\"test1\" WHERE ( (\"name\") = (?) ) LIMIT 1", |
|
286 |
sqlbuilder.toString() |
|
287 |
); |
|
288 |
assertEquals( |
|
289 |
"[geom, id, name]", |
|
290 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
291 |
); |
|
292 |
assertEquals( |
|
293 |
"['yoyo']", |
|
294 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
295 |
); |
|
296 |
} |
|
297 |
|
|
298 |
public void testFetchFeatureType() throws Exception { |
|
299 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
300 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
301 |
|
|
302 |
sqlbuilder.select().column().all(); |
|
303 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
304 |
sqlbuilder.select().limit(1); |
|
305 |
|
|
306 |
System.out.println("# Test:: testFetchFeatureType"); |
|
307 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
308 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
309 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
310 |
|
|
311 |
//# Test:: testFetchFeatureType |
|
312 |
//# SQL:: SELECT * FROM "test1" LIMIT 1 |
|
313 |
//# Variables:: [] |
|
314 |
//# Parametros:: [] |
|
315 |
|
|
316 |
assertEquals( |
|
317 |
"SELECT * FROM \"dbo\".\"test1\" WHERE ROWNUM <= 1", |
|
318 |
sqlbuilder.toString() |
|
319 |
); |
|
320 |
assertEquals( |
|
321 |
"[]", |
|
322 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
323 |
); |
|
324 |
assertEquals( |
|
325 |
"[]", |
|
326 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
327 |
); |
|
328 |
} |
|
329 |
|
|
330 |
public void testPerformDeletes() throws Exception { |
|
331 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
332 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
333 |
|
|
334 |
sqlbuilder.delete().table().database("master").schema("dbo").name("test1"); |
|
335 |
sqlbuilder.delete().where().set( |
|
336 |
expbuilder.eq( |
|
337 |
expbuilder.column("id1"), |
|
338 |
expbuilder.parameter("id1").as_variable() |
|
339 |
) |
|
340 |
); |
|
341 |
sqlbuilder.delete().where().and( |
|
342 |
expbuilder.eq( |
|
343 |
expbuilder.column("id2"), |
|
344 |
expbuilder.parameter("id2").as_variable() |
|
345 |
) |
|
346 |
); |
|
347 |
|
|
348 |
System.out.println("# Test:: testPerformDeletes"); |
|
349 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
350 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
351 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
352 |
assertEquals( |
|
353 |
"DELETE FROM \"dbo\".\"test1\" WHERE ( (( (\"id1\") = (?) )) AND (( (\"id2\") = (?) )) )", |
|
354 |
sqlbuilder.toString() |
|
355 |
); |
|
356 |
assertEquals( |
|
357 |
"[id1, id2]", |
|
358 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
359 |
); |
|
360 |
assertEquals( |
|
361 |
"[\"id1\", \"id2\"]", |
|
362 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
363 |
); |
|
364 |
} |
|
365 |
|
|
366 |
public void testPerformInserts1() throws Exception { |
|
367 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
368 |
|
|
369 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
370 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
371 |
|
|
372 |
sqlbuilder.insert().table().database("master").schema("dbo").name("test1"); |
|
373 |
sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id")); |
|
374 |
sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name")); |
|
375 |
sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj)); |
|
376 |
|
|
377 |
System.out.println("# Test:: testPerformInserts1"); |
|
378 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
379 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
380 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
381 |
assertEquals( |
|
382 |
"INSERT INTO \"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, NVL2((?),SDO_GEOMETRY((?), (4326)),NULL) )", |
|
383 |
sqlbuilder.toString() |
|
384 |
); |
|
385 |
assertEquals( |
|
386 |
"[geom, id, name]", |
|
387 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
388 |
); |
|
389 |
assertEquals( |
|
390 |
"[\"id\", \"name\", \"geom\", \"geom\"]", |
|
391 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
392 |
); |
|
393 |
} |
|
394 |
|
|
395 |
public void testPerformInserts2() throws Exception { |
|
396 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
397 |
|
|
398 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
399 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
400 |
|
|
401 |
sqlbuilder.insert().table().database("master").schema("dbo").name("test1"); |
|
402 |
sqlbuilder.insert().column().name("id").with_value(expbuilder.parameter("id")); |
|
403 |
sqlbuilder.insert().column().name("name").with_value(expbuilder.parameter("name")); |
|
404 |
sqlbuilder.insert().column().name("geom").with_value(expbuilder.parameter("geom").as_geometry_variable().srs(proj)); |
|
405 |
|
|
406 |
System.out.println("# Test:: testPerformInserts2"); |
|
407 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
408 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
409 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
410 |
assertEquals( |
|
411 |
"INSERT INTO \"dbo\".\"test1\" ( \"id\", \"name\", \"geom\" ) VALUES ( ?, ?, NVL2((?),SDO_GEOMETRY((?), (4326)),NULL) )", |
|
412 |
sqlbuilder.toString() |
|
413 |
); |
|
414 |
assertEquals( |
|
415 |
"[geom, id, name]", |
|
416 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
417 |
); |
|
418 |
assertEquals( |
|
419 |
"[\"id\", \"name\", \"geom\", \"geom\"]", |
|
420 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
421 |
); |
|
422 |
} |
|
423 |
|
|
424 |
public void testPerformUpdates1() throws Exception { |
|
425 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
426 |
|
|
427 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
428 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
429 |
|
|
430 |
sqlbuilder.update().table().database("master").schema("dbo").name("test1"); |
|
431 |
sqlbuilder.update().where().set( |
|
432 |
expbuilder.eq( |
|
433 |
expbuilder.column("id"), |
|
434 |
expbuilder.parameter("id").as_variable() |
|
435 |
) |
|
436 |
); |
|
437 |
sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name")); |
|
438 |
sqlbuilder.update().column().name("geom").with_value( |
|
439 |
expbuilder.parameter("geom").as_geometry_variable().srs(proj) |
|
440 |
); |
|
441 |
|
|
442 |
System.out.println("# Test:: testPerformUpdates"); |
|
443 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
444 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
445 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
446 |
assertEquals( |
|
447 |
"UPDATE \"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = NVL2((?),SDO_GEOMETRY((?), (4326)),NULL) WHERE ( (\"id\") = (?) )", |
|
448 |
sqlbuilder.toString() |
|
449 |
); |
|
450 |
assertEquals( |
|
451 |
"[geom, id, name]", |
|
452 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
453 |
); |
|
454 |
assertEquals( |
|
455 |
"[\"name\", \"geom\", \"geom\", \"id\"]", |
|
456 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
457 |
); |
|
458 |
} |
|
459 |
|
|
460 |
public void testPerformUpdates2() throws Exception { |
|
461 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
462 |
|
|
463 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
464 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
465 |
|
|
466 |
sqlbuilder.update().table().database("master").schema("dbo").name("test1"); |
|
467 |
sqlbuilder.update().where().set( |
|
468 |
expbuilder.eq( |
|
469 |
expbuilder.column("id"), |
|
470 |
expbuilder.parameter("id").as_variable() |
|
471 |
) |
|
472 |
); |
|
473 |
sqlbuilder.update().column().name("name").with_value(expbuilder.parameter("name")); |
|
474 |
sqlbuilder.update().column().name("geom").with_value( |
|
475 |
expbuilder.parameter("geom").as_geometry_variable() |
|
476 |
.srs(expbuilder.parameter().value(proj)) |
|
477 |
); |
|
478 |
|
|
479 |
System.out.println("# Test:: testPerformUpdates"); |
|
480 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
481 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
482 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
483 |
assertEquals( |
|
484 |
"UPDATE \"dbo\".\"test1\" SET \"name\" = ?, \"geom\" = NVL2((?),SDO_GEOMETRY((?), (?)),NULL) WHERE ( (\"id\") = (?) )", |
|
485 |
sqlbuilder.toString() |
|
486 |
); |
|
487 |
|
|
488 |
assertEquals( |
|
489 |
"[geom, id, name]", |
|
490 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
491 |
); |
|
492 |
assertEquals( |
|
493 |
"[\"name\", \"geom\", \"geom\", 4326, \"id\"]", |
|
494 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
495 |
); |
|
496 |
} |
|
497 |
|
|
498 |
public void testGrant1() throws Exception { |
|
499 |
|
|
500 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
501 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
502 |
|
|
503 |
sqlbuilder.grant().table().database("master").schema("dbo").name("test1"); |
|
504 |
sqlbuilder.grant().role("prueba").select().insert().update(); |
|
505 |
sqlbuilder.grant().role("gis").all(); |
|
506 |
|
|
507 |
|
|
508 |
System.out.println("# Test:: testGrant1"); |
|
509 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
510 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
511 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
512 |
assertEquals( |
|
513 |
"", |
|
514 |
sqlbuilder.toString() |
|
515 |
); |
|
516 |
assertEquals( |
|
517 |
"[]", |
|
518 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
519 |
); |
|
520 |
assertEquals( |
|
521 |
"[]", |
|
522 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
523 |
); |
|
524 |
} |
|
525 |
|
|
526 |
public void testGrant2() throws Exception { |
|
527 |
|
|
528 |
SQLBuilder sqlbuilder = new SQLBuilderBase(); |
|
529 |
ExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
530 |
|
|
531 |
sqlbuilder.grant().table().database("master").schema("dbo").name("test1"); |
|
532 |
sqlbuilder.grant().role("prueba").privilege(Privilege.SELECT) |
|
533 |
.privilege(Privilege.INSERT) |
|
534 |
.privilege(Privilege.UPDATE); |
|
535 |
sqlbuilder.grant().role("gis").privilege(Privilege.ALL); |
|
536 |
|
|
537 |
|
|
538 |
System.out.println("# Test:: testGrant2"); |
|
539 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
540 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
541 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
542 |
assertEquals( |
|
543 |
"", |
|
544 |
sqlbuilder.toString() |
|
545 |
); |
|
546 |
assertEquals( |
|
547 |
"[]", |
|
548 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
549 |
); |
|
550 |
assertEquals( |
|
551 |
"[]", |
|
552 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
553 |
); |
|
554 |
} |
|
555 |
|
|
556 |
public void testSelect() throws Exception { |
|
557 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
558 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
559 |
|
|
560 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
561 |
|
|
562 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
563 |
Polygon limit = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D); |
|
564 |
limit.addVertex(0, 0); |
|
565 |
limit.addVertex(0, 100); |
|
566 |
limit.addVertex(100, 100); |
|
567 |
limit.addVertex(100, 0); |
|
568 |
limit.addVertex(0, 0); |
|
569 |
|
|
570 |
sqlbuilder.select().column().value(expbuilder.parameter("Geometry").as_geometry_variable().srs(proj)); |
|
571 |
sqlbuilder.select().column().value(expbuilder.parameter("ID").as_variable()); |
|
572 |
sqlbuilder.select().column().value(expbuilder.constant(limit)); |
|
573 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
574 |
|
|
575 |
System.out.println("# Test:: testSelect"); |
|
576 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
577 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
578 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
579 |
|
|
580 |
//# Test:: testCount |
|
581 |
//# SQL:: SELECT NVL2((?),SDO_GEOMETRY((?).Get_WKB(), (?)),NULL), "ID", SDO_GEOMETRY((TO_BLOB(HEXTORAW('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'))), (4326)) FROM "dbo"."test1" |
|
582 |
//# Variables:: [] |
|
583 |
//# Parametros:: ["Geometry", "Geometry", "ID"] |
|
584 |
|
|
585 |
assertEquals( |
|
586 |
"SELECT NVL2((?),SDO_GEOMETRY((?), (4326)),NULL), ?, SDO_GEOMETRY((TO_BLOB(HEXTORAW('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'))), (0)) FROM \"dbo\".\"test1\"", |
|
587 |
sqlbuilder.toString() |
|
588 |
); |
|
589 |
assertEquals( |
|
590 |
"[]", |
|
591 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
592 |
); |
|
593 |
assertEquals( |
|
594 |
"[\"Geometry\", \"Geometry\", \"ID\"]", |
|
595 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
596 |
); |
|
597 |
} |
|
598 |
|
|
599 |
|
|
600 |
public void testSelectIntersect() throws Exception { |
|
601 |
SQLBuilder sqlbuilder = createSQLBuilder(); |
|
602 |
GeometryExpressionBuilder expbuilder = sqlbuilder.expression(); |
|
603 |
|
|
604 |
IProjection proj = CRSFactory.getCRS("EPSG:4326"); |
|
605 |
|
|
606 |
GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
607 |
Polygon envelope = geometryManager.createPolygon(Geometry.SUBTYPES.GEOM2D); |
|
608 |
envelope.addVertex(0, 0); |
|
609 |
envelope.addVertex(0, 100); |
|
610 |
envelope.addVertex(100, 100); |
|
611 |
envelope.addVertex(100, 0); |
|
612 |
envelope.addVertex(0, 0); |
|
613 |
|
|
614 |
GeometryExpressionBuilderHelper.GeometryParameter column = expbuilder.parameter("Geometry").as_geometry_variable().srs(proj); |
|
615 |
|
|
616 |
sqlbuilder.select().column().value(column); |
|
617 |
sqlbuilder.select().column().value(expbuilder.parameter("ID").as_variable()); |
|
618 |
sqlbuilder.select().from().table().database("master").schema("dbo").name("test1"); |
|
619 |
sqlbuilder.select().where().set( |
|
620 |
expbuilder.not_is_null(column)).and( |
|
621 |
expbuilder.ST_Intersects( |
|
622 |
column, |
|
623 |
expbuilder.geometry(envelope, proj) |
|
624 |
) |
|
625 |
); |
|
626 |
|
|
627 |
System.out.println("# Test:: testSelect"); |
|
628 |
System.out.println("# SQL:: " + sqlbuilder.toString()); |
|
629 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
|
630 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
|
631 |
|
|
632 |
//# Test:: testCount |
|
633 |
//# SQL:: SELECT NVL2((?),SDO_GEOMETRY((?).Get_WKB(), (?)),NULL), "ID", SDO_GEOMETRY((TO_BLOB(HEXTORAW('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'))), (4326)) FROM "dbo"."test1" |
|
634 |
//# Variables:: [] |
|
635 |
//# Parametros:: ["Geometry", "Geometry", "ID"] |
|
636 |
|
|
637 |
assertEquals( |
|
638 |
"SELECT NVL2((?),SDO_GEOMETRY((?), (4326)),NULL), ? FROM \"dbo\".\"test1\" WHERE ( (( (NVL2((?),SDO_GEOMETRY((?), (4326)),NULL)) IS NOT NULL )) AND ((SDO_RELATE(NVL2((?),SDO_GEOMETRY((?), (4326)),NULL), SDO_GEOMETRY((TO_BLOB(HEXTORAW('000000000300000001000000050000000000000000000000000000000000000000000000004059000000000000405900000000000040590000000000004059000000000000000000000000000000000000000000000000000000000000'))), (4326)), 'mask=ANYINTERACT') = 'TRUE')) )", |
|
639 |
sqlbuilder.toString() |
|
640 |
); |
|
641 |
assertEquals( |
|
642 |
"[]", |
|
643 |
ArrayUtils.toString(sqlbuilder.variables_names()) |
|
644 |
); |
|
645 |
assertEquals( |
|
646 |
"[\"Geometry\", \"Geometry\", \"ID\", \"Geometry\", \"Geometry\", \"Geometry\", \"Geometry\"]", |
|
647 |
ArrayUtils.toString(sqlbuilder.parameters_names()) |
|
648 |
); |
|
649 |
} |
|
650 |
|
|
651 |
|
|
652 |
} |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/TestUtils.java | ||
---|---|---|
1 |
package org.gvsig.oracle.dal; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileInputStream; |
|
5 |
import java.io.FileOutputStream; |
|
6 |
import java.net.URL; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.List; |
|
9 |
import java.util.Properties; |
|
10 |
import org.apache.commons.io.FileUtils; |
|
11 |
import org.apache.commons.io.FilenameUtils; |
|
12 |
import org.apache.commons.lang3.StringUtils; |
|
13 |
import org.gvsig.fmap.dal.DALLocator; |
|
14 |
import org.gvsig.fmap.dal.DataManager; |
|
15 |
import org.gvsig.fmap.dal.DataStore; |
|
16 |
import org.gvsig.fmap.dal.feature.Feature; |
|
17 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
18 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
|
19 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
20 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
21 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
22 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
23 |
import org.gvsig.fmap.dal.store.jdbc2.spi.FakeConnectionProvider; |
|
24 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
|
25 |
import org.slf4j.Logger; |
|
26 |
import org.slf4j.LoggerFactory; |
|
27 |
|
|
28 |
public class TestUtils { |
|
29 |
|
|
30 |
public static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class); |
|
31 |
|
|
32 |
public static final String PROVIDER_NAME = OracleLibrary.NAME; |
|
33 |
public static final String TEST_USER = "dba"; |
|
34 |
public static final String TEST_SCHEMA = "public"; |
|
35 |
public static final String TEST_DB_NAME = "dbtest"; |
|
36 |
|
|
37 |
public static OracleConnectionParameters buildDBConnection(String dbname) throws Exception { |
|
38 |
DataManager dataManager = DALLocator.getDataManager(); |
|
39 |
OracleConnectionParameters conn = (OracleConnectionParameters) |
|
40 |
dataManager.createServerExplorerParameters(OracleLibrary.NAME); |
|
41 |
|
|
42 |
Properties p = new Properties(); |
|
43 |
File userDirectory = FileUtils.getUserDirectory(); |
|
44 |
String properties = FilenameUtils.concat( |
|
45 |
userDirectory.getCanonicalPath(), |
|
46 |
".gvSIG_Oracle_testDBConnection.properties"); |
|
47 |
File fileProperties = new File(properties); |
|
48 |
if(!fileProperties.exists()) { |
|
49 |
p.setProperty("host", "127.0.0.1"); |
|
50 |
p.setProperty("port", "1521"); |
|
51 |
p.setProperty("dbuser", TEST_USER); |
|
52 |
p.setProperty("schema", TEST_SCHEMA); |
|
53 |
p.setProperty("password", "PASSWD"); |
|
54 |
p.setProperty("dbname", TEST_DB_NAME); |
|
55 |
p.store(new FileOutputStream(properties), "Oracle test DB connection"); |
|
56 |
} else { |
|
57 |
FileInputStream fis = new FileInputStream(properties); |
|
58 |
p.load(fis); |
|
59 |
} |
|
60 |
|
|
61 |
conn.setDynValue("host", p.getProperty("host", null)); |
|
62 |
conn.setDynValue("port", p.getProperty("port", null)); |
|
63 |
conn.setDynValue("dbuser", p.getProperty("dbuser", null)); |
|
64 |
conn.setDynValue("schema", p.getProperty("schema", null)); |
|
65 |
conn.setDynValue("password", p.getProperty("password", null)); |
|
66 |
conn.setDynValue("dbname", p.getProperty("dbname", null)); |
|
67 |
|
|
68 |
return conn; |
|
69 |
} |
|
70 |
|
|
71 |
public static JDBCServerExplorer openServerExplorer(String dbname) throws Exception { |
|
72 |
DataManager dataManager = DALLocator.getDataManager(); |
|
73 |
OracleConnectionParameters conn = buildDBConnection(dbname); |
|
74 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
|
75 |
PROVIDER_NAME, conn |
|
76 |
); |
|
77 |
return explorer; |
|
78 |
} |
|
79 |
|
|
80 |
public static File getTargetFolder() throws Exception { |
|
81 |
URL url = TestUtils.class.getResource("/"); |
|
82 |
File x = new File(url.toURI()); |
|
83 |
File target = x.getParentFile(); |
|
84 |
return target; |
|
85 |
} |
|
86 |
|
|
87 |
public static File getResource(String name) throws Exception { |
|
88 |
File x = new File(getTargetFolder(), name); |
|
89 |
return x; |
|
90 |
} |
|
91 |
|
|
92 |
public static File getResourceAsFile(String pathname) throws Exception { |
|
93 |
URL url = TestUtils.class.getResource(pathname); |
|
94 |
File x = new File(url.toURI()); |
|
95 |
return x; |
|
96 |
} |
|
97 |
|
|
98 |
public static void removeDALResource(String dbname, String tableName) throws Exception { |
|
99 |
// OracleConnectionParameters connection = buildDBConnection(dbname); |
|
100 |
// DatabaseWorkspaceManager workspace = DALLocator.getDataManager().createDatabaseWorkspaceManager( |
|
101 |
// (DataServerExplorerParameters) connection |
|
102 |
// ); |
|
103 |
|
|
104 |
JDBCServerExplorer explorer = openServerExplorer(dbname); |
|
105 |
JDBCStoreParameters params = explorer.get(tableName); |
|
106 |
|
|
107 |
ResourcesStorage resources = explorer.getResourcesStorage(params); |
|
108 |
|
|
109 |
resources.remove("dal"); |
|
110 |
} |
|
111 |
|
|
112 |
public static FeatureStore openSourceStore1() throws Exception { |
|
113 |
DataManager dataManager = DALLocator.getDataManager(); |
|
114 |
File f = getResourceAsFile("/org/gvsig/oracle/dal/testCreateSource1.csv"); |
|
115 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
116 |
DataStore.CSV_PROVIDER_NAME, |
|
117 |
"file=",f, |
|
118 |
"automaticTypesDetection=", false, |
|
119 |
"locale=","en" |
|
120 |
); |
|
121 |
return store; |
|
122 |
} |
|
123 |
|
|
124 |
public static FeatureStore openSourceStoreShort() throws Exception { |
|
125 |
DataManager dataManager = DALLocator.getDataManager(); |
|
126 |
File f = getResourceAsFile("/org/gvsig/oracle/dal/testCreateSource_short.csv"); |
|
127 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
128 |
DataStore.CSV_PROVIDER_NAME, |
|
129 |
"file=",f, |
|
130 |
"automaticTypesDetection=", false, |
|
131 |
"locale=","en" |
|
132 |
); |
|
133 |
return store; |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
public static List<String> getSQLs(String name) throws Exception { |
|
138 |
File f = getResourceAsFile("/org/gvsig/oracle/dal/"+name); |
|
139 |
List<String> SQLs = new ArrayList<>(); |
|
140 |
List<String> lines = FileUtils.readLines(f); |
|
141 |
StringBuilder sb = new StringBuilder(); |
|
142 |
for (String line : lines) { |
|
143 |
line = StringUtils.stripStart(line, null); |
|
144 |
if( line.startsWith("--") ) { |
|
145 |
continue; |
|
146 |
} |
|
147 |
if( line.endsWith(";") ) { |
|
148 |
sb.append(line.substring(0, line.length()-1)); |
|
149 |
SQLs.add(sb.toString()); |
|
150 |
sb.setLength(0); |
|
151 |
} else { |
|
152 |
sb.append(line); |
|
153 |
} |
|
154 |
} |
|
155 |
return SQLs; |
|
156 |
} |
|
157 |
|
|
158 |
public static FeatureProvider getFeatureProvider(Feature feature) { |
|
159 |
return ((DefaultFeature)feature).getData(); |
|
160 |
} |
|
161 |
|
|
162 |
public static JDBCHelper getJDBCHelper() { |
|
163 |
return getJDBCHelper(TEST_SCHEMA, TEST_USER); |
|
164 |
} |
|
165 |
|
|
166 |
public static JDBCHelper getJDBCHelper(String schema, String user) { |
|
167 |
OracleExplorerParameters params = new OracleExplorerParameters(); |
|
168 |
params.setSchema(schema); |
|
169 |
params.setUser(user); |
|
170 |
params.setDBName(TEST_DB_NAME); |
|
171 |
OracleHelper helper = new OracleHelper(params, new FakeConnectionProvider(params)); |
|
172 |
return helper; |
|
173 |
} |
|
174 |
|
|
175 |
} |
org.gvsig.oracle/tags/org.gvsig.oracle-2.0.43/org.gvsig.oracle.provider/src/test/java/org/gvsig/oracle/dal/TestCreate.java | ||
---|---|---|
1 |
package org.gvsig.oracle.dal; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import static junit.framework.TestCase.assertEquals; |
|
7 |
import org.gvsig.fmap.dal.DALLocator; |
|
8 |
import org.gvsig.fmap.dal.DataManager; |
|
9 |
import org.gvsig.fmap.dal.DataTypes; |
|
10 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
11 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
12 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
13 |
import org.gvsig.fmap.dal.feature.Feature; |
|
14 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
15 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
16 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
17 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
|
18 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
19 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
|
20 |
import org.gvsig.fmap.geom.Geometry; |
|
21 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
22 |
import org.slf4j.Logger; |
|
23 |
import org.slf4j.LoggerFactory; |
|
24 |
|
|
25 |
public class TestCreate extends TestCase { |
|
26 |
|
|
27 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCreate.class); |
|
28 |
|
|
29 |
public static final String DBNAME = "testCreate"; |
|
30 |
|
|
31 |
public static final int ZERO_DEFAULT_DISPLAY_SIZE = 0; |
|
32 |
public static final int BYTE_DEFAULT_DISPLAY_SIZE = 4; |
|
33 |
public static final int FLOAT_DEFAULT_DISPLAY_SIZE = 4; |
|
34 |
public static final int DOUBLE_DEFAULT_DISPLAY_SIZE = 8; |
|
35 |
|
|
36 |
public TestCreate(String testName) { |
|
37 |
super(testName); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
protected void setUp() throws Exception { |
|
42 |
super.setUp(); |
|
43 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
protected void tearDown() throws Exception { |
|
48 |
super.tearDown(); |
|
49 |
} |
|
50 |
|
|
51 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
52 |
// public void testHello() {} |
|
53 |
protected String getProviderName() { |
|
54 |
return OracleLibrary.NAME; |
|
55 |
} |
|
56 |
|
|
57 |
protected String getTargetName() { |
|
58 |
return "testCreateTarget6".toUpperCase(); |
|
59 |
} |
|
60 |
|
|
61 |
protected FeatureStore openTargetStore1(JDBCServerExplorer explorer) throws Exception { |
|
62 |
JDBCStoreParameters params = explorer.get(getTargetName()); |
|
63 |
|
|
64 |
DataManager dataManager = DALLocator.getDataManager(); |
|
65 |
FeatureStore store; |
|
66 |
try { |
|
67 |
store = (FeatureStore) dataManager.openStore( |
|
68 |
getProviderName(), |
|
69 |
params |
|
70 |
); |
|
71 |
} catch (ValidateDataParametersException ex) { |
|
72 |
LOGGER.warn(ex.getLocalizedMessageStack()); |
|
73 |
throw ex; |
|
74 |
} |
|
75 |
return store; |
|
76 |
} |
|
77 |
|
|
78 |
protected void createFrom(JDBCServerExplorer explorer, FeatureStore sourceStore) throws Exception { |
|
79 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) explorer.getAddParameters( |
|
80 |
getTargetName() |
|
81 |
); |
|
82 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
|
83 |
ft.addAll(sourceStore.getDefaultFeatureType()); |
|
84 |
explorer.add(getProviderName(), params, true); |
|
85 |
} |
|
86 |
|
|
87 |
protected void checkTypes(JDBCServerExplorer explorer, FeatureType sourceFeatureType, boolean withDalResource) throws Exception { |
|
88 |
FeatureStore targetStore = openTargetStore1(explorer); |
|
89 |
FeatureType targetFeatureType = targetStore.getDefaultFeatureType(); |
|
90 |
|
|
91 |
assertEquals("Feature type size", sourceFeatureType.size(), targetFeatureType.size()); |
|
92 |
for (int i = 0; i < sourceFeatureType.size(); i++) { |
|
93 |
FeatureAttributeDescriptor sourceAttr = sourceFeatureType.get(i); |
|
94 |
FeatureAttributeDescriptor targetAttr = targetFeatureType.get(i); |
|
95 |
if (withDalResource) { |
|
96 |
if (sourceAttr.getType() == DataTypes.GEOMETRY) { |
|
97 |
assertEquals( |
|
98 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
99 |
sourceAttr.getName().toUpperCase(), |
|
100 |
targetAttr.getName() |
|
101 |
); |
|
102 |
} else { |
|
103 |
assertEquals( |
|
104 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
105 |
sourceAttr.getName(), |
|
106 |
targetAttr.getName() |
|
107 |
); |
|
108 |
} |
|
109 |
|
|
110 |
assertEquals( |
|
111 |
String.format("Field %s type mismatch", sourceAttr.getName()), |
|
112 |
sourceAttr.getDataTypeName(), |
|
113 |
targetAttr.getDataTypeName() |
|
114 |
); |
|
115 |
assertEquals( |
|
116 |
String.format("Field %s display size mismatch", sourceAttr.getName()), |
|
117 |
sourceAttr.getDisplaySize(), |
|
118 |
targetAttr.getDisplaySize() |
|
119 |
); |
|
120 |
assertEquals( |
|
121 |
String.format("Field %s size mismatch", sourceAttr.getName()), |
|
122 |
sourceAttr.getSize(), |
|
123 |
targetAttr.getSize() |
|
124 |
); |
|
125 |
assertEquals( |
|
126 |
String.format("Field %s precision mismatch", sourceAttr.getName()), |
|
127 |
sourceAttr.getPrecision(), |
|
128 |
targetAttr.getPrecision() |
|
129 |
); |
|
130 |
assertEquals( |
|
131 |
String.format("Field %s scale mismatch", sourceAttr.getName()), |
|
132 |
sourceAttr.getScale(), |
|
133 |
targetAttr.getScale() |
|
134 |
); |
|
135 |
|
|
136 |
if (sourceAttr.getType() == DataTypes.GEOMETRY) { |
|
137 |
assertEquals( |
|
138 |
String.format("Field %s geometry type mismatch", sourceAttr.getName()), |
|
139 |
sourceAttr.getGeomType().getName(), |
|
140 |
targetAttr.getGeomType().getName() |
|
141 |
); |
|
142 |
assertEquals( |
|
143 |
String.format("Field %s geometry SRS mismatch", sourceAttr.getName()), |
|
144 |
sourceAttr.getSRS().getAbrev(), |
|
145 |
targetAttr.getSRS().getAbrev() |
|
146 |
); |
|
147 |
|
|
148 |
} |
|
149 |
|
|
150 |
} else { |
|
151 |
switch (sourceAttr.getType()) { |
|
152 |
case DataTypes.BYTE: |
|
153 |
assertEquals( |
|
154 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
|
155 |
sourceAttr.getName(), |
|
156 |
targetAttr.getName() |
Also available in: Unified diff