001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/ogcwebservices/wfs/operation/transaction/Delete.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.Iterator;
040 import java.util.List;
041 import java.util.Map;
042
043 import org.deegree.datatypes.QualifiedName;
044 import org.deegree.model.feature.Feature;
045 import org.deegree.model.filterencoding.Filter;
046
047 /**
048 * Represents a <code>Delete</code> operation as a part of a {@link Transaction} request.
049 * <p>
050 * WFS Specification OGC 04-094 (#12.2.6 Pg.71):
051 * <p>
052 * The <code>Delete</code> element is used to indicate that one of more feature instances should be deleted. The scope
053 * of the delete operation is constrained by using the <code>Filter</code> element as described in the <b>Filter
054 * Encoding Specification[3]</b>.<br>
055 * In the event, that the {@link Filter} element does not identify any {@link Feature} instances to <code>Delete</code>,
056 * the <code>Delete</code> action will simply have no effect. <br>
057 * <b>This is not an exception condition</b>.
058 *
059 * @author <a href="mailto:deshmukh@lat-lon.de">Anup Deshmukh </a>
060 * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
061 * @author last edited by: $Author: aionita $
062 *
063 * @version $Revision: 23794 $, $Date: 2010-04-23 15:05:33 +0200 (Fr, 23 Apr 2010) $
064 */
065 public class Delete extends TransactionOperation {
066
067 private QualifiedName typeName;
068
069 private Filter filter;
070
071 /**
072 * Creates a new <code>Delete<code> instance.
073 *
074 * @param handle
075 * optional identifier for the operation (for error messsages)
076 * @param typeName
077 * name of the targeted feature type
078 * @param filter
079 * selects the feature instances to be deleted
080 */
081 public Delete( String handle, QualifiedName typeName, Filter filter ) {
082 super( handle );
083 this.typeName = typeName;
084 this.filter = filter;
085 }
086
087 /**
088 * Returns the name of the targeted feature type.
089 *
090 * @return the name of the targeted feature type.
091 */
092 public QualifiedName getTypeName() {
093 return this.typeName;
094 }
095
096 /**
097 * Setter method for the type name
098 *
099 * @param typeName
100 * a {@link QualifiedName}
101 */
102 public void setTypeName( QualifiedName typeName ) {
103 this.typeName = typeName;
104 }
105
106 /**
107 * Return <code>Filter</code>.
108 *
109 * @return Filter filter
110 */
111 public Filter getFilter() {
112 return this.filter;
113 }
114
115 /**
116 * sets the filter condition for an delete operation. This method may be use by classes/moduls that need to
117 * manipulate an update operation e.g. to ensure security constraints.
118 *
119 * @param filter
120 */
121 public void setFilter( Filter filter ) {
122 this.filter = filter;
123 }
124
125 /**
126 * Returns the names of the feature types that are affected by the operation.
127 * <p>
128 * For the <code>Delete</code> operation, this is a list with a single entry - the value of the "typeName"
129 * attribute.
130 *
131 * @return the names of the affected feature types.
132 */
133 @Override
134 public List<QualifiedName> getAffectedFeatureTypes() {
135 List<QualifiedName> featureTypes = new ArrayList<QualifiedName>( 1 );
136 featureTypes.add( this.typeName );
137 return featureTypes;
138 }
139
140 /**
141 * Creates <code>Delete</code> instances from a KVP request.
142 *
143 * @param typeFilter
144 * @return Delete instances
145 */
146 protected static List<Delete> create( Map<QualifiedName, Filter> typeFilter ) {
147
148 List<Delete> deletes = new ArrayList<Delete>();
149 if ( typeFilter != null ) {
150 Iterator<QualifiedName> iter = typeFilter.keySet().iterator();
151 while ( iter.hasNext() ) {
152 QualifiedName typeName = iter.next();
153 Filter filter = typeFilter.get( typeName );
154 deletes.add( new Delete( null, typeName, filter ) );
155 }
156 }
157 return deletes;
158 }
159 }