use of org.geotoolkit.gml.xml.v321.TimeInstantType in project ddf by codice.
the class WfsFilterDelegate method createTimeInstantType.
private TimeInstantType createTimeInstantType(String type, String date) {
TimeInstantType timeInstantType = gml320ObjectFactory.createTimeInstantType();
timeInstantType.setTimePosition(createTimePositionType(date));
timeInstantType.setId(type + "." + System.currentTimeMillis());
return timeInstantType;
}
use of org.geotoolkit.gml.xml.v321.TimeInstantType in project ddf by codice.
the class WfsFilterDelegateTest method testSequentialPropertyIsOfTemporalType.
private void testSequentialPropertyIsOfTemporalType(String methName, String temporalOpName) throws Exception {
SequentialTestMockHolder sequentialTestMockHolder = new SequentialTestMockHolder().invoke();
WfsFilterDelegate delegate = sequentialTestMockHolder.getDelegate();
String mockMetacardAttribute = sequentialTestMockHolder.getMockMetacardAttribute();
String mockFeatureProperty = sequentialTestMockHolder.getMockFeatureProperty();
String mockFeatureType = sequentialTestMockHolder.getMockFeatureType();
DateTime date = new DateTime().minusDays(365);
// Perform Test
Method method = WfsFilterDelegate.class.getMethod(methName, String.class, Date.class);
FilterType filter = (FilterType) method.invoke(delegate, mockMetacardAttribute, date.toDate());
// Verify
assertThat(filter.getTemporalOps().getName().toString(), is(temporalOpName));
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) filter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.getValueReference(), is(mockFeatureProperty));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimeInstantType timeInstant = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
assertThat(timeInstant.getTimePosition().getValue().get(0), is(ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(date)));
assertThat("Strings matches expected pattern", timeInstant.getId().matches(getRegEx(mockFeatureType)), equalTo(true));
}
use of org.geotoolkit.gml.xml.v321.TimeInstantType in project ddf by codice.
the class WfsFilterDelegateTest method testRelativeTemporalOnlyQueryAfterSupported.
/**
* If the WFS server does support an 'After' temporal query and supports a 'During' temporal
* query, the query should remain an 'After' query
*/
@Test
public void testRelativeTemporalOnlyQueryAfterSupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
assertThat(afterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After"));
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 beginDate = timePositionTypeToDate(beginPositionType);
Date endDate = new Date();
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
}
use of org.geotoolkit.gml.xml.v321.TimeInstantType in project ddf by codice.
the class WfsFilterDelegateTest 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));
}
use of org.geotoolkit.gml.xml.v321.TimeInstantType in project arctic-sea by 52North.
the class GmlEncoderv321 method createTimeInstantType.
private TimeInstantType createTimeInstantType(TimeInstant timeInstant) throws EncodingException {
TimeInstantType timeInstantType = TimeInstantType.Factory.newInstance(getXmlOptions());
createTimeInstantType(timeInstant, timeInstantType);
return timeInstantType;
}
Aggregations