use of org.geotoolkit.ogc.xml.v110.SortPropertyType in project ddf by codice.
the class WfsSource method buildSortBy.
private SortByType buildSortBy(QName featureType, SortBy incomingSortBy) {
net.opengis.filter.v_1_1_0.ObjectFactory filterObjectFactory = new net.opengis.filter.v_1_1_0.ObjectFactory();
String propertyName = mapSortByPropertyName(featureType, incomingSortBy.getPropertyName().getPropertyName(), metacardMappers);
if (propertyName != null) {
SortOrder sortOrder = incomingSortBy.getSortOrder();
SortPropertyType sortPropertyType = filterObjectFactory.createSortPropertyType();
PropertyNameType propertyNameType = filterObjectFactory.createPropertyNameType();
List<Serializable> props = Arrays.asList(propertyName);
propertyNameType.setContent(props);
sortPropertyType.setPropertyName(propertyNameType);
if (SortOrder.ASCENDING.equals(sortOrder)) {
sortPropertyType.setSortOrder(SortOrderType.ASC);
} else if (SortOrder.DESCENDING.equals(sortOrder)) {
sortPropertyType.setSortOrder(SortOrderType.DESC);
} else {
LOGGER.debug("Unable to build query. Unknown sort order of [{}].", sortOrder == null ? null : sortOrder.identifier());
return null;
}
SortByType sortByType = filterObjectFactory.createSortByType();
sortByType.getSortProperty().add(sortPropertyType);
return sortByType;
}
return null;
}
use of org.geotoolkit.ogc.xml.v110.SortPropertyType 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.geotoolkit.ogc.xml.v110.SortPropertyType in project geotoolkit by Geomatys.
the class AbstractGetRecords method getResponseStream.
/**
* {@inheritDoc}
*/
@Override
public InputStream getResponseStream() throws IOException {
final URL url = getURL();
URLConnection conec = url.openConnection();
security.secure(conec);
conec.setDoOutput(true);
conec.setRequestProperty("Content-Type", "text/xml");
OutputStream stream = conec.getOutputStream();
stream = security.encrypt(stream);
try {
final Marshaller marsh = POOL.acquireMarshaller();
/*
* Getting typeNames value used to build QueryType object
*/
final List<QName> typNames = new ArrayList<>();
if (typeNames != null) {
typNames.add(TypeNames.valueOf(typeNames));
}
/*
* Getting ElementSetType value used to build QueryType object
*/
ElementSetName esnt = null;
if (elementSetName != null) {
esnt = createElementSetName(version, elementSetName);
}
/*
* Getting SortByType value, default is null
*
* @TODO if sortBy is not null we must creates SortByType instance
* the value can be sortBy=Title:A,Abstract:D where A for ascending order and D for decending.
* see Table 29 - Parameters in GetRecords operation request in document named
* OpenGIS Catalogue Services Specification 2.0.2 -ISO Metadata Application Profile
*
*/
final SortByType sort;
if (sortBy != null) {
String[] fields = sortBy.split(",");
List<SortPropertyType> sortProps = new ArrayList<>();
for (String field : fields) {
String[] split = field.split(":");
SortOrder sortOrder = split.length == 1 ? null : ("D".equals(split[1]) ? DESCENDING : ASCENDING);
sortProps.add(new SortPropertyType(split[0], sortOrder));
}
sort = new SortByType(sortProps);
} else {
sort = null;
}
/*
* Building QueryType from the cql constraint
*/
QueryConstraint qct = null;
if (constraint != null && !constraint.isEmpty()) {
try {
final FilterType filterType;
Filter filter = CQL.parseFilter(constraint, new FilterFactoryImpl());
if (filter instanceof FilterType) {
filterType = (FilterType) filter;
} else {
filterType = new FilterType(filter);
}
qct = createQueryConstraint(version, filterType, constraintLanguageVersion != null ? constraintLanguageVersion : "1.1.0");
} catch (CQLException ex) {
// @TODO maybe use another Exception.
throw new IllegalArgumentException("Constraint cannot be parsed to filter, the constraint parameter value is not in OGC CQL format.", ex);
}
}
final Query queryType = createQuery(version, typNames, esnt, sort, qct);
final DistributedSearch ds = createDistributedSearch(version, hopcount);
final org.geotoolkit.csw.xml.GetRecordsRequest recordsXml = createGetRecord(version, "CSW", resultType, requestId, outputFormat, outputSchema, startPosition, maxRecords, queryType, ds);
marsh.marshal(recordsXml, stream);
POOL.recycle(marsh);
} catch (JAXBException ex) {
throw new IOException(ex);
}
stream.close();
return security.decrypt(conec.getInputStream());
}
use of org.geotoolkit.ogc.xml.v110.SortPropertyType in project geotoolkit by Geomatys.
the class OGC110toGTTransformer method visitSortBy.
public List<SortProperty> visitSortBy(final SortByType type) {
final List<SortProperty> sorts = new ArrayList<>();
for (final SortPropertyType spt : type.getSortProperty()) {
final ValueReference pn = visitPropertyName(spt.getValueReference());
sorts.add(filterFactory.sort(pn, spt.getSortOrder()));
}
return sorts;
}
Aggregations