001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.geoserver.wfs;
006:
007: import org.vfny.geoserver.global.Config;
008: import org.vfny.geoserver.global.ConfigurationException;
009: import org.vfny.geoserver.global.Data;
010: import org.vfny.geoserver.global.GeoServer;
011: import org.vfny.geoserver.global.GeoValidator;
012: import org.vfny.geoserver.global.dto.ServiceDTO;
013: import org.vfny.geoserver.global.dto.WFSDTO;
014:
015: /**
016: * WFS
017: *
018: * <p>
019: * Represents the GeoServer information required to configure an instance of
020: * the WFS Server. This class holds the currently used configuration and is
021: * instantiated initially by the GeoServerPlugIn at start-up, but may be
022: * modified by the Configuration Interface during runtime. Such modifications
023: * come from the GeoServer Object in the SessionContext.
024: * </p>
025: *
026: * <p>
027: * WFS wfs = new WFS(dto); System.out.println(wfs.getName());
028: * System.out.println(wfs.getAbstract());
029: * </p>
030: *
031: * @author Gabriel Rold???n
032: * @author Chris Holmes
033: * @author Justin Deoliveira
034: *
035: * @version $Id: WFS.java 7731 2007-11-10 02:52:30Z groldan $
036: */
037: public class WFS extends org.vfny.geoserver.global.Service {
038: /** web container key */
039: public static final String WEB_CONTAINER_KEY = "WFS";
040:
041: /** ServiceLevel bit used to indicate Basic support */
042: public static final int SERVICE_BASIC = WFSDTO.SERVICE_BASIC;
043:
044: /** ServiceLevel bit used to indicate Transaction Insert support */
045: public static final int SERVICE_INSERT = WFSDTO.SERVICE_INSERT;
046:
047: /** ServiceLevel bit used to indicate Transaction Update support */
048: public static final int SERVICE_UPDATE = WFSDTO.SERVICE_UPDATE;
049:
050: /** ServiceLevel bit used to indicate Transaction Delete support */
051: public static final int SERVICE_DELETE = WFSDTO.SERVICE_DELETE;
052:
053: /** ServiceLevel bit used to indicate Locking support */
054: public static final int SERVICE_LOCKING = WFSDTO.SERVICE_LOCKING;
055:
056: /** ServiceLevel mask equivilent to basic WFS conformance */
057: public static final int BASIC = WFSDTO.BASIC;
058:
059: /** ServiceLevel mask for transactional WFS conformance. */
060: public static final int TRANSACTIONAL = WFSDTO.TRANSACTIONAL;
061:
062: /** ServiceLevel mask equivilent to complete WFS conformance */
063: public static final int COMPLETE = WFSDTO.COMPLETE;
064:
065: /**
066: * Properties
067: */
068: private GeoValidator gv;
069: private int serviceLevel;
070: private boolean srsXmlStyle;
071: private boolean citeConformanceHacks;
072: private boolean featureBounding;
073:
074: /**
075: * WFS constructor.
076: *
077: * <p>
078: * Stores the data specified in the WFSDTO object in this WFS Object for
079: * GeoServer to use.
080: * </p>
081: *
082: * @param config The data intended for GeoServer to use.
083: */
084: public WFS(WFSDTO config) {
085: super (config.getService());
086: setId("wfs");
087: setSrsXmlStyle(config.isSrsXmlStyle());
088: setServiceLevel(config.getServiceLevel());
089: setCiteConformanceHacks(config.getCiteConformanceHacks());
090: setFeatureBounding(config.isFeatureBounding());
091: }
092:
093: /**
094: * Creates the WFS service by getting the WFSDTO object from the
095: * config and calling {@link #WFS(WFSDTO)}.
096: *
097: * @throws ConfigurationException
098: */
099: public WFS(Config config, Data data, GeoServer geoServer,
100: GeoValidator validator) throws ConfigurationException {
101: this (config.getWfs());
102: setData(data);
103: setGeoServer(geoServer);
104: setValidation(validator);
105: }
106:
107: /**
108: * WFS constructor.
109: *
110: * <p>
111: * Package constructor intended for default use by GeoServer
112: * </p>
113: *
114: * @see GeoServer#GeoServer()
115: */
116: WFS() {
117: super (new ServiceDTO());
118: setId("wfs");
119: }
120:
121: /**
122: * load purpose.
123: *
124: * <p>
125: * Loads a new data set into this object.
126: * </p>
127: *
128: * @param config
129: */
130: public void load(WFSDTO config) {
131: super .load(config.getService());
132: setSrsXmlStyle(config.isSrsXmlStyle());
133: setServiceLevel(config.getServiceLevel());
134: setCiteConformanceHacks(config.getCiteConformanceHacks());
135: setFeatureBounding(config.isFeatureBounding());
136: }
137:
138: /**
139: * Implement toDTO.
140: *
141: * <p>
142: * Package method used by GeoServer. This method may return references, and
143: * does not clone, so extreme caution sould be used when traversing the
144: * results.
145: * </p>
146: *
147: * @return WFSDTO An instance of the data this class represents. Please see
148: * Caution Above.
149: *
150: * @see org.vfny.geoserver.global.GlobalLayerSupertype#toDTO()
151: * @see WFSDTO
152: */
153: public Object toDTO() {
154: WFSDTO dto = new WFSDTO();
155: dto.setService((ServiceDTO) super .toDTO());
156:
157: dto.setServiceLevel(serviceLevel);
158: dto.setSrsXmlStyle(srsXmlStyle);
159: dto.setCiteConformanceHacks(citeConformanceHacks);
160: dto.setFeatureBounding(featureBounding);
161:
162: return dto;
163: }
164:
165: /**
166: * Whether the srs xml attribute should be in the EPSG:4326 (non-xml)
167: * style, or in the http://www.opengis.net/gml/srs/epsg.xml#4326 style.
168: *
169: * @return <tt>true</tt> if the srs is reported with the xml style
170: */
171: public boolean isSrsXmlStyle() {
172: return srsXmlStyle;
173: }
174:
175: /**
176: * Sets whether the srs xml attribute should be in the EPSG:4326 (non-xml)
177: * style, or in the http://www.opengis.net/gml/srs/epsg.xml#4326 style.
178: *
179: * @param doXmlStyle whether the srs style should be xml or not.
180: */
181: public void setSrsXmlStyle(boolean doXmlStyle) {
182: this .srsXmlStyle = doXmlStyle;
183: }
184:
185: /**
186: * Gets the prefix for the srs name, based on the SrsXmlStyle property. If
187: * srsXmlStyle is <tt>true</tt> then it is of the xml style, if false then
188: * it is EPSG: style. More apps seem to like the EPSG: style, but the
189: * specs seem to lean more to the xml type. The xml style should actually
190: * be more complete, with online lookups for the URI's, but I've seen no
191: * real online srs services.
192: *
193: * @return <tt>http://www.opengis.net/gml/srs/epsg.xml#</tt> if srsXmlStyle
194: * is <tt>true</tt>, <tt>EPSG:</tt> if <tt>false</tt>
195: */
196: public String getSrsPrefix() {
197: return srsXmlStyle ? "http://www.opengis.net/gml/srs/epsg.xml#"
198: : "EPSG:";
199: }
200:
201: /**
202: * Access gv property.
203: *
204: * @return Returns the gv.
205: */
206: public GeoValidator getValidation() {
207: return gv;
208: }
209:
210: /**
211: * Set gv to gv.
212: *
213: * @param gv The gv to set.
214: */
215: void setValidation(GeoValidator gv) {
216: this .gv = gv;
217: }
218:
219: /**
220: * Sets serviceLevel property.
221: *
222: * @param serviceLevel The new service level.
223: */
224: public void setServiceLevel(int serviceLevel) {
225: this .serviceLevel = serviceLevel;
226: }
227:
228: /**
229: * Access serviceLevel property.
230: *
231: * @return Returns the serviceLevel.
232: */
233: public int getServiceLevel() {
234: return serviceLevel;
235: }
236:
237: /**
238: * turn on/off the citeConformanceHacks option.
239: *
240: * @param on
241: */
242: public void setCiteConformanceHacks(boolean on) {
243: citeConformanceHacks = on;
244: }
245:
246: /**
247: * get the current value of the citeConformanceHacks
248: *
249: * @return
250: */
251: public boolean getCiteConformanceHacks() {
252: return (citeConformanceHacks);
253: }
254:
255: /**
256: * Returns whether the gml returned by getFeature includes an
257: * auto-calculated bounds element on each feature or not.
258: *
259: * @return <tt>true</tt> if the gml features will have boundedBy
260: * automatically generated.
261: */
262: public boolean isFeatureBounding() {
263: return featureBounding;
264: }
265:
266: /**
267: * Sets whether the gml returned by getFeature includes an auto-calculated
268: * bounds element on each feature or not.
269: *
270: * @param featureBounding <tt>true</tt> if gml features should have
271: * boundedBy automatically generated.
272: */
273: public void setFeatureBounding(boolean featureBounding) {
274: this.featureBounding = featureBounding;
275: }
276: }
|