001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/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 17:22:25 +0100 (Do, 27 Dez 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, FeatureCollection fc ) { 109 super( handle ); 110 this.idGenMode = idGenMode; 111 this.srsName = srsName; 112 this.fc = fc; 113 } 114 115 /** 116 * Returns the mode for id generation. 117 * <p> 118 * Must be one of the following: 119 * <ul> 120 * <li>ID_GEN.USE_EXISTING</li> 121 * <li>ID_GEN.REPLACE_DUPLICATE</li> 122 * <li>ID_GEN.GENERATE_NEW</li> 123 * </ul> 124 * 125 * @return the mode for id generation 126 */ 127 public ID_GEN getIdGen() { 128 return this.idGenMode; 129 } 130 131 /** 132 * Returns the asserted SRS of the features to be inserted. 133 * 134 * @return the asserted SRS of the features 135 */ 136 public URI getSRSName() { 137 return this.srsName; 138 } 139 140 /** 141 * Returns the feature instances to be inserted. 142 * 143 * @return the feature instances to be inserted 144 */ 145 public FeatureCollection getFeatures() { 146 return this.fc; 147 } 148 149 /** 150 * Returns the names of the feature types that are affected by the operation. 151 * 152 * @return the names of the affected feature types 153 */ 154 @Override 155 public List<QualifiedName> getAffectedFeatureTypes() { 156 Set<QualifiedName> featureTypeSet = new HashSet<QualifiedName>(); 157 for ( int i = 0; i < this.fc.size(); i++ ) { 158 Feature feature = this.fc.getFeature( i ); 159 featureTypeSet.add( feature.getName() ); 160 } 161 List<QualifiedName> featureTypes = new ArrayList<QualifiedName>( featureTypeSet ); 162 return featureTypes; 163 } 164 }