Search in sources :

Example 16 with CswSourceConfiguration

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

the class TestCswFilterDelegate method testPropertyIsEqualToAlternateIdMapping.

@Test
public void testPropertyIsEqualToAlternateIdMapping() throws JAXBException, SAXException, IOException {
    String replacedIdentifierProperty = propertyName;
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, replacedIdentifierProperty);
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
    FilterType filterType = localCswFilterDelegate.propertyIsEqualTo(Core.ID, stringLiteral, isCaseSensitive);
    assertXMLEqual(propertyIsEqualToXml, 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 17 with CswSourceConfiguration

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

the class TestCswFilterDelegate method testConfigurableMetacardMappingApiso.

@Test
public void testConfigurableMetacardMappingApiso() throws JAXBException, SAXException, IOException {
    // Setup
    CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration();
    cswSourceConfiguration.putMetacardCswMapping(Core.ID, APISO_IDENTIFIER);
    cswSourceConfiguration.putMetacardCswMapping(Core.MODIFIED, APISO_MODIFIED);
    cswSourceConfiguration.putMetacardCswMapping(Metacard.CONTENT_TYPE, APISO_TYPE);
    cswSourceConfiguration.putMetacardCswMapping(Core.TITLE, APISO_TITLE);
    cswSourceConfiguration.putMetacardCswMapping(CswConstants.ANY_TEXT, APISO_ANYTEXT);
    cswSourceConfiguration.setCswAxisOrder(CswAxisOrder.LAT_LON);
    cswSourceConfiguration.setUsePosList(false);
    String contentType = "myContentType";
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration, getCswMetacardType());
    // Perform Test
    /**
         * Incoming query with Metacard.CONTENT_TYPE equal to myContentType. Metacard.CONTENT_TYPE
         * will be mapped to format in the CswFilterDelegate.
         */
    FilterType filterType = localCswFilterDelegate.propertyIsEqualTo(Metacard.CONTENT_TYPE, contentType, isCaseSensitive);
    // Verify
    /**
         * Verify that a PropertyIsEqualTo filter is created with PropertyName of format and Literal
         * equal to myContentType
         */
    assertXMLEqual(configurableApisoTypeMappingXml, getXmlFromMarshaller(filterType));
    /**
         * Incoming query with Metacard.ANY_TEXT equal to myContentType. Metacard.ANY_TEXT
         * will be mapped to format in the CswFilterDelegate.
         */
    FilterType anyTextfilterType = localCswFilterDelegate.propertyIsLike(Metacard.ANY_TEXT, contentType, isCaseSensitive);
    String xml = getXmlFromMarshaller(anyTextfilterType);
    assertXMLEqual(configurableApisoAnyTextMappingXml, xml);
}
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 18 with CswSourceConfiguration

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

the class TestCswFilterDelegate method initCswSourceConfiguration.

private CswSourceConfiguration initCswSourceConfiguration(CswAxisOrder cswAxisOrder, boolean usePosList, String contentType, String effectiveDateMapping, String createdDateMapping, String modifiedDateMapping, String identifierMapping) {
    CswSourceConfiguration cswSourceConfiguration = new CswSourceConfiguration();
    cswSourceConfiguration.putMetacardCswMapping(Core.ID, identifierMapping);
    cswSourceConfiguration.setCswAxisOrder(cswAxisOrder);
    cswSourceConfiguration.setUsePosList(usePosList);
    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 19 with CswSourceConfiguration

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

the class TestCswFilterDelegate method testAfter.

@Test
public void testAfter() throws Exception {
    // Setup
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, false, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, CswConstants.CSW_IDENTIFIER);
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    String dateStr = fmt.print(testStartDate);
    String controlFilterAsXml = afterXml.replace(REPLACE_TEMPORAL_PROPERTY, createdDateMapping).replace(REPLACE_DATE, dateStr);
    CswFilterDelegate localCswFilterDelegate = createCswFilterDelegate(cswSourceConfiguration);
    // Perform Test
    FilterType filterType = localCswFilterDelegate.after(propertyNameCreated, testStartDate.toDate());
    // Verify
    assertXMLEqual(controlFilterAsXml, getXmlFromMarshaller(filterType));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) FilterType(net.opengis.filter.v_1_1_0.FilterType) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Test(org.junit.Test)

Example 20 with CswSourceConfiguration

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

the class TestCswCqlFilter method testPropertyIsEqualToStringLiteralAlternateIdMapping.

/**
     * Property is equal to with alternate id property
     *
     * @throws UnsupportedQueryException
     */
@Test
public void testPropertyIsEqualToStringLiteralAlternateIdMapping() throws UnsupportedQueryException {
    String replacedIdentifierProperty = propertyName;
    CswSourceConfiguration cswSourceConfiguration = initCswSourceConfiguration(CswAxisOrder.LAT_LON, CswConstants.CSW_TYPE, effectiveDateMapping, createdDateMapping, modifiedDateMapping, replacedIdentifierProperty);
    CswFilterDelegate cswFilterDelegate = initDefaultCswFilterDelegate(cswSourceConfiguration);
    FilterType filterType = cswFilterDelegate.propertyIsEqualTo(propertyName, stringLiteral, isCaseSensitive);
    String cqlText = CswCqlTextFilter.getInstance().getCqlText(filterType);
    assertThat(propertyIsEqualTo, is(cqlText));
}
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)

Aggregations

CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)34 Test (org.junit.Test)29 FilterType (net.opengis.filter.v_1_1_0.FilterType)12 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)10 ByteArrayInputStream (java.io.ByteArrayInputStream)6 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)6 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)5 Matchers.anyString (org.mockito.Matchers.anyString)5 HashMap (java.util.HashMap)4 DateTime (org.joda.time.DateTime)4 ResourceResponse (ddf.catalog.operation.ResourceResponse)3 SourceResponse (ddf.catalog.operation.SourceResponse)3 Resource (ddf.catalog.resource.Resource)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 MediaType (javax.ws.rs.core.MediaType)3 Response (javax.ws.rs.core.Response)3 AcknowledgementType (net.opengis.cat.csw.v_2_0_2.AcknowledgementType)3 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)3 CswSubscribe (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSubscribe)3