Search in sources :

Example 1 with DomainType

use of org.geosdi.geoplatform.xml.ows.v100.DomainType in project ddf by codice.

the class TestCswCqlFilter method getOperation.

private static Operation getOperation() {
    List<DomainType> getRecordsParameters = new ArrayList<>(6);
    DomainType typeName = new DomainType();
    typeName.setName(CswConstants.TYPE_NAME_PARAMETER);
    getRecordsParameters.add(typeName);
    DomainType outputSchema = new DomainType();
    outputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
    getRecordsParameters.add(outputSchema);
    DomainType constraintLang = new DomainType();
    constraintLang.setName(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
    getRecordsParameters.add(constraintLang);
    DomainType outputFormat = new DomainType();
    outputFormat.setName(CswConstants.OUTPUT_FORMAT_PARAMETER);
    getRecordsParameters.add(outputFormat);
    DomainType resultType = new DomainType();
    resultType.setName(CswConstants.RESULT_TYPE_PARAMETER);
    getRecordsParameters.add(resultType);
    DomainType elementSetName = new DomainType();
    elementSetName.setName(CswConstants.ELEMENT_SET_NAME_PARAMETER);
    getRecordsParameters.add(elementSetName);
    Operation getRecords = new Operation();
    getRecords.setName(CswConstants.GET_RECORDS);
    getRecords.setParameter(getRecordsParameters);
    List<Operation> operations = new ArrayList<>(1);
    operations.add(getRecords);
    return getRecords;
}
Also used : DomainType(net.opengis.ows.v_1_0_0.DomainType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation)

Example 2 with DomainType

use of org.geosdi.geoplatform.xml.ows.v100.DomainType in project ddf by codice.

the class TestWfsSource method testSortingAscendingSortingNotSupported.

/**
     * Verify that the SortBy is NOT set.  In this case, sorting is not supported in the capabilities.
     */
@Test
public void testSortingAscendingSortingNotSupported() throws Exception {
    // Setup
    final String searchPhrase = "*";
    final String mockTemporalFeatureProperty = "myTemporalFeatureProperty";
    final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
    final int pageSize = 1;
    // Set ImplementsSorting to FALSE (sorting not supported)
    FilterCapabilities mockCapabilitiesSortingNotSupported = MockWfsServer.getFilterCapabilities();
    ConformanceType conformance = mockCapabilitiesSortingNotSupported.getConformance();
    List<DomainType> domainTypes = conformance.getConstraint();
    for (DomainType domainType : domainTypes) {
        if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
            ValueType valueType = new ValueType();
            valueType.setValue("FALSE");
            domainType.setDefaultValue(valueType);
            break;
        }
    }
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, mockCapabilitiesSortingNotSupported, GeospatialUtil.EPSG_4326_URN, 1, false, false, 0);
    MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
    when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
    when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
    List<MetacardMapper> mappers = new ArrayList<MetacardMapper>(1);
    mappers.add(mockMetacardMapper);
    source.setMetacardToFeatureMapper(mappers);
    QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
    query.setPageSize(pageSize);
    SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
    query.setSortBy(sortBy);
    // Perform Test
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    // Verify
    QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
    assertFalse(queryType.isSetAbstractSortingClause());
}
Also used : ValueType(net.opengis.ows.v_1_1_0.ValueType) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) QueryImpl(ddf.catalog.operation.impl.QueryImpl) DomainType(net.opengis.ows.v_1_1_0.DomainType) SortByImpl(ddf.catalog.filter.impl.SortByImpl) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) QueryType(net.opengis.wfs.v_2_0_0.QueryType) MetacardMapper(org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType) Test(org.junit.Test)

Example 3 with DomainType

use of org.geosdi.geoplatform.xml.ows.v100.DomainType in project ddf by codice.

the class TestWfsFilterDelegate method testConformanceAllowedValues.

@Test
public void testConformanceAllowedValues() {
    // Setup
    FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
    ConformanceType conformance = capabilities.getConformance();
    List<DomainType> domainTypes = conformance.getConstraint();
    for (DomainType domainType : domainTypes) {
        if (StringUtils.equals(domainType.getName(), "ImplementsSorting")) {
            domainType.setNoValues(null);
            ValueType asc = new ValueType();
            asc.setValue("ASC");
            ValueType desc = new ValueType();
            desc.setValue("DESC");
            AllowedValues allowedValues = new AllowedValues();
            List<Object> values = new ArrayList<>();
            values.add(asc);
            values.add(desc);
            allowedValues.setValueOrRange(values);
            domainType.setAllowedValues(allowedValues);
            ValueType defaultValue = new ValueType();
            defaultValue.setValue("ASC");
            domainType.setDefaultValue(defaultValue);
            break;
        }
    }
    // Perform Test
    WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LAT_LON_ORDER);
    // Verify
    assertThat(delegate.isSortingSupported(), is(true));
    assertThat(delegate.getAllowedSortOrders().size(), is(2));
    assertThat(delegate.getAllowedSortOrders().contains(SortOrder.ASCENDING), is(true));
    assertThat(delegate.getAllowedSortOrders().contains(SortOrder.DESCENDING), is(true));
}
Also used : FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) DomainType(net.opengis.ows.v_1_1_0.DomainType) AllowedValues(net.opengis.ows.v_1_1_0.AllowedValues) ValueType(net.opengis.ows.v_1_1_0.ValueType) ArrayList(java.util.ArrayList) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) Test(org.junit.Test)

Example 4 with DomainType

use of org.geosdi.geoplatform.xml.ows.v100.DomainType in project ddf by codice.

the class TestCswFilterDelegate method getOperation.

private static Operation getOperation() {
    List<DomainType> getRecordsParameters = new ArrayList<>(6);
    DomainType typeName = new DomainType();
    typeName.setName(CswConstants.TYPE_NAME_PARAMETER);
    getRecordsParameters.add(typeName);
    DomainType outputSchema = new DomainType();
    outputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
    getRecordsParameters.add(outputSchema);
    DomainType constraintLang = new DomainType();
    constraintLang.setName(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
    getRecordsParameters.add(constraintLang);
    DomainType outputFormat = new DomainType();
    outputFormat.setName(CswConstants.OUTPUT_FORMAT_PARAMETER);
    getRecordsParameters.add(outputFormat);
    DomainType resultType = new DomainType();
    resultType.setName(CswConstants.RESULT_TYPE_PARAMETER);
    getRecordsParameters.add(resultType);
    DomainType elementSetName = new DomainType();
    elementSetName.setName(CswConstants.ELEMENT_SET_NAME_PARAMETER);
    getRecordsParameters.add(elementSetName);
    Operation getRecords = new Operation();
    getRecords.setName(CswConstants.GET_RECORDS);
    getRecords.setParameter(getRecordsParameters);
    List<Operation> operations = new ArrayList<>(1);
    operations.add(getRecords);
    return getRecords;
}
Also used : DomainType(net.opengis.ows.v_1_0_0.DomainType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation)

Example 5 with DomainType

use of org.geosdi.geoplatform.xml.ows.v100.DomainType in project ddf by codice.

the class TestCswEndpoint method verifyOperationsMetadata.

/**
     * Helper method to verify the OperationsMetadata section matches the endpoint's definition
     *
     * @param ct The CapabilitiesType to verify
     */
private void verifyOperationsMetadata(CapabilitiesType ct) {
    OperationsMetadata om = ct.getOperationsMetadata();
    List<Operation> opList = om.getOperation();
    ArrayList<String> opNames = new ArrayList<>();
    for (Operation op : opList) {
        opNames.add(op.getName());
        if (StringUtils.equals(CswConstants.TRANSACTION, op.getName()) || StringUtils.equals(CswConstants.GET_RECORDS, op.getName())) {
            for (DomainType parameter : op.getParameter()) {
                if (StringUtils.equals(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER, parameter.getName())) {
                    assertThat(parameter.getValue(), contains(CswConstants.CONSTRAINT_LANGUAGE_FILTER, CswConstants.CONSTRAINT_LANGUAGE_CQL));
                } else if (StringUtils.equals(CswConstants.TYPE_NAMES_PARAMETER, parameter.getName())) {
                    // TODO : Remove conditional when GMD Metacard Transformer is merged (DDF-1976)
                    if (StringUtils.equals(op.getName(), CswConstants.TRANSACTION)) {
                        assertThat(parameter.getValue(), contains(CswConstants.CSW_RECORD));
                    } else {
                        assertThat(parameter.getValue(), hasItems(CswConstants.CSW_RECORD, GmdConstants.GMD_METACARD_TYPE_NAME));
                    }
                }
            }
        }
    }
    assertThat(opNames.contains(CswConstants.GET_CAPABILITIES), is(true));
    assertThat(opNames.contains(CswConstants.DESCRIBE_RECORD), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORDS), is(true));
    assertThat(opNames.contains(CswConstants.GET_RECORD_BY_ID), is(true));
    assertThat(opNames.contains(CswConstants.TRANSACTION), is(true));
}
Also used : OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) DomainType(net.opengis.ows.v_1_0_0.DomainType) ArrayList(java.util.ArrayList) Operation(net.opengis.ows.v_1_0_0.Operation)

Aggregations

DomainType (net.opengis.ows.v_1_0_0.DomainType)21 ArrayList (java.util.ArrayList)13 Operation (net.opengis.ows.v_1_0_0.Operation)13 Test (org.junit.Test)9 CapabilitiesType (net.opengis.cat.csw.v_2_0_2.CapabilitiesType)5 ConformanceType (net.opengis.filter.v_2_0_0.ConformanceType)5 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)5 OperationsMetadata (net.opengis.ows.v_1_0_0.OperationsMetadata)5 DomainType (net.opengis.ows.v_1_1_0.DomainType)5 ValueType (net.opengis.ows.v_1_1_0.ValueType)5 GetCapabilitiesType (net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)4 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)4 SortByImpl (ddf.catalog.filter.impl.SortByImpl)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 GetCapabilitiesRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest)2 Joiner (com.google.common.base.Joiner)1 Sets (com.google.common.collect.Sets)1 Metacard (ddf.catalog.data.Metacard)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1