Search in sources :

Example 16 with ValueType

use of org.geotoolkit.ows.xml.v110.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenStatusFilter_ShouldReturnStatusOk.

/**
 * Test read pen request batch paginated given school group code filter should return status ok.
 *
 * @throws Exception the exception
 */
@Test
public void testReadPenRequestBatchPaginated_GivenStatusFilter_ShouldReturnStatusOk() throws Exception {
    final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_pen_req_batch.json")).getFile());
    final List<PenRequestBatch> entities = new ObjectMapper().readValue(file, new TypeReference<>() {
    });
    final var models = entities.stream().map(mapper::toModel).collect(Collectors.toList()).stream().map(PenRequestBatchTestUtils::populateAuditColumnsAndHistory).collect(Collectors.toList());
    this.penRequestBatchRepository.saveAll(models);
    final SearchCriteria criteria = SearchCriteria.builder().key("penRequestBatchStatusCode").operation(FilterOperation.EQUAL).value(PenRequestBatchStatusCodes.LOADED.getCode()).valueType(ValueType.STRING).build();
    final List<SearchCriteria> criteriaList = new ArrayList<>();
    criteriaList.add(criteria);
    final List<Search> searches = new LinkedList<>();
    searches.add(Search.builder().searchCriteriaList(criteriaList).build());
    final ObjectMapper objectMapper = new ObjectMapper();
    final String criteriaJSON = objectMapper.writeValueAsString(searches);
    final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch/history/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH_HISTORY"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
    this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.content", hasSize(2)));
}
Also used : MockMvcRequestBuilders.asyncDispatch(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) java.util(java.util) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) AND(ca.bc.gov.educ.penreg.api.struct.v1.Condition.AND) Autowired(org.springframework.beans.factory.annotation.Autowired) PenRequestBatchTestUtils(ca.bc.gov.educ.penreg.api.support.PenRequestBatchTestUtils) PenRequestBatchStudentRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchStudentRepository) PenRequestBatchMapper(ca.bc.gov.educ.penreg.api.mappers.v1.PenRequestBatchMapper) MockMvc(org.springframework.test.web.servlet.MockMvc) PenRequestBatch(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatch) MockitoAnnotations(org.mockito.MockitoAnnotations) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) OR(ca.bc.gov.educ.penreg.api.struct.v1.Condition.OR) MvcResult(org.springframework.test.web.servlet.MvcResult) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) TypeReference(com.fasterxml.jackson.core.type.TypeReference) SchoolGroupCodes(ca.bc.gov.educ.penreg.api.constants.SchoolGroupCodes) PenRequestBatchRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchRepository) Before(org.junit.Before) PenRequestBatchStatusCodes(ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStatusCodes) PenRequestBatchHistoryRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchHistoryRepository) ValueType(ca.bc.gov.educ.penreg.api.struct.v1.ValueType) SecurityMockMvcRequestPostProcessors.jwt(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt) FilterOperation(ca.bc.gov.educ.penreg.api.filter.FilterOperation) MockMvcResultHandlers.print(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SearchCriteria(ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) Search(ca.bc.gov.educ.penreg.api.struct.v1.Search) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) MvcResult(org.springframework.test.web.servlet.MvcResult) SearchCriteria(ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria) PenRequestBatch(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatch) Search(ca.bc.gov.educ.penreg.api.struct.v1.Search) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 17 with ValueType

use of org.geotoolkit.ows.xml.v110.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenMultipleGroupCondition_ShouldReturnStatusOk.

/**
 * Test read pen request batch paginated given multiple group condition should return status ok.
 *
 * @throws Exception the exception
 */
@Test
public void testReadPenRequestBatchPaginated_GivenMultipleGroupCondition_ShouldReturnStatusOk() throws Exception {
    final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_pen_req_batch.json")).getFile());
    final List<PenRequestBatch> entities = new ObjectMapper().readValue(file, new TypeReference<>() {
    });
    final var models = entities.stream().map(mapper::toModel).collect(Collectors.toList()).stream().map(PenRequestBatchTestUtils::populateAuditColumnsAndHistory).collect(Collectors.toList());
    this.penRequestBatchRepository.saveAll(models);
    final SearchCriteria criteria = SearchCriteria.builder().key("schoolGroupCode").operation(FilterOperation.EQUAL).value(SchoolGroupCodes.K12.getCode()).valueType(ValueType.STRING).build();
    final SearchCriteria criteria2 = SearchCriteria.builder().key("penRequestBatchStatusCode").condition(OR).operation(FilterOperation.IN).value("LOADED,ACTIVE").valueType(ValueType.STRING).build();
    final SearchCriteria criteria3 = SearchCriteria.builder().key("sisProductName").condition(OR).operation(FilterOperation.CONTAINS_IGNORE_CASE).value("MYED").valueType(ValueType.STRING).build();
    final List<SearchCriteria> criteriaList = new LinkedList<>();
    criteriaList.add(criteria);
    criteriaList.add(criteria2);
    criteriaList.add(criteria3);
    final SearchCriteria criteria4 = SearchCriteria.builder().key("matchedCount").operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
    final SearchCriteria criteria5 = SearchCriteria.builder().key("fixableCount").condition(OR).operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
    final SearchCriteria criteria6 = SearchCriteria.builder().key("sourceStudentCount").condition(OR).operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
    final List<SearchCriteria> criteriaList1 = new LinkedList<>();
    criteriaList1.add(criteria4);
    criteriaList1.add(criteria5);
    criteriaList1.add(criteria6);
    final SearchCriteria criteria7 = SearchCriteria.builder().key("studentCount").operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
    final SearchCriteria criteria8 = SearchCriteria.builder().key("sisVendorName").condition(OR).operation(FilterOperation.EQUAL).value("Follett Software").valueType(ValueType.STRING).build();
    final SearchCriteria criteria9 = SearchCriteria.builder().key("mincode").condition(OR).operation(FilterOperation.EQUAL).value("09898027").valueType(ValueType.STRING).build();
    final List<SearchCriteria> criteriaList2 = new LinkedList<>();
    criteriaList1.add(criteria7);
    criteriaList1.add(criteria8);
    criteriaList1.add(criteria9);
    final List<Search> searches = new LinkedList<>();
    searches.add(Search.builder().searchCriteriaList(criteriaList).build());
    searches.add(Search.builder().condition(AND).searchCriteriaList(criteriaList1).build());
    searches.add(Search.builder().condition(AND).searchCriteriaList(criteriaList2).build());
    final ObjectMapper objectMapper = new ObjectMapper();
    final String criteriaJSON = objectMapper.writeValueAsString(searches);
    final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch/history/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH_HISTORY"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
    this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk());
}
Also used : MockMvcRequestBuilders.asyncDispatch(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) java.util(java.util) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) AND(ca.bc.gov.educ.penreg.api.struct.v1.Condition.AND) Autowired(org.springframework.beans.factory.annotation.Autowired) PenRequestBatchTestUtils(ca.bc.gov.educ.penreg.api.support.PenRequestBatchTestUtils) PenRequestBatchStudentRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchStudentRepository) PenRequestBatchMapper(ca.bc.gov.educ.penreg.api.mappers.v1.PenRequestBatchMapper) MockMvc(org.springframework.test.web.servlet.MockMvc) PenRequestBatch(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatch) MockitoAnnotations(org.mockito.MockitoAnnotations) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) OR(ca.bc.gov.educ.penreg.api.struct.v1.Condition.OR) MvcResult(org.springframework.test.web.servlet.MvcResult) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) TypeReference(com.fasterxml.jackson.core.type.TypeReference) SchoolGroupCodes(ca.bc.gov.educ.penreg.api.constants.SchoolGroupCodes) PenRequestBatchRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchRepository) Before(org.junit.Before) PenRequestBatchStatusCodes(ca.bc.gov.educ.penreg.api.constants.PenRequestBatchStatusCodes) PenRequestBatchHistoryRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchHistoryRepository) ValueType(ca.bc.gov.educ.penreg.api.struct.v1.ValueType) SecurityMockMvcRequestPostProcessors.jwt(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt) FilterOperation(ca.bc.gov.educ.penreg.api.filter.FilterOperation) MockMvcResultHandlers.print(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SearchCriteria(ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) File(java.io.File) Search(ca.bc.gov.educ.penreg.api.struct.v1.Search) MockMvcRequestBuilders.get(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get) MvcResult(org.springframework.test.web.servlet.MvcResult) SearchCriteria(ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria) PenRequestBatch(ca.bc.gov.educ.penreg.api.struct.v1.PenRequestBatch) Search(ca.bc.gov.educ.penreg.api.struct.v1.Search) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 18 with ValueType

use of org.geotoolkit.ows.xml.v110.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.

the class PenRequestBatchSagaControllerTest method testGetSagaPaginated_givenSearchCriteria_shouldReturnStatusOk.

@Test
@SuppressWarnings("java:S100")
public void testGetSagaPaginated_givenSearchCriteria_shouldReturnStatusOk() throws Exception {
    final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_multiple_sagas.json")).getFile());
    final List<Saga> sagaStructs = new ObjectMapper().readValue(file, new TypeReference<>() {
    });
    final List<ca.bc.gov.educ.penreg.api.model.v1.Saga> sagaEntities = sagaStructs.stream().map(mapper::toModel).collect(Collectors.toList());
    for (val saga : sagaEntities) {
        saga.setSagaId(null);
        saga.setCreateDate(LocalDateTime.now());
        saga.setUpdateDate(LocalDateTime.now());
    }
    this.repository.saveAll(sagaEntities);
    final SearchCriteria criteria = SearchCriteria.builder().key("sagaState").operation(FilterOperation.IN).value("IN_PROGRESS").valueType(ValueType.STRING).build();
    final SearchCriteria criteria2 = SearchCriteria.builder().key("sagaName").condition(AND).operation(FilterOperation.EQUAL).value("PEN_REQUEST_BATCH_ARCHIVE_AND_RETURN_SAGA").valueType(ValueType.STRING).build();
    final List<SearchCriteria> criteriaList = new ArrayList<>();
    criteriaList.add(criteria);
    criteriaList.add(criteria2);
    final List<Search> searches = new LinkedList<>();
    searches.add(Search.builder().searchCriteriaList(criteriaList).build());
    final ObjectMapper objectMapper = new ObjectMapper();
    final String criteriaJSON = objectMapper.writeValueAsString(searches);
    final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch-saga/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "PEN_REQUEST_BATCH_READ_SAGA"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
    this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.content", hasSize(1)));
}
Also used : lombok.val(lombok.val) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) java.util(java.util) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) LocalDateTime(java.time.LocalDateTime) AND(ca.bc.gov.educ.penreg.api.struct.v1.Condition.AND) Autowired(org.springframework.beans.factory.annotation.Autowired) PenRequestBatchTestUtils(ca.bc.gov.educ.penreg.api.support.PenRequestBatchTestUtils) SagaRepository(ca.bc.gov.educ.penreg.api.repository.SagaRepository) JsonUtil(ca.bc.gov.educ.penreg.api.util.JsonUtil) SagaMapper(ca.bc.gov.educ.penreg.api.mappers.v1.SagaMapper) PenRequestBatchEntity(ca.bc.gov.educ.penreg.api.model.v1.PenRequestBatchEntity) MockMvc(org.springframework.test.web.servlet.MockMvc) SagaEnum(ca.bc.gov.educ.penreg.api.constants.SagaEnum) MockitoAnnotations(org.mockito.MockitoAnnotations) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) MvcResult(org.springframework.test.web.servlet.MvcResult) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) TypeReference(com.fasterxml.jackson.core.type.TypeReference) PenRequestBatchRepository(ca.bc.gov.educ.penreg.api.repository.PenRequestBatchRepository) Before(org.junit.Before) ValueType(ca.bc.gov.educ.penreg.api.struct.v1.ValueType) SecurityMockMvcRequestPostProcessors.jwt(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.jwt) FilterOperation(ca.bc.gov.educ.penreg.api.filter.FilterOperation) SagaEventRepository(ca.bc.gov.educ.penreg.api.repository.SagaEventRepository) MockMvcResultHandlers.print(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print) MediaType(org.springframework.http.MediaType) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) lombok.val(lombok.val) SagaService(ca.bc.gov.educ.penreg.api.service.SagaService) SearchCriteria(ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria) Test(org.junit.Test) Collectors(java.util.stream.Collectors) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) Saga(ca.bc.gov.educ.penreg.api.struct.v1.Saga) File(java.io.File) Search(ca.bc.gov.educ.penreg.api.struct.v1.Search) Matchers.is(org.hamcrest.Matchers.is) MvcResult(org.springframework.test.web.servlet.MvcResult) SearchCriteria(ca.bc.gov.educ.penreg.api.struct.v1.SearchCriteria) Saga(ca.bc.gov.educ.penreg.api.struct.v1.Saga) Search(ca.bc.gov.educ.penreg.api.struct.v1.Search) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BasePenRegAPITest(ca.bc.gov.educ.penreg.api.BasePenRegAPITest) Test(org.junit.Test)

Example 19 with ValueType

use of org.geotoolkit.ows.xml.v110.ValueType in project geotoolkit by Geomatys.

the class WPS2ProcessDescriptor method toDescriptor.

/**
 * Convert Description to GeneralParameterDescriptor.
 *
 * @throws UnsupportedOperationException if data type could not be mapped
 */
private static GeneralParameterDescriptor toDescriptor(String processId, Description input) throws UnsupportedParameterException {
    final List<? extends Description> subInputs;
    final DataDescription dataDescType;
    final int min;
    final int max;
    if (input instanceof InputDescription) {
        final InputDescription id = (InputDescription) input;
        subInputs = id.getInput();
        dataDescType = id.getDataDescription();
        max = id.getMaxOccurs();
        min = id.getMinOccurs();
    } else if (input instanceof OutputDescription) {
        final OutputDescription od = (OutputDescription) input;
        subInputs = od.getOutput();
        dataDescType = od.getDataDescription();
        min = 1;
        max = 1;
    } else {
        throw new IllegalArgumentException("Unexpected description type " + input.getClass());
    }
    final String inputName = input.getIdentifier().getValue();
    final String title = input.getFirstTitle();
    final String remarks = input.getFirstAbstract();
    Map userObject = new HashMap();
    for (MetadataType meta : input.getMetadata()) {
        if (meta instanceof AdditionalParametersType) {
            AdditionalParametersType params = (AdditionalParametersType) meta;
            for (AdditionalParameter param : params.getAdditionalParameter()) {
                userObject.put(param.getName().getValue(), param.getValue());
            }
        }
    }
    if (dataDescType instanceof LiteralData) {
        final LiteralData cd = (LiteralData) dataDescType;
        for (LiteralDataDomain domain : cd.getLiteralDataDomain()) {
            final LiteralAdaptor adaptor = LiteralAdaptor.create(domain);
            if (adaptor == null)
                continue;
            String defaultValueValue = null;
            final ValueType defaultValue = domain.getDefaultValue();
            if (defaultValue != null)
                defaultValueValue = defaultValue.getValue();
            final Unit unit = getUnit(domain.getUOM());
            Object[] allowedValues = null;
            if (domain.getAllowedValues() != null && domain.getAllowedValues().getStringValues() != null) {
                allowedValues = new Object[domain.getAllowedValues().getStringValues().size()];
                int i = 0;
                for (String value : domain.getAllowedValues().getStringValues()) {
                    allowedValues[i] = adaptor.convert(value);
                    i++;
                }
            }
            try {
                userObject.put(DataAdaptor.USE_ADAPTOR, adaptor);
                return new ExtendedParameterDescriptor(inputName, title, remarks, min, max, adaptor.getValueClass(), adaptor.convert(defaultValueValue), allowedValues, userObject);
            } catch (UnconvertibleObjectException ex2) {
                throw new UnsupportedParameterException(processId, inputName, "Can't convert the default literal input value.", ex2);
            }
        }
        throw new UnsupportedParameterException(processId, inputName, "Unidentifiable literal input " + inputName);
    } else if (dataDescType instanceof ComplexData) {
        final ComplexData cdt = (ComplexData) dataDescType;
        // ensure default format is first in the list
        Collections.sort(cdt.getFormat(), (Format o1, Format o2) -> {
            boolean d1 = Boolean.TRUE.equals(o1.isDefault());
            boolean d2 = Boolean.TRUE.equals(o2.isDefault());
            if (d1 == d2)
                return 0;
            return d1 ? -1 : +1;
        });
        // find a complexe type adaptor
        DataAdaptor adaptor = null;
        for (Format format : cdt.getFormat()) {
            adaptor = ComplexAdaptor.getAdaptor(format);
            if (adaptor != null)
                break;
        }
        if (adaptor == null) {
            final StringBuilder sb = new StringBuilder();
            for (Format format : cdt.getFormat()) {
                if (sb.length() != 0)
                    sb.append(", ");
                sb.append(format.getMimeType()).append(' ');
                sb.append(format.getEncoding()).append(' ');
                sb.append(format.getSchema());
            }
            throw new UnsupportedParameterException(processId, inputName, "No compatible format found for parameter " + inputName + " formats : " + sb);
        }
        userObject.put(DataAdaptor.USE_ADAPTOR, adaptor);
        return new ExtendedParameterDescriptor(inputName, title, remarks, min, max, adaptor.getValueClass(), null, null, userObject);
    } else if (dataDescType instanceof BoundingBoxData) {
        final BboxAdaptor adaptor = BboxAdaptor.create((BoundingBoxData) dataDescType);
        userObject.put(DataAdaptor.USE_ADAPTOR, adaptor);
        return new ExtendedParameterDescriptor(inputName, title, remarks, min, max, Envelope.class, null, null, userObject);
    } else if (!subInputs.isEmpty()) {
        // sub group type
        final List<GeneralParameterDescriptor> params = new ArrayList<>();
        for (Description dt : subInputs) {
            params.add(toDescriptor(processId, dt));
        }
        return new ParameterBuilder().addName(inputName).addName(title).setRemarks(remarks).createGroup(params.toArray(new GeneralParameterDescriptor[0]));
    } else {
        throw new UnsupportedParameterException(processId, inputName, "Unidentifiable input " + inputName + " " + dataDescType);
    }
}
Also used : AdditionalParametersType(org.geotoolkit.ows.xml.v200.AdditionalParametersType) DataDescription(org.geotoolkit.wps.xml.v200.DataDescription) Description(org.geotoolkit.wps.xml.v200.Description) InputDescription(org.geotoolkit.wps.xml.v200.InputDescription) OutputDescription(org.geotoolkit.wps.xml.v200.OutputDescription) ProcessDescription(org.geotoolkit.wps.xml.v200.ProcessDescription) HashMap(java.util.HashMap) InternationalString(org.opengis.util.InternationalString) DefaultInternationalString(org.apache.sis.util.DefaultInternationalString) Unit(javax.measure.Unit) DataDescription(org.geotoolkit.wps.xml.v200.DataDescription) BboxAdaptor(org.geotoolkit.wps.adaptor.BboxAdaptor) OutputDescription(org.geotoolkit.wps.xml.v200.OutputDescription) UnconvertibleObjectException(org.apache.sis.util.UnconvertibleObjectException) Format(org.geotoolkit.wps.xml.v200.Format) ComplexData(org.geotoolkit.wps.xml.v200.ComplexData) DataAdaptor(org.geotoolkit.wps.adaptor.DataAdaptor) BoundingBoxData(org.geotoolkit.wps.xml.v200.BoundingBoxData) InputDescription(org.geotoolkit.wps.xml.v200.InputDescription) ArrayList(java.util.ArrayList) List(java.util.List) ParameterBuilder(org.apache.sis.parameter.ParameterBuilder) LiteralDataDomain(org.geotoolkit.wps.xml.v200.LiteralDataDomain) LiteralAdaptor(org.geotoolkit.wps.adaptor.LiteralAdaptor) LiteralData(org.geotoolkit.wps.xml.v200.LiteralData) ValueType(org.geotoolkit.ows.xml.v200.ValueType) MetadataType(org.geotoolkit.ows.xml.v200.MetadataType) DomainMetadataType(org.geotoolkit.ows.xml.v200.DomainMetadataType) AdditionalParameter(org.geotoolkit.ows.xml.v200.AdditionalParameter) ExtendedParameterDescriptor(org.geotoolkit.utility.parameter.ExtendedParameterDescriptor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with ValueType

use of org.geotoolkit.ows.xml.v110.ValueType in project entity-service by hypertrace.

the class ArrayFilteringExpressionConverter method convert.

@Override
public FilterTypeExpression convert(final ColumnIdentifier columnIdentifier, final Operator operator, final LiteralConstant constant, final RequestContext requestContext) throws ConversionException {
    if (ARRAY_OPERATORS.contains(operator)) {
        return primitiveFilteringExpressionConverter.convert(columnIdentifier, operator, constant, requestContext);
    }
    final String id = columnIdentifier.getColumnName();
    final String subDocPath = getSubDocPathById(entityAttributeMapping, id, requestContext);
    final Value value = constant.getValue();
    final ValueType valueType = value.getValueType();
    final List<?> list = valueOneOfAccessor.access(value, valueType);
    if (list.isEmpty()) {
        throw new ConversionException("Conversion of empty-list is unsupported");
    }
    final IdentifierConverter identifierConverter = identifierConverterFactory.getIdentifierConverter(id, subDocPath, valueType, requestContext);
    final IdentifierConversionMetadata metadata = IdentifierConversionMetadata.builder().subDocPath(subDocPath).operator(operator).valueType(valueType).build();
    final String suffixedSubDocPath = identifierConverter.convert(metadata, requestContext);
    final List<RelationalExpression> expressions = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
        final IdentifierExpression lhs = IdentifierExpression.of(String.format(suffixedSubDocPath, i));
        final RelationalOperator relationalOperator = convertOperator(operator);
        final ConstantExpression rhs = valueHelper.convertToConstantExpression(value, i);
        final RelationalExpression expression = RelationalExpression.of(lhs, relationalOperator, rhs);
        expressions.add(expression);
    }
    if (expressions.size() == 1) {
        return expressions.get(0);
    }
    return LogicalExpression.builder().operator(LogicalOperator.AND).operands(expressions).build();
}
Also used : ConversionException(org.hypertrace.entity.query.service.converter.ConversionException) RelationalOperator(org.hypertrace.core.documentstore.expression.operators.RelationalOperator) RelationalExpression(org.hypertrace.core.documentstore.expression.impl.RelationalExpression) ValueType(org.hypertrace.entity.query.service.v1.ValueType) ConstantExpression(org.hypertrace.core.documentstore.expression.impl.ConstantExpression) ArrayList(java.util.ArrayList) IdentifierExpression(org.hypertrace.core.documentstore.expression.impl.IdentifierExpression) IdentifierConverter(org.hypertrace.entity.query.service.converter.identifier.IdentifierConverter) Value(org.hypertrace.entity.query.service.v1.Value) IdentifierConversionMetadata(org.hypertrace.entity.query.service.converter.identifier.IdentifierConversionMetadata)

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