comparison src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 133:6b80d2c7536e

Improved broken layer handling.
author vc11884admin@VC11884.win.bsh.de
date Tue, 21 Jun 2011 15:22:06 +0200
parents 5991c1f90f91
children a4ab239509f1
comparison
equal deleted inserted replaced
132:02df1dbc2166 133:6b80d2c7536e
9 import com.esri.arcgis.system.IPropertySet; 9 import com.esri.arcgis.system.IPropertySet;
10 import org.w3c.dom.Element; 10 import org.w3c.dom.Element;
11 11
12 import de.intevation.mxd.utils.MapToXMLUtils; 12 import de.intevation.mxd.utils.MapToXMLUtils;
13 import java.io.IOException; 13 import java.io.IOException;
14 14 import com.esri.arcgis.interop.AutomationException;
15 /** 15 /**
16 * Reads Layer information. 16 * Reads Layer information.
17 * 17 *
18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 18 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
19 */ 19 */
65 try { 65 try {
66 layerElement = util.addLayer(); 66 layerElement = util.addLayer();
67 } 67 }
68 catch(Exception e) { 68 catch(Exception e) {
69 logger.error("Failed to create DOM-Element for Layer."); 69 logger.error("Failed to create DOM-Element for Layer.");
70 throw new IOException( 70 return null;
71 this.getClass()+toString() +
72 "Error creating dom element");
73 } 71 }
74 72
75 try { 73 try {
76 layerElement.setAttribute("name", layer.getName()); 74 layerElement.setAttribute("name", layer.getName());
77 } 75 }
157 "Unknown FeatureClass name:" + 155 "Unknown FeatureClass name:" +
158 fcn.getClass().toString()); 156 fcn.getClass().toString());
159 } 157 }
160 } 158 }
161 catch(IOException ioe) { 159 catch(IOException ioe) {
162 logger.warn("Could not read datasource. Stopped reading layer."); 160 logger.warn(
163 throw new IOException( 161 "Could not read datasource." +
164 this.getClass().toString() + 162 " Stopped reading layer " + layer.getName() + ".");
165 "Error reading datasource."); 163 util.removeLayer(layerElement);
164 return null;
166 } 165 }
167 166
168 try { 167 try {
169 String datatype = layer.getDataSourceType(); 168 String datatype = layer.getDataSourceType();
170 if(datatype.equals("Shapefile Feature Class")) { 169 if(layer.getWorkspace().getType() == 0) {
171 layerElement.setAttribute("connection_type", "local"); 170 layerElement.setAttribute("connection_type", "local");
172 layerElement.setAttribute( 171 layerElement.setAttribute(
173 "workspace", 172 "workspace",
174 layer.getWorkspace().getPathName()); 173 layer.getWorkspace().getPathName());
175 } 174 }
176 else if(datatype.equals("File Geodatabase Feature Class")){ 175 else if(layer.getWorkspace().getType() == 1){
177 layerElement.setAttribute("connection_type", "ogr"); 176 layerElement.setAttribute("connection_type", "ogr");
178 layerElement.setAttribute("data", layer.getFeatureClass().getFeatureDataset().getName()); 177 layerElement.setAttribute(
178 "data",
179 layer.getFeatureClass().getFeatureDataset().getName());
179 layerElement.setAttribute( 180 layerElement.setAttribute(
180 "workspace", 181 "workspace",
181 layer.getWorkspace().getPathName()); 182 layer.getWorkspace().getPathName());
182 183
183 } 184 }
184 else if(datatype.equals("SDE Feature Class")) { 185 else if(layer.getWorkspace().getType() == 2) {
185 IPropertySet set = layer.getWorkspace().getConnectionProperties(); 186 IPropertySet set = layer.getWorkspace().getConnectionProperties();
186 Object names[] = new Object[set.getCount()]; 187 Object names[] = new Object[set.getCount()];
187 Object prop[] = new Object[set.getCount()]; 188 Object prop[] = new Object[set.getCount()];
188 set.getAllProperties(names, prop); 189 set.getAllProperties(names, prop);
189 layerElement.setAttribute("connection_type", "SDE"); 190 layerElement.setAttribute("connection_type", "SDE");
195 prop_names[j].toLowerCase(), 196 prop_names[j].toLowerCase(),
196 set.getProperty(prop_names[j]).toString()); 197 set.getProperty(prop_names[j]).toString());
197 } 198 }
198 } 199 }
199 } 200 }
200 layerElement.setAttribute( 201 try {
201 "join_table", 202 layerElement.setAttribute(
202 layer.getRelationshipClass() 203 "join_table",
203 .getOriginClass().getAliasName()); 204 layer.getRelationshipClass()
204 layerElement.setAttribute( 205 .getOriginClass().getAliasName());
205 "join_field", 206 layerElement.setAttribute(
206 layer.getRelationshipClass().getOriginPrimaryKey()); 207 "join_field",
207 layerElement.setAttribute( 208 layer.getRelationshipClass().getOriginPrimaryKey());
208 "join_table_target", 209 layerElement.setAttribute(
209 layer.getRelationshipClass() 210 "join_table_target",
210 .getDestinationClass().getAliasName()); 211 layer.getRelationshipClass()
211 layerElement.setAttribute( 212 .getDestinationClass().getAliasName());
212 "join_field_target", 213 layerElement.setAttribute(
213 layer.getRelationshipClass().getOriginForeignKey()); 214 "join_field_target",
215 layer.getRelationshipClass().getOriginForeignKey());
216 }
217 catch(AutomationException ioe) {
218 //Do nothing, cause no jointable defined.
219 }
220 catch(IOException ae) {
221 //Do nothing, cause no jointable defined.
222 }
223 catch(NullPointerException npe) {
224 //Do nothing, cause no jointable defined.
225 }
214 } 226 }
215 } 227 }
216 catch(Exception e) { 228 catch(Exception e) {
217 logger.error( 229 logger.error(
218 "Could not read layer datasource." + 230 "Could not read layer datasource." +
219 " Stopped reading layer."); 231 " Stopped reading layer " + layer.getName() + ".");
220 throw new IOException( 232 util.removeLayer(layerElement);
221 this.getClass().toString() + 233 return null;
222 " Error reading data source.");
223 } 234 }
224 return layerElement; 235 return layerElement;
225 } 236 }
226 } 237 }
227 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 238 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)