Search in sources :

Example 1 with OperationChainDAO

use of uk.gov.gchq.gaffer.operation.OperationChainDAO in project Gaffer by gchq.

the class AddNamedOperation method setOperationChain.

@JsonIgnore
public void setOperationChain(final OperationChain operationChain) {
    try {
        if (operationChain instanceof OperationChainDAO) {
            this.operations = new String(JSONSerialiser.serialise(operationChain), Charset.forName(CHARSET_NAME));
        } else {
            final OperationChainDAO dao = new OperationChainDAO(operationChain.getOperations());
            this.operations = new String(JSONSerialiser.serialise(dao), Charset.forName(CHARSET_NAME));
        }
    } catch (final SerialisationException se) {
        throw new IllegalArgumentException(se.getMessage());
    }
}
Also used : OperationChainDAO(uk.gov.gchq.gaffer.operation.OperationChainDAO) SerialisationException(uk.gov.gchq.gaffer.exception.SerialisationException) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Example 2 with OperationChainDAO

use of uk.gov.gchq.gaffer.operation.OperationChainDAO in project Gaffer by gchq.

the class OperationService method _execute.

@SuppressWarnings("ThrowFromFinallyBlock")
protected <O> O _execute(final OperationChainDAO<O> opChain) {
    final Context context = userFactory.createContext();
    preOperationHook(opChain, context);
    O result;
    try {
        result = graphFactory.getGraph().execute(opChain, context);
    } catch (final OperationException e) {
        CloseableUtil.close(opChain);
        throw new RuntimeException("Error executing operation chain: " + e.getMessage(), e);
    } finally {
        try {
            postOperationHook(opChain, context);
        } catch (final Exception e) {
            CloseableUtil.close(opChain);
            throw e;
        }
    }
    return result;
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) OperationException(uk.gov.gchq.gaffer.operation.OperationException) IOException(java.io.IOException) OperationException(uk.gov.gchq.gaffer.operation.OperationException) OperationChainDAO(uk.gov.gchq.gaffer.operation.OperationChainDAO)

Aggregations

OperationChainDAO (uk.gov.gchq.gaffer.operation.OperationChainDAO)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 IOException (java.io.IOException)1 SerialisationException (uk.gov.gchq.gaffer.exception.SerialisationException)1 OperationException (uk.gov.gchq.gaffer.operation.OperationException)1 Context (uk.gov.gchq.gaffer.store.Context)1