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