Search in sources :

Example 6 with InsertAction

use of org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction in project ddf by codice.

the class TransactionRequestConverterTest method testMultipleOperations.

@Test
public void testMultipleOperations() throws Exception {
    CswTransactionRequest transactionRequest = new CswTransactionRequest();
    MetacardImpl metacard = new MetacardImpl();
    metacard.setId(METACARD_ID);
    transactionRequest.setService(CswConstants.CSW);
    transactionRequest.setVerbose(true);
    transactionRequest.setVersion(CswConstants.VERSION_2_0_2);
    InsertAction insertAction = new InsertActionImpl(CswConstants.CSW_METACARD_TYPE_NAME, null, Arrays.asList(metacard));
    transactionRequest.getInsertActions().add(insertAction);
    UpdateAction updateAction = new UpdateActionImpl(metacard, CswConstants.CSW_METACARD_TYPE_NAME, null);
    transactionRequest.getUpdateActions().add(updateAction);
    DeleteType deleteType = new DeleteType();
    QueryConstraintType queryConstraintType = new QueryConstraintType();
    queryConstraintType.setCqlText("identifier = " + METACARD_ID);
    deleteType.setConstraint(queryConstraintType);
    DeleteAction deleteAction = new DeleteActionImpl(deleteType, null);
    transactionRequest.getDeleteActions().add(deleteAction);
    String xml = xStream.toXML(transactionRequest);
    Diff diff = XMLUnit.compareXML(xml, EXPECTED_MULTI_OP_XML);
    assertThat(diff.similar(), is(true));
}
Also used : InsertActionImpl(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertActionImpl) UpdateActionImpl(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateActionImpl) UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.actions.UpdateAction) Diff(org.custommonkey.xmlunit.Diff) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) InsertAction(org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction) DeleteAction(org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction) DeleteType(net.opengis.cat.csw.v_2_0_2.DeleteType) DeleteActionImpl(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteActionImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) Test(org.junit.Test)

Example 7 with InsertAction

use of org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction in project ddf by codice.

the class TransactionRequestConverterTest method testUnmarshalInsert.

@Test
public void testUnmarshalInsert() throws Exception {
    String insertRequest = IOUtils.toString(TransactionRequestConverterTest.class.getResourceAsStream("/insertRequest.xml"));
    CswTransactionRequest request = (CswTransactionRequest) xStream.fromXML(insertRequest);
    assertThat(request.getDeleteActions(), emptyCollectionOf(DeleteAction.class));
    assertThat(request.getUpdateActions(), emptyCollectionOf(UpdateAction.class));
    assertThat(request.getInsertActions(), hasSize(1));
    InsertAction action = request.getInsertActions().get(0);
    assertThat(action.getTypeName(), is(CswConstants.CSW_RECORD));
}
Also used : UpdateAction(org.codice.ddf.spatial.ogc.csw.catalog.actions.UpdateAction) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) InsertAction(org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction) DeleteAction(org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction) Test(org.junit.Test)

Aggregations

InsertAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction)7 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)6 DeleteAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction)5 Test (org.junit.Test)5 Metacard (ddf.catalog.data.Metacard)4 UpdateAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.UpdateAction)4 Converter (com.thoughtworks.xstream.converters.Converter)2 UnmarshallingContext (com.thoughtworks.xstream.converters.UnmarshallingContext)2 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)2 InsertActionImpl (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.InsertActionImpl)2 CswRecordConverter (org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter)2 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)2 Diff (org.custommonkey.xmlunit.Diff)2 FederationException (ddf.catalog.federation.FederationException)1 CreateRequest (ddf.catalog.operation.CreateRequest)1 CreateResponse (ddf.catalog.operation.CreateResponse)1 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)1 ResourceNotFoundException (ddf.catalog.resource.ResourceNotFoundException)1 ResourceNotSupportedException (ddf.catalog.resource.ResourceNotSupportedException)1