Search in sources :

Example 6 with Operation

use of net.opengis.ows.v_1_0_0.Operation 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 7 with Operation

use of net.opengis.ows.v_1_0_0.Operation 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)

Example 8 with Operation

use of net.opengis.ows.v_1_0_0.Operation in project ddf by codice.

the class TestCswEndpoint method testGetCapabilitiesTypeFederatedCatalogs.

@Test
public void testGetCapabilitiesTypeFederatedCatalogs() {
    GetCapabilitiesType gct = createDefaultGetCapabilitiesType();
    CapabilitiesType ct = null;
    try {
        ct = csw.getCapabilities(gct);
    } catch (CswException e) {
        fail("CswException caught during getCapabilities GET request: " + e.getMessage());
    }
    assertThat(ct, notNullValue());
    assertThat(ct.getOperationsMetadata(), notNullValue());
    for (Operation operation : ct.getOperationsMetadata().getOperation()) {
        if (StringUtils.equals(operation.getName(), CswConstants.GET_RECORDS)) {
            for (DomainType constraint : operation.getConstraint()) {
                if (StringUtils.equals(constraint.getName(), CswConstants.FEDERATED_CATALOGS)) {
                    assertThat(constraint.getValue().size(), is(3));
                    return;
                }
            }
        }
    }
    fail("Didn't find [" + CswConstants.FEDERATED_CATALOGS + "] in request [" + CswConstants.GET_RECORDS + "]");
}
Also used : DomainType(net.opengis.ows.v_1_0_0.DomainType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) GetCapabilitiesType(net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) Operation(net.opengis.ows.v_1_0_0.Operation) Test(org.junit.Test)

Example 9 with Operation

use of net.opengis.ows.v_1_0_0.Operation in project ddf by codice.

the class TestCswSourceBase method configureMockCsw.

protected void configureMockCsw(int numRecordsReturned, long numRecordsMatched, String cswVersion) throws CswException {
    ServiceIdentification mockServiceIdentification = mock(ServiceIdentification.class);
    when(mockServiceIdentification.getAbstract()).thenReturn("myDescription");
    CapabilitiesType mockCapabilities = mock(CapabilitiesType.class);
    when(mockCapabilities.getVersion()).thenReturn(cswVersion);
    when(mockCapabilities.getServiceIdentification()).thenReturn(mockServiceIdentification);
    when(mockCapabilities.getServiceIdentification()).thenReturn(mockServiceIdentification);
    when(mockCsw.getCapabilities(any(GetCapabilitiesRequest.class))).thenReturn(mockCapabilities);
    FilterCapabilities mockFilterCapabilities = mock(FilterCapabilities.class);
    when(mockCapabilities.getFilterCapabilities()).thenReturn(mockFilterCapabilities);
    List<ComparisonOperatorType> comparisonOpsList = new ArrayList<>();
    comparisonOpsList.add(ComparisonOperatorType.EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.LIKE);
    comparisonOpsList.add(ComparisonOperatorType.NOT_EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.GREATER_THAN);
    comparisonOpsList.add(ComparisonOperatorType.GREATER_THAN_EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.LESS_THAN);
    comparisonOpsList.add(ComparisonOperatorType.LESS_THAN_EQUAL_TO);
    comparisonOpsList.add(ComparisonOperatorType.BETWEEN);
    comparisonOpsList.add(ComparisonOperatorType.NULL_CHECK);
    ComparisonOperatorsType comparisonOps = new ComparisonOperatorsType();
    comparisonOps.setComparisonOperator(comparisonOpsList);
    ScalarCapabilitiesType mockScalarCapabilities = mock(ScalarCapabilitiesType.class);
    when(mockScalarCapabilities.getLogicalOperators()).thenReturn(mock(LogicalOperators.class));
    mockScalarCapabilities.setComparisonOperators(comparisonOps);
    when(mockScalarCapabilities.getComparisonOperators()).thenReturn(comparisonOps);
    when(mockFilterCapabilities.getScalarCapabilities()).thenReturn(mockScalarCapabilities);
    List<DomainType> getRecordsParameters = new ArrayList<>();
    DomainType typeName = new DomainType();
    typeName.setName(CswConstants.TYPE_NAME_PARAMETER);
    typeName.setValue(Collections.singletonList("csw:Record"));
    getRecordsParameters.add(typeName);
    DomainType typeNames = new DomainType();
    typeNames.setName(CswConstants.TYPE_NAMES_PARAMETER);
    getRecordsParameters.add(typeNames);
    DomainType getRecordsOutputSchema = new DomainType();
    getRecordsOutputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
    getRecordsOutputSchema.getValue().add(CswConstants.CSW_OUTPUT_SCHEMA);
    getRecordsParameters.add(getRecordsOutputSchema);
    DomainType constraintLang = new DomainType();
    constraintLang.setName(CswConstants.CONSTRAINT_LANGUAGE_PARAMETER);
    constraintLang.setValue(Collections.singletonList(CswConstants.CONSTRAINT_LANGUAGE_FILTER));
    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);
    List<DomainType> getRecordByIdParameters = new ArrayList<>();
    DomainType getRecordByIdOutputSchema = new DomainType();
    getRecordByIdOutputSchema.setName(CswConstants.OUTPUT_SCHEMA_PARAMETER);
    List<String> outputSchemas = new ArrayList<>();
    outputSchemas.add(CswConstants.CSW_OUTPUT_SCHEMA);
    getRecordByIdOutputSchema.setValue(outputSchemas);
    getRecordByIdParameters.add(getRecordByIdOutputSchema);
    Operation getRecords = new Operation();
    getRecords.setName(CswConstants.GET_RECORDS);
    getRecords.setParameter(getRecordsParameters);
    Operation getRecordById = new Operation();
    getRecordById.setName(CswConstants.GET_RECORD_BY_ID);
    getRecordById.setParameter(getRecordByIdParameters);
    List<Operation> operations = new ArrayList<>(2);
    operations.add(getRecords);
    operations.add(getRecordById);
    OperationsMetadata mockOperationsMetadata = mock(OperationsMetadata.class);
    mockOperationsMetadata.setOperation(operations);
    when(mockCapabilities.getOperationsMetadata()).thenReturn(mockOperationsMetadata);
    when(mockOperationsMetadata.getOperation()).thenReturn(operations);
    if (numRecordsReturned > 0) {
        List<Metacard> metacards = new ArrayList<>(numRecordsReturned);
        for (int i = 1; i <= numRecordsReturned; i++) {
            String id = "ID_" + String.valueOf(i);
            MetacardImpl metacard = new MetacardImpl();
            metacard.setId(id);
            metacard.setContentTypeName("myContentType");
            metacards.add(metacard);
        }
        SearchResultsType searchResults = mock(SearchResultsType.class);
        when(searchResults.getNumberOfRecordsMatched()).thenReturn(BigInteger.valueOf(numRecordsMatched));
        when(searchResults.getNumberOfRecordsReturned()).thenReturn(BigInteger.valueOf(numRecordsReturned));
        CswRecordCollection mockCswRecordCollection = mock(CswRecordCollection.class);
        when(mockCswRecordCollection.getCswRecords()).thenReturn(metacards);
        when(mockCswRecordCollection.getNumberOfRecordsMatched()).thenReturn(numRecordsMatched);
        when(mockCswRecordCollection.getNumberOfRecordsReturned()).thenReturn((long) numRecordsReturned);
        when(mockCsw.getRecords(any(GetRecordsType.class))).thenReturn(mockCswRecordCollection);
    }
}
Also used : GetCapabilitiesRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest) OperationsMetadata(net.opengis.ows.v_1_0_0.OperationsMetadata) SearchResultsType(net.opengis.cat.csw.v_2_0_2.SearchResultsType) ArrayList(java.util.ArrayList) LogicalOperators(net.opengis.filter.v_1_1_0.LogicalOperators) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) Matchers.anyString(org.mockito.Matchers.anyString) Operation(net.opengis.ows.v_1_0_0.Operation) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) FilterCapabilities(net.opengis.filter.v_1_1_0.FilterCapabilities) ComparisonOperatorsType(net.opengis.filter.v_1_1_0.ComparisonOperatorsType) Metacard(ddf.catalog.data.Metacard) DomainType(net.opengis.ows.v_1_0_0.DomainType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) ScalarCapabilitiesType(net.opengis.filter.v_1_1_0.ScalarCapabilitiesType) CapabilitiesType(net.opengis.cat.csw.v_2_0_2.CapabilitiesType) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) ComparisonOperatorType(net.opengis.filter.v_1_1_0.ComparisonOperatorType) ServiceIdentification(net.opengis.ows.v_1_0_0.ServiceIdentification)

Example 10 with Operation

use of net.opengis.ows.v_1_0_0.Operation in project ddf by codice.

the class CswEndpoint method buildOperation.

/**
     * Creates an Operation object for the OperationsMetadata section TODO: We currently don't use
     * the constraint or metadata elements, those can be added in as desired
     *
     * @param name  The name of the operation
     * @param types The request types supported (GET/POST)
     * @return The constructed Operation object
     */
private Operation buildOperation(String name, List<QName> types) {
    Operation op = new Operation();
    op.setName(name);
    ArrayList<DCP> dcpList = new ArrayList<>();
    DCP dcp = new DCP();
    HTTP http = new HTTP();
    for (QName type : types) {
        RequestMethodType rmt = new RequestMethodType();
        rmt.setHref(uri.getBaseUri().toASCIIString());
        JAXBElement<RequestMethodType> requestElement = new JAXBElement<>(type, RequestMethodType.class, rmt);
        if (type.equals(CswConstants.POST)) {
            requestElement.getValue().getConstraint().add(createDomainType(CswConstants.POST_ENCODING, CswConstants.XML));
        }
        http.getGetOrPost().add(requestElement);
    }
    dcp.setHTTP(http);
    dcpList.add(dcp);
    op.setDCP(dcpList);
    return op;
}
Also used : DCP(net.opengis.ows.v_1_0_0.DCP) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) HTTP(net.opengis.ows.v_1_0_0.HTTP) Operation(net.opengis.ows.v_1_0_0.Operation) JAXBElement(javax.xml.bind.JAXBElement) RequestMethodType(net.opengis.ows.v_1_0_0.RequestMethodType)

Aggregations

Operation (net.opengis.ows.v_1_0_0.Operation)10 DomainType (net.opengis.ows.v_1_0_0.DomainType)9 ArrayList (java.util.ArrayList)7 OperationsMetadata (net.opengis.ows.v_1_0_0.OperationsMetadata)5 CapabilitiesType (net.opengis.cat.csw.v_2_0_2.CapabilitiesType)3 QName (javax.xml.namespace.QName)2 GetCapabilitiesType (net.opengis.cat.csw.v_2_0_2.GetCapabilitiesType)2 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)2 GetCapabilitiesRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.GetCapabilitiesRequest)2 Test (org.junit.Test)2 Metacard (ddf.catalog.data.Metacard)1 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 HashSet (java.util.HashSet)1 JAXBElement (javax.xml.bind.JAXBElement)1 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)1 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)1 ComparisonOperatorType (net.opengis.filter.v_1_1_0.ComparisonOperatorType)1 ComparisonOperatorsType (net.opengis.filter.v_1_1_0.ComparisonOperatorsType)1 FilterCapabilities (net.opengis.filter.v_1_1_0.FilterCapabilities)1 LogicalOperators (net.opengis.filter.v_1_1_0.LogicalOperators)1