use of net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand in project ddf by codice.
the class WfsFilterDelegate method buildAfterFilterType.
private FilterType buildAfterFilterType(String propertyName, String date) {
TemporalOperand timeInstantTemporalOperand = new TemporalOperand();
timeInstantTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_INSTANT));
if (!isTemporalOperandSupported(timeInstantTemporalOperand)) {
throw new UnsupportedOperationException("Temporal Operand [" + timeInstantTemporalOperand.getName() + "] is not supported.");
}
if (!isValidInputParameters(propertyName, date)) {
throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
}
if (!isPropertyTemporalType(propertyName)) {
throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timeInstantTemporalOperand.getName() + ".");
}
FilterType filter = filterObjectFactory.createFilterType();
if (featureMetacardType.getProperties().contains(propertyName)) {
FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (featureAttributeDescriptor.isIndexed()) {
filter.setTemporalOps(createAfter(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), date));
} else {
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
if (!isTemporalOpSupported(TEMPORAL_OPERATORS.After)) {
if (isTemporalOpSupported(TEMPORAL_OPERATORS.During)) {
return buildDuringFilterType(propertyName, date, convertDateToIso8601Format(new Date()));
}
}
return filter;
}
use of net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand in project ddf by codice.
the class WfsFilterDelegate method updateAllowedOperations.
private final void updateAllowedOperations(FilterCapabilities filterCapabilities) {
comparisonOps = Collections.newSetFromMap(new ConcurrentHashMap<COMPARISON_OPERATORS, Boolean>(new EnumMap<COMPARISON_OPERATORS, Boolean>(COMPARISON_OPERATORS.class)));
geometryOperands = new ArrayList<QName>();
temporalOperands = new ArrayList<QName>();
if (filterCapabilities == null) {
LOGGER.debug("WFS 2.0 Service doesn't support any filters");
return;
}
// CONFORMANCE
configureConformance(filterCapabilities.getConformance());
ScalarCapabilitiesType scalarCapabilities = filterCapabilities.getScalarCapabilities();
if (scalarCapabilities != null) {
// LOGICAL OPERATORS
if (scalarCapabilities.getLogicalOperators() != null) {
logicalOps = true;
}
// COMPARISON OPERATORS
ComparisonOperatorsType comparisonOperators = scalarCapabilities.getComparisonOperators();
if (comparisonOperators != null) {
for (ComparisonOperatorType comp : comparisonOperators.getComparisonOperator()) {
if (null != comp) {
comparisonOps.add(COMPARISON_OPERATORS.valueOf(comp.getName()));
}
}
}
}
// SPATIAL OPERATORS
SpatialCapabilitiesType spatialCapabilities = filterCapabilities.getSpatialCapabilities();
if (spatialCapabilities != null) {
if (spatialCapabilities.getSpatialOperators() != null) {
setSpatialOps(spatialCapabilities.getSpatialOperators());
}
// GEOMETRY OPERANDS
GeometryOperandsType geometryOperandsType = spatialCapabilities.getGeometryOperands();
if (geometryOperandsType != null) {
for (GeometryOperandsType.GeometryOperand geoOperand : geometryOperandsType.getGeometryOperand()) {
if (geoOperand.getName() != null) {
geometryOperands.add(geoOperand.getName());
}
}
LOGGER.debug("geometryOperands: {}", geometryOperands);
}
}
// TEMPORAL OPERATORS
TemporalCapabilitiesType temporalCapabilitiesType = filterCapabilities.getTemporalCapabilities();
if (temporalCapabilitiesType != null) {
if (temporalCapabilitiesType.getTemporalOperators() != null) {
setTemporalOps(temporalCapabilitiesType.getTemporalOperators());
}
// TEMPORAL OPERANDS
TemporalOperandsType temporalOperandsType = temporalCapabilitiesType.getTemporalOperands();
if (temporalOperandsType != null) {
for (TemporalOperandsType.TemporalOperand temporalOperand : temporalOperandsType.getTemporalOperand()) {
if (temporalOperand.getName() != null) {
temporalOperands.add(temporalOperand.getName());
}
}
LOGGER.debug("temporalOperands: {}", temporalOperands);
}
}
}
use of net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand in project ddf by codice.
the class MockWfsServer method getFilterCapabilities.
public static FilterCapabilities getFilterCapabilities() {
FilterCapabilities capabilities = new FilterCapabilities();
ConformanceType conformance = new ConformanceType();
for (CONFORMANCE_CONSTRAINTS constraint : CONFORMANCE_CONSTRAINTS.values()) {
DomainType domain = new DomainType();
NoValues noValues = new NoValues();
domain.setNoValues(noValues);
ValueType value = new ValueType();
value.setValue("TRUE");
domain.setDefaultValue(value);
domain.setName(constraint.toString());
conformance.getConstraint().add(domain);
}
capabilities.setConformance(conformance);
ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
scalar.setLogicalOperators(new LogicalOperators());
scalar.setComparisonOperators(new ComparisonOperatorsType());
for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
ComparisonOperatorType operator = new ComparisonOperatorType();
operator.setName(compOp.toString());
scalar.getComparisonOperators().getComparisonOperator().add(operator);
}
capabilities.setScalarCapabilities(scalar);
SpatialCapabilitiesType spatial = new SpatialCapabilitiesType();
spatial.setSpatialOperators(new SpatialOperatorsType());
for (SPATIAL_OPERATORS spatialOp : SPATIAL_OPERATORS.values()) {
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(spatialOp.toString());
spatial.getSpatialOperators().getSpatialOperator().add(operator);
}
GeometryOperandsType geometryOperands = new GeometryOperandsType();
List<QName> qnames = Arrays.asList(Wfs20Constants.POINT, Wfs20Constants.ENVELOPE, Wfs20Constants.POLYGON, Wfs20Constants.LINESTRING);
for (QName qName : qnames) {
GeometryOperand operand = new GeometryOperand();
operand.setName(qName);
geometryOperands.getGeometryOperand().add(operand);
}
spatial.setGeometryOperands(geometryOperands);
capabilities.setSpatialCapabilities(spatial);
TemporalCapabilitiesType temporal = new TemporalCapabilitiesType();
temporal.setTemporalOperators(new TemporalOperatorsType());
for (TEMPORAL_OPERATORS temporalOp : TEMPORAL_OPERATORS.values()) {
TemporalOperatorType operator = new TemporalOperatorType();
operator.setName(temporalOp.toString());
temporal.getTemporalOperators().getTemporalOperator().add(operator);
}
TemporalOperandsType temporalOperands = new TemporalOperandsType();
List<QName> timeQNames = Arrays.asList(new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimePeriod"), new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimeInstant"));
for (QName qName : timeQNames) {
TemporalOperand operand = new TemporalOperand();
operand.setName(qName);
temporalOperands.getTemporalOperand().add(operand);
}
temporal.setTemporalOperands(temporalOperands);
capabilities.setTemporalCapabilities(temporal);
return capabilities;
}
use of net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand in project ddf by codice.
the class WfsFilterDelegate method buildBeforeFilterType.
private FilterType buildBeforeFilterType(String propertyName, String date) {
TemporalOperand timeInstantTemporalOperand = new TemporalOperand();
timeInstantTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_INSTANT));
if (!isTemporalOperandSupported(timeInstantTemporalOperand)) {
throw new UnsupportedOperationException("Temporal Operand [" + timeInstantTemporalOperand.getName() + "] is not supported.");
}
if (!isValidInputParameters(propertyName, date)) {
throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
}
if (!isPropertyTemporalType(propertyName)) {
throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timeInstantTemporalOperand.getName() + ".");
}
FilterType filter = filterObjectFactory.createFilterType();
if (featureMetacardType.getProperties().contains(propertyName)) {
FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (featureAttributeDescriptor.isIndexed()) {
filter.setTemporalOps(createBefore(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), date));
} else {
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
return filter;
}
use of net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand in project ddf by codice.
the class WfsFilterDelegate method buildDuringFilterType.
private FilterType buildDuringFilterType(String propertyName, String startDate, String endDate) {
if (!isTemporalOpSupported(TEMPORAL_OPERATORS.During)) {
throw new UnsupportedOperationException("Temporal Operator [" + TEMPORAL_OPERATORS.During + "] is not supported.");
}
TemporalOperand timePeriodTemporalOperand = new TemporalOperand();
timePeriodTemporalOperand.setName(new QName(Wfs20Constants.GML_3_2_NAMESPACE, Wfs20Constants.TIME_PERIOD));
if (!isTemporalOperandSupported(timePeriodTemporalOperand)) {
throw new UnsupportedOperationException("Temporal Operand [" + timePeriodTemporalOperand.getName() + "] is not supported.");
}
if (!isValidInputParameters(propertyName, startDate, endDate)) {
throw new IllegalArgumentException(MISSING_PARAMETERS_MSG);
}
if (!isPropertyTemporalType(propertyName)) {
throw new IllegalArgumentException("Property [" + propertyName + "] is not of type " + timePeriodTemporalOperand.getName() + ".");
}
FilterType filter = filterObjectFactory.createFilterType();
if (featureMetacardType.getProperties().contains(propertyName)) {
FeatureAttributeDescriptor featureAttributeDescriptor = (FeatureAttributeDescriptor) featureMetacardType.getAttributeDescriptor(propertyName);
if (featureAttributeDescriptor.isIndexed()) {
filter.setTemporalOps(createDuring(featureAttributeDescriptor.getPropertyName(), featureMetacardType.getName(), startDate, endDate));
} else {
throw new IllegalArgumentException(String.format(PROPERTY_NOT_QUERYABLE, propertyName));
}
} else {
return null;
}
return filter;
}
Aggregations