Search in sources :

Example 11 with DeleteAction

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

the class TransactionRequestConverterTest method testUnmarshalDelete.

@Test
public void testUnmarshalDelete() throws Exception {
    String deleteRequest = IOUtils.toString(TransactionRequestConverterTest.class.getResourceAsStream("/deleteRequest.xml"));
    CswTransactionRequest request = (CswTransactionRequest) xStream.fromXML(deleteRequest);
    assertThat(request.getDeleteActions(), hasSize(1));
    assertThat(request.getUpdateActions(), emptyCollectionOf(UpdateAction.class));
    assertThat(request.getInsertActions(), emptyCollectionOf(InsertAction.class));
    DeleteAction action = request.getDeleteActions().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)

Example 12 with DeleteAction

use of org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction 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)

Aggregations

DeleteAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.DeleteAction)12 CswTransactionRequest (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest)10 Test (org.junit.Test)8 UpdateAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.UpdateAction)6 Metacard (ddf.catalog.data.Metacard)5 InsertAction (org.codice.ddf.spatial.ogc.csw.catalog.actions.InsertAction)5 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)5 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)4 IngestException (ddf.catalog.source.IngestException)4 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)4 DeleteType (net.opengis.cat.csw.v_2_0_2.DeleteType)4 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)4 TransactionResponseType (net.opengis.cat.csw.v_2_0_2.TransactionResponseType)4 DeleteActionImpl (org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.DeleteActionImpl)4 Converter (com.thoughtworks.xstream.converters.Converter)3 FederationException (ddf.catalog.federation.FederationException)3 CreateRequest (ddf.catalog.operation.CreateRequest)3 DeleteResponse (ddf.catalog.operation.DeleteResponse)3 QueryRequest (ddf.catalog.operation.QueryRequest)3 Subject (org.apache.shiro.subject.Subject)3