// TODO what if this is a Geometry property, also need to validate literals
// initialize
LOGGER.finer("Parsing property clause for "+parent.getNodeName());
String sErr = parent.getNodeName();
Discoverable discoverable = this.parsePropertyName(parent,xpath);
propertyClause.setTarget(discoverable);
// anytext queries are only supported for PropertyIsLike
if (discoverable.getMeaning().getMeaningType().equals(PropertyMeaningType.ANYTEXT)) {
if (!(propertyClause instanceof PropertyClause.PropertyIsLike)) {
String sPropName = "AnyText";
Node ndPropName = (Node)xpath.evaluate("ogc:PropertyName",parent,XPathConstants.NODE);
if (ndPropName != null) {
sPropName = Val.chkStr(ndPropName.getTextContent());
}
String msg = sErr+" - PropertyIsLike is the only supported operand for PropertyName: "+sPropName;
throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"PropertyName",msg);
}
}
// between comparison - set lower and upper boundaries
if (propertyClause instanceof PropertyClause.PropertyIsBetween) {
PropertyClause.PropertyIsBetween between;
between = (PropertyClause.PropertyIsBetween)propertyClause;
Node ndLower = (Node)xpath.evaluate("ogc:LowerBoundary",parent,XPathConstants.NODE);
Node ndUpper = (Node)xpath.evaluate("ogc:UpperBoundary",parent,XPathConstants.NODE);
String sLower = "";
String sUpper = "";
if ((ndLower == null) && (ndUpper == null)) {
String msg = sErr+" - a LowerBoundary or UpperBoundary was not found.";
throw new OwsException(OwsException.OWSCODE_MissingParameterValue,"PropertyIsBetween",msg);
}
if (ndLower != null) {
sLower = ndLower.getTextContent();
between.setLowerBoundary(sLower);
// TODO validate content
}
if (ndUpper != null) {
sUpper = ndUpper.getTextContent();
between.setUpperBoundary(sUpper);
// TODO validate content
}
if ((sLower == null) || (sLower.length() == 0)) {
if ((sUpper == null) || (sUpper.length() == 0)) {
String msg = sErr+" - the LowerBoundary and UpperBoundary are empty.";
throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"PropertyIsBetween",msg);
}
}
// null check - no literal required
} else if (propertyClause instanceof PropertyClause.PropertyIsNull) {
// non-range clauses
} else {
Node ndLiteral = (Node)xpath.evaluate("ogc:Literal", parent,XPathConstants.NODE);
if (ndLiteral == null) {
String msg = sErr+" - an ogc:Literal was not found.";
throw new OwsException(OwsException.OWSCODE_MissingParameterValue,"Literal",msg);
}
String sLiteral = ndLiteral.getTextContent();
propertyClause.setLiteral(sLiteral);
// TODO validate content
if ((sLiteral == null) || (sLiteral.length() == 0)) {
String msg = sErr+".ogc:Literal - the supplied literal was empty.";
throw new OwsException(OwsException.OWSCODE_InvalidParameterValue,"Literal",msg);
}
// set like comparison attributes
if (propertyClause instanceof PropertyClause.PropertyIsLike) {
PropertyClause.PropertyIsLike like;
like = (PropertyClause.PropertyIsLike) propertyClause;
like.setEscapeChar(xpath.evaluate("@escapeChar", parent));
like.setSingleChar(xpath.evaluate("@singleChar", parent));
like.setWildCard(xpath.evaluate("@wildCard", parent));
}
// initialize the language code, (INSPIRE requirement but generally applicable)
// INSPIRE requirement, specify the language for exceptions in this manner
// doesn't seem to be a good approach
if ((this.opContext != null) && (propertyClause instanceof PropertyClause.PropertyIsEqualTo)) {
if (discoverable.getMeaning().getName().equals("apiso.Language")) {
if ((sLiteral != null) && (sLiteral.length() > 0)) {
CapabilityOptions cOptions = this.opContext.getRequestOptions().getCapabilityOptions();
if (cOptions.getLanguageCode() == null) {
cOptions.setLanguageCode(sLiteral);
}