Search in sources :

Example 36 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class WfsFilterDelegate method buildFeatureIdFilter.

private FilterType buildFeatureIdFilter(Set<String> ids) {
    FilterType filterType = new FilterType();
    for (String id : ids) {
        List<JAXBElement<? extends AbstractIdType>> idFilterTypeList = filterType.getId();
        ResourceIdType resId = new ResourceIdType();
        resId.setRid(id);
        idFilterTypeList.add(filterObjectFactory.createResourceId(resId));
    }
    return filterType;
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) ResourceIdType(net.opengis.filter.v_2_0_0.ResourceIdType) LineString(com.vividsolutions.jts.geom.LineString) JAXBElement(javax.xml.bind.JAXBElement) AbstractIdType(net.opengis.filter.v_2_0_0.AbstractIdType)

Example 37 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class AbstractCswSource method createQueryConstraint.

private QueryConstraintType createQueryConstraint(Query query) throws UnsupportedQueryException {
    FilterType filter = createFilter(query);
    if (null == filter) {
        return null;
    }
    QueryConstraintType queryConstraintType = new QueryConstraintType();
    queryConstraintType.setVersion(CswConstants.CONSTRAINT_VERSION);
    if (isConstraintCql || cswSourceConfiguration.isCqlForced()) {
        queryConstraintType.setCqlText(CswCqlTextFilter.getInstance().getCqlText(filter));
    } else {
        queryConstraintType.setFilter(filter);
    }
    return queryConstraintType;
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType)

Example 38 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestTransactionMessageBodyReader method testReadUpdateByConstraintFrom.

@Test
public void testReadUpdateByConstraintFrom() throws IOException, ParseException {
    TransactionMessageBodyReader reader = new TransactionMessageBodyReader(mock(Converter.class), CswQueryFactoryTest.getCswMetacardType(), registry);
    CswTransactionRequest request = reader.readFrom(CswTransactionRequest.class, null, null, null, null, IOUtils.toInputStream(UPDATE_REQUEST_BY_CONSTRAINT_XML));
    assertThat(request, notNullValue());
    assertThat(request.getInsertActions().size(), is(0));
    assertThat(request.getDeleteActions().size(), is(0));
    assertThat(request.getUpdateActions().size(), is(1));
    UpdateAction updateAction = request.getUpdateActions().get(0);
    assertThat(updateAction, notNullValue());
    assertThat(updateAction.getMetacard(), nullValue());
    Map<String, Serializable> recordProperties = updateAction.getRecordProperties();
    assertThat(recordProperties, notNullValue());
    assertThat(recordProperties.size(), is(4));
    Serializable newSubjectValue = recordProperties.get(Topic.CATEGORY);
    assertThat(newSubjectValue, notNullValue());
    assertThat(newSubjectValue, is("Foo"));
    Serializable newDateValue = recordProperties.get("modified");
    assertThat(newDateValue, notNullValue());
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = simpleDateFormat.parse("2015-07-21");
    assertThat(newDateValue, is(date));
    Serializable newLocationValue = recordProperties.get("location");
    assertThat(newLocationValue, notNullValue());
    assertThat(newLocationValue, is("POLYGON ((1.0 2.0, 3.0 2.0, 3.0 4.0, 1.0 4.0, 1.0 2.0))"));
    Serializable newFormatValue = recordProperties.get("media.format");
    // No <Value> was specified in the request.
    assertThat(newFormatValue, nullValue());
    QueryConstraintType constraint = updateAction.getConstraint();
    assertThat(constraint, notNullValue());
    FilterType filter = constraint.getFilter();
    assertThat(filter, notNullValue());
    assertThat(filter.isSetComparisonOps(), is(true));
    assertThat(filter.isSetLogicOps(), is(false));
    assertThat(filter.isSetSpatialOps(), is(false));
    assertThat(request.getService(), is(CswConstants.CSW));
    assertThat(request.getVersion(), is(CswConstants.VERSION_2_0_2));
    assertThat(request.isVerbose(), is(false));
}
Also used : Serializable(java.io.Serializable) FilterType(net.opengis.filter.v_1_1_0.FilterType) UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateAction) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) Converter(com.thoughtworks.xstream.converters.Converter) CswRecordConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 39 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class CswQueryFactoryTest method generateTemporalFilter.

private Filter generateTemporalFilter(JAXBElement<BinaryComparisonOpType> temporalOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    FilterType filter = new FilterType();
    filter.setComparisonOps(temporalOps);
    constraint.setFilter(filter);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
    return frameworkQuery.getFilter();
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType)

Example 40 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestWfsFilterDelegate method testAbsoluteTemporalOnlyQueryDuringUnSupported.

/**
     * If the WFS server does not support an 'After' and 'Before' temporal query,
     * and supports a 'During' temporal query, the query should be translated
     * into 'During <after> to <before>'
     */
@Test
public void testAbsoluteTemporalOnlyQueryDuringUnSupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    FilterType beforeFilter = setupBeforeFilterType();
    WfsFilterDelegate delegate = setupTemporalFilterDelegate();
    // Get After Filter Date
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType beginPositionType = timePeriod.getTimePosition();
    Date afterDate = timePositionTypeToDate(beginPositionType);
    // Get Before Filter Date
    binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType endPositionType = timePeriod.getTimePosition();
    Date beforeDate = timePositionTypeToDate(endPositionType);
    List<FilterType> testFilters = new ArrayList<>();
    testFilters.add(afterFilter);
    testFilters.add(beforeFilter);
    List<FilterType> convertedFilters = delegate.applyTemporalFallbacks(testFilters);
    FilterType resultAfterFilter = convertedFilters.get(0);
    FilterType resultBeforeFilter = convertedFilters.get(1);
    assertThat(resultAfterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After"));
    assertThat(resultBeforeFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}Before"));
    // Get Resulting After Filter Date
    binaryTemporalOpType = (BinaryTemporalOpType) resultAfterFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    beginPositionType = timePeriodType.getTimePosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    // Get Resulting Before Filter Date
    binaryTemporalOpType = (BinaryTemporalOpType) resultBeforeFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    endPositionType = timePeriodType.getTimePosition();
    Date endDate = timePositionTypeToDate(endPositionType);
    // Verify Date range is created correctly
    assertThat(endDate.after(beginDate), is(true));
    assertThat(endDate.equals(beforeDate), is(true));
    assertThat(beginDate.equals(afterDate), is(true));
}
Also used : TimeInstantType(net.opengis.gml.v_3_2_1.TimeInstantType) FilterType(net.opengis.filter.v_2_0_0.FilterType) ArrayList(java.util.ArrayList) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType) TimePositionType(net.opengis.gml.v_3_2_1.TimePositionType) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)212 FilterType (net.opengis.filter.v_1_1_0.FilterType)209 FilterType (net.opengis.filter.v_2_0_0.FilterType)58 ArrayList (java.util.ArrayList)50 JAXBElement (javax.xml.bind.JAXBElement)12 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)12 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)11 FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)11 QName (javax.xml.namespace.QName)10 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)10 LineString (com.vividsolutions.jts.geom.LineString)9 Date (java.util.Date)9 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)9 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)9 DateTime (org.joda.time.DateTime)8 Method (java.lang.reflect.Method)7 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)7 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)7 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)7 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)7