001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/wfs/operation/transaction/Insert.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.net.URI;
046: import java.util.ArrayList;
047: import java.util.HashSet;
048: import java.util.List;
049: import java.util.Set;
050:
051: import org.deegree.datatypes.QualifiedName;
052: import org.deegree.model.feature.Feature;
053: import org.deegree.model.feature.FeatureCollection;
054:
055: /**
056: * Represents an <code>Insert</code> operation as a part of a {@link Transaction} request.
057: *
058: * @author <a href="mailto:deshmukh@lat-lon.de">Anup Deshmukh </a>
059: * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
060: * @author last edited by: $Author: apoth $
061: *
062: * @version $Revision: 9345 $, $Date: 2007-12-27 08:22:25 -0800 (Thu, 27 Dec 2007) $
063: */
064: public class Insert extends TransactionOperation {
065:
066: /**
067: * Generation strategies for feature ids.
068: */
069: public static enum ID_GEN {
070:
071: /** Use provided feature ids. */
072: USE_EXISTING,
073:
074: /** Use provided feature ids, generate new id if feature with same id already exists. */
075: REPLACE_DUPLICATE,
076:
077: /** Always generate new feature ids. */
078: GENERATE_NEW
079: }
080:
081: /** Always generate new feature ids. */
082: public static final String ID_GEN_GENERATE_NEW_STRING = "GenerateNew";
083:
084: /** Use provided feature ids. */
085: public static final String ID_GEN_USE_EXISTING_STRING = "UseExisting";
086:
087: /** Use provided feature ids, generate new id if feature with same id already exists. */
088: public static final String ID_GEN_REPLACE_DUPLICATE_STRING = "ReplaceDuplicate";
089:
090: private ID_GEN idGenMode;
091:
092: private URI srsName;
093:
094: private FeatureCollection fc;
095:
096: /**
097: * Creates a new <code>Insert</code> instance.
098: *
099: * @param handle
100: * optional identifier for the operation (for error messsages)
101: * @param idGenMode
102: * mode for feature id generation
103: * @param srsName
104: * name of the spatial reference system
105: * @param fc
106: * feature instances to be inserted, wrapped in a <code>FeatureCollection</code>
107: */
108: public Insert(String handle, ID_GEN idGenMode, URI srsName,
109: FeatureCollection fc) {
110: super (handle);
111: this .idGenMode = idGenMode;
112: this .srsName = srsName;
113: this .fc = fc;
114: }
115:
116: /**
117: * Returns the mode for id generation.
118: * <p>
119: * Must be one of the following:
120: * <ul>
121: * <li>ID_GEN.USE_EXISTING</li>
122: * <li>ID_GEN.REPLACE_DUPLICATE</li>
123: * <li>ID_GEN.GENERATE_NEW</li>
124: * </ul>
125: *
126: * @return the mode for id generation
127: */
128: public ID_GEN getIdGen() {
129: return this .idGenMode;
130: }
131:
132: /**
133: * Returns the asserted SRS of the features to be inserted.
134: *
135: * @return the asserted SRS of the features
136: */
137: public URI getSRSName() {
138: return this .srsName;
139: }
140:
141: /**
142: * Returns the feature instances to be inserted.
143: *
144: * @return the feature instances to be inserted
145: */
146: public FeatureCollection getFeatures() {
147: return this .fc;
148: }
149:
150: /**
151: * Returns the names of the feature types that are affected by the operation.
152: *
153: * @return the names of the affected feature types
154: */
155: @Override
156: public List<QualifiedName> getAffectedFeatureTypes() {
157: Set<QualifiedName> featureTypeSet = new HashSet<QualifiedName>();
158: for (int i = 0; i < this .fc.size(); i++) {
159: Feature feature = this .fc.getFeature(i);
160: featureTypeSet.add(feature.getName());
161: }
162: List<QualifiedName> featureTypes = new ArrayList<QualifiedName>(
163: featureTypeSet);
164: return featureTypes;
165: }
166: }
|