use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class WfsFilterDelegateTest method testDuringPropertyIsOfTemporalType.
@Test
public /**
* Doing a Absolute query from the search UI creates a During filter with the selected Begin and
* End date/times.
*
* <p>Example During filter:
*
* <p><Filter> <During> <ValueReference>myFeatureProperty</ValueReference> <ns4:TimePeriod
* ns4:id="myFeatureType.1406219647420">
* <ns4:beginPosition>1974-08-01T16:29:45.430-07:00</ns4:beginPosition>
* <ns4:endPosition>2014-07-22T16:29:45.430-07:00</ns4:endPosition> </ns4:TimePeriod> </During>
* </Filter>
*/
void testDuringPropertyIsOfTemporalType() {
SequentialTestMockHolder sequentialTestMockHolder = new SequentialTestMockHolder().invoke();
WfsFilterDelegate delegate = sequentialTestMockHolder.getDelegate();
String mockMetacardAttribute = sequentialTestMockHolder.getMockMetacardAttribute();
String mockFeatureProperty = sequentialTestMockHolder.getMockFeatureProperty();
String mockFeatureType = sequentialTestMockHolder.getMockFeatureType();
DateTime startDate = new DateTime(2014, 01, 01, 01, 01, 01, 123, DateTimeZone.forID("-07:00"));
DateTime endDate = new DateTime(2014, 01, 02, 01, 01, 01, 123, DateTimeZone.forID("-07:00"));
// Perform Test
FilterType filter = delegate.during(mockMetacardAttribute, startDate.toDate(), endDate.toDate());
// Verify
assertThat(filter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) filter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.getValueReference(), is(mockFeatureProperty));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
assertThat(timePeriod.getBeginPosition().getValue().get(0), is("2014-01-01T08:01:01Z"));
assertThat(timePeriod.getEndPosition().getValue().get(0), is("2014-01-02T08:01:01Z"));
assertThat("Strings matches expected pattern", timePeriod.getId().matches(getRegEx(mockFeatureType)), equalTo(true));
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class WfsFilterDelegateTest method testDuringFilterTypeDates.
@Test
public void testDuringFilterTypeDates() {
setupMockMetacardType();
FilterType duringFilter = setupDuringFilterType();
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
TimePositionType beginPositionType = timePeriod.getBeginPosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
TimePositionType endPositionType = timePeriod.getEndPosition();
Date endDate = timePositionTypeToDate(endPositionType);
assertThat(endDate.after(beginDate), is(true));
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project arctic-sea by 52North.
the class FesDecoderv20 method parseTemporalFilterType.
/**
* parses a single temporal filter of the requests and returns SOS temporal
* filter
*
* @param xbTemporalOpsType
* XmlObject representing the temporal filter
* @return Returns SOS representation of temporal filter
*
* @throws DecodingException
* * if parsing of the element failed
*/
private TemporalFilter parseTemporalFilterType(TemporalOpsType xbTemporalOpsType) throws DecodingException {
TemporalFilter temporalFilter = new TemporalFilter();
try {
if (xbTemporalOpsType instanceof BinaryTemporalOpType) {
BinaryTemporalOpType btot = (BinaryTemporalOpType) xbTemporalOpsType;
if (btot.getValueReference() != null && !btot.getValueReference().isEmpty()) {
temporalFilter.setValueReference(btot.getValueReference().trim());
}
NodeList nodes = btot.getDomNode().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
if (nodes.item(i).getNamespaceURI() != null && !nodes.item(i).getLocalName().equals(FilterConstants.EN_VALUE_REFERENCE)) {
Object timeObject = decodeXmlObject(Factory.parse(nodes.item(i)));
if (timeObject instanceof Time) {
TimeOperator operator;
Time time = (Time) timeObject;
String localName = XmlHelper.getLocalName(xbTemporalOpsType);
if (localName.equals(TimeOperator2.After.name())) {
operator = TimeOperator.TM_After;
} else if (localName.equals(TimeOperator2.Before.name())) {
operator = TimeOperator.TM_Before;
} else if (localName.equals(TimeOperator2.Begins.name())) {
operator = TimeOperator.TM_Begins;
} else if (localName.equals(TimeOperator2.BegunBy.name())) {
operator = TimeOperator.TM_BegunBy;
} else if (localName.equals(TimeOperator2.TContains.name())) {
operator = TimeOperator.TM_Contains;
} else if (localName.equals(TimeOperator2.During.name())) {
operator = TimeOperator.TM_During;
} else if (localName.equals(TimeOperator2.EndedBy.name())) {
operator = TimeOperator.TM_EndedBy;
} else if (localName.equals(TimeOperator2.Ends.name())) {
operator = TimeOperator.TM_Ends;
} else if (localName.equals(TimeOperator2.TEquals.name())) {
operator = TimeOperator.TM_Equals;
} else if (localName.equals(TimeOperator2.Meets.name())) {
operator = TimeOperator.TM_Meets;
} else if (localName.equals(TimeOperator2.MetBy.name())) {
operator = TimeOperator.TM_MetBy;
} else if (localName.equals(TimeOperator2.TOverlaps.name())) {
operator = TimeOperator.TM_Overlaps;
} else if (localName.equals(TimeOperator2.OverlappedBy.name())) {
operator = TimeOperator.TM_OverlappedBy;
} else {
throw unsupportedTemporalOperator();
}
temporalFilter.setOperator(operator);
temporalFilter.setTime(time);
break;
} else {
throw new DecodingException(Sos2Constants.GetObservationParams.temporalFilter, "The requested temporal filter value is not supported by this SOS!");
}
}
}
} else {
throw unsupportedTemporalOperator();
}
} catch (XmlException xmle) {
throw new DecodingException("Error while parsing temporal filter!", xmle);
}
return temporalFilter;
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project arctic-sea by 52North.
the class FesEncoderv20 method encodeTemporalFilterEquals.
private XmlObject encodeTemporalFilterEquals(TemporalFilter temporalFilter) throws EncodingException {
final TEqualsDocument equalsDoc = TEqualsDocument.Factory.newInstance(getXmlOptions());
final BinaryTemporalOpType equals = equalsDoc.addNewTEquals();
if (temporalFilter.getTime() instanceof TimeInstant) {
equals.set(encodeObjectToXml(GmlConstants.NS_GML_32, temporalFilter.getTime(), EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT)));
} else {
throw new EncodingException("The temporal filter value is not a TimeInstant!");
}
checkAndAddValueReference(equals, temporalFilter);
return equalsDoc;
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project arctic-sea by 52North.
the class FesEncoderv20 method encodeTemporalFilterDuring.
private XmlObject encodeTemporalFilterDuring(TemporalFilter temporalFilter) throws EncodingException {
final DuringDocument duringDoc = DuringDocument.Factory.newInstance(getXmlOptions());
final BinaryTemporalOpType during = duringDoc.addNewDuring();
if (temporalFilter.getTime() instanceof TimePeriod) {
during.set(encodeObjectToXml(GmlConstants.NS_GML_32, temporalFilter.getTime(), EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT)));
} else {
throw new EncodingException("The temporal filter value is not a TimePeriod!");
}
checkAndAddValueReference(during, temporalFilter);
return duringDoc;
}
Aggregations