Search in sources :

Example 36 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class ProcessingDetailsImplTest method testEqualityWithNullSourceIds.

@Test
public void testEqualityWithNullSourceIds() {
    Exception exception = new UnsupportedQueryException("We do not support this query");
    ProcessingDetails processingDetails = new ProcessingDetailsImpl(null, exception, "warning");
    ProcessingDetails identicalProcessingDetails = new ProcessingDetailsImpl(null, exception, "warning");
    assertThat(processingDetails, is(identicalProcessingDetails));
}
Also used : UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) Test(org.junit.Test)

Example 37 with ProcessingDetailsImpl

use of ddf.catalog.operation.impl.ProcessingDetailsImpl in project ddf by codice.

the class AbstractCswStore method update.

@Override
public UpdateResponse update(UpdateRequest updateRequest) throws IngestException {
    Map<String, Serializable> properties = new HashMap<>();
    validateOperation();
    Subject subject = (Subject) updateRequest.getPropertyValue(SecurityConstants.SECURITY_SUBJECT);
    Csw csw = factory.getClientForSubject(subject);
    CswTransactionRequest transactionRequest = getTransactionRequest();
    OperationTransaction opTrans = (OperationTransaction) updateRequest.getPropertyValue(Constants.OPERATION_TRANSACTION_KEY);
    String insertTypeName = schemaTransformerManager.getTransformerIdForSchema(cswSourceConfiguration.getOutputSchema());
    HashSet<ProcessingDetails> errors = new HashSet<>();
    if (insertTypeName == null) {
        insertTypeName = CswConstants.CSW_RECORD;
    }
    ArrayList<Metacard> updatedMetacards = new ArrayList<>(updateRequest.getUpdates().size());
    ArrayList<Filter> updatedMetacardFilters = new ArrayList<>(updateRequest.getUpdates().size());
    for (Map.Entry<Serializable, Metacard> update : updateRequest.getUpdates()) {
        Metacard metacard = update.getValue();
        properties.put(metacard.getId(), metacard);
        updatedMetacardFilters.add(filterBuilder.attribute(updateRequest.getAttributeName()).is().equalTo().text(update.getKey().toString()));
        transactionRequest.getUpdateActions().add(new UpdateActionImpl(metacard, insertTypeName, null));
    }
    try {
        TransactionResponseType response = csw.transaction(transactionRequest);
        if (response.getTransactionSummary().getTotalUpdated().longValue() != updateRequest.getUpdates().size()) {
            errors.add(new ProcessingDetailsImpl(this.getId(), null, "One or more updates failed"));
        }
    } catch (CswException e) {
        throw new IngestException("Csw Transaction Failed.", e);
    }
    try {
        updatedMetacards.addAll(transactionQuery(updatedMetacardFilters, subject));
    } catch (UnsupportedQueryException e) {
        errors.add(new ProcessingDetailsImpl(this.getId(), e, "Failed to retrieve updated metacards"));
    }
    return new UpdateResponseImpl(updateRequest, properties, updatedMetacards, new ArrayList(opTrans.getPreviousStateMetacards()), errors);
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) CswException(org.codice.ddf.spatial.ogc.csw.catalog.common.CswException) ProcessingDetailsImpl(ddf.catalog.operation.impl.ProcessingDetailsImpl) TransactionResponseType(net.opengis.cat.csw.v_2_0_2.TransactionResponseType) OperationTransaction(ddf.catalog.operation.OperationTransaction) ProcessingDetails(ddf.catalog.operation.ProcessingDetails) UpdateResponseImpl(ddf.catalog.operation.impl.UpdateResponseImpl) IngestException(ddf.catalog.source.IngestException) HashSet(java.util.HashSet) UpdateActionImpl(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.UpdateActionImpl) Csw(org.codice.ddf.spatial.ogc.csw.catalog.common.Csw) Subject(ddf.security.Subject) Metacard(ddf.catalog.data.Metacard) Filter(org.opengis.filter.Filter) CswTransactionRequest(org.codice.ddf.spatial.ogc.csw.catalog.common.transaction.CswTransactionRequest) Map(java.util.Map) DefaultCswRecordMap(org.codice.ddf.spatial.ogc.csw.catalog.common.converter.DefaultCswRecordMap) HashMap(java.util.HashMap)

Aggregations

ProcessingDetailsImpl (ddf.catalog.operation.impl.ProcessingDetailsImpl)37 Test (org.junit.Test)19 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)18 ProcessingDetails (ddf.catalog.operation.ProcessingDetails)13 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)8 IngestException (ddf.catalog.source.IngestException)8 HashSet (java.util.HashSet)8 QueryRequest (ddf.catalog.operation.QueryRequest)7 SourceResponse (ddf.catalog.operation.SourceResponse)6 Serializable (java.io.Serializable)6 HashMap (java.util.HashMap)6 Tag (io.micrometer.core.instrument.Tag)5 ArrayList (java.util.ArrayList)5 Metacard (ddf.catalog.data.Metacard)4 QueryResponse (ddf.catalog.operation.QueryResponse)4 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)4 CatalogStore (ddf.catalog.source.CatalogStore)3 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3