use of org.geotoolkit.ogc.xml.v200.PropertyIsLikeType in project ddf by codice.
the class CswFilterFactory method createPropertyIsLike.
private JAXBElement<PropertyIsLikeType> createPropertyIsLike(String propertyName, Object literal, boolean isCaseSensitive) {
PropertyIsLikeType propertyIsLikeType = new PropertyIsLikeType();
propertyIsLikeType.setEscapeChar(CswConstants.ESCAPE);
propertyIsLikeType.setSingleChar(CswConstants.SINGLE_CHAR);
propertyIsLikeType.setWildCard(CswConstants.WILD_CARD);
propertyIsLikeType.setPropertyName(createPropertyNameType(Arrays.asList(new Object[] { propertyName })).getValue());
propertyIsLikeType.setLiteral(createLiteralType(literal).getValue());
propertyIsLikeType.setMatchCase(isCaseSensitive);
return filterObjectFactory.createPropertyIsLike(propertyIsLikeType);
}
use of org.geotoolkit.ogc.xml.v200.PropertyIsLikeType in project ddf by codice.
the class WfsFilterDelegateTest method testLogicalAndOrComparison.
private void testLogicalAndOrComparison(String methName, String compOpName) throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
List<FilterType> filtersToCombine = new ArrayList<>();
filtersToCombine.add(compFilter1);
filtersToCombine.add(compFilter2);
// Perform Test
Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
// Verify
assertThat(filter.getLogicOps().getName().toString(), is(compOpName));
BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
Assert.assertThat(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().size(), is(2));
for (JAXBElement<?> jaxbElement : logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps()) {
PropertyIsLikeType compOpsType = (PropertyIsLikeType) jaxbElement.getValue();
String valRef = fetchPropertyIsLikeExpression(compOpsType, VALUE_REFERENCE);
assertThat(valRef, is(mockProperty));
String literal = fetchPropertyIsLikeExpression(compOpsType, LITERAL);
assertThat(literal, is(LITERAL));
}
}
use of org.geotoolkit.ogc.xml.v200.PropertyIsLikeType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalNotOfComparison.
@Test
public void testLogicalNotOfComparison() throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType filterToBeNoted = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
//Perform Test
FilterType filter = delegate.not(filterToBeNoted);
//Verify
assertThat(filter.getLogicOps().getName().toString(), is(LOGICAL_NOT_NAME));
UnaryLogicOpType logicOpType = (UnaryLogicOpType) filter.getLogicOps().getValue();
PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) logicOpType.getComparisonOps().getValue();
String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
assertThat(valRef1, is(mockProperty));
String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
assertThat(literal1, is(LITERAL));
}
use of org.geotoolkit.ogc.xml.v200.PropertyIsLikeType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalCombinationOfLogicals.
private void testLogicalCombinationOfLogicals(String methName, String compOpName) throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
List<FilterType> subFiltersToBeOred = new ArrayList<>();
subFiltersToBeOred.add(compFilter1);
subFiltersToBeOred.add(compFilter2);
FilterType spatialFilter1 = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
FilterType spatialFilter2 = delegate.dwithin(Metacard.ANY_GEO, "POINT (50 10)", Double.valueOf(1500));
List<FilterType> subFiltersToBeAnded = new ArrayList<>();
subFiltersToBeAnded.add(spatialFilter1);
subFiltersToBeAnded.add(spatialFilter2);
List<FilterType> filtersToCombine = new ArrayList<>();
filtersToCombine.add(delegate.or(subFiltersToBeOred));
filtersToCombine.add(delegate.and(subFiltersToBeAnded));
Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
//Verify
assertThat(filter.getLogicOps().getName().toString(), is(compOpName));
BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
BinaryLogicOpType logicOrType = (BinaryLogicOpType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
assertThat(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getName().toString(), is(LOGICAL_OR_NAME));
assertThat(logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps().size(), is(2));
for (JAXBElement<?> jaxbElement : logicOrType.getComparisonOpsOrSpatialOpsOrTemporalOps()) {
PropertyIsLikeType compOpsType = (PropertyIsLikeType) jaxbElement.getValue();
String valRef = fetchPropertyIsLikeExpression(compOpsType, VALUE_REFERENCE);
assertThat(valRef, is(mockProperty));
String literal = fetchPropertyIsLikeExpression(compOpsType, LITERAL);
assertThat(literal, is(LITERAL));
}
BinaryLogicOpType logicAndType = (BinaryLogicOpType) logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
assertThat(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getName().toString(), is(LOGICAL_AND_NAME));
DistanceBufferType spatialOpsType1 = (DistanceBufferType) logicAndType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue();
assertThat(Double.toString(spatialOpsType1.getDistance().getValue()), is(Double.valueOf(1000).toString()));
DistanceBufferType spatialOpsType2 = (DistanceBufferType) logicAndType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue();
assertThat(Double.toString(spatialOpsType2.getDistance().getValue()), is(Double.valueOf(1500).toString()));
}
use of org.geotoolkit.ogc.xml.v200.PropertyIsLikeType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalAndOrComparison.
private void testLogicalAndOrComparison(String methName, String compOpName) throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
List<FilterType> filtersToCombine = new ArrayList<>();
filtersToCombine.add(compFilter1);
filtersToCombine.add(compFilter2);
//Perform Test
Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
//Verify
assertThat(filter.getLogicOps().getName().toString(), is(compOpName));
BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
Assert.assertThat(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().size(), is(2));
for (JAXBElement<?> jaxbElement : logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps()) {
PropertyIsLikeType compOpsType = (PropertyIsLikeType) jaxbElement.getValue();
String valRef = fetchPropertyIsLikeExpression(compOpsType, VALUE_REFERENCE);
assertThat(valRef, is(mockProperty));
String literal = fetchPropertyIsLikeExpression(compOpsType, LITERAL);
assertThat(literal, is(LITERAL));
}
}
Aggregations