comparison geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/GroupBySample.java @ 885:1c3efbd2fc5a

Removes trailing whitespace. geo-backend/trunk@850 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 29 Mar 2010 07:49:16 +0000
parents 0ee3c0ed40e4
children ebeb56428409
comparison
equal deleted inserted replaced
884:12f88239fb33 885:1c3efbd2fc5a
13 import com.esri.sde.sdk.client.SeShapeFilter; 13 import com.esri.sde.sdk.client.SeShapeFilter;
14 import com.esri.sde.sdk.client.SeSqlConstruct; 14 import com.esri.sde.sdk.client.SeSqlConstruct;
15 15
16 public class GroupBySample { 16 public class GroupBySample {
17 17
18 18
19 public void executeQuery(SeConnection con, String[] pLayername, 19 public void executeQuery(SeConnection con, String[] pLayername,
20 String pSpatialColumnName, String pWhere, 20 String pSpatialColumnName, String pWhere,
21 SDEPoint[] g, String[] pReturnFields, String byClause) { 21 SDEPoint[] g, String[] pReturnFields, String byClause) {
22 22
23 try { 23 try {
24 // get the layer for querying 24 // get the layer for querying
25 25
26 SeShapeFilter[] filters = null; 26 SeShapeFilter[] filters = null;
27 if (g != null){ 27 if (g != null){
28 SeLayer lLayer = new SeLayer(con, pLayername[0], pSpatialColumnName); 28 SeLayer lLayer = new SeLayer(con, pLayername[0], pSpatialColumnName);
29 SeShape shape = new SeShape(); 29 SeShape shape = new SeShape();
30 shape.setCoordRef(lLayer.getCoordRef()); 30 shape.setCoordRef(lLayer.getCoordRef());
31 31
32 32
33 33
34 shape.generatePolygon(g.length, 1, null, g); 34 shape.generatePolygon(g.length, 1, null, g);
35 SeShapeFilter filter = new SeShapeFilter(pLayername[0], 35 SeShapeFilter filter = new SeShapeFilter(pLayername[0],
36 pSpatialColumnName, shape, SeFilter.METHOD_AI); 36 pSpatialColumnName, shape, SeFilter.METHOD_AI);
37 filters = new SeShapeFilter[1]; 37 filters = new SeShapeFilter[1];
38 filters[0] = filter; 38 filters[0] = filter;
39 } 39 }
40 40
41 SeQuery spatialQuery = null; 41 SeQuery spatialQuery = null;
42 SeSqlConstruct sqlCons = new SeSqlConstruct(pLayername, pWhere); 42 SeSqlConstruct sqlCons = new SeSqlConstruct(pLayername, pWhere);
43 spatialQuery = new SeQuery(con); 43 spatialQuery = new SeQuery(con);
44 44
45 SeQueryInfo queryInfo = new SeQueryInfo(); 45 SeQueryInfo queryInfo = new SeQueryInfo();
46 queryInfo.setColumns(pReturnFields); 46 queryInfo.setColumns(pReturnFields);
47 47
48 if (byClause != null){ 48 if (byClause != null){
49 queryInfo.setByClause(byClause); 49 queryInfo.setByClause(byClause);
50 } 50 }
51 51
52 queryInfo.setConstruct(sqlCons); 52 queryInfo.setConstruct(sqlCons);
53 spatialQuery.prepareQueryInfo(queryInfo); 53 spatialQuery.prepareQueryInfo(queryInfo);
54 54
55 /* 55 /*
56 * Set spatial constraints 56 * Set spatial constraints
66 for (lCount = 0; (row =spatialQuery.fetch()) != null; lCount++) { 66 for (lCount = 0; (row =spatialQuery.fetch()) != null; lCount++) {
67 // one time execution 67 // one time execution
68 if (lCount == 0) { 68 if (lCount == 0) {
69 // analyze cols of result set 69 // analyze cols of result set
70 SeColumnDefinition[] lCols = row.getColumns(); 70 SeColumnDefinition[] lCols = row.getColumns();
71 71
72 } 72 }
73 short lNumCols = row.getNumColumns(); 73 short lNumCols = row.getNumColumns();
74 74
75 for (int i = 0; i < lNumCols; i++) { 75 for (int i = 0; i < lNumCols; i++) {
76 System.out.println(row.getObject(i)); 76 System.out.println(row.getObject(i));
77 } 77 }
78 78
79 } 79 }
80 spatialQuery.close(); 80 spatialQuery.close();
81 81
82 } catch (Exception e){ 82 } catch (Exception e){
83 e.printStackTrace(); 83 e.printStackTrace();
84 } 84 }
85 85
86 } 86 }
87 87
88 88
89 /** 89 /**
90 * @param args 90 * @param args
91 */ 91 */
92 public static void main(String[] args) { 92 public static void main(String[] args) {
93 93
94 try { 94 try {
95 String[] layerNames = new String[] { "median.meshpoint", "median.mesh" }; 95 String[] layerNames = new String[] { "median.meshpoint", "median.mesh" };
96 String spatialColumnName = "SHAPE"; 96 String spatialColumnName = "SHAPE";
97 String where = "median.meshpoint.meshid = median.mesh.meshid"; 97 String where = "median.meshpoint.meshid = median.mesh.meshid";
98 String[] returnFields = new String[] { "sourceid" }; 98 String[] returnFields = new String[] { "sourceid" };
107 String server = ""; 107 String server = "";
108 String port = ""; 108 String port = "";
109 String database = ""; 109 String database = "";
110 String username = ""; 110 String username = "";
111 String credentials = ""; 111 String credentials = "";
112 SeConnection con = new SeConnection(server, port, 112 SeConnection con = new SeConnection(server, port,
113 database, username, 113 database, username,
114 credentials); 114 credentials);
115 new GroupBySample().executeQuery(con, layerNames, spatialColumnName, 115 new GroupBySample().executeQuery(con, layerNames, spatialColumnName,
116 where, g, returnFields, byClause); 116 where, g, returnFields, byClause);
117 117
118 118
119 } catch (SeException e) { 119 } catch (SeException e) {
120 e.printStackTrace(); 120 e.printStackTrace();
121 } 121 }
122 } 122 }
123 } 123 }

http://dive4elements.wald.intevation.org