Search in sources :

Example 1 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project ddf by codice.

the class TestRegistryStore method testCreateNoExistingMetacard.

@Test
public void testCreateNoExistingMetacard() throws Exception {
    Metacard mcard = getDefaultMetacard();
    Csw csw = mock(Csw.class);
    TransactionResponseType responseType = mock(TransactionResponseType.class);
    InsertResultType insertResultType = mock(InsertResultType.class);
    BriefRecordType briefRecord = mock(BriefRecordType.class);
    JAXBElement identifier = mock(JAXBElement.class);
    SimpleLiteral literal = mock(SimpleLiteral.class);
    when(literal.getContent()).thenReturn(Collections.singletonList(mcard.getId()));
    when(identifier.getValue()).thenReturn(literal);
    when(briefRecord.getIdentifier()).thenReturn(Collections.singletonList(identifier));
    when(insertResultType.getBriefRecord()).thenReturn(Collections.singletonList(briefRecord));
    when(responseType.getInsertResult()).thenReturn(Collections.singletonList(insertResultType));
    when(factory.getClientForSubject(any())).thenReturn(csw);
    when(csw.transaction(any())).thenReturn(responseType);
    when(transformer.getTransformerIdForSchema(any())).thenReturn("myInsertType");
    queryResults.add(new ResultImpl(mcard));
    CreateRequest request = new CreateRequestImpl(mcard);
    CreateResponse response = registryStore.create(request);
    assertThat(response.getCreatedMetacards().get(0), is(mcard));
}
Also used : Metacard(ddf.catalog.data.Metacard) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) CreateRequest(ddf.catalog.operation.CreateRequest) CreateResponse(ddf.catalog.operation.CreateResponse) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) SimpleLiteral(net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral) ResultImpl(ddf.catalog.data.impl.ResultImpl) JAXBElement(javax.xml.bind.JAXBElement) InsertResultType(net.opengis.cat.csw.v_2_0_2.InsertResultType) BriefRecordType(net.opengis.cat.csw.v_2_0_2.BriefRecordType) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) Test(org.junit.Test)

Example 2 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project arctic-sea by 52North.

the class InsertResultRequestEncoder method create.

@Override
protected XmlObject create(InsertResultRequest request) throws EncodingException {
    validateInput(request);
    InsertResultDocument doc = InsertResultDocument.Factory.newInstance(getXmlOptions());
    InsertResultType insertResult = doc.addNewInsertResult();
    insertResult.setService(request.getService());
    insertResult.setVersion(request.getVersion());
    insertResult.setTemplate(request.getTemplateIdentifier());
    addResultValues(request, insertResult);
    return doc;
}
Also used : InsertResultType(net.opengis.sos.x20.InsertResultType) InsertResultDocument(net.opengis.sos.x20.InsertResultDocument)

Example 3 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project arctic-sea by 52North.

the class InsertResultRequestEncoderTest method shouldEncodeInsertResultRequest.

@Test
public void shouldEncodeInsertResultRequest() throws EncodingException {
    String version = Sos2Constants.SERVICEVERSION;
    String service = SosConstants.SOS;
    String templateIdentifier = "test-template-identifier";
    String resultValues = "test-result-values";
    InsertResultRequest request = new InsertResultRequest(service, version);
    request.setTemplateIdentifier(templateIdentifier);
    request.setResultValues(resultValues);
    XmlObject encodedRequest = encoder.create(request);
    assertThat(encodedRequest, Matchers.instanceOf(InsertResultDocument.class));
    assertThat(((InsertResultDocument) encodedRequest).getInsertResult(), Matchers.notNullValue());
    InsertResultType xbRequest = ((InsertResultDocument) encodedRequest).getInsertResult();
    assertThat(xbRequest.getService(), Is.is(service));
    assertThat(xbRequest.getVersion(), Is.is(version));
    assertThat(xbRequest.getTemplate(), Is.is(templateIdentifier));
    assertThat(xbRequest.getResultValues(), Matchers.instanceOf(XmlString.class));
    assertThat(((XmlString) xbRequest.getResultValues()).getStringValue(), Is.is(resultValues));
}
Also used : InsertResultRequest(org.n52.shetland.ogc.sos.request.InsertResultRequest) XmlString(org.apache.xmlbeans.XmlString) XmlObject(org.apache.xmlbeans.XmlObject) XmlString(org.apache.xmlbeans.XmlString) InsertResultType(net.opengis.sos.x20.InsertResultType) InsertResultDocument(net.opengis.sos.x20.InsertResultDocument) Test(org.junit.jupiter.api.Test)

Example 4 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method transactionResponseMarshalingTest.

@Test
public void transactionResponseMarshalingTest() throws JAXBException, IOException, ParserConfigurationException, SAXException {
    Marshaller marshaller = pool.acquireMarshaller();
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    Object record = new BriefRecordType(id, title, type, bbox);
    final List<InsertResultType> inserteds = new ArrayList<>();
    inserteds.add(new InsertResultType(Arrays.asList(record), null));
    TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
    TransactionResponseType request = new TransactionResponseType(summ, inserteds, "2.0.2");
    String expResult = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + "  <csw:TransactionSummary requestId=\"rid\">\n" + "    <csw:totalInserted>2</csw:totalInserted>\n" + "    <csw:totalUpdated>0</csw:totalUpdated>\n" + "    <csw:totalDeleted>1</csw:totalDeleted>\n" + "  </csw:TransactionSummary>\n" + "  <csw:InsertResult>\n" + "    <csw:BriefRecord>\n" + "      <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "      <dc:title>(JASON-1)</dc:title>\n" + "      <dc:type>clearinghouse</dc:type>\n" + "      <ows:WGS84BoundingBox dimensions=\"2\">\n" + "        <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "        <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "      </ows:WGS84BoundingBox>\n" + "    </csw:BriefRecord>\n" + "  </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
    StringWriter sw = new StringWriter();
    marshaller.marshal(request, sw);
    String result = sw.toString();
    assertXmlEquals(expResult, result, "xmlns:*");
    pool.recycle(marshaller);
}
Also used : Marshaller(javax.xml.bind.Marshaller) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) TransactionSummaryType(org.geotoolkit.csw.xml.v202.TransactionSummaryType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) TransactionResponseType(org.geotoolkit.csw.xml.v202.TransactionResponseType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) StringWriter(java.io.StringWriter) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) InsertResultType(org.geotoolkit.csw.xml.v202.InsertResultType) Test(org.junit.Test)

Example 5 with InsertResultType

use of org.geotoolkit.csw.xml.v202.InsertResultType in project geotoolkit by Geomatys.

the class CswXMLBindingTest method transactionResponseUnmarshalingTest.

/**
 * Test simple Record Marshalling.
 */
@Test
public void transactionResponseUnmarshalingTest() throws JAXBException {
    Unmarshaller unmarshaller = pool.acquireUnmarshaller();
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<csw:TransactionResponse version=\"2.0.2\" xmlns:csw=\"http://www.opengis.net/cat/csw/2.0.2\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:ows=\"http://www.opengis.net/ows\">\n" + "  <csw:TransactionSummary requestId=\"rid\">\n" + "    <csw:totalInserted>2</csw:totalInserted>\n" + "    <csw:totalUpdated>0</csw:totalUpdated>\n" + "    <csw:totalDeleted>1</csw:totalDeleted>\n" + "  </csw:TransactionSummary>\n" + "  <csw:InsertResult>\n" + "    <csw:BriefRecord>\n" + "      <dc:identifier>{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}</dc:identifier>\n" + "      <dc:title>(JASON-1)</dc:title>\n" + "      <dc:type>clearinghouse</dc:type>\n" + "      <ows:WGS84BoundingBox dimensions=\"2\">\n" + "        <ows:LowerCorner>180.0 -66.0000000558794</ows:LowerCorner>\n" + "        <ows:UpperCorner>-180.0 65.9999999720603</ows:UpperCorner>\n" + "      </ows:WGS84BoundingBox>\n" + "    </csw:BriefRecord>\n" + "  </csw:InsertResult>\n" + "</csw:TransactionResponse>\n";
    TransactionResponseType result = ((JAXBElement<TransactionResponseType>) unmarshaller.unmarshal(new StringReader(xml))).getValue();
    SimpleLiteral id = new SimpleLiteral("{8C71082D-5B3B-5F9D-FC40-F7807C8AB645}");
    SimpleLiteral title = new SimpleLiteral("(JASON-1)");
    SimpleLiteral type = new SimpleLiteral("clearinghouse");
    List<BoundingBoxType> bbox = new ArrayList<>();
    bbox.add(new WGS84BoundingBoxType(180, -66.0000000558794, -180, 65.9999999720603));
    Object record = new BriefRecordType(id, title, type, bbox);
    final List<InsertResultType> inserteds = new ArrayList<>();
    inserteds.add(new InsertResultType(Arrays.asList(record), null));
    TransactionSummaryType summ = new TransactionSummaryType(2, 0, 1, "rid");
    TransactionResponseType expResult = new TransactionResponseType(summ, inserteds, "2.0.2");
    assertEquals(expResult.getTransactionSummary(), result.getTransactionSummary());
    assertEquals(expResult.getInsertResult(), result.getInsertResult());
    assertEquals(expResult, result);
    pool.recycle(unmarshaller);
}
Also used : WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) ArrayList(java.util.ArrayList) JAXBElement(javax.xml.bind.JAXBElement) TransactionSummaryType(org.geotoolkit.csw.xml.v202.TransactionSummaryType) BriefRecordType(org.geotoolkit.csw.xml.v202.BriefRecordType) TransactionResponseType(org.geotoolkit.csw.xml.v202.TransactionResponseType) BoundingBoxType(org.geotoolkit.ows.xml.v100.BoundingBoxType) WGS84BoundingBoxType(org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType) StringReader(java.io.StringReader) SimpleLiteral(org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral) Unmarshaller(javax.xml.bind.Unmarshaller) InsertResultType(org.geotoolkit.csw.xml.v202.InsertResultType) Test(org.junit.Test)

Aggregations

InsertResultType (net.opengis.sos.x20.InsertResultType)3 Test (org.junit.Test)3 Metacard (ddf.catalog.data.Metacard)2 ArrayList (java.util.ArrayList)2 JAXBElement (javax.xml.bind.JAXBElement)2 BriefRecordType (net.opengis.cat.csw.v_2_0_2.BriefRecordType)2 InsertResultType (net.opengis.cat.csw.v_2_0_2.InsertResultType)2 SimpleLiteral (net.opengis.cat.csw.v_2_0_2.dc.elements.SimpleLiteral)2 InsertResultDocument (net.opengis.sos.x20.InsertResultDocument)2 BriefRecordType (org.geotoolkit.csw.xml.v202.BriefRecordType)2 InsertResultType (org.geotoolkit.csw.xml.v202.InsertResultType)2 TransactionResponseType (org.geotoolkit.csw.xml.v202.TransactionResponseType)2 TransactionSummaryType (org.geotoolkit.csw.xml.v202.TransactionSummaryType)2 SimpleLiteral (org.geotoolkit.dublincore.xml.v2.elements.SimpleLiteral)2 BoundingBoxType (org.geotoolkit.ows.xml.v100.BoundingBoxType)2 WGS84BoundingBoxType (org.geotoolkit.ows.xml.v100.WGS84BoundingBoxType)2 InsertResultRequest (org.n52.shetland.ogc.sos.request.InsertResultRequest)2 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 CreateRequest (ddf.catalog.operation.CreateRequest)1 CreateResponse (ddf.catalog.operation.CreateResponse)1