Search in sources :

Example 26 with ValueType

use of org.hypertrace.entity.query.service.v1.ValueType in project ddf by codice.

the class MockWfsServer method getFilterCapabilities.

public static FilterCapabilities getFilterCapabilities() {
    FilterCapabilities capabilities = new FilterCapabilities();
    ConformanceType conformance = new ConformanceType();
    for (CONFORMANCE_CONSTRAINTS constraint : CONFORMANCE_CONSTRAINTS.values()) {
        DomainType domain = new DomainType();
        NoValues noValues = new NoValues();
        domain.setNoValues(noValues);
        ValueType value = new ValueType();
        value.setValue("TRUE");
        domain.setDefaultValue(value);
        domain.setName(constraint.toString());
        conformance.getConstraint().add(domain);
    }
    capabilities.setConformance(conformance);
    ScalarCapabilitiesType scalar = new ScalarCapabilitiesType();
    scalar.setLogicalOperators(new LogicalOperators());
    scalar.setComparisonOperators(new ComparisonOperatorsType());
    for (COMPARISON_OPERATORS compOp : COMPARISON_OPERATORS.values()) {
        ComparisonOperatorType operator = new ComparisonOperatorType();
        operator.setName(compOp.toString());
        scalar.getComparisonOperators().getComparisonOperator().add(operator);
    }
    capabilities.setScalarCapabilities(scalar);
    SpatialCapabilitiesType spatial = new SpatialCapabilitiesType();
    spatial.setSpatialOperators(new SpatialOperatorsType());
    for (SPATIAL_OPERATORS spatialOp : SPATIAL_OPERATORS.values()) {
        SpatialOperatorType operator = new SpatialOperatorType();
        operator.setName(spatialOp.toString());
        spatial.getSpatialOperators().getSpatialOperator().add(operator);
    }
    GeometryOperandsType geometryOperands = new GeometryOperandsType();
    List<QName> qnames = Arrays.asList(Wfs20Constants.POINT, Wfs20Constants.ENVELOPE, Wfs20Constants.POLYGON, Wfs20Constants.LINESTRING);
    for (QName qName : qnames) {
        GeometryOperand operand = new GeometryOperand();
        operand.setName(qName);
        geometryOperands.getGeometryOperand().add(operand);
    }
    spatial.setGeometryOperands(geometryOperands);
    capabilities.setSpatialCapabilities(spatial);
    TemporalCapabilitiesType temporal = new TemporalCapabilitiesType();
    temporal.setTemporalOperators(new TemporalOperatorsType());
    for (TEMPORAL_OPERATORS temporalOp : TEMPORAL_OPERATORS.values()) {
        TemporalOperatorType operator = new TemporalOperatorType();
        operator.setName(temporalOp.toString());
        temporal.getTemporalOperators().getTemporalOperator().add(operator);
    }
    TemporalOperandsType temporalOperands = new TemporalOperandsType();
    List<QName> timeQNames = Arrays.asList(new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimePeriod"), new QName(Wfs20Constants.GML_3_2_NAMESPACE, "TimeInstant"));
    for (QName qName : timeQNames) {
        TemporalOperand operand = new TemporalOperand();
        operand.setName(qName);
        temporalOperands.getTemporalOperand().add(operand);
    }
    temporal.setTemporalOperands(temporalOperands);
    capabilities.setTemporalCapabilities(temporal);
    return capabilities;
}
Also used : SpatialCapabilitiesType(net.opengis.filter.v_2_0_0.SpatialCapabilitiesType) FilterCapabilities(net.opengis.filter.v_2_0_0.FilterCapabilities) DomainType(net.opengis.ows.v_1_1_0.DomainType) SpatialOperatorsType(net.opengis.filter.v_2_0_0.SpatialOperatorsType) GeometryOperandsType(net.opengis.filter.v_2_0_0.GeometryOperandsType) TemporalOperatorsType(net.opengis.filter.v_2_0_0.TemporalOperatorsType) NoValues(net.opengis.ows.v_1_1_0.NoValues) ComparisonOperatorType(net.opengis.filter.v_2_0_0.ComparisonOperatorType) TemporalOperand(net.opengis.filter.v_2_0_0.TemporalOperandsType.TemporalOperand) ConformanceType(net.opengis.filter.v_2_0_0.ConformanceType) COMPARISON_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.COMPARISON_OPERATORS) TemporalCapabilitiesType(net.opengis.filter.v_2_0_0.TemporalCapabilitiesType) SPATIAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.SPATIAL_OPERATORS) ValueType(net.opengis.ows.v_1_1_0.ValueType) QName(javax.xml.namespace.QName) SpatialOperatorType(net.opengis.filter.v_2_0_0.SpatialOperatorType) TEMPORAL_OPERATORS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.TEMPORAL_OPERATORS) LogicalOperators(net.opengis.filter.v_2_0_0.LogicalOperators) GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) CONFORMANCE_CONSTRAINTS(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20Constants.CONFORMANCE_CONSTRAINTS) ComparisonOperatorsType(net.opengis.filter.v_2_0_0.ComparisonOperatorsType) ScalarCapabilitiesType(net.opengis.filter.v_2_0_0.ScalarCapabilitiesType) TemporalOperatorType(net.opengis.filter.v_2_0_0.TemporalOperatorType) TemporalOperandsType(net.opengis.filter.v_2_0_0.TemporalOperandsType)

Example 27 with ValueType

use of org.hypertrace.entity.query.service.v1.ValueType in project ddf by codice.

the class WfsFilterDelegateTest 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, mockMapper, 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 28 with ValueType

use of org.hypertrace.entity.query.service.v1.ValueType in project ddf by codice.

the class WfsSourceTest 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, 1, false, false, 0);
    MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
    when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
    when(mockMetacardMapper.getSortByTemporalFeatureProperty()).thenReturn(mockTemporalFeatureProperty);
    List<MetacardMapper> mappers = new ArrayList<>(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 29 with ValueType

use of org.hypertrace.entity.query.service.v1.ValueType in project ddf by codice.

the class WfsFilterDelegate method configureSorting.

private void configureSorting(DomainType constraint) {
    if (constraint.getNoValues() != null && constraint.getDefaultValue() != null) {
        if (StringUtils.equalsIgnoreCase(constraint.getDefaultValue().getValue(), Boolean.TRUE.toString())) {
            this.isSortingSupported = true;
        } else if (StringUtils.equalsIgnoreCase(constraint.getDefaultValue().getValue(), Boolean.FALSE.toString())) {
            this.isSortingSupported = false;
        }
    }
    if (constraint.getAllowedValues() != null) {
        this.isSortingSupported = true;
        AllowedValues allowedValues = constraint.getAllowedValues();
        List<Object> values = allowedValues.getValueOrRange();
        for (Object value : values) {
            if (value instanceof ValueType) {
                String sortOrder = ((ValueType) value).getValue();
                // Could be ASC, ASCENDING, etc.
                if (StringUtils.startsWithIgnoreCase(sortOrder, "A")) {
                    allowedSortOrders.add(SortOrder.ASCENDING);
                } else if (StringUtils.startsWithIgnoreCase(sortOrder, "D")) {
                    allowedSortOrders.add(SortOrder.DESCENDING);
                }
            }
        }
    }
}
Also used : AllowedValues(net.opengis.ows.v_1_1_0.AllowedValues) ValueType(net.opengis.ows.v_1_1_0.ValueType) LineString(org.locationtech.jts.geom.LineString)

Example 30 with ValueType

use of org.hypertrace.entity.query.service.v1.ValueType in project tck by dmn-tck.

the class DmnScalaTCKTest method getValue.

private Object getValue(ValueType valueType) {
    final JAXBElement<Object> value = valueType.getValue();
    final JAXBElement<ValueType.List> listValue = valueType.getList();
    final List<Component> componentValue = valueType.getComponent();
    if (value == null && listValue == null && componentValue == null) {
        return null;
    }
    if (listValue != null) {
        final List<Object> list = new ArrayList<>();
        for (ValueType item : listValue.getValue().getItem()) {
            list.add(getValue(item));
        }
        return list;
    }
    if (componentValue != null && !componentValue.isEmpty()) {
        final Map<String, Object> context = new HashMap<>();
        for (Component component : componentValue) {
            final Object compValue = getValue(component);
            context.put(component.getName(), compValue);
        }
        return context;
    }
    if (value instanceof Node) {
        final Node node = (Node) value;
        final String text = node.getFirstChild().getTextContent();
        if ("true".equalsIgnoreCase(text) || "false".equalsIgnoreCase(text)) {
            return Boolean.valueOf(text);
        }
        try {
            return Long.valueOf(text);
        } catch (NumberFormatException e) {
        }
        try {
            return Double.valueOf(text);
        } catch (NumberFormatException e) {
        }
        return text;
    }
    if (value != null) {
        final Object singleValue = value.getValue();
        if (singleValue instanceof XMLGregorianCalendar) {
            return transformDateTime((XMLGregorianCalendar) singleValue);
        }
        if (singleValue instanceof Duration) {
            return transformDuration((Duration) singleValue);
        }
        if (singleValue instanceof String[]) {
            String[] array = (String[]) singleValue;
            return Arrays.asList(array);
        }
        return singleValue;
    }
    throw new RuntimeException(String.format("Unexpected value: '%s'", valueType));
}
Also used : ValueType(org.omg.dmn.tck.marshaller._20160719.ValueType) HashMap(java.util.HashMap) Node(org.w3c.dom.Node) ResultNode(org.omg.dmn.tck.marshaller._20160719.TestCases.TestCase.ResultNode) ArrayList(java.util.ArrayList) Duration(javax.xml.datatype.Duration) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.omg.dmn.tck.marshaller._20160719.ValueType.Component)

Aggregations

Test (org.junit.Test)25 BasePenRegAPITest (ca.bc.gov.educ.penreg.api.BasePenRegAPITest)21 FilterOperation (ca.bc.gov.educ.penreg.api.filter.FilterOperation)21 AND (ca.bc.gov.educ.penreg.api.struct.v1.Condition.AND)21 Search (ca.bc.gov.educ.penreg.api.struct.v1.Search)21 SearchCriteria (ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria)21 ValueType (ca.bc.gov.educ.penreg.api.struct.v1.ValueType)21 PenRequestBatchTestUtils (ca.bc.gov.educ.penreg.api.support.PenRequestBatchTestUtils)21 TypeReference (com.fasterxml.jackson.core.type.TypeReference)21 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)21 File (java.io.File)21 java.util (java.util)21 Collectors (java.util.stream.Collectors)21 Before (org.junit.Before)21 MockitoAnnotations (org.mockito.MockitoAnnotations)21 Autowired (org.springframework.beans.factory.annotation.Autowired)21 APPLICATION_JSON (org.springframework.http.MediaType.APPLICATION_JSON)21 SecurityMockMvcRequestPostProcessors.jwt (org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt)21 MockMvc (org.springframework.test.web.servlet.MockMvc)21 MvcResult (org.springframework.test.web.servlet.MvcResult)21