001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/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 17:22:25 +0100 (Do, 27 Dez 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, Map<PropertyPath, FeatureProperty> replacementProps,
104 Filter filter ) {
105 super( handle );
106 this.typeName = typeName;
107 this.replacementProps = replacementProps;
108 this.filter = filter;
109 }
110
111 /**
112 * Creates a new <code>Update</code> instance.
113 * <p>
114 * NOTE: This constructor will be removed in the future, because it makes the DOM representation
115 * available and breaks the layering (DOM should not be used on this level).
116 *
117 * @param handle
118 * optional identifier for the operation (for error messsages)
119 * @param typeName
120 * the name of the targeted feature type
121 * @param replacementProps
122 * property paths and their replacement values
123 * @param rawProps
124 * property paths and their DOM nodes
125 * @param filter
126 * selects the feature instances to be updated
127 * @deprecated This method breaks the layering -- it makes the DOM representation available.
128 */
129 @Deprecated
130 Update( String handle, QualifiedName typeName, Map<PropertyPath, FeatureProperty> replacementProps,
131 Map<PropertyPath, Node> rawProps, Filter filter ) {
132 super( handle );
133 this.typeName = typeName;
134 this.replacementProps = replacementProps;
135 this.rawProps = rawProps;
136 this.filter = filter;
137 }
138
139 /**
140 * Creates a new <code>Update</code> instance.
141 *
142 * @param handle
143 * optional identifier for the operation (for error messsages)
144 * @param typeName
145 * the name of the targeted feature type
146 * @param replacementFeature
147 * property names and their replacement values
148 * @param filter
149 * selects the (single) feature instance to be replaced
150 */
151 public Update( String handle, QualifiedName typeName, Feature replacementFeature, Filter filter ) {
152 super( handle );
153 this.typeName = typeName;
154 this.replacementFeature = replacementFeature;
155 this.filter = filter;
156 }
157
158 /**
159 * Returns the name of the targeted feature type.
160 *
161 * @return the name of the targeted feature type.
162 */
163 public QualifiedName getTypeName() {
164 return this.typeName;
165 }
166
167 /**
168 * Returns the filter that selects the feature instances to be updated.
169 *
170 * @return the filter that selects the feature instances to be updated
171 */
172 public Filter getFilter() {
173 return this.filter;
174 }
175
176 /**
177 * Sets the filter that determines the features that are affected by the operation.
178 *
179 * @param filter
180 * determines the features that are affected by the operation
181 */
182 public void setFilter( Filter filter ) {
183 this.filter = filter;
184 }
185
186 /**
187 * Returns the feature that will replace the matched feature instance. If the returned value is null, this is a
188 * "standard" update operation that updates a number of flat properties instead.
189 *
190 * @return the feature that will replace the (single) matched feature instance
191 */
192 public Feature getFeature() {
193 return this.replacementFeature;
194 }
195
196 /**
197 * Return the properties and their replacement values that are targeted by this update operation.
198 *
199 * @return the properties and their replacement values
200 */
201 public Map<PropertyPath, FeatureProperty> getReplacementProperties() {
202 return this.replacementProps;
203 }
204
205 /**
206 * Return the properties and their replacement values (as DOM representation).
207 *
208 * NOTE: This constructor will be removed in the future, because it makes the DOM representation
209 * available and breaks the layering (DOM should not be used on this level).
210 *
211 * @return the properties and their replacement values (as Nodes)
212 * @deprecated This method breaks the layering -- it makes the DOM representation available.
213 */
214 @Deprecated
215 public Map<PropertyPath, Node> getRawProperties() {
216 return this.rawProps;
217 }
218
219 @Override
220 public List<QualifiedName> getAffectedFeatureTypes() {
221 List<QualifiedName> featureTypes = new ArrayList<QualifiedName>( 1 );
222 featureTypes.add( this.typeName );
223 return featureTypes;
224 }
225 }