001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/wfs/operation/transaction/Update.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstraße 19
030: 53177 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042: ---------------------------------------------------------------------------*/
043: package org.deegree.ogcwebservices.wfs.operation.transaction;
044:
045: import java.util.ArrayList;
046: import java.util.List;
047: import java.util.Map;
048:
049: import org.deegree.datatypes.QualifiedName;
050: import org.deegree.model.feature.Feature;
051: import org.deegree.model.feature.FeatureProperty;
052: import org.deegree.model.filterencoding.Filter;
053: import org.deegree.ogcbase.PropertyPath;
054: import org.w3c.dom.Node;
055:
056: /**
057: * Represents an <code>Update</code> operation as a part of a {@link Transaction} request.
058: * <p>
059: * WFS Specification OBC 04-094 (#12.2.5 Pg.68)
060: * <p>
061: * The <code>Update</code> element describes one update operation that is to be applied to a <code>Feature</code> or
062: * a set of <code>Feature</code>s of a single <code>FeatureType</code>.
063: * <p>
064: * Multiple <code>Update</code> operations can be contained in a single <code>Transaction</code> request. An
065: * <code>Update</code> element contains one or more <b>Property</b> elements that specify the name and replacement
066: * value for a property that belongs to the <code>FeatureType</code> specified using the <b>mandatory typeName</b>
067: * attribute.
068: * <p>
069: * Additionally, a deegree specific addition to this specification is supported:<br>
070: * Instead of a number of properties, it is also possible to specify a root feature that will replace the feature that
071: * is matched by the filter. In this case, the filter must match exactly one (or zero) feature instances.
072: *
073: * @author <a href="mailto:deshmukh@lat-lon.de">Anup Deshmukh </a>
074: * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
075: * @author last edited by: $Author: apoth $
076: *
077: * @version $Revision: 9345 $, $Date: 2007-12-27 08:22:25 -0800 (Thu, 27 Dec 2007) $
078: */
079: public class Update extends TransactionOperation {
080:
081: private QualifiedName typeName;
082:
083: private Feature replacementFeature;
084:
085: private Map<PropertyPath, FeatureProperty> replacementProps;
086:
087: private Filter filter;
088:
089: private Map<PropertyPath, Node> rawProps;
090:
091: /**
092: * Creates a new <code>Update</code> instance.
093: *
094: * @param handle
095: * optional identifier for the operation (for error messsages)
096: * @param typeName
097: * the name of the targeted feature type
098: * @param replacementProps
099: * property paths and their replacement values
100: * @param filter
101: * selects the feature instances to be updated
102: */
103: public Update(String handle, QualifiedName typeName,
104: Map<PropertyPath, FeatureProperty> replacementProps,
105: Filter filter) {
106: super (handle);
107: this .typeName = typeName;
108: this .replacementProps = replacementProps;
109: this .filter = filter;
110: }
111:
112: /**
113: * Creates a new <code>Update</code> instance.
114: * <p>
115: * NOTE: This constructor will be removed in the future, because it makes the DOM representation
116: * available and breaks the layering (DOM should not be used on this level).
117: *
118: * @param handle
119: * optional identifier for the operation (for error messsages)
120: * @param typeName
121: * the name of the targeted feature type
122: * @param replacementProps
123: * property paths and their replacement values
124: * @param rawProps
125: * property paths and their DOM nodes
126: * @param filter
127: * selects the feature instances to be updated
128: * @deprecated This method breaks the layering -- it makes the DOM representation available.
129: */
130: @Deprecated
131: Update(String handle, QualifiedName typeName,
132: Map<PropertyPath, FeatureProperty> replacementProps,
133: Map<PropertyPath, Node> rawProps, Filter filter) {
134: super (handle);
135: this .typeName = typeName;
136: this .replacementProps = replacementProps;
137: this .rawProps = rawProps;
138: this .filter = filter;
139: }
140:
141: /**
142: * Creates a new <code>Update</code> instance.
143: *
144: * @param handle
145: * optional identifier for the operation (for error messsages)
146: * @param typeName
147: * the name of the targeted feature type
148: * @param replacementFeature
149: * property names and their replacement values
150: * @param filter
151: * selects the (single) feature instance to be replaced
152: */
153: public Update(String handle, QualifiedName typeName,
154: Feature replacementFeature, Filter filter) {
155: super (handle);
156: this .typeName = typeName;
157: this .replacementFeature = replacementFeature;
158: this .filter = filter;
159: }
160:
161: /**
162: * Returns the name of the targeted feature type.
163: *
164: * @return the name of the targeted feature type.
165: */
166: public QualifiedName getTypeName() {
167: return this .typeName;
168: }
169:
170: /**
171: * Returns the filter that selects the feature instances to be updated.
172: *
173: * @return the filter that selects the feature instances to be updated
174: */
175: public Filter getFilter() {
176: return this .filter;
177: }
178:
179: /**
180: * Sets the filter that determines the features that are affected by the operation.
181: *
182: * @param filter
183: * determines the features that are affected by the operation
184: */
185: public void setFilter(Filter filter) {
186: this .filter = filter;
187: }
188:
189: /**
190: * Returns the feature that will replace the matched feature instance. If the returned value is null, this is a
191: * "standard" update operation that updates a number of flat properties instead.
192: *
193: * @return the feature that will replace the (single) matched feature instance
194: */
195: public Feature getFeature() {
196: return this .replacementFeature;
197: }
198:
199: /**
200: * Return the properties and their replacement values that are targeted by this update operation.
201: *
202: * @return the properties and their replacement values
203: */
204: public Map<PropertyPath, FeatureProperty> getReplacementProperties() {
205: return this .replacementProps;
206: }
207:
208: /**
209: * Return the properties and their replacement values (as DOM representation).
210: *
211: * NOTE: This constructor will be removed in the future, because it makes the DOM representation
212: * available and breaks the layering (DOM should not be used on this level).
213: *
214: * @return the properties and their replacement values (as Nodes)
215: * @deprecated This method breaks the layering -- it makes the DOM representation available.
216: */
217: @Deprecated
218: public Map<PropertyPath, Node> getRawProperties() {
219: return this .rawProps;
220: }
221:
222: @Override
223: public List<QualifiedName> getAffectedFeatureTypes() {
224: List<QualifiedName> featureTypes = new ArrayList<QualifiedName>(
225: 1);
226: featureTypes.add(this.typeName);
227: return featureTypes;
228: }
229: }
|