Search in sources :

Example 51 with PropertyNameType

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;
}
Also used : Serializable(java.io.Serializable) Query(ddf.catalog.operation.Query) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) SortPropertyType(net.opengis.filter.v_1_1_0.SortPropertyType) SortByType(net.opengis.filter.v_1_1_0.SortByType) PropertyNameType(net.opengis.filter.v_1_1_0.PropertyNameType)

Example 52 with PropertyNameType

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;
}
Also used : UnaryLogicOpType(org.geosdi.geoplatform.xml.filter.v110.UnaryLogicOpType) EnvelopeType(org.geosdi.geoplatform.xml.gml.v311.EnvelopeType) ArrayList(java.util.ArrayList) BinarySpatialOpType(org.geosdi.geoplatform.xml.filter.v110.BinarySpatialOpType) JAXBElement(javax.xml.bind.JAXBElement) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 53 with PropertyNameType

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;
}
Also used : FilterType(org.geosdi.geoplatform.xml.filter.v110.FilterType) EnvelopeType(org.geosdi.geoplatform.xml.gml.v311.EnvelopeType) BBOXType(org.geosdi.geoplatform.xml.filter.v110.BBOXType) DirectPositionType(org.geosdi.geoplatform.xml.gml.v311.DirectPositionType) ObjectFactory(org.geosdi.geoplatform.xml.gml.v311.ObjectFactory) BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 54 with PropertyNameType

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;
}
Also used : SortPropertyType(net.opengis.filter.v_1_1_0.SortPropertyType) SortByType(net.opengis.filter.v_1_1_0.SortByType) PropertyNameType(net.opengis.filter.v_1_1_0.PropertyNameType)

Example 55 with PropertyNameType

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);
}
Also used : ArrayList(java.util.ArrayList) QueryConstraintType(org.geotoolkit.csw.xml.v202.QueryConstraintType) NotType(org.geotoolkit.ogc.xml.v110.NotType) StringReader(java.io.StringReader) ElementSetNameType(org.geotoolkit.csw.xml.v202.ElementSetNameType) Unmarshaller(javax.xml.bind.Unmarshaller) PropertyNameType(org.geotoolkit.ogc.xml.v110.PropertyNameType) QName(javax.xml.namespace.QName) GetRecordsType(org.geotoolkit.csw.xml.v202.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) FilterType(org.geotoolkit.ogc.xml.v110.FilterType) QueryType(org.geotoolkit.csw.xml.v202.QueryType) PropertyIsLikeType(org.geotoolkit.ogc.xml.v110.PropertyIsLikeType) Test(org.junit.Test)

Aggregations

PropertyNameType (org.geotoolkit.ogc.xml.v110.PropertyNameType)62 JAXBElement (javax.xml.bind.JAXBElement)46 LiteralType (org.geotoolkit.ogc.xml.v110.LiteralType)38 Test (org.junit.Test)38 Unmarshaller (javax.xml.bind.Unmarshaller)37 Marshaller (javax.xml.bind.Marshaller)36 ValueReference (org.opengis.filter.ValueReference)36 Literal (org.opengis.filter.Literal)30 Filter (org.opengis.filter.Filter)26 PropertyNameType (org.geotoolkit.ogc.xml.v100.PropertyNameType)20 BinaryComparisonOperator (org.opengis.filter.BinaryComparisonOperator)20 LiteralType (org.geotoolkit.ogc.xml.v100.LiteralType)16 FilterType (org.geotoolkit.ogc.xml.v110.FilterType)16 PropertyNameType (net.opengis.filter.v_1_1_0.PropertyNameType)13 FilterType (org.geotoolkit.ogc.xml.v100.FilterType)12 Expression (org.opengis.filter.Expression)12 ComparisonOpsType (org.geotoolkit.ogc.xml.v100.ComparisonOpsType)10 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v100.BinaryComparisonOpType)9 BinaryComparisonOpType (org.geotoolkit.ogc.xml.v110.BinaryComparisonOpType)9 ComparisonOpsType (org.geotoolkit.ogc.xml.v110.ComparisonOpsType)9