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.vfny.geoserver.config;
006:
007: import org.geoserver.wfs.WFS;
008: import org.vfny.geoserver.global.dto.ServiceDTO;
009: import org.vfny.geoserver.global.dto.WFSDTO;
010:
011: /**
012: * WFS purpose.
013: *
014: * <p>
015: * Description of WFS Used to store WFS data.
016: * </p>
017: *
018: * <p></p>
019: *
020: * @author dzwiers, Refractions Research, Inc.
021: * @version $Id: WFSConfig.java 6326 2007-03-15 18:36:40Z jdeolive $
022: */
023: public class WFSConfig extends ServiceConfig {
024: public static final String CONFIG_KEY = "Config.WFS";
025: private int serviceLevel;
026: private boolean citeConformanceHacks = false; // see WFSDTO for more info
027: private boolean featureBounding = false;
028: private boolean srsXmlStyle = true;
029:
030: /**
031: * WFS constructor.
032: *
033: * <p>
034: * Creates a WFS to represent an instance with default data.
035: * </p>
036: *
037: * @see defaultSettings()
038: */
039: public WFSConfig() {
040: super ();
041: srsXmlStyle = true;
042: }
043:
044: /**
045: * WFS constructor.
046: *
047: * <p>
048: * Creates a copy of the WFS provided. If the WFS provided is null then
049: * default values are used. All the data structures are cloned.
050: * </p>
051: *
052: * @param w The WFS to copy.
053: */
054: public WFSConfig(WFSDTO w) {
055: super (w.getService());
056: serviceLevel = w.getServiceLevel();
057: srsXmlStyle = w.isSrsXmlStyle();
058: citeConformanceHacks = w.getCiteConformanceHacks();
059: featureBounding = w.isFeatureBounding();
060: }
061:
062: /**
063: * Creates the WFSConfig.
064: *
065: * @param wfs The wfs module.
066: *
067: */
068: public WFSConfig(WFS wfs) {
069: this ((WFSDTO) wfs.toDTO());
070: }
071:
072: /**
073: * Implement loadDTO.
074: *
075: * <p>
076: * Takes a WMSDTO and loads it into this WMSConfig Object
077: * </p>
078: *
079: * @param dto an instance of WMSDTO
080: *
081: * @throws NullPointerException DOCUMENT ME!
082: *
083: * @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object)
084: */
085: public void update(WFSDTO dto) {
086: if (dto == null) {
087: throw new NullPointerException(
088: "WFS Data Transfer Object required");
089: }
090:
091: super .update(dto.getService());
092: srsXmlStyle = dto.isSrsXmlStyle();
093: serviceLevel = dto.getServiceLevel();
094:
095: citeConformanceHacks = dto.getCiteConformanceHacks();
096: featureBounding = dto.isFeatureBounding();
097: }
098:
099: /**
100: * Implement toDTO.
101: *
102: * <p>
103: * Returns a copy of the data in a ServiceDTO object
104: * </p>
105: *
106: * @return a copy of the data in a ServiceDTO object
107: *
108: * @see org.vfny.geoserver.config.DataStructure#toDTO()
109: */
110: public WFSDTO toDTO() {
111: WFSDTO wfsDto = new WFSDTO();
112: wfsDto.setService((ServiceDTO) super .toServDTO());
113: wfsDto.setServiceLevel(serviceLevel);
114: wfsDto.setSrsXmlStyle(srsXmlStyle);
115:
116: wfsDto.setCiteConformanceHacks(citeConformanceHacks);
117: wfsDto.setFeatureBounding(featureBounding);
118:
119: return wfsDto;
120: }
121:
122: /**
123: * Access serviceLevel property.
124: *
125: * @return Returns the serviceLevel.
126: */
127: public int getServiceLevel() {
128: return serviceLevel;
129: }
130:
131: /**
132: * Set serviceLevel to serviceLevel.
133: *
134: * @param serviceLevel The serviceLevel to set.
135: */
136: public void setServiceLevel(int serviceLevel) {
137: this .serviceLevel = serviceLevel;
138: }
139:
140: /**
141: * Whether the srs xml attribute should be in the EPSG:4326 (non-xml)
142: * style, or in the http://www.opengis.net/gml/srs/epsg.xml#4326 style.
143: *
144: * @return <tt>true</tt> if the srs is reported with the xml style
145: */
146: public boolean isSrsXmlStyle() {
147: return srsXmlStyle;
148: }
149:
150: /**
151: * Sets whether the srs xml attribute should be in the EPSG:4326 (non-xml)
152: * style, or in the http://www.opengis.net/gml/srs/epsg.xml#4326 style.
153: *
154: * @param doXmlStyle whether the srs style should be xml or not.
155: */
156: public void setSrsXmlStyle(boolean doXmlStyle) {
157: this .srsXmlStyle = doXmlStyle;
158: }
159:
160: /**
161: * turn on/off the citeConformanceHacks option.
162: *
163: * @param on
164: */
165: public void setCiteConformanceHacks(boolean on) {
166: citeConformanceHacks = on;
167: }
168:
169: /**
170: * get the current value of the citeConformanceHacks
171: *
172: * @return
173: */
174: public boolean getCiteConformanceHacks() {
175: return (citeConformanceHacks);
176: }
177:
178: /**
179: * Returns whether the gml returned by getFeature includes an
180: * auto-calculated bounds element on each feature or not.
181: *
182: * @return <tt>true</tt> if the gml features will have boundedBy
183: * automatically generated.
184: */
185: public boolean isFeatureBounding() {
186: return featureBounding;
187: }
188:
189: /**
190: * Sets whether the gml returned by getFeature includes an auto-calculated
191: * bounds element on each feature or not.
192: *
193: * @param featureBounding <tt>true</tt> if gml features should have
194: * boundedBy automatically generated.
195: */
196: public void setFeatureBounding(boolean featureBounding) {
197: this.featureBounding = featureBounding;
198: }
199: }
|