Search in sources :

Example 26 with BinaryComparisonOpType

use of org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType in project ddf by codice.

the class WfsFilterDelegate method createPropertyIsFilter.

private JAXBElement<? extends ComparisonOpsType> createPropertyIsFilter(String property, Object literal, PROPERTY_IS_OPS operation) {
    switch(operation) {
        case PropertyIsEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsEqualTo = filterObjectFactory.createPropertyIsEqualTo(new BinaryComparisonOpType());
            propIsEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsEqualTo;
        case PropertyIsNotEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsNotEqualTo = filterObjectFactory.createPropertyIsNotEqualTo(new BinaryComparisonOpType());
            propIsNotEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsNotEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsNotEqualTo;
        case PropertyIsGreaterThan:
            JAXBElement<BinaryComparisonOpType> propIsGreaterThan = filterObjectFactory.createPropertyIsGreaterThan(new BinaryComparisonOpType());
            propIsGreaterThan.getValue().getExpression().add(createPropertyNameType(property));
            propIsGreaterThan.getValue().getExpression().add(createLiteralType(literal));
            return propIsGreaterThan;
        case PropertyIsGreaterThanOrEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsGreaterThanOrEqualTo = filterObjectFactory.createPropertyIsGreaterThanOrEqualTo(new BinaryComparisonOpType());
            propIsGreaterThanOrEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsGreaterThanOrEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsGreaterThanOrEqualTo;
        case PropertyIsLessThan:
            JAXBElement<BinaryComparisonOpType> propIsLessThan = filterObjectFactory.createPropertyIsLessThan(new BinaryComparisonOpType());
            propIsLessThan.getValue().getExpression().add(createPropertyNameType(property));
            propIsLessThan.getValue().getExpression().add(createLiteralType(literal));
            return propIsLessThan;
        case PropertyIsLessThanOrEqualTo:
            JAXBElement<BinaryComparisonOpType> propIsLessThanOrEqualTo = filterObjectFactory.createPropertyIsLessThanOrEqualTo(new BinaryComparisonOpType());
            propIsLessThanOrEqualTo.getValue().getExpression().add(createPropertyNameType(property));
            propIsLessThanOrEqualTo.getValue().getExpression().add(createLiteralType(literal));
            return propIsLessThanOrEqualTo;
        case PropertyIsLike:
            JAXBElement<PropertyIsLikeType> propIsLike = filterObjectFactory.createPropertyIsLike(new PropertyIsLikeType());
            propIsLike.getValue().setPropertyName(createPropertyNameType(property).getValue());
            propIsLike.getValue().setEscape(WfsConstants.ESCAPE);
            propIsLike.getValue().setSingleChar(SINGLE_CHAR);
            propIsLike.getValue().setWildCard(WfsConstants.WILD_CARD);
            propIsLike.getValue().setLiteral(createLiteralType(literal).getValue());
            return propIsLike;
        default:
            throw new UnsupportedOperationException("Unsupported Property Comparison Type");
    }
}
Also used : BinaryComparisonOpType(ogc.schema.opengis.filter.v_1_0_0.BinaryComparisonOpType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType)

Example 27 with BinaryComparisonOpType

use of org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType in project arctic-sea by 52North.

the class FesDecoderV20Test method should_parse_PropertyIsEqualTo_Filter.

/**
 * Test PropertyIsEqualTo filter decoding
 *
 * @throws OwsExceptionReport
 */
@Test
public void should_parse_PropertyIsEqualTo_Filter() throws DecodingException {
    PropertyIsEqualToDocument propertyIsEqualToDoc = PropertyIsEqualToDocument.Factory.newInstance();
    BinaryComparisonOpType propertyIsEqualToType = propertyIsEqualToDoc.addNewPropertyIsEqualTo();
    // valueReference
    XmlString valueReference = (XmlString) propertyIsEqualToType.addNewExpression().substitute(FilterConstants.QN_VALUE_REFERENCE, XmlString.type);
    valueReference.setStringValue(TEST_VALUE_REFERENCE);
    // literal
    LiteralType literalType = (LiteralType) propertyIsEqualToType.addNewExpression().substitute(FilterConstants.QN_LITERAL, LiteralType.type);
    XmlString newInstance = XmlString.Factory.newInstance();
    newInstance.setStringValue(TEST_LITERAL);
    literalType.set(newInstance);
    // create document
    FilterDocument filterDoc = FilterDocument.Factory.newInstance();
    FilterType filterType = filterDoc.addNewFilter();
    filterType.setComparisonOps(propertyIsEqualToType);
    filterType.getComparisonOps().substitute(FilterConstants.QN_PROPERTY_IS_EQUAL_TO, BinaryComparisonOpType.type);
    ComparisonFilter comparisonFilter = (ComparisonFilter) decoder.decode(filterDoc);
    // test
    assertThat(comparisonFilter.getOperator(), is(FilterConstants.ComparisonOperator.PropertyIsEqualTo));
    assertThat(comparisonFilter.getValueReference(), is(TEST_VALUE_REFERENCE));
    assertThat(comparisonFilter.getValue(), is(TEST_LITERAL));
}
Also used : PropertyIsEqualToDocument(net.opengis.fes.x20.PropertyIsEqualToDocument) FilterType(net.opengis.fes.x20.FilterType) ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) XmlString(org.apache.xmlbeans.XmlString) LiteralType(net.opengis.fes.x20.LiteralType) FilterDocument(net.opengis.fes.x20.FilterDocument) BinaryComparisonOpType(net.opengis.fes.x20.BinaryComparisonOpType) Test(org.junit.jupiter.api.Test)

Example 28 with BinaryComparisonOpType

use of org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType in project geo-platform by geosdi.

the class TimeSearchRequestFilter method createFilterTimePredicate.

/**
 * @param startDate
 * @param endDate
 * @return {@link List<JAXBElement<?>}
 */
private List<JAXBElement<?>> createFilterTimePredicate(Date startDate, Date endDate) {
    BinaryComparisonOpType begin = this.createBinaryComparisonOpType(TEMP_BEGIN, formatter.format(startDate));
    BinaryComparisonOpType end = this.createBinaryComparisonOpType(TEMP_END, formatter.format(endDate));
    List<JAXBElement<?>> timePredicate = new ArrayList(2);
    timePredicate.add(filterFactory.createPropertyIsGreaterThanOrEqualTo(begin));
    timePredicate.add(filterFactory.createPropertyIsLessThanOrEqualTo(end));
    return timePredicate;
}
Also used : ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) BinaryComparisonOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryComparisonOpType)

Example 29 with BinaryComparisonOpType

use of org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType in project geo-platform by geosdi.

the class BaseBinaryStrategy method createBinaryComparisonTypeForDate.

/**
 * @param queryRestrictionDTO
 * @return {@link BinaryComparisonOpType}
 */
protected BinaryComparisonOpType createBinaryComparisonTypeForDate(QueryRestrictionDTO queryRestrictionDTO) {
    return new BinaryComparisonOpType() {

        {
            PropertyNameType propertyNameType = new PropertyNameType();
            propertyNameType.setContent(asList(queryRestrictionDTO.getAttribute().getName()));
            FunctionType functionType = new FunctionType();
            functionType.setName("dateParse");
            LiteralType literalType = new LiteralType();
            literalType.setContent(asList(queryRestrictionDTO.getRestriction()));
            LiteralType literalTypeFormat = new LiteralType();
            literalTypeFormat.setContent(dateFormatStrategyFinder.findDateFormat(queryRestrictionDTO.getAttribute()));
            List<JAXBElement<?>> functionElements = new ArrayList<>(2);
            functionElements.add(filterFactory.createLiteral(literalTypeFormat));
            functionElements.add(filterFactory.createLiteral(literalType));
            functionType.setExpression(functionElements);
            List<JAXBElement<?>> elements = new ArrayList<>(2);
            elements.add(filterFactory.createPropertyName(propertyNameType));
            elements.add(filterFactory.createFunction(functionType));
            super.setExpression(elements);
        }
    };
}
Also used : FunctionType(org.geosdi.geoplatform.xml.filter.v110.FunctionType) ArrayList(java.util.ArrayList) LiteralType(org.geosdi.geoplatform.xml.filter.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) BinaryComparisonOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryComparisonOpType) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 30 with BinaryComparisonOpType

use of org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType in project geo-platform by geosdi.

the class BaseBinaryStrategy method createBinaryComparisonType.

/**
 * @param queryRestrictionDTO
 * @return {@link BinaryComparisonOpType}
 */
protected BinaryComparisonOpType createBinaryComparisonType(QueryRestrictionDTO queryRestrictionDTO) {
    return new BinaryComparisonOpType() {

        {
            PropertyNameType propertyNameType = new PropertyNameType();
            propertyNameType.setContent(asList(queryRestrictionDTO.getAttribute().getName()));
            LiteralType literalType = new LiteralType();
            literalType.setContent(asList(queryRestrictionDTO.getRestriction()));
            List<JAXBElement<?>> elements = new ArrayList<>(2);
            elements.add(filterFactory.createPropertyName(propertyNameType));
            elements.add(filterFactory.createLiteral(literalType));
            super.setExpression(elements);
        }
    };
}
Also used : ArrayList(java.util.ArrayList) LiteralType(org.geosdi.geoplatform.xml.filter.v110.LiteralType) JAXBElement(javax.xml.bind.JAXBElement) BinaryComparisonOpType(org.geosdi.geoplatform.xml.filter.v110.BinaryComparisonOpType) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Aggregations

Test (org.junit.Test)22 JAXBElement (javax.xml.bind.JAXBElement)21 Marshaller (javax.xml.bind.Marshaller)18 Unmarshaller (javax.xml.bind.Unmarshaller)18 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)18 Filter (org.opengis.filter.Filter)18 Literal (org.opengis.filter.Literal)18 ValueReference (org.opengis.filter.ValueReference)18 BinaryComparisonOpType (net.opengis.filter.v_1_1_0.BinaryComparisonOpType)13 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)9 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)9 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)9 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)9 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)9 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)9 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)9 PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)9 ComparisonOpsType (org.geotoolkit.ogc.xml.v110.ComparisonOpsType)7 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)6 LogicalOperator (org.opengis.filter.LogicalOperator)6