Revision 44678
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.api/src/test/java/org/gvsig/fmap/dal/feature/DummyFeatureAttributeDescriptor.java | ||
---|---|---|
630 | 630 |
} |
631 | 631 |
|
632 | 632 |
@Override |
633 |
public boolean supportSize() { |
|
634 |
return false; |
|
635 |
} |
|
636 |
|
|
637 |
@Override |
|
638 |
public boolean supportPrecision() { |
|
639 |
return false; |
|
640 |
} |
|
641 |
|
|
642 |
@Override |
|
643 |
public boolean supportScale() { |
|
644 |
return false; |
|
645 |
} |
|
646 |
|
|
647 |
@Override |
|
648 | 633 |
public int getRoundMode() { |
649 | 634 |
return BigDecimal.ROUND_HALF_UP; |
650 | 635 |
} |
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/feature/FeatureAttributeDescriptor.java | ||
---|---|---|
107 | 107 |
public int getSize(); |
108 | 108 |
|
109 | 109 |
/** |
110 |
* Return true if the attribitute support the "size". Only String and |
|
111 |
* ByteArray support size. |
|
112 |
* |
|
113 |
* @return |
|
114 |
*/ |
|
115 |
public boolean supportSize(); |
|
116 |
|
|
117 |
/** |
|
118 | 110 |
* For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum |
119 | 111 |
* number of digits. For other types, this must always return zero. |
120 | 112 |
* |
... | ... | |
123 | 115 |
public int getPrecision(); |
124 | 116 |
|
125 | 117 |
/** |
126 |
* Return true if the attribitute support the "precision". Only numeric types |
|
127 |
* support precision. |
|
128 |
* |
|
129 |
* @return |
|
130 |
*/ |
|
131 |
public boolean supportPrecision(); |
|
132 |
|
|
133 |
/** |
|
134 | 118 |
* For attributes of type {@link DataTypes#DECIMAL}, this returns the maximum |
135 | 119 |
* number of digits after the decimal point. For other types, this must always |
136 | 120 |
* return zero. |
... | ... | |
140 | 124 |
public int getScale(); |
141 | 125 |
|
142 | 126 |
/** |
143 |
* Return true if the attribitute support the "scale". Only float, double and |
|
144 |
* Decimal support scale. |
|
145 |
* |
|
146 |
* @return |
|
147 |
*/ |
|
148 |
public boolean supportScale(); |
|
149 |
|
|
150 |
/** |
|
151 | 127 |
* For attributes of type {@link DataTypes#DECIMAL}, this returns the |
152 | 128 |
* MathContext associated to this. For other types return |
153 | 129 |
* {@link MathContext#UNLIMITED}. |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.spi/src/main/java/org/gvsig/fmap/dal/feature/spi/SQLBuilderBase.java | ||
---|---|---|
50 | 50 |
import org.gvsig.fmap.dal.SQLBuilder.UpdateTableStatisticsBuilder; |
51 | 51 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
52 | 52 |
import org.gvsig.fmap.geom.Geometry; |
53 |
import org.gvsig.tools.dataTypes.DataType; |
|
53 | 54 |
import org.slf4j.Logger; |
54 | 55 |
import org.slf4j.LoggerFactory; |
55 | 56 |
|
... | ... | |
2476 | 2477 |
protected String type_char = "CHARACTER(1)"; |
2477 | 2478 |
protected String type_date = "DATE"; |
2478 | 2479 |
protected String type_double = "DOUBLE PRECISION"; //float con 53 bits de mantisa, float(54) |
2479 |
protected String type_numeric_p = "NUMERIC({0,Number,#######})"; |
|
2480 |
protected String type_numeric_ps = "NUMERIC({0,Number,#######},{1,Number,#######})"; |
|
2481 |
protected String type_bigdecimal = "NUMERIC({0,Number,#######},{1,Number,#######})"; |
|
2480 |
protected String type_decimal_ps = "NUMERIC({0,Number,##########},{1,Number,##########})"; |
|
2481 |
protected String type_decimal_p = "NUMERIC({0,Number,##########})"; |
|
2482 | 2482 |
protected String type_float = "REAL"; //float con 24 bits de mantisa, float(24) |
2483 | 2483 |
protected String type_int = "INT"; |
2484 | 2484 |
protected String type_long = "BIGINT"; |
... | ... | |
2636 | 2636 |
switch (type) { |
2637 | 2637 |
case DataTypes.BOOLEAN: |
2638 | 2638 |
return type_boolean; |
2639 |
case DataTypes.BYTE: |
|
2640 |
return type_byte; |
|
2641 |
case DataTypes.BYTEARRAY: |
|
2642 |
return type_bytearray; |
|
2643 |
case DataTypes.GEOMETRY: |
|
2644 |
return type_geometry; |
|
2645 | 2639 |
case DataTypes.CHAR: |
2646 | 2640 |
return type_char; |
2647 |
case DataTypes.DATE: |
|
2648 |
return type_date; |
|
2649 |
case DataTypes.DOUBLE: |
|
2650 |
// FIXME: Si cargamos la capa "country" al exportarla a |
|
2651 |
// SQLServer falla por: |
|
2652 |
// Error de desbordamiento aritm?tico al convertir float al tipo de datos numeric. |
|
2653 |
// Al parecer la capa declara la columna sqkm_ctry como Numeric(12,6) y para |
|
2654 |
// Algeria intenta asignarle un valor de 2320972.0 y falla. |
|
2655 |
// Habria que repasar el proveedor de shape. |
|
2656 | 2641 |
|
2657 |
// if (p > 1) { |
|
2658 |
// if (s < 0) { |
|
2659 |
// return MessageFormat.format(config.getString(SQLConfig.type_numeric_p), p); |
|
2660 |
// } |
|
2661 |
// return MessageFormat.format(config.getString(SQLConfig.type_numeric_ps), p,s); |
|
2662 |
// } |
|
2663 |
return MessageFormat.format(type_double, precision, scale); |
|
2642 |
|
|
2643 |
case DataTypes.BYTE: |
|
2644 |
return type_byte; |
|
2645 |
case DataTypes.INT: |
|
2646 |
return type_int; |
|
2647 |
case DataTypes.LONG: |
|
2648 |
return type_long; |
|
2649 |
|
|
2650 |
case DataTypes.FLOAT: |
|
2651 |
return type_float; |
|
2652 |
case DataTypes.DOUBLE: |
|
2653 |
return type_double; |
|
2664 | 2654 |
case DataTypes.DECIMAL: |
2665 | 2655 |
if (precision < 1) { |
2666 |
precision = 20;
|
|
2656 |
precision = DataType.DECIMAL_DEFAULT_PRECISION;
|
|
2667 | 2657 |
} |
2668 |
if (scale < 0) {
|
|
2669 |
scale = 10;
|
|
2658 |
if (scale < 1) {
|
|
2659 |
return MessageFormat.format(type_decimal_p, precision);
|
|
2670 | 2660 |
} |
2671 |
return MessageFormat.format(type_bigdecimal, precision, scale); |
|
2672 |
case DataTypes.FLOAT: |
|
2673 |
return MessageFormat.format(type_float, precision, scale); |
|
2674 |
case DataTypes.INT: |
|
2675 |
return MessageFormat.format(type_int, precision, scale); |
|
2676 |
case DataTypes.LONG: |
|
2677 |
return MessageFormat.format(type_long, precision, scale); |
|
2661 |
return MessageFormat.format(type_decimal_ps, precision, scale); |
|
2662 |
|
|
2663 |
|
|
2678 | 2664 |
case DataTypes.STRING: |
2679 | 2665 |
if (size < 0) { |
2680 | 2666 |
return type_string; |
... | ... | |
2682 | 2668 |
return MessageFormat.format(type_string_p, size); |
2683 | 2669 |
} |
2684 | 2670 |
return type_string; |
2671 |
|
|
2672 |
|
|
2673 |
case DataTypes.DATE: |
|
2674 |
return type_date; |
|
2685 | 2675 |
case DataTypes.TIME: |
2686 | 2676 |
return type_time; |
2687 | 2677 |
case DataTypes.TIMESTAMP: |
2688 | 2678 |
return type_timestamp; |
2679 |
|
|
2680 |
case DataTypes.BYTEARRAY: |
|
2681 |
return type_bytearray; |
|
2682 |
|
|
2683 |
case DataTypes.GEOMETRY: |
|
2684 |
return type_geometry; |
|
2685 |
|
|
2689 | 2686 |
case DataTypes.VERSION: |
2690 | 2687 |
return type_version; |
2691 | 2688 |
case DataTypes.URI: |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/pom.xml | ||
---|---|---|
118 | 118 |
<groupId>org.apache.maven.plugins</groupId> |
119 | 119 |
<artifactId>maven-surefire-plugin</artifactId> |
120 | 120 |
<configuration> |
121 |
<testFailureIgnore>true</testFailureIgnore>
|
|
121 |
<testFailureIgnore>false</testFailureIgnore>
|
|
122 | 122 |
</configuration> |
123 | 123 |
</plugin> |
124 | 124 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/test/resources/org/gvsig/fmap/dal/store/testCreateSource1.csv | ||
---|---|---|
1 |
ID/Integer;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 |
; ; ; ; ; ; ; ; ; ; ; ; ;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 |
12;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) |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/test/resources/org/gvsig/fmap/dal/store/shp/testCreateSource1.csv | ||
---|---|---|
1 |
ID/Integer;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 |
; ; ; ; ; ; ; ; ; ; ; ; ;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 |
12;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) |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.shp/src/test/java/org/gvsig/fmap/dal/store/shp/TestUtils.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
public static FeatureStore openSourceStore1() throws Exception { |
54 | 54 |
DataManager dataManager = DALLocator.getDataManager(); |
55 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/testCreateSource1.csv"); |
|
55 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/shp/testCreateSource1.csv");
|
|
56 | 56 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
57 | 57 |
DataStore.CSV_PROVIDER_NAME, |
58 | 58 |
"file=",f, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/test/java/org/gvsig/fmap/dal/store/dbf/TestUtils.java | ||
---|---|---|
41 | 41 |
|
42 | 42 |
public static FeatureStore openSourceStore1() throws Exception { |
43 | 43 |
DataManager dataManager = DALLocator.getDataManager(); |
44 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/testCreateSource1.csv"); |
|
44 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/dbf/testCreateSource1.csv");
|
|
45 | 45 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
46 | 46 |
DataStore.CSV_PROVIDER_NAME, |
47 | 47 |
"file",f, |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/test/resources/org/gvsig/fmap/dal/store/testCreateSource1.csv | ||
---|---|---|
1 |
ID/Integer;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 |
|
2 |
; ; ; ; ; ; ; ; ; ; ; ; ;T; |
|
3 |
1;10;T;1000;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123 |
|
4 |
2;20;T;2000;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123 |
|
5 |
3;30;T;3000;20191029121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123 |
|
6 |
4;40;T;4000;20190929121314;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123 |
|
7 |
5;50;T;5000;20190829121314;20190829;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123 |
|
8 |
6;60;T;6000;20190729121314;20190729;171314;T;Yo yo6;F;12104.54321;T;104.21;T;456.123 |
|
9 |
7;70;T;7000;20190629121314;20190629;181314;T;Yo yo7;F;12105.54321;T;105.21;T;456.123 |
|
10 |
8;80;T;8000;20190529121314;20190529;191314;T;Yo yo8;F;12106.54321;T;106.21;T;456.123 |
|
11 |
9;90;T;9000;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T;107.21;T;456.123 |
|
12 |
10; ;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123 |
|
13 |
11;22; ;2002;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123 |
|
14 |
12;33;T; ;20190929121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123 |
|
15 |
12;41;T;4001; ;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123 |
|
16 |
14;52;T;5002;20190829121314; ;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123 |
|
17 |
15;63;T;6003;20190729121314;20190729; ;T;Yo yo6;F;12104.54321;T;104.21;T;456.123 |
|
18 |
16;74;T;7004;20190629121314;20190629;181314;T; ;F;12105.54321;T;105.21;T;456.123 |
|
19 |
17;85;T;8005;20190529121314;20190529;191314;T;Yo yo8;F; ;T;106.21;T;456.123 |
|
20 |
18;96;T;9006;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T; ;T;456.123 |
|
21 |
19;97;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123 |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/src/test/resources/org/gvsig/fmap/dal/store/dbf/testCreateSource1.csv | ||
---|---|---|
1 |
ID/Integer;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 |
|
2 |
; ; ; ; ; ; ; ; ; ; ; ; ;T; |
|
3 |
1;10;T;1000;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123 |
|
4 |
2;20;T;2000;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123 |
|
5 |
3;30;T;3000;20191029121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123 |
|
6 |
4;40;T;4000;20190929121314;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123 |
|
7 |
5;50;T;5000;20190829121314;20190829;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123 |
|
8 |
6;60;T;6000;20190729121314;20190729;171314;T;Yo yo6;F;12104.54321;T;104.21;T;456.123 |
|
9 |
7;70;T;7000;20190629121314;20190629;181314;T;Yo yo7;F;12105.54321;T;105.21;T;456.123 |
|
10 |
8;80;T;8000;20190529121314;20190529;191314;T;Yo yo8;F;12106.54321;T;106.21;T;456.123 |
|
11 |
9;90;T;9000;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T;107.21;T;456.123 |
|
12 |
10; ;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123 |
|
13 |
11;22; ;2002;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;456.123 |
|
14 |
12;33;T; ;20190929121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;456.123 |
|
15 |
12;41;T;4001; ;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;456.123 |
|
16 |
14;52;T;5002;20190829121314; ;161314;T;Yo yo5;F;12103.54321;T;103.21;T;456.123 |
|
17 |
15;63;T;6003;20190729121314;20190729; ;T;Yo yo6;F;12104.54321;T;104.21;T;456.123 |
|
18 |
16;74;T;7004;20190629121314;20190629;181314;T; ;F;12105.54321;T;105.21;T;456.123 |
|
19 |
17;85;T;8005;20190529121314;20190529;191314;T;Yo yo8;F; ;T;106.21;T;456.123 |
|
20 |
18;96;T;9006;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T; ;T;456.123 |
|
21 |
19;97;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;456.123 |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.file/org.gvsig.fmap.dal.file.dbf/pom.xml | ||
---|---|---|
125 | 125 |
<groupId>org.apache.maven.plugins</groupId> |
126 | 126 |
<artifactId>maven-surefire-plugin</artifactId> |
127 | 127 |
<configuration> |
128 |
<testFailureIgnore>true</testFailureIgnore>
|
|
128 |
<testFailureIgnore>false</testFailureIgnore>
|
|
129 | 129 |
</configuration> |
130 | 130 |
</plugin> |
131 | 131 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureReference.java | ||
---|---|---|
179 | 179 |
return (DefaultFeatureStore) this.storeRef.get(); |
180 | 180 |
} |
181 | 181 |
|
182 |
private void calculatePK(FeatureProvider fdata) {
|
|
182 |
public void calculatePK(FeatureProvider fdata) { // Usado en los test de BBDD
|
|
183 | 183 |
FeatureAttributeDescriptor[] pkattrs = fdata.getType().getPrimaryKey(); |
184 | 184 |
if( ArrayUtils.isEmpty(pkattrs) ) { |
185 | 185 |
this.pk = null; |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.impl/src/main/java/org/gvsig/fmap/dal/feature/impl/DefaultFeatureAttributeDescriptor.java | ||
---|---|---|
35 | 35 |
import java.util.Map; |
36 | 36 |
import java.util.Map.Entry; |
37 | 37 |
import java.util.Objects; |
38 |
import java.util.logging.Level; |
|
38 | 39 |
import org.apache.commons.lang3.ArrayUtils; |
39 | 40 |
import org.apache.commons.lang3.StringUtils; |
40 | 41 |
import org.cresques.cts.IProjection; |
... | ... | |
149 | 150 |
|
150 | 151 |
public DefaultFeatureAttributeDescriptor() { |
151 | 152 |
// Usada en la persistencia |
153 |
this.precision = DataType.PRECISION_NONE; |
|
154 |
this.scale = DataType.SCALE_NONE; |
|
155 |
this.roundMode = BigDecimal.ROUND_HALF_UP; |
|
152 | 156 |
} |
153 | 157 |
|
154 | 158 |
protected DefaultFeatureAttributeDescriptor(FeatureType type) { |
... | ... | |
165 | 169 |
this.size = 0; |
166 | 170 |
this.name = null; |
167 | 171 |
this.objectClass = null; |
168 |
this.precision = 0;
|
|
169 |
this.scale = 0;
|
|
172 |
this.precision = DataType.PRECISION_NONE;
|
|
173 |
this.scale = DataType.SCALE_NONE;
|
|
170 | 174 |
this.roundMode = BigDecimal.ROUND_HALF_UP; |
171 | 175 |
this.evaluator = null; |
172 | 176 |
this.primaryKey = false; |
... | ... | |
713 | 717 |
|
714 | 718 |
@Override |
715 | 719 |
public void saveToState(PersistentState state) throws PersistenceException { |
720 |
Coercion toString = ToolsLocator.getDataTypesManager().getCoercion(DataTypes.STRING); |
|
721 |
|
|
716 | 722 |
state.set("allowNull", allowNull); |
717 | 723 |
state.set("dataType", dataType.getType()); |
718 | 724 |
state.set("dataProfile", dataProfile); |
... | ... | |
729 | 735 |
state.set("precision", precision); |
730 | 736 |
state.set("scale", scale); |
731 | 737 |
state.set("roundMode", roundMode); |
732 |
state.set("locale", this.locale == null ? null : this.locale.toLanguageTag()); |
|
738 |
try { |
|
739 |
state.set("locale", toString.coerce(this.locale)); |
|
740 |
} catch (CoercionException ex) { |
|
741 |
state.setNull("locale"); |
|
742 |
} |
|
733 | 743 |
state.set("evaluator", evaluator); |
734 | 744 |
|
735 | 745 |
state.set("primaryKey", primaryKey); |
... | ... | |
816 | 826 |
definition.addDynFieldString("name"); |
817 | 827 |
definition.addDynFieldString("objectClass"); |
818 | 828 |
definition.addDynFieldInt("precision"); |
819 |
definition.addDynFieldInt("scale"); |
|
820 |
definition.addDynFieldInt("roundMode"); |
|
821 |
definition.addDynFieldString("locale"); |
|
822 |
definition.addDynFieldObject("evaluator") |
|
823 |
.setClassOfValue(Evaluator.class); |
|
829 |
definition.addDynFieldInt("scale").setMandatory(false).setDefaultDynValue(DataType.SCALE_NONE); |
|
830 |
definition.addDynFieldInt("roundMode").setMandatory(false).setDefaultDynValue(BigDecimal.ROUND_HALF_UP); |
|
831 |
definition.addDynFieldString("locale").setMandatory(false).setDefaultDynValue("null"); |
|
832 |
definition.addDynFieldObject("evaluator").setClassOfValue(Evaluator.class); |
|
824 | 833 |
definition.addDynFieldBoolean("primaryKey"); |
825 | 834 |
definition.addDynFieldBoolean("readOnly"); |
826 | 835 |
definition.addDynFieldObject("SRS") |
... | ... | |
1411 | 1420 |
return this; |
1412 | 1421 |
} |
1413 | 1422 |
|
1414 |
@Override |
|
1415 |
public boolean supportSize() { |
|
1416 |
return this.getDataType().supportSize(); |
|
1417 |
} |
|
1418 |
|
|
1419 |
@Override |
|
1420 |
public boolean supportPrecision() { |
|
1421 |
return this.getDataType().supportPrecision(); |
|
1422 |
} |
|
1423 |
|
|
1424 |
@Override |
|
1425 |
public boolean supportScale() { |
|
1426 |
return this.getDataType().supportScale(); |
|
1427 |
} |
|
1428 |
|
|
1429 | 1423 |
private class ConstantValueEvaluator extends AbstractEvaluator { |
1430 | 1424 |
|
1431 | 1425 |
@Override |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/TestUtils.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 | 4 |
import java.net.URL; |
5 |
import java.util.ArrayList; |
|
6 |
import java.util.List; |
|
7 |
import org.apache.commons.io.FileUtils; |
|
8 |
import org.apache.commons.lang3.StringUtils; |
|
5 | 9 |
import org.gvsig.fmap.dal.DALLocator; |
6 | 10 |
import org.gvsig.fmap.dal.DataManager; |
7 | 11 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
8 | 12 |
import org.gvsig.fmap.dal.DataStore; |
9 | 13 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
14 |
import org.gvsig.fmap.dal.feature.Feature; |
|
10 | 15 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
16 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
|
17 |
import org.gvsig.fmap.dal.feature.spi.FeatureProvider; |
|
11 | 18 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCServerExplorer; |
12 | 19 |
import org.slf4j.Logger; |
13 | 20 |
import org.slf4j.LoggerFactory; |
... | ... | |
26 | 33 |
dataManager.createServerExplorerParameters(H2SpatialLibrary.NAME); |
27 | 34 |
|
28 | 35 |
File dbfile = TestUtils.getResource(String.format( |
29 |
"db/%s-%d-%03d",
|
|
36 |
"test-dbs/%s-%d-%03d",
|
|
30 | 37 |
dbname, |
31 | 38 |
System.currentTimeMillis(), |
32 | 39 |
dbcounter++ |
... | ... | |
75 | 82 |
|
76 | 83 |
public static FeatureStore openSourceStore1() throws Exception { |
77 | 84 |
DataManager dataManager = DALLocator.getDataManager(); |
78 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/testCreateSource1.csv"); |
|
85 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/h2/testCreateSource1.csv");
|
|
79 | 86 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
80 | 87 |
DataStore.CSV_PROVIDER_NAME, |
81 | 88 |
"file=",f, |
... | ... | |
84 | 91 |
); |
85 | 92 |
return store; |
86 | 93 |
} |
94 |
|
|
95 |
|
|
96 |
public static List<String> getSQLs(String name) throws Exception { |
|
97 |
File f = getResourceAsFile("/org/gvsig/fmap/dal/store/h2/"+name); |
|
98 |
List<String> SQLs = new ArrayList<>(); |
|
99 |
List<String> lines = FileUtils.readLines(f); |
|
100 |
StringBuilder sb = new StringBuilder(); |
|
101 |
for (String line : lines) { |
|
102 |
line = StringUtils.stripStart(line, null); |
|
103 |
if( line.startsWith("--") ) { |
|
104 |
continue; |
|
105 |
} |
|
106 |
if( line.endsWith(";") ) { |
|
107 |
sb.append(line.substring(0, line.length()-1)); |
|
108 |
SQLs.add(sb.toString()); |
|
109 |
sb.setLength(0); |
|
110 |
} else { |
|
111 |
sb.append(line); |
|
112 |
} |
|
113 |
} |
|
114 |
return SQLs; |
|
115 |
} |
|
87 | 116 |
|
117 |
public static FeatureProvider getFeatureProvider(Feature feature) { |
|
118 |
return ((DefaultFeature)feature).getData(); |
|
119 |
} |
|
88 | 120 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/TestCreate.java | ||
---|---|---|
72 | 72 |
|
73 | 73 |
protected void createFrom(JDBCServerExplorer explorer, FeatureStore sourceStore) throws Exception { |
74 | 74 |
NewFeatureStoreParameters params = (NewFeatureStoreParameters) explorer.getAddParameters( |
75 |
getProviderName()
|
|
75 |
getTargetName()
|
|
76 | 76 |
); |
77 | 77 |
EditableFeatureType ft = params.getDefaultFeatureType(); |
78 | 78 |
ft.addAll(sourceStore.getDefaultFeatureType()); |
... | ... | |
101 | 101 |
case DataTypes.TIMESTAMP: |
102 | 102 |
case DataTypes.DOUBLE: |
103 | 103 |
case DataTypes.FLOAT: |
104 |
case DataTypes.DECIMAL: |
|
104 | 105 |
assertEquals( |
105 | 106 |
String.format("Field %s name mismatch", sourceAttr.getName()), |
106 | 107 |
sourceAttr.getName(), |
... | ... | |
122 | 123 |
targetAttr.getPrecision() |
123 | 124 |
); |
124 | 125 |
assertEquals( |
125 |
String.format("Field %s precision mismatch", sourceAttr.getName()),
|
|
126 |
String.format("Field %s scale mismatch", sourceAttr.getName()),
|
|
126 | 127 |
sourceAttr.getScale(), |
127 | 128 |
targetAttr.getScale() |
128 | 129 |
); |
... | ... | |
234 | 235 |
Object sourceValue = sourceFeature.get(sourceAttr.getName()); |
235 | 236 |
Object targetValue = targetFeature.get(sourceAttr.getName()); |
236 | 237 |
if( sourceValue == null ) { |
237 |
LOGGER.info("sourceValue is null");
|
|
238 |
LOGGER.info(String.format("Feature %03d attribute %s is null", i, sourceAttr.getName()));
|
|
238 | 239 |
} |
239 | 240 |
assertEquals( |
240 | 241 |
String.format("Feature %03d attribute %s", i, sourceAttr.getName()), |
... | ... | |
247 | 248 |
} |
248 | 249 |
|
249 | 250 |
|
250 |
public void testCreateWithDALFile() throws Exception {
|
|
251 |
public void testCreate() throws Exception { |
|
251 | 252 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
252 | 253 |
JDBCServerExplorer explorer = TestUtils.openServerExplorer(DBNAME); |
253 | 254 |
|
... | ... | |
257 | 258 |
copyFrom(explorer, sourceStore, FeatureStore.MODE_APPEND); |
258 | 259 |
checkData(explorer, sourceStore); |
259 | 260 |
|
261 |
JDBCStoreParameters params = explorer.get(this.getTargetName()); |
|
262 |
explorer.remove(params); |
|
263 |
|
|
260 | 264 |
createFrom(explorer, sourceStore); |
261 | 265 |
copyFrom(explorer, sourceStore, FeatureStore.MODE_FULLEDIT); |
262 | 266 |
checkData(explorer, sourceStore); |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestAppend.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.fmap.dal.DataTypes; |
|
7 |
import org.gvsig.fmap.dal.feature.Feature; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
11 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
12 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
16 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
17 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.AppendOperation; |
|
18 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
19 |
import org.slf4j.Logger; |
|
20 |
import org.slf4j.LoggerFactory; |
|
21 |
|
|
22 |
public class TestAppend extends TestCase { |
|
23 |
|
|
24 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestAppend.class); |
|
25 |
|
|
26 |
public TestAppend(String testName) { |
|
27 |
super(testName); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void setUp() throws Exception { |
|
32 |
super.setUp(); |
|
33 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
protected void tearDown() throws Exception { |
|
38 |
super.tearDown(); |
|
39 |
} |
|
40 |
|
|
41 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
42 |
// public void testHello() {} |
|
43 |
|
|
44 |
public void testAppend() throws Exception { |
|
45 |
JDBCHelper helper = new H2SpatialHelper(); |
|
46 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
47 |
OperationsFactory operations = helper.getOperations(); |
|
48 |
|
|
49 |
List<String> expectedSQLs = TestUtils.getSQLs("append.sql"); |
|
50 |
|
|
51 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
52 |
|
|
53 |
TableReference table = operations.createTableReference( |
|
54 |
"dbtest", |
|
55 |
sqlbuilder.default_schema(), |
|
56 |
"test", |
|
57 |
null |
|
58 |
); |
|
59 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
60 |
AppendOperation append = operations.createAppend( |
|
61 |
table, |
|
62 |
featureType |
|
63 |
); |
|
64 |
append.begin(); |
|
65 |
List<String> SQLs = new ArrayList<>(); |
|
66 |
SQLs.addAll(append.getPreviousSQLs()); |
|
67 |
SQLs.add( append.getSQL()); |
|
68 |
SQLs.addAll(append.getPostSQLs()); |
|
69 |
assertEquals("Append num SQLs", expectedSQLs.size(), SQLs.size()); |
|
70 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
71 |
assertEquals("Append SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
72 |
} |
|
73 |
|
|
74 |
for (Feature sourceFeature : sourceStore.getFeatureSet()) { |
|
75 |
List<Object> parametersSQL = append.getSQLParameters(TestUtils.getFeatureProvider(sourceFeature)); |
|
76 |
List<Object> expectedParameters = this.getExpectedparameters(sourceFeature); |
|
77 |
assertEquals("Append num. parameters", parametersSQL.size(), expectedParameters.size()); |
|
78 |
for (int i = 0; i < expectedParameters.size(); i++) { |
|
79 |
assertEquals("Append parameter "+i, expectedParameters.get(i), parametersSQL.get(i)); |
|
80 |
} |
|
81 |
} |
|
82 |
append.end(); |
|
83 |
} |
|
84 |
|
|
85 |
private List<Object> getExpectedparameters(Feature sourceFeature) { |
|
86 |
FeatureType ft = sourceFeature.getType(); |
|
87 |
List<Object> values = new ArrayList<>(); |
|
88 |
for (FeatureAttributeDescriptor attr : ft) { |
|
89 |
Object v = sourceFeature.get(attr.getIndex()); |
|
90 |
values.add(v); |
|
91 |
if( attr.getType()==DataTypes.GEOMETRY ) { |
|
92 |
String srs = attr.getSRS().getAbrev(); |
|
93 |
values.add(Integer.parseInt(srs.split(":")[1])); |
|
94 |
} |
|
95 |
} |
|
96 |
return values; |
|
97 |
} |
|
98 |
|
|
99 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestFetchFeatureType.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.Collections; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
8 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
9 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureTypeOperation; |
|
15 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
16 |
import org.slf4j.Logger; |
|
17 |
import org.slf4j.LoggerFactory; |
|
18 |
|
|
19 |
public class TestFetchFeatureType extends TestCase { |
|
20 |
|
|
21 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureType.class); |
|
22 |
|
|
23 |
public TestFetchFeatureType(String testName) { |
|
24 |
super(testName); |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
protected void setUp() throws Exception { |
|
29 |
super.setUp(); |
|
30 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
protected void tearDown() throws Exception { |
|
35 |
super.tearDown(); |
|
36 |
} |
|
37 |
|
|
38 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
39 |
// public void testHello() {} |
|
40 |
|
|
41 |
public void testFetchFeatureType() throws Exception { |
|
42 |
JDBCHelper helper = new H2SpatialHelper(); |
|
43 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
44 |
OperationsFactory operations = helper.getOperations(); |
|
45 |
|
|
46 |
List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureType.sql"); |
|
47 |
|
|
48 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
49 |
|
|
50 |
TableReference table = operations.createTableReference( |
|
51 |
"dbtest", |
|
52 |
sqlbuilder.default_schema(), |
|
53 |
"test", |
|
54 |
null |
|
55 |
); |
|
56 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
57 |
FetchFeatureTypeOperation fetchFeatureType = operations.createFetchFeatureType( |
|
58 |
featureType.getEditable(), |
|
59 |
table, |
|
60 |
Collections.EMPTY_LIST, |
|
61 |
null, // "Geometry" |
|
62 |
featureType.getDefaultSRS() |
|
63 |
); |
|
64 |
|
|
65 |
|
|
66 |
String retrieveFirstRowOfTableSQL = fetchFeatureType.getSQLToRetrieveFirstRowOfTable(); |
|
67 |
String retrievePrimaryKeysFromInformationSchemaSQL = fetchFeatureType.getSQLToRetrievePrimaryKeysFromInformationSchema(); |
|
68 |
|
|
69 |
assertEquals("FetchFeatureType first row SQL", expectedSQLs.get(0), retrieveFirstRowOfTableSQL); |
|
70 |
assertEquals("FetchFeatureType get primery keys SQL", expectedSQLs.get(1), retrievePrimaryKeysFromInformationSchemaSQL); |
|
71 |
} |
|
72 |
|
|
73 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestCount.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
8 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CountOperation; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestCount extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCount.class); |
|
21 |
|
|
22 |
public TestCount(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testCount() throws Exception { |
|
41 |
JDBCHelper helper = new H2SpatialHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("count.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
CountOperation count = operations.createCount( |
|
57 |
featureType, |
|
58 |
table, |
|
59 |
null, null |
|
60 |
); |
|
61 |
|
|
62 |
String sql = count.getSQL(); |
|
63 |
assertEquals("Count SQL", expectedSQLs.get(0), sql); |
|
64 |
} |
|
65 |
|
|
66 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestResultSetForSetProvider.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
8 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.ResultSetForSetProviderOperation; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestResultSetForSetProvider extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestResultSetForSetProvider.class); |
|
21 |
|
|
22 |
public TestResultSetForSetProvider(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testResultSetForSetProvider() throws Exception { |
|
41 |
JDBCHelper helper = new H2SpatialHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("resultSetForSetProvider.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
ResultSetForSetProviderOperation resultSetForSetProvider = operations.createResultSetForSetProvider( |
|
57 |
table, |
|
58 |
null, |
|
59 |
null, |
|
60 |
null, |
|
61 |
featureType, |
|
62 |
featureType, |
|
63 |
0, |
|
64 |
0, |
|
65 |
0 |
|
66 |
); |
|
67 |
String sql = resultSetForSetProvider.getSQL(); |
|
68 |
assertEquals("ResultSetForSetProvider SQL", expectedSQLs.get(0), sql); |
|
69 |
} |
|
70 |
|
|
71 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestFetchFeatureProviderByReference.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.Feature; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
|
7 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
9 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
|
10 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureReference; |
|
11 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
12 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
14 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
16 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
17 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.FetchFeatureProviderByReferenceOperation; |
|
18 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
19 |
import org.slf4j.Logger; |
|
20 |
import org.slf4j.LoggerFactory; |
|
21 |
|
|
22 |
public class TestFetchFeatureProviderByReference extends TestCase { |
|
23 |
|
|
24 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestFetchFeatureProviderByReference.class); |
|
25 |
|
|
26 |
public TestFetchFeatureProviderByReference(String testName) { |
|
27 |
super(testName); |
|
28 |
} |
|
29 |
|
|
30 |
@Override |
|
31 |
protected void setUp() throws Exception { |
|
32 |
super.setUp(); |
|
33 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
protected void tearDown() throws Exception { |
|
38 |
super.tearDown(); |
|
39 |
} |
|
40 |
|
|
41 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
42 |
// public void testHello() {} |
|
43 |
|
|
44 |
public void testFetchFeatureProviderByReference() throws Exception { |
|
45 |
JDBCHelper helper = new H2SpatialHelper(); |
|
46 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
47 |
OperationsFactory operations = helper.getOperations(); |
|
48 |
|
|
49 |
List<String> expectedSQLs = TestUtils.getSQLs("fetchFeatureProviderByReference.sql"); |
|
50 |
|
|
51 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
52 |
TableReference table = operations.createTableReference( |
|
53 |
"dbtest", |
|
54 |
sqlbuilder.default_schema(), |
|
55 |
"test", |
|
56 |
null |
|
57 |
); |
|
58 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
59 |
Feature feature = sourceStore.getFeatures().get(1); |
|
60 |
FeatureReference reference = feature.getReference(); |
|
61 |
|
|
62 |
// Como venimos de un CSV, este no tiene calculado el PK en la FeatureReference |
|
63 |
// (ya que el CSV usa OID). |
|
64 |
// Forzamos a que se calcule. |
|
65 |
((DefaultFeatureReference) reference).calculatePK(((DefaultFeature)feature).getData()); |
|
66 |
|
|
67 |
FetchFeatureProviderByReferenceOperation fetchFeatureProviderByReference = operations.createFetchFeatureProviderByReference( |
|
68 |
(DefaultFeatureReference) reference, |
|
69 |
featureType, |
|
70 |
table |
|
71 |
); |
|
72 |
|
|
73 |
String sql = fetchFeatureProviderByReference.getSQL(); |
|
74 |
assertEquals("FetchFeatureProviderByReference SQL", expectedSQLs.get(0), sql); |
|
75 |
} |
|
76 |
|
|
77 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestCalculateEnvelope.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
8 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CalculateEnvelopeOfColumnOperation; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestCalculateEnvelope extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCalculateEnvelope.class); |
|
21 |
|
|
22 |
public TestCalculateEnvelope(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testCalculateEnvelope() throws Exception { |
|
41 |
JDBCHelper helper = new H2SpatialHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("calculateEnvelope.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
CalculateEnvelopeOfColumnOperation calculateEnvelope = operations.createCalculateEnvelopeOfColumn( |
|
57 |
featureType, |
|
58 |
table, |
|
59 |
"Geometry", |
|
60 |
null, |
|
61 |
null, |
|
62 |
featureType.getDefaultSRS() |
|
63 |
); |
|
64 |
|
|
65 |
String sql = calculateEnvelope.getSQL(); |
|
66 |
assertEquals("CalculateEnvelope SQL", expectedSQLs.get(0), sql); |
|
67 |
} |
|
68 |
|
|
69 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestCreateTable.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
8 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.CreateTableOperation; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestCreateTable extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestCreateTable.class); |
|
21 |
|
|
22 |
public TestCreateTable(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testCreateTable() throws Exception { |
|
41 |
JDBCHelper helper = new H2SpatialHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("createTable.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
CreateTableOperation createTable = operations.createTable( |
|
57 |
table, |
|
58 |
featureType, |
|
59 |
null, |
|
60 |
null |
|
61 |
); |
|
62 |
List<String> SQLs = createTable.getSQLs(); |
|
63 |
assertEquals("CreateTable num. SQLs", expectedSQLs.size(), SQLs.size()); |
|
64 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
65 |
assertEquals("CreateTable SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
66 |
} |
|
67 |
|
|
68 |
} |
|
69 |
|
|
70 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestDropTable.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
7 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
8 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.DropTableOperation; |
|
13 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
14 |
import org.slf4j.Logger; |
|
15 |
import org.slf4j.LoggerFactory; |
|
16 |
|
|
17 |
public class TestDropTable extends TestCase { |
|
18 |
|
|
19 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestDropTable.class); |
|
20 |
|
|
21 |
public TestDropTable(String testName) { |
|
22 |
super(testName); |
|
23 |
} |
|
24 |
|
|
25 |
@Override |
|
26 |
protected void setUp() throws Exception { |
|
27 |
super.setUp(); |
|
28 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
29 |
} |
|
30 |
|
|
31 |
@Override |
|
32 |
protected void tearDown() throws Exception { |
|
33 |
super.tearDown(); |
|
34 |
} |
|
35 |
|
|
36 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
37 |
// public void testHello() {} |
|
38 |
|
|
39 |
public void testDropTable() throws Exception { |
|
40 |
JDBCHelper helper = new H2SpatialHelper(); |
|
41 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
42 |
OperationsFactory operations = helper.getOperations(); |
|
43 |
|
|
44 |
List<String> expectedSQLs = TestUtils.getSQLs("dropTable.sql"); |
|
45 |
|
|
46 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
47 |
|
|
48 |
TableReference table = operations.createTableReference( |
|
49 |
"dbtest", |
|
50 |
sqlbuilder.default_schema(), |
|
51 |
"test", |
|
52 |
null |
|
53 |
); |
|
54 |
DropTableOperation dropTable = operations.createDropTable( |
|
55 |
table |
|
56 |
); |
|
57 |
List<String> SQLs = dropTable.getSQLs(); |
|
58 |
assertEquals("DropTable num. SQLs", expectedSQLs.size(), SQLs.size()); |
|
59 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
60 |
assertEquals("DropTable SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestTableIsEmpty.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
8 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.TableIsEmptyOperation; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestTableIsEmpty extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestTableIsEmpty.class); |
|
21 |
|
|
22 |
public TestTableIsEmpty(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testTableIsEmpty() throws Exception { |
|
41 |
JDBCHelper helper = new H2SpatialHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("tableIsEmpty.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
TableIsEmptyOperation tableIsEmpty = operations.createTableIsEmpty( |
|
57 |
featureType, |
|
58 |
table, |
|
59 |
null, |
|
60 |
null |
|
61 |
); |
|
62 |
|
|
63 |
String sql = tableIsEmpty.getSQL(); |
|
64 |
assertEquals("TableIsEmpty SQL", expectedSQLs.get(0), sql); |
|
65 |
} |
|
66 |
|
|
67 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestPerformChanges.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.Collections; |
|
4 |
import java.util.List; |
|
5 |
import junit.framework.TestCase; |
|
6 |
import org.gvsig.fmap.dal.DALLocator; |
|
7 |
import org.gvsig.fmap.dal.DataTypes; |
|
8 |
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor; |
|
9 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
11 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
12 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider.FeatureTypeChanged; |
|
13 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
14 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
15 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
16 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
17 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
18 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
19 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.PerformChangesOperation; |
|
20 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
21 |
import org.slf4j.Logger; |
|
22 |
import org.slf4j.LoggerFactory; |
|
23 |
|
|
24 |
public class TestPerformChanges extends TestCase { |
|
25 |
|
|
26 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestPerformChanges.class); |
|
27 |
|
|
28 |
public TestPerformChanges(String testName) { |
|
29 |
super(testName); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void setUp() throws Exception { |
|
34 |
super.setUp(); |
|
35 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
36 |
} |
|
37 |
|
|
38 |
@Override |
|
39 |
protected void tearDown() throws Exception { |
|
40 |
super.tearDown(); |
|
41 |
} |
|
42 |
|
|
43 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
44 |
// public void testHello() {} |
|
45 |
|
|
46 |
public void testPerformChanges() throws Exception { |
|
47 |
JDBCHelper helper = new H2SpatialHelper(); |
|
48 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
49 |
OperationsFactory operations = helper.getOperations(); |
|
50 |
|
|
51 |
List<String> expectedSQLs = TestUtils.getSQLs("performChanges.sql"); |
|
52 |
|
|
53 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
54 |
|
|
55 |
TableReference table = operations.createTableReference( |
|
56 |
"dbtest", |
|
57 |
sqlbuilder.default_schema(), |
|
58 |
"test", |
|
59 |
null |
|
60 |
); |
|
61 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
62 |
|
|
63 |
|
|
64 |
FeatureTypeChanged featureTypeChanged = new FeatureTypeChanged() { |
|
65 |
@Override |
|
66 |
public FeatureType getSource() { |
|
67 |
EditableFeatureType ft = DALLocator.getDataManager().createFeatureType(); |
|
68 |
EditableFeatureAttributeDescriptor id = ft.add("ID", DataTypes.INT); |
|
69 |
id.copyFrom(featureType.getAttributeDescriptor("ID")); |
|
70 |
return ft; |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public FeatureType getTarget() { |
|
75 |
return featureType; |
|
76 |
} |
|
77 |
}; |
|
78 |
List<FeatureTypeChanged> featureTypesChangeds = Collections.singletonList(featureTypeChanged); |
|
79 |
|
|
80 |
PerformChangesOperation performChanges = operations.createPerformChanges( |
|
81 |
table, |
|
82 |
sourceStore.getDefaultFeatureType(), |
|
83 |
null, |
|
84 |
null, |
|
85 |
null, |
|
86 |
featureTypesChangeds.iterator() |
|
87 |
); |
|
88 |
String insertSQL = performChanges.getInsertSQL(); |
|
89 |
String deleteSQL = performChanges.getDeleteSQL(); |
|
90 |
String updateSQL = performChanges.getUpdateSQL(); |
|
91 |
List<String> updateTableSQLs = performChanges.getUpdateTableSQLs(); |
|
92 |
|
|
93 |
assertEquals("Insert SQL", expectedSQLs.get(0), insertSQL); |
|
94 |
assertEquals("Delete SQL", expectedSQLs.get(1), deleteSQL); |
|
95 |
assertEquals("Update SQL", expectedSQLs.get(2), updateSQL); |
|
96 |
assertEquals("UpdateTable num. SQLs", expectedSQLs.size()-3, updateTableSQLs.size()); |
|
97 |
for (int i = 0; i < updateTableSQLs.size(); i++) { |
|
98 |
assertEquals("UpdateTable SQL "+i, expectedSQLs.get(i+3), updateTableSQLs.get(i)); |
|
99 |
} |
|
100 |
|
|
101 |
|
|
102 |
} |
|
103 |
|
|
104 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/operations/sql/TestUpdateTableStatistics.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.store.h2.operations.sql; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
import junit.framework.TestCase; |
|
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
7 |
import org.gvsig.fmap.dal.store.h2.H2SpatialHelper; |
|
8 |
import org.gvsig.fmap.dal.store.h2.TestUtils; |
|
9 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCHelper; |
|
10 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory; |
|
11 |
import org.gvsig.fmap.dal.store.jdbc2.OperationsFactory.TableReference; |
|
12 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
|
13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.operations.UpdateTableStatisticsOperation; |
|
14 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class TestUpdateTableStatistics extends TestCase { |
|
19 |
|
|
20 |
private static final Logger LOGGER = LoggerFactory.getLogger(TestUpdateTableStatistics.class); |
|
21 |
|
|
22 |
public TestUpdateTableStatistics(String testName) { |
|
23 |
super(testName); |
|
24 |
} |
|
25 |
|
|
26 |
@Override |
|
27 |
protected void setUp() throws Exception { |
|
28 |
super.setUp(); |
|
29 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
protected void tearDown() throws Exception { |
|
34 |
super.tearDown(); |
|
35 |
} |
|
36 |
|
|
37 |
// TODO add test methods here. The name must begin with 'test'. For example: |
|
38 |
// public void testHello() {} |
|
39 |
|
|
40 |
public void testUpdateTableStatistics() throws Exception { |
|
41 |
JDBCHelper helper = new H2SpatialHelper(); |
|
42 |
JDBCSQLBuilderBase sqlbuilder = helper.createSQLBuilder(); |
|
43 |
OperationsFactory operations = helper.getOperations(); |
|
44 |
|
|
45 |
List<String> expectedSQLs = TestUtils.getSQLs("updateTableStatistics.sql"); |
|
46 |
|
|
47 |
FeatureStore sourceStore = TestUtils.openSourceStore1(); |
|
48 |
|
|
49 |
TableReference table = operations.createTableReference( |
|
50 |
"dbtest", |
|
51 |
sqlbuilder.default_schema(), |
|
52 |
"test", |
|
53 |
null |
|
54 |
); |
|
55 |
FeatureType featureType = sourceStore.getDefaultFeatureType(); |
|
56 |
UpdateTableStatisticsOperation updateTableStatistics = operations.createUpdateTableStatistics( |
|
57 |
table |
|
58 |
); |
|
59 |
|
|
60 |
List<String> SQLs = updateTableStatistics.getSQLs(); |
|
61 |
assertEquals("UpdateTableStatistics num. SQLs", expectedSQLs.size(), SQLs.size()); |
|
62 |
for (int i = 0; i < expectedSQLs.size(); i++) { |
|
63 |
assertEquals("UpdateTableStatistics SQL "+i, expectedSQLs.get(i), SQLs.get(i)); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/java/org/gvsig/fmap/dal/store/h2/H2SpatialSQLBuilderTest.java | ||
---|---|---|
217 | 217 |
System.out.println("# Variables:: " + ArrayUtils.toString(sqlbuilder.variables_names())); |
218 | 218 |
System.out.println("# Parametros:: " + ArrayUtils.toString(sqlbuilder.parameters_names())); |
219 | 219 |
assertEquals( |
220 |
"CREATE TABLE \"dbo\".\"test1\" (\"name\" VARCHAR(45) DEFAULT NULL, \"id\" INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL, \"geom\" GEOMETRY ); ALTER TABLE \"dbo\".\"test1\" ADD CONSTRAINT IF NOT EXISTS \"constraint_test1_geom_dim\" CHECK NVL2(\"geom\", ST_CoordDim(\"geom\") = 2, TRUE)",
|
|
220 |
"CREATE TABLE \"dbo\".\"test1\" (\"name\" VARCHAR(45) DEFAULT NULL, \"id\" INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL, \"geom\" GEOMETRY(1) CHECK NVL2(\"geom\", ST_GeometryTypeCode(\"geom\") = 0 AND ST_CoordDim(\"geom\") = 2, TRUE) )",
|
|
221 | 221 |
sqlbuilder.toString() |
222 | 222 |
); |
223 | 223 |
assertEquals( |
trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.h2/src/test/resources/org/gvsig/fmap/dal/store/testCreateSource1.csv | ||
---|---|---|
1 |
ID/Integer;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;Geometry/Geometry/set/geomtype=Point:2D/set/srs=EPSG:4326 |
|
2 |
1;10;T;1000;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;"POINT (-3.8945156972987958 42.01053743584765)" |
|
3 |
2;20;T;2000;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;"POINT (-2.1079618220646115 41.983079082675474)" |
|
4 |
3;30;T;3000;20191029121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;"POINT (-2.57249737803327 41.35372113353277)" |
|
5 |
4;40;T;4000;20190929121314;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;"POINT (-4.061822048036304 41.35877680235475)" |
|
6 |
5;50;T;5000;20190829121314;20190829;161314;T;Yo yo5;F;12103.54321;T;103.21;T;"POINT (-3.974317066986988 40.78701209315094)" |
|
7 |
6;60;T;6000;20190729121314;20190729;171314;T;Yo yo6;F;12104.54321;T;104.21;T;"POINT (-2.510509736717547 40.69847453392384)" |
|
8 |
7;70;T;7000;20190629121314;20190629;181314;T;Yo yo7;F;12105.54321;T;105.21;T;"POINT (-0.5317736981843011 40.66396082637622)" |
|
9 |
8;80;T;8000;20190529121314;20190529;191314;T;Yo yo8;F;12106.54321;T;106.21;T;"POINT (-0.3626917259170671 41.13652386601604)" |
|
10 |
9;90;T;9000;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T;107.21;T;"POINT (-1.2461823078608523 41.84950010180092)" |
|
11 |
10;;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;"POINT (-1.2145405488596532 41.22158511004416)" |
|
12 |
11;22; ;2002;20191129121314;20191129;131314;T;Yo yo2;F;12100.54321;T;100.21;T;"POINT (-0.7699089544899235 41.630581204431756)" |
|
13 |
12;33;T; ;20190929121314;20191029;141314;T;Yo yo3;F;12101.54321;T;101.21;T;"POINT (0.4821915816701051 41.75970939133133)" |
|
14 |
12;41;T;4001; ;20190929;151314;T;Yo yo4;F;12102.54321;T;102.21;T;"POINT (0.7912661147227479 41.919324620992036)" |
|
15 |
14;52;T;5002;20190829121314; ;161314;T;Yo yo5;F;12103.54321;T;103.21;T;"POINT (1.052534629531243 41.493736996249545)" |
|
16 |
15;63;T;6003;20190729121314;20190729; ;T;Yo yo6;F;12104.54321;T;104.21;T;"POINT (0.8097002367335026 41.0899480235613)" |
|
17 |
16;74;T;7004;20190629121314;20190629;181314;T; ;F;12105.54321;T;105.21;T;"POINT (-0.4883960310112362 41.17597288081971)" |
|
18 |
17;85;T;8005;20190529121314;20190529;191314;T;Yo yo8;F; ;T;106.21;T;"POINT (-0.6439030698437881 40.89530766155764)" |
|
19 |
18;96;T;9006;20190429121314;20190429;201314;T;Yo yo9;F;12107.54321;T; ;T;"POINT (-1.3061826868199504 40.72372835570524)" |
|
20 |
19;97;T;1001;20191229121314;20191229;121314;T;Yo yo1;F;12345.54321;T;123.21;T;"POINT (-1.4673843010413785 40.51985891271157)" |
Also available in: Unified diff