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