Search in sources :

Example 1 with Defaultr

use of com.bazaarvoice.jolt.Defaultr in project camel by apache.

the class JoltEndpoint method getTransform.

private synchronized Transform getTransform() throws Exception {
    if (transform == null) {
        if (log.isDebugEnabled()) {
            String path = getResourceUri();
            log.debug("Jolt content read from resource {} with resourceUri: {} for endpoint {}", new Object[] { getResourceUri(), path, getEndpointUri() });
        }
        // Sortr does not require a spec
        if (this.transformDsl == JoltTransformType.Sortr) {
            this.transform = new Sortr();
        } else {
            // getResourceAsInputStream also considers the content cache
            Object spec = JsonUtils.jsonToObject(getResourceAsInputStream());
            switch(this.transformDsl) {
                case Shiftr:
                    this.transform = new Shiftr(spec);
                    break;
                case Defaultr:
                    this.transform = new Defaultr(spec);
                    break;
                case Removr:
                    this.transform = new Removr(spec);
                    break;
                case Chainr:
                default:
                    this.transform = Chainr.fromSpec(spec);
                    break;
            }
        }
    }
    return transform;
}
Also used : Defaultr(com.bazaarvoice.jolt.Defaultr) Sortr(com.bazaarvoice.jolt.Sortr) Shiftr(com.bazaarvoice.jolt.Shiftr) Removr(com.bazaarvoice.jolt.Removr)

Example 2 with Defaultr

use of com.bazaarvoice.jolt.Defaultr in project nifi by apache.

the class TestTransformFactory method testGetDefaultTransform.

@Test
public void testGetDefaultTransform() throws Exception {
    final String defaultrSpec = new String(Files.readAllBytes(Paths.get("src/test/resources/TestTransformFactory/defaultrSpec.json")));
    JoltTransform transform = TransformFactory.getTransform(getClass().getClassLoader(), "jolt-transform-default", JsonUtils.jsonToObject(defaultrSpec));
    assertTrue(transform instanceof Defaultr);
}
Also used : Defaultr(com.bazaarvoice.jolt.Defaultr) JoltTransform(com.bazaarvoice.jolt.JoltTransform) Test(org.junit.Test)

Aggregations

Defaultr (com.bazaarvoice.jolt.Defaultr)2 JoltTransform (com.bazaarvoice.jolt.JoltTransform)1 Removr (com.bazaarvoice.jolt.Removr)1 Shiftr (com.bazaarvoice.jolt.Shiftr)1 Sortr (com.bazaarvoice.jolt.Sortr)1 Test (org.junit.Test)1