Permalink
Browse files

Make it possible to encode extended caps in operations metadata via a…

…n EncoderDelegate
  • Loading branch information...
1 parent c5d1e9c commit 0a026b65254d2c8dc35129222bf6c0f508b59b97 @aaime aaime committed Oct 25, 2012
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<ecore:EPackage xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="ows10"
- nsURI="http://www.opengis.net/ows" nsPrefix="ows">
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="ows10" nsURI="http://www.opengis.net/ows" nsPrefix="ows">
<eClassifiers xsi:type="ecore:EClass" name="AcceptFormatsType">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="AcceptFormatsType"/>
@@ -1149,7 +1147,8 @@
<details key="documentation" value="Optional unordered list of valid domain constraints on non-parameter quantities that each apply to this server. The list of required and optional constraints shall be specified in the Implementation Specification for this service."/>
</eAnnotations>
</eStructuralFeatures>
- <eStructuralFeatures xsi:type="ecore:EReference" name="extendedCapabilities" eType="#//Object"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="extendedCapabilities" eType="#//Object"
+ resolveProxies="false"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="RequestMethodType" eSuperTypes="#//OnlineResourceType">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
@@ -146,14 +146,6 @@ public EList getConstraint() {
* @generated
*/
public Object getExtendedCapabilities() {
- if (extendedCapabilities != null && ((EObject)extendedCapabilities).eIsProxy()) {
- InternalEObject oldExtendedCapabilities = (InternalEObject)extendedCapabilities;
- extendedCapabilities = (Object)eResolveProxy(oldExtendedCapabilities);
- if (extendedCapabilities != oldExtendedCapabilities) {
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.RESOLVE, Ows10Package.OPERATIONS_METADATA_TYPE__EXTENDED_CAPABILITIES, oldExtendedCapabilities, extendedCapabilities));
- }
- }
return extendedCapabilities;
}
@@ -162,15 +154,6 @@ public Object getExtendedCapabilities() {
* <!-- end-user-doc -->
* @generated
*/
- public Object basicGetExtendedCapabilities() {
- return extendedCapabilities;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
public void setExtendedCapabilities(Object newExtendedCapabilities) {
Object oldExtendedCapabilities = extendedCapabilities;
extendedCapabilities = newExtendedCapabilities;
@@ -209,8 +192,7 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
case Ows10Package.OPERATIONS_METADATA_TYPE__CONSTRAINT:
return getConstraint();
case Ows10Package.OPERATIONS_METADATA_TYPE__EXTENDED_CAPABILITIES:
- if (resolve) return getExtendedCapabilities();
- return basicGetExtendedCapabilities();
+ return getExtendedCapabilities();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -2179,7 +2179,7 @@ public void initializePackageContents() {
initEReference(getOperationsMetadataType_Operation(), this.getOperationType(), null, "operation", null, 2, -1, OperationsMetadataType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getOperationsMetadataType_Parameter(), this.getDomainType(), null, "parameter", null, 0, -1, OperationsMetadataType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEReference(getOperationsMetadataType_Constraint(), this.getDomainType(), null, "constraint", null, 0, -1, OperationsMetadataType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getOperationsMetadataType_ExtendedCapabilities(), this.getObject(), null, "extendedCapabilities", null, 0, 1, OperationsMetadataType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEReference(getOperationsMetadataType_ExtendedCapabilities(), this.getObject(), null, "extendedCapabilities", null, 0, 1, OperationsMetadataType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
initEClass(requestMethodTypeEClass, RequestMethodType.class, "RequestMethodType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getRequestMethodType_Constraint(), this.getDomainType(), null, "constraint", null, 0, -1, RequestMethodType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
@@ -90,7 +90,14 @@
<artifactId>gt-epsg-hsql</artifactId>
<version>${project.version}</version>
<scope>test</scope>
- </dependency>
+ </dependency>
+
+ <dependency>
+ <groupId>xmlunit</groupId>
+ <artifactId>xmlunit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<build>
@@ -4,27 +4,36 @@
import java.io.StringReader;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import net.opengis.cat.csw20.CapabilitiesType;
+import net.opengis.cat.csw20.Csw20Factory;
import net.opengis.cat.csw20.GetCapabilitiesType;
import net.opengis.ows10.ContactType;
import net.opengis.ows10.DCPType;
import net.opengis.ows10.DomainType;
import net.opengis.ows10.KeywordsType;
import net.opengis.ows10.OperationType;
import net.opengis.ows10.OperationsMetadataType;
+import net.opengis.ows10.Ows10Factory;
import net.opengis.ows10.RequestMethodType;
import net.opengis.ows10.ResponsiblePartySubsetType;
+import net.opengis.ows10.SectionsType;
import net.opengis.ows10.ServiceIdentificationType;
import net.opengis.ows10.ServiceProviderType;
+import org.custommonkey.xmlunit.SimpleNamespaceContext;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.custommonkey.xmlunit.XMLUnit;
import org.geotools.filter.v1_1.OGC;
import org.geotools.gml2.GML;
import org.geotools.ows.OWS;
+import org.geotools.xlink.XLINK;
import org.geotools.xml.Encoder;
+import org.geotools.xml.EncoderDelegate;
import org.geotools.xml.Parser;
-import org.junit.Ignore;
import org.junit.Test;
import org.opengis.filter.capability.ArithmeticOperators;
import org.opengis.filter.capability.ComparisonOperators;
@@ -34,6 +43,9 @@
import org.opengis.filter.capability.ScalarCapabilities;
import org.opengis.filter.capability.SpatialCapabilities;
import org.opengis.filter.capability.SpatialOperators;
+import org.w3c.dom.Document;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.helpers.AttributesImpl;
public class CSWCapabilitiesTest {
@@ -162,4 +174,50 @@ public void testRoundTripCapabilities() throws Exception {
CapabilitiesType reParsed = (CapabilitiesType) parser.parse(new StringReader(encoded));
assertTrue(EMFUtils.emfEquals(caps, reParsed));
}
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void testExtendedCapabilities() throws Exception {
+ Csw20Factory cswf = Csw20Factory.eINSTANCE;
+ Ows10Factory owsf = Ows10Factory.eINSTANCE;
+ CapabilitiesType caps = cswf.createCapabilitiesType();
+ OperationsMetadataType om = owsf.createOperationsMetadataType();
+ caps.setOperationsMetadata(om);
+ final String rimNamespace = "urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0";
+ om.setExtendedCapabilities(new EncoderDelegate() {
+
+ @Override
+ public void encode(ContentHandler output) throws Exception {
+ AttributesImpl atts = new AttributesImpl();
+ output.startPrefixMapping("rim", rimNamespace);
+ atts.addAttribute(rimNamespace, "test", "rim:test", "xs:string", "test");
+ output.startElement(rimNamespace, "Slot", "rim:Slot", atts);
+ String content = "test content";
+ output.characters(content.toCharArray(), 0, content.length());
+ output.endElement(rimNamespace, "test", "rim:test");
+ output.endPrefixMapping("rim");
+ }
+ });
+
+ Encoder encoder = new Encoder(new CSWConfiguration());
+ encoder.setIndenting(true);
+ encoder.setNamespaceAware(true);
+ encoder.getNamespaces().declarePrefix("ows", OWS.NAMESPACE);
+ encoder.getNamespaces().declarePrefix("ogc", OGC.NAMESPACE);
+ encoder.getNamespaces().declarePrefix("gml", GML.NAMESPACE);
+ String encoded = encoder.encodeAsString(caps, CSW.Capabilities);
+
+ // System.out.println(encoded);
+
+ // prepare xmlunit
+ Map<String, String> namespaces = new HashMap<String, String>();
+ namespaces.put("csw", CSW.NAMESPACE);
+ namespaces.put("ows", OWS.NAMESPACE);
+ namespaces.put("rim", rimNamespace);
+ XMLUnit.setXpathNamespaceContext(new SimpleNamespaceContext(namespaces));
+
+ Document doc = XMLUnit.buildControlDocument(encoded);
+ XMLAssert.assertXpathEvaluatesTo("test", "/csw:Capabilities/ows:OperationsMetadata/rim:Slot/@rim:test", doc);
+ XMLAssert.assertXpathEvaluatesTo("test content", "/csw:Capabilities/ows:OperationsMetadata/rim:Slot", doc);
+ }
}

0 comments on commit 0a026b6

Please sign in to comment.