001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.geoserver.wfs.xml.v1_1_0;
006:
007: import net.opengis.wfs.AllSomeType;
008: import net.opengis.wfs.DeleteElementType;
009: import net.opengis.wfs.InsertElementType;
010: import net.opengis.wfs.NativeType;
011: import net.opengis.wfs.TransactionType;
012: import net.opengis.wfs.UpdateElementType;
013: import net.opengis.wfs.WfsFactory;
014: import org.geotools.xml.AbstractComplexEMFBinding;
015: import org.geotools.xml.ElementInstance;
016: import org.geotools.xml.Node;
017: import java.util.Iterator;
018: import javax.xml.namespace.QName;
019:
020: /**
021: * Binding object for the type http://www.opengis.net/wfs:TransactionType.
022: *
023: * <p>
024: * <pre>
025: * <code>
026: * <xsd:complexType name="TransactionType">
027: * <xsd:annotation>
028: * <xsd:documentation>
029: * The TransactionType defines the Transaction operation. A
030: * Transaction element contains one or more Insert, Update
031: * Delete and Native elements that allow a client application
032: * to create, modify or remove feature instances from the
033: * feature repository that a Web Feature Service controls.
034: * </xsd:documentation>
035: * </xsd:annotation>
036: * <xsd:complexContent>
037: * <xsd:extension base="ows:GetCapabilitiesType">
038: * <xsd:sequence>
039: * <xsd:element minOccurs="0" ref="wfs:LockId">
040: * <xsd:annotation>
041: * <xsd:documentation>
042: * In order for a client application to operate upon
043: * locked feature instances, the Transaction request
044: * must include the LockId element. The content of
045: * this element must be the lock identifier the client
046: * application obtained from a previous
047: * GetFeatureWithLock or LockFeature operation.
048: *
049: * If the correct lock identifier is specified the Web
050: * Feature Service knows that the client application may
051: * operate upon the locked feature instances.
052: *
053: * No LockId element needs to be specified to operate upon
054: * unlocked features.
055: * </xsd:documentation>
056: * </xsd:annotation>
057: * </xsd:element>
058: * <xsd:choice maxOccurs="unbounded" minOccurs="0">
059: * <xsd:element ref="wfs:Insert"/>
060: * <xsd:element ref="wfs:Update"/>
061: * <xsd:element ref="wfs:Delete"/>
062: * <xsd:element ref="wfs:Native"/>
063: * </xsd:choice>
064: * </xsd:sequence>
065: * <xsd:attribute name="releaseAction" type="wfs:AllSomeType" use="optional">
066: * <xsd:annotation>
067: * <xsd:documentation>
068: * The releaseAction attribute is used to control how a Web
069: * Feature service releases locks on feature instances after
070: * a Transaction request has been processed.
071: *
072: * Valid values are ALL or SOME.
073: *
074: * A value of ALL means that the Web Feature Service should
075: * release the locks of all feature instances locked with the
076: * specified lockId regardless or whether or not the features
077: * were actually modified.
078: *
079: * A value of SOME means that the Web Feature Service will
080: * only release the locks held on feature instances that
081: * were actually operated upon by the transaction. The
082: * lockId that the client application obtained shall remain
083: * valid and the other, unmodified, feature instances shall
084: * remain locked.
085: *
086: * If the expiry attribute was specified in the original
087: * operation that locked the feature instances, then the
088: * expiry counter will be reset to give the client
089: * application that same amount of time to post subsequent
090: * transactions against the locked features.
091: * </xsd:documentation>
092: * </xsd:annotation>
093: * </xsd:attribute>
094: * </xsd:extension>
095: * </xsd:complexContent>
096: * </xsd:complexType>
097: *
098: * </code>
099: * </pre>
100: * </p>
101: *
102: * @generated
103: */
104: public class TransactionTypeBinding extends AbstractComplexEMFBinding {
105: WfsFactory wfsfactory;
106:
107: public TransactionTypeBinding(WfsFactory wfsfactory) {
108: this .wfsfactory = wfsfactory;
109: }
110:
111: /**
112: * @generated
113: */
114: public QName getTarget() {
115: return WFS.TRANSACTIONTYPE;
116: }
117:
118: /**
119: * Sets execution mode to be before
120: */
121: public int getExecutionMode() {
122: return BEFORE;
123: }
124:
125: /**
126: * <!-- begin-user-doc -->
127: * <!-- end-user-doc -->
128: *
129: * @generated modifiable
130: */
131: public Class getType() {
132: return TransactionType.class;
133: }
134:
135: /**
136: * <!-- begin-user-doc -->
137: * <!-- end-user-doc -->
138: *
139: * @generated modifiable
140: */
141: public Object parse(ElementInstance instance, Node node,
142: Object value) throws Exception {
143: TransactionType transaction = wfsfactory
144: .createTransactionType();
145:
146: //<xsd:element minOccurs="0" ref="wfs:LockId">
147: if (node.hasChild("LockId")) {
148: transaction
149: .setLockId((String) node.getChildValue("LockId"));
150: }
151:
152: //<xsd:choice maxOccurs="unbounded" minOccurs="0">
153: // <xsd:element ref="wfs:Insert"/>
154: // <xsd:element ref="wfs:Update"/>
155: // <xsd:element ref="wfs:Delete"/>
156: // <xsd:element ref="wfs:Native"/>
157: //</xsd:choice>
158: for (Iterator itr = node.getChildren().iterator(); itr
159: .hasNext();) {
160: Node child = (Node) itr.next();
161: Object cv = child.getValue();
162:
163: if (cv instanceof InsertElementType) {
164: transaction.getInsert().add(cv);
165: } else if (cv instanceof UpdateElementType) {
166: transaction.getUpdate().add(cv);
167: } else if (cv instanceof DeleteElementType) {
168: transaction.getDelete().add(cv);
169: } else if (cv instanceof NativeType) {
170: transaction.getNative().add(cv);
171: }
172: }
173:
174: //<xsd:attribute name="releaseAction" type="wfs:AllSomeType" use="optional">
175: if (node.hasAttribute(AllSomeType.class)) {
176: transaction.setReleaseAction((AllSomeType) node
177: .getAttributeValue(AllSomeType.class));
178: }
179:
180: return transaction;
181: }
182: }
|