Search in sources :

Example 61 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class CswCqlFilterTest method initCswSourceConfiguration.

private CswSourceConfiguration initCswSourceConfiguration(CswAxisOrder cswAxisOrder, String contentType, String effectiveDateMapping, String createdDateMapping, String modifiedDateMapping, String identifierMapping) {
    CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration();
    cswSourceConfiguration.putMetacardCswMapping(Core.ID, identifierMapping);
    cswSourceConfiguration.setCswAxisOrder(cswAxisOrder);
    cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, contentType);
    cswSourceConfiguration.putMetacardCswMapping(Metacard.EFFECTIVE, effectiveDateMapping);
    cswSourceConfiguration.putMetacardCswMapping(Core.CREATED, createdDateMapping);
    cswSourceConfiguration.putMetacardCswMapping(Core.MODIFIED, modifiedDateMapping);
    return cswSourceConfiguration;
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)

Example 62 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class CswFilterDelegateTest method initCswSourceConfiguration.

private CswSourceConfiguration initCswSourceConfiguration(CswAxisOrder cswAxisOrder, boolean usePosList, String contentType) {
    CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration();
    cswSourceConfiguration.putMetacardCswMapping(Core.ID, CswConstants.CSW_IDENTIFIER);
    cswSourceConfiguration.setCswAxisOrder(cswAxisOrder);
    cswSourceConfiguration.setUsePosList(usePosList);
    cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, contentType);
    return cswSourceConfiguration;
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)

Example 63 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class CswFilterDelegateTest method testDuringAlteredCreatedDateMapping.

@Test
public void testDuringAlteredCreatedDateMapping() throws JAXBException, SAXException, IOException {
    String replacedTemporalProperty = "myCreatedDate";
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, effectiveDateMapping, replacedTemporalProperty, modifiedDateMapping, CswConstants.CSW_IDENTIFIER);
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
    String xml = getXmlProperty(localCswFilterDelegate, propertyNameCreated, BETWEEN, testStartDate.toCalendar(null).getTime(), testEndDate.toCalendar(null).getTime());
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    String startDateStr = fmt.print(testStartDate);
    String endDateStr = fmt.print(testEndDate);
    String testResponse = duringXml.replace(REPLACE_START_DATE, startDateStr).replace(REPLACE_END_DATE, endDateStr).replace(REPLACE_TEMPORAL_PROPERTY, replacedTemporalProperty);
    assertXMLEqual(testResponse, xml);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Test(org.junit.Test)

Example 64 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class CswFilterDelegateTest method testIntersectsFallbackToNotDisjointPropertyOwsBoundingBox.

@Test
public void testIntersectsFallbackToNotDisjointPropertyOwsBoundingBox() throws JAXBException, SAXException, IOException {
    String propName = CswConstants.BBOX_PROP;
    CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration();
    cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, CswConstants.CSW_TYPE);
    CswFilterDelegate localCswFilterDelegate = initCswFilterDelegate(getMockFilterCapabilitiesForSpatialFallback(Arrays.asList(DISJOINT), Arrays.asList("Polygon")), initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE));
    FilterType filterType = localCswFilterDelegate.intersects(propName, polygonWkt);
    assertXMLEqual(notDisjointPolygonXmlPropertyOwsBoundingBox, getXmlFromMarshaller(filterType));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) FilterType(net.opengis.filter.v_1_1_0.FilterType) Test(org.junit.Test)

Example 65 with CswSourceConfiguration

use of org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration in project ddf by codice.

the class CswFilterDelegateTest method testRelative.

@Test
public void testRelative() throws JAXBException, SAXException, IOException {
    long duration = 92000000000L;
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, CswConstants.CSW_IDENTIFIER);
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
    Map<String, Object> propMap = new HashMap<>();
    propMap.put("extendedComparisonOp", "relative");
    propMap.put("duration", new Long(duration));
    String xml = getXmlProperty(localCswFilterDelegate, propertyNameModified, BETWEEN, testStartDate.toCalendar(null).getTime(), testEndDate.toCalendar(null).getTime(), propMap);
    String durationCompare = duringXml.replace(REPLACE_START_DATE, "").replace(REPLACE_END_DATE, "").replace(REPLACE_TEMPORAL_PROPERTY, modifiedDateMapping);
    String pattern = "(?i)(<ns.:Literal>)(.+?)(</ns.:Literal>)";
    String compareXml = xml.replaceAll(pattern, "<ogc:Literal xmlns:ogc=\"http://www.opengis.net/ogc\"></ogc:Literal>");
    Diff xmlDiff = new Diff(durationCompare, compareXml);
    xmlDiff.overrideElementQualifier(new ElementNameQualifier() {

        @Override
        protected boolean equalsNamespace(Node control, Node test) {
            return true;
        }
    });
    xmlDiff.overrideDifferenceListener(new DifferenceListener() {

        @Override
        public int differenceFound(Difference diff) {
            if (diff.getId() == DifferenceConstants.NAMESPACE_PREFIX_ID) {
                return RETURN_IGNORE_DIFFERENCE_NODES_IDENTICAL;
            }
            return RETURN_ACCEPT_DIFFERENCE;
        }

        @Override
        public void skippedComparison(Node arg0, Node arg1) {
        }
    });
    assertXMLIdentical(xmlDiff, true);
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) HashMap(java.util.HashMap) Diff(org.custommonkey.xmlunit.Diff) Node(org.w3c.dom.Node) Difference(org.custommonkey.xmlunit.Difference) DifferenceListener(org.custommonkey.xmlunit.DifferenceListener) ElementNameQualifier(org.custommonkey.xmlunit.ElementNameQualifier) Test(org.junit.Test)

Aggregations

CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)70 Test (org.junit.Test)60 FilterType (net.opengis.filter.v_1_1_0.FilterType)24 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)20 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)15 ByteArrayInputStream (java.io.ByteArrayInputStream)14 Matchers.anyString (org.mockito.Matchers.anyString)14 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)11 Matchers.containsString (org.hamcrest.Matchers.containsString)9 InputStream (java.io.InputStream)8 HashMap (java.util.HashMap)8 DateTime (org.joda.time.DateTime)8 ResourceResponse (ddf.catalog.operation.ResourceResponse)6 SourceResponse (ddf.catalog.operation.SourceResponse)6 Resource (ddf.catalog.resource.Resource)6 MediaType (javax.ws.rs.core.MediaType)6 Response (javax.ws.rs.core.Response)6 AcknowledgementType (net.opengis.cat.csw.v_2_0_2.AcknowledgementType)6 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)6 CswSubscribe (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSubscribe)6