use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC100Test method testFilterComparisonPropertyIsNull.
@Test
public void testFilterComparisonPropertyIsNull() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISNULL);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
NullOperator prop = (NullOperator) filter;
ValueReference center = (ValueReference) prop.getExpressions().get(0);
assertEquals(center.getXPath(), valueStr);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getComparisonOps());
ComparisonOpsType cot = ft.getComparisonOps().getValue();
PropertyIsNullType pibt = (PropertyIsNullType) cot;
PropertyNameType pnt = (PropertyNameType) pibt.getPropertyName();
assertEquals(pnt.getContent(), valueStr);
MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISNULL);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsLike.
@Test
public void testFilterComparisonPropertyIsLike() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLIKE);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
LikeOperator prop = (LikeOperator) filter;
ValueReference exp = (ValueReference) prop.getExpressions().get(0);
char escape = prop.getEscapeChar();
String literal = (String) ((Literal) prop.getExpressions().get(1)).getValue();
char single = prop.getSingleChar();
char wild = prop.getWildCard();
assertEquals(exp.getXPath(), "LAST_NAME");
assertEquals(literal, "JOHN*");
assertEquals(escape, '!');
assertEquals(single, '#');
assertEquals(wild, '*');
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getComparisonOps());
ComparisonOpsType cot = ft.getComparisonOps().getValue();
PropertyIsLikeType pibt = (PropertyIsLikeType) cot;
PropertyNameType lf = pibt.getPropertyName();
LiteralType lt = pibt.getLiteralType();
char esc = pibt.getEscapeChar();
char sin = pibt.getSingleChar();
char wi = pibt.getWildCard();
assertEquals(lf.getContent(), "LAST_NAME");
assertEquals(lt.getContent().get(0).toString().trim(), "JOHN*");
assertEquals(esc, '!');
assertEquals(sin, '#');
assertEquals(wi, '*');
MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLIKE);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterLogicalNot.
@Test
public void testFilterLogicalNot() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_LOG_NOT);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
LogicalOperator prop = (LogicalOperator) filter;
BinaryComparisonOperator subfilter = (BinaryComparisonOperator) prop.getOperands().get(0);
ValueReference left = (ValueReference) subfilter.getOperand1();
Literal right = (Literal) subfilter.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getLogicOps());
LogicOpsType cot = ft.getLogicOps().getValue();
assertEquals(ft.getLogicOps().getName().getLocalPart(), OGCJAXBStatics.FILTER_LOGIC_NOT);
UnaryLogicOpType pibt = (UnaryLogicOpType) cot;
BinaryComparisonOpType leftoptype = (BinaryComparisonOpType) pibt.getComparisonOps().getValue();
PropertyNameType lf = (PropertyNameType) leftoptype.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) leftoptype.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(valueF, rg.getContent().get(0));
MARSHALLER.marshal(ft.getLogicOps(), TEST_FILE_FIL_LOG_NOT);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testExpPropertyName.
@Test
public void testExpPropertyName() throws JAXBException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_EXP_PROPERTYNAME);
assertNotNull(obj);
JAXBElement<PropertyNameType> jax = (JAXBElement<PropertyNameType>) obj;
ValueReference exp = (ValueReference) TRANSFORMER_GT.visitExpression(jax);
assertNotNull(exp);
String val = exp.getXPath().trim();
assertEquals(val, valueStr);
// Write test
jax = (JAXBElement<PropertyNameType>) TRANSFORMER_OGC.extract(exp);
assertNotNull(jax);
String str = jax.getValue().getContent().trim();
assertEquals(str, valueStr);
MARSHALLER.marshal(jax, TEST_FILE_EXP_PROPERTYNAME);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
use of org.geotoolkit.ogc.xml.v110.PropertyNameType in project geotoolkit by Geomatys.
the class OGC110Test method testFilterComparisonPropertyIsLessThan.
@Test
public void testFilterComparisonPropertyIsLessThan() throws JAXBException, NoSuchAuthorityCodeException, FactoryException {
final Unmarshaller UNMARSHALLER = POOL.acquireUnmarshaller();
final Marshaller MARSHALLER = POOL.acquireMarshaller();
// Read test
Object obj = UNMARSHALLER.unmarshal(FILE_FIL_COMP_ISLESS);
assertNotNull(obj);
JAXBElement<? extends FilterType> jaxfilter = (JAXBElement<? extends FilterType>) obj;
assertNotNull(jaxfilter);
Filter filter = TRANSFORMER_GT.visitFilter(jaxfilter.getValue());
assertNotNull(filter);
BinaryComparisonOperator prop = (BinaryComparisonOperator) filter;
ValueReference left = (ValueReference) prop.getOperand1();
Literal right = (Literal) prop.getOperand2();
assertEquals(left.getXPath(), valueStr);
assertEquals(((Number) right.apply(null)).floatValue(), valueF, DELTA);
// write test
FilterType ft = TRANSFORMER_OGC.apply(filter);
assertNotNull(ft.getComparisonOps());
ComparisonOpsType cot = ft.getComparisonOps().getValue();
BinaryComparisonOpType pibt = (BinaryComparisonOpType) cot;
PropertyNameType lf = (PropertyNameType) pibt.getExpression().get(0).getValue();
LiteralType rg = (LiteralType) pibt.getExpression().get(1).getValue();
assertEquals(valueStr, lf.getContent());
numberEquals(valueF, rg.getContent().get(0));
MARSHALLER.marshal(ft.getComparisonOps(), TEST_FILE_FIL_COMP_ISLESS);
POOL.recycle(MARSHALLER);
POOL.recycle(UNMARSHALLER);
}
Aggregations