use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project ddf by codice.
the class AbstractCswSource method createSortBy.
private SortByType createSortBy(QueryRequest queryRequest) {
Query query = queryRequest.getQuery();
SortByType cswSortBy = null;
if (query != null && query.getSortBy() != null && query.getSortBy().getPropertyName() != null) {
List<SortBy> sortBys = new ArrayList<>();
sortBys.add(query.getSortBy());
Serializable extSortBySer = queryRequest.getPropertyValue(ADDITIONAL_SORT_BYS);
if (extSortBySer instanceof SortBy[]) {
SortBy[] extSortBys = (SortBy[]) extSortBySer;
if (extSortBys.length > 0) {
sortBys.addAll(Arrays.asList(extSortBys));
}
}
for (SortBy sortBy : sortBys) {
SortPropertyType sortProperty = new SortPropertyType();
PropertyNameType propertyName = new PropertyNameType();
if (sortBy.getPropertyName() != null) {
String propName = sortBy.getPropertyName().getPropertyName();
if (propName != null) {
if (Result.TEMPORAL.equals(propName) || Metacard.ANY_DATE.equals(propName)) {
propName = Core.MODIFIED;
} else if (Result.RELEVANCE.equals(propName) || Metacard.ANY_TEXT.equals(propName)) {
propName = Core.TITLE;
} else if (Result.DISTANCE.equals(propName) || Metacard.ANY_GEO.equals(propName)) {
continue;
}
if (cswSortBy == null) {
cswSortBy = new SortByType();
}
propertyName.setContent(Arrays.asList((Object) cswFilterDelegate.mapPropertyName(propName)));
sortProperty.setPropertyName(propertyName);
if (SortOrder.DESCENDING.equals(query.getSortBy().getSortOrder())) {
sortProperty.setSortOrder(SortOrderType.DESC);
} else {
sortProperty.setSortOrder(SortOrderType.ASC);
}
cswSortBy.getSortProperty().add(sortProperty);
}
}
}
} else {
return null;
}
return cswSortBy;
}
use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geo-platform by geosdi.
the class AreaSearchRequestFilter method createFilterAreaPredicate.
/**
* @param areaSearchType
* @param bBox
* @return {@link List<JAXBElement<?>}
*/
private List<JAXBElement<?>> createFilterAreaPredicate(AreaSearchType areaSearchType, BBox bBox) {
List<JAXBElement<?>> areaPredicate = new ArrayList(2);
BinarySpatialOpType binarySpatial = new BinarySpatialOpType();
PropertyNameType propertyNameType = new PropertyNameType();
propertyNameType.setContent(Arrays.<Object>asList(BOUNDING_BOX));
binarySpatial.setPropertyName(propertyNameType);
EnvelopeType envelope = this.createEnvelope(bBox);
binarySpatial.setEnvelope(gmlFactory.createEnvelope(envelope));
switch(areaSearchType) {
case ENCLOSES:
areaPredicate.add(filterFactory.createContains(binarySpatial));
break;
case IS:
areaPredicate.add(filterFactory.createEquals(binarySpatial));
break;
case OUTSIDE:
// Workaround for GeoNetwork bug: DISJOINT = NOT(INTERSECTS)
UnaryLogicOpType unary = new UnaryLogicOpType();
unary.setSpatialOps(filterFactory.createIntersects(binarySpatial));
areaPredicate.add(filterFactory.createNot(unary));
// areaPredicate.add(filterFactory.createDisjoint(binarySpatial));
break;
case OVERLAP:
areaPredicate.add(filterFactory.createIntersects(binarySpatial));
break;
}
return areaPredicate;
}
use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geo-platform by geosdi.
the class QueryRestrictionsBuilderTest method createFilterType.
/**
* @return {@link FilterType}
*/
private FilterType createFilterType() {
FilterType filter = new FilterType();
BBox bbox = new BBox(14.131237640976908, 36.56356461583572, 15.821758881211283, 37.143760728459014);
BBOXType bBoxType = new BBOXType();
PropertyNameType propertyNameType = new PropertyNameType();
propertyNameType.setContent(Arrays.asList("the_geom"));
bBoxType.setPropertyName(propertyNameType);
EnvelopeType envelope = new EnvelopeType();
DirectPositionType lower = new DirectPositionType();
lower.setValue(asList(bbox.getMinX(), bbox.getMinY()));
envelope.setLowerCorner(lower);
DirectPositionType upper = new DirectPositionType();
upper.setValue(asList(bbox.getMaxX(), bbox.getMaxY()));
envelope.setUpperCorner(upper);
envelope.setSrsName("EPSG:4326");
bBoxType.setEnvelope(new ObjectFactory().createEnvelope(envelope));
filter.setSpatialOps(new org.geosdi.geoplatform.xml.filter.v110.ObjectFactory().createBBOX(bBoxType));
return filter;
}
use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project ddf by codice.
the class AbstractCswSource method createSortBy.
private SortByType createSortBy(Query query) {
SortByType sortBy = null;
if (query.getSortBy() != null) {
sortBy = new SortByType();
SortPropertyType sortProperty = new SortPropertyType();
PropertyNameType propertyName = new PropertyNameType();
String propName;
if (query.getSortBy().getPropertyName() != null) {
propName = query.getSortBy().getPropertyName().getPropertyName();
if (propName != null) {
if (Result.TEMPORAL.equals(propName) || Metacard.ANY_DATE.equals(propName)) {
propName = Core.MODIFIED;
} else if (Result.RELEVANCE.equals(propName) || Metacard.ANY_TEXT.equals(propName)) {
propName = Core.TITLE;
} else if (Result.DISTANCE.equals(propName) || Metacard.ANY_GEO.equals(propName)) {
return null;
}
propertyName.setContent(Arrays.asList((Object) cswFilterDelegate.mapPropertyName(propName)));
sortProperty.setPropertyName(propertyName);
if (SortOrder.DESCENDING.equals(query.getSortBy().getSortOrder())) {
sortProperty.setSortOrder(SortOrderType.DESC);
} else {
sortProperty.setSortOrder(SortOrderType.ASC);
}
sortBy.getSortProperty().add(sortProperty);
}
} else {
return null;
}
}
return sortBy;
}
use of org.geosdi.geoplatform.xml.filter.v110.PropertyNameType in project geotoolkit by Geomatys.
the class CswXMLBindingTest method getRecordsUnMarshalingTest.
/**
* Test simple Record Marshalling.
*/
@Test
public void getRecordsUnMarshalingTest() throws JAXBException {
Unmarshaller unmarshaller = pool.acquireUnmarshaller();
/*
* Test unmarshalling csw getRecordByIdResponse v2.0.2
*/
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<csw:GetRecords xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\"" + " maxRecords=\"20\" startPosition=\"1\" outputSchema=\"http://www.opengis.net/cat/csw/2.0.2\" outputFormat=\"application/xml\"" + " resultType=\"results\" version=\"2.0.2\" service=\"CSW\">\n" + " <csw:Query typeNames=\"csw:Record\">\n" + " <csw:ElementSetName>full</csw:ElementSetName>\n" + " <csw:Constraint version=\"1.1.0\">\n" + " <ogc:Filter>\n" + " <ogc:Not>\n" + " <ogc:PropertyIsLike wildCard=\"*\" singleChar=\"?\" escapeChar=\"\\\">\n" + " <ogc:PropertyName>dc:Title</ogc:PropertyName>\n" + " <ogc:Literal>something?</ogc:Literal>\n" + " </ogc:PropertyIsLike>\n" + " </ogc:Not>\n" + " </ogc:Filter>\n" + " </csw:Constraint>\n" + " </csw:Query>\n" + "</csw:GetRecords>\n";
StringReader sr = new StringReader(xml);
Object result = unmarshaller.unmarshal(sr);
/*
* we build the first filter : < dublinCore:Title IS LIKE '*' >
*/
List<QName> typeNames = new ArrayList<>();
PropertyNameType pname = new PropertyNameType("dc:Title");
PropertyIsLikeType pil = new PropertyIsLikeType(pname, "something?", "*", "?", "\\");
NotType n = new NotType(pil);
FilterType filter1 = new FilterType(n);
QueryConstraintType constraint = new QueryConstraintType(filter1, "1.1.0");
typeNames.add(_Record_QNAME);
QueryType query = new QueryType(typeNames, new ElementSetNameType(ElementSetType.FULL), null, constraint);
GetRecordsType expResult = new GetRecordsType("CSW", "2.0.2", ResultType.RESULTS, null, "application/xml", "http://www.opengis.net/cat/csw/2.0.2", 1, 20, query, null);
LOGGER.log(Level.FINER, "RESULT:\n{0}", result);
LOGGER.log(Level.FINER, "EXPRESULT:\n{0}", expResult);
GetRecordsType gres = (GetRecordsType) result;
QueryType expQT = (QueryType) expResult.getAbstractQuery();
QueryType resQT = (QueryType) gres.getAbstractQuery();
assertEquals(expQT.getConstraint().getFilter().getLogicOps().getValue(), resQT.getConstraint().getFilter().getLogicOps().getValue());
assertEquals(expQT.getConstraint().getFilter(), resQT.getConstraint().getFilter());
assertEquals(expQT.getConstraint(), resQT.getConstraint());
assertEquals(expResult.getAbstractQuery(), gres.getAbstractQuery());
assertEquals(expResult, result);
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" + "<cat:GetRecords xmlns:ogc=\"http://www.opengis.net/ogc\" xmlns:cat=\"http://www.opengis.net/cat/csw\"" + " maxRecords=\"20\" startPosition=\"1\" outputSchema=\"http://www.opengis.net/cat/csw\" outputFormat=\"application/xml\"" + " resultType=\"results\" version=\"2.0.0\" service=\"CSW\">\n" + " <cat:Query typeNames=\"cat:Record\">\n" + " <cat:ElementSetName>full</cat:ElementSetName>\n" + " <cat:Constraint version=\"1.1.0\">\n" + " <ogc:Filter>\n" + " <ogc:Not>\n" + " <ogc:PropertyIsLike wildCard=\"*\" singleChar=\"?\" escapeChar=\"\\\">\n" + " <ogc:PropertyName>dc:Title</ogc:PropertyName>\n" + " <ogc:Literal>something?</ogc:Literal>\n" + " </ogc:PropertyIsLike>\n" + " </ogc:Not>\n" + " </ogc:Filter>\n" + " </cat:Constraint>\n" + " </cat:Query>\n" + "</cat:GetRecords>\n";
org.geotoolkit.csw.xml.v200.QueryConstraintType constraint200 = new org.geotoolkit.csw.xml.v200.QueryConstraintType(filter1, "1.1.0");
typeNames = new ArrayList<>();
typeNames.add(org.geotoolkit.csw.xml.v200.ObjectFactory._Record_QNAME);
org.geotoolkit.csw.xml.v200.QueryType query200 = new org.geotoolkit.csw.xml.v200.QueryType(typeNames, new org.geotoolkit.csw.xml.v200.ElementSetNameType(ElementSetType.FULL), constraint200);
org.geotoolkit.csw.xml.v200.GetRecordsType expResult200 = new org.geotoolkit.csw.xml.v200.GetRecordsType("CSW", "2.0.0", ResultType.RESULTS, null, "application/xml", "http://www.opengis.net/cat/csw", 1, 20, query200, null);
sr = new StringReader(xml);
result = unmarshaller.unmarshal(sr);
assertTrue(result instanceof JAXBElement);
org.geotoolkit.csw.xml.v200.GetRecordsType result200 = (org.geotoolkit.csw.xml.v200.GetRecordsType) ((JAXBElement) result).getValue();
assertEquals(expResult200.getAbstractQuery(), result200.getAbstractQuery());
assertEquals(expResult200, result200);
pool.recycle(unmarshaller);
}
Aggregations