comparison geo-backend/src/test/java/de/intevation/gnv/geobackend/base/query/ToCharSample.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 ToCharSample { 16 public class ToCharSample {
17 17
18 18
19 public boolean executeQuery(SeConnection con, String[] pLayername, 19 public boolean 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 return true; 81 return true;
82 } catch (Exception e){ 82 } catch (Exception e){
83 e.printStackTrace(); 83 e.printStackTrace();
84 return false; 84 return false;
85 } 85 }
86 86
87 } 87 }
88 88
89 89
90 /** 90 /**
91 * @param args 91 * @param args
92 */ 92 */
93 public static void main(String[] args) { 93 public static void main(String[] args) {
94 94
95 try { 95 try {
96 96
97 String[] layerNames = new String[] { "MEDIAN.TRACK" }; 97 String[] layerNames = new String[] { "MEDIAN.TRACK" };
98 String spatialColumnName = "SHAPE"; 98 String spatialColumnName = "SHAPE";
99 String where = "MEDIAN.TRACK.CRUISEID = 47"; 99 String where = "MEDIAN.TRACK.CRUISEID = 47";
100 String[] returnFields = new String[] { "MEDIAN.TRACK.TRACKID KEY", 100 String[] returnFields = new String[] { "MEDIAN.TRACK.TRACKID KEY",
101 "to_char(STARTDATE,'DD.MM.YYYY HH24:MI') || ' - '|| to_char(ENDDATE,'DD.MM.YYYY HH24:MI') || ' - '|| NAME VALUE", 101 "to_char(STARTDATE,'DD.MM.YYYY HH24:MI') || ' - '|| to_char(ENDDATE,'DD.MM.YYYY HH24:MI') || ' - '|| NAME VALUE",
102 "NAME" }; 102 "NAME" };
103 String byClause = "ORDER BY STARTDATE, ENDDATE, NAME"; 103 String byClause = "ORDER BY STARTDATE, ENDDATE, NAME";
104 SDEPoint[] g = new SDEPoint[5]; 104 SDEPoint[] g = new SDEPoint[5];
105 g[0] = new SDEPoint(52, 8); 105 g[0] = new SDEPoint(52, 8);
111 String server = ""; 111 String server = "";
112 String port = ""; 112 String port = "";
113 String database = ""; 113 String database = "";
114 String username = ""; 114 String username = "";
115 String credentials = ""; 115 String credentials = "";
116 116
117 SeConnection con = new SeConnection(server, port, 117 SeConnection con = new SeConnection(server, port,
118 database, username, 118 database, username,
119 credentials); 119 credentials);
120 boolean success = new ToCharSample().executeQuery(con, layerNames, spatialColumnName, 120 boolean success = new ToCharSample().executeQuery(con, layerNames, spatialColumnName,
121 where, g, returnFields, byClause); 121 where, g, returnFields, byClause);
122 122
123 if (success){ 123 if (success){
124 System.out.println("Terminated successful."); 124 System.out.println("Terminated successful.");
125 }else{ 125 }else{
126 System.out.println("Terminated with an Exception."); 126 System.out.println("Terminated with an Exception.");
127 } 127 }

http://dive4elements.wald.intevation.org