Search in sources :

Example 31 with ImmutableMessage

use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.

the class ExpressionTest method testTrailingTMLPath.

@Test
public void testTrailingTMLPath() throws Exception {
    Expression.compileExpressions = true;
    ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
    ImmutableMessage inner = ImmutableFactory.empty().with("innerint", 3, "integer");
    ImmutableMessage combined = outer.withSubMessage("sub", inner);
    Operand o = Expression.evaluateImmutable("[sub/]", null, Optional.of(combined), Optional.empty());
    ImmutableMessage s = o.immutableMessageValue();
    assertEquals(3, s.value("innerint").get());
}
Also used : Operand(com.dexels.navajo.document.Operand) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Test(org.junit.Test)

Example 32 with ImmutableMessage

use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.

the class ExpressionTest method testTrailingTMLPathParam.

@Test
public void testTrailingTMLPathParam() throws Exception {
    Expression.compileExpressions = true;
    ImmutableMessage outer = ImmutableFactory.empty().with("outerint", 1, "integer");
    ImmutableMessage inner = ImmutableFactory.empty().with("innerint", 3, "integer");
    ImmutableMessage combined = outer.withSubMessage("sub", inner);
    Operand o = Expression.evaluateImmutable("[@sub/]", null, Optional.empty(), Optional.of(combined));
    ImmutableMessage s = o.immutableMessageValue();
    assertEquals(3, s.value("innerint").get());
}
Also used : Operand(com.dexels.navajo.document.Operand) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Test(org.junit.Test)

Example 33 with ImmutableMessage

use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.

the class TestSerializeReplicationMessage method testRepl.

@Test
public void testRepl() {
    ReplicationMessageParser parser = new JSONReplicationMessageParserImpl();
    ImmutableMessage m = parser.parseStream(this.getClass().getClassLoader().getResourceAsStream("person.json")).message();
    StreamDocument.replicationMessageToStreamEvents("Person", m, false).compose(StreamDocument.inNavajo("TestService", Optional.empty(), Optional.empty())).lift(StreamDocument.serialize()).lift(StreamDocument.decode("UTF-8")).blockingForEach(e -> {
        System.err.print(e);
    });
}
Also used : ReplicationMessageParser(com.dexels.replication.api.ReplicationMessageParser) JSONReplicationMessageParserImpl(com.dexels.replication.impl.json.JSONReplicationMessageParserImpl) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Test(org.junit.Test)

Example 34 with ImmutableMessage

use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.

the class CallRemoteSource method execute.

@Override
public Flowable<DataItem> execute(StreamScriptContext context, Optional<ImmutableMessage> current, ImmutableMessage param) {
    ReactiveResolvedParameters resolved = params.resolve(context, current, ImmutableFactory.empty(), metadata);
    String server = resolved.paramString("server");
    String username = resolved.paramString("username");
    String password = resolved.paramString("password");
    final String service = resolved.paramString("service");
    Flowable<NavajoStreamEvent> flow = client.callWithBodyToStream(server, e -> e.header("X-Navajo-Username", username).header("X-Navajo-Password", password).header("X-Navajo-Service", service).method(HttpMethod.POST), Flowable.<NavajoStreamEvent>empty().compose(StreamDocument.inNavajo(service, Optional.of(username), Optional.of(password))).lift(StreamDocument.serialize()), "text/xml").lift(XML.parseFlowable(10)).concatMap(e -> e).lift(StreamDocument.parse()).concatMap(e -> e).filter(e -> e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_STARTED && e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_DONE);
    Flowable<DataItem> fw = Flowable.just(DataItem.ofEventStream(flow));
    return fw;
}
Also used : ReactiveResolvedParameters(com.dexels.navajo.reactive.api.ReactiveResolvedParameters) Type(com.dexels.navajo.document.stream.DataItem.Type) ReactiveParameters(com.dexels.navajo.reactive.api.ReactiveParameters) DataItem(com.dexels.navajo.document.stream.DataItem) StreamScriptContext(com.dexels.navajo.document.stream.api.StreamScriptContext) ImmutableFactory(com.dexels.immutable.factory.ImmutableFactory) SourceMetadata(com.dexels.navajo.reactive.api.SourceMetadata) HttpMethod(org.eclipse.jetty.http.HttpMethod) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent) ReactiveResolvedParameters(com.dexels.navajo.reactive.api.ReactiveResolvedParameters) Flowable(io.reactivex.Flowable) Optional(java.util.Optional) XML(com.dexels.navajo.document.stream.xml.XML) JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient) StreamDocument(com.dexels.navajo.document.stream.StreamDocument) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) ReactiveSource(com.dexels.navajo.reactive.api.ReactiveSource) DataItem(com.dexels.navajo.document.stream.DataItem) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent)

Example 35 with ImmutableMessage

use of com.dexels.immutable.api.ImmutableMessage in project navajo by Dexels.

the class CallRemoteTransformer method execute.

@Override
public FlowableTransformer<DataItem, DataItem> execute(StreamScriptContext context, Optional<ImmutableMessage> current, ImmutableMessage param) {
    ReactiveResolvedParameters resolved = parameters.resolve(context, current, param, metadata);
    String server = resolved.paramString("server");
    String username = resolved.paramString("username");
    String password = resolved.paramString("password");
    final String service = resolved.paramString("service");
    return flow -> {
        Flowable<NavajoStreamEvent> result = client.callWithBodyToStream(server, e -> e.header("X-Navajo-Username", username).header("X-Navajo-Password", password).header("X-Navajo-Service", service), flow.map(di -> di.eventStream()).concatMap(e -> e).lift(StreamDocument.serialize()), "text/xml").lift(XML.parseFlowable(10)).concatMap(e -> e).lift(StreamDocument.parse()).concatMap(e -> e).filter(e -> e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_STARTED && e.type() != NavajoStreamEvent.NavajoEventTypes.NAVAJO_DONE);
        return Flowable.just(DataItem.ofEventStream(result));
    };
}
Also used : ReactiveResolvedParameters(com.dexels.navajo.reactive.api.ReactiveResolvedParameters) ReactiveTransformer(com.dexels.navajo.reactive.api.ReactiveTransformer) ReactiveParameters(com.dexels.navajo.reactive.api.ReactiveParameters) DataItem(com.dexels.navajo.document.stream.DataItem) TransformerMetadata(com.dexels.navajo.reactive.api.TransformerMetadata) StreamScriptContext(com.dexels.navajo.document.stream.api.StreamScriptContext) FlowableTransformer(io.reactivex.FlowableTransformer) NavajoStreamEvent(com.dexels.navajo.document.stream.events.NavajoStreamEvent) ReactiveResolvedParameters(com.dexels.navajo.reactive.api.ReactiveResolvedParameters) Flowable(io.reactivex.Flowable) Optional(java.util.Optional) XML(com.dexels.navajo.document.stream.xml.XML) JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient) StreamDocument(com.dexels.navajo.document.stream.StreamDocument) ImmutableMessage(com.dexels.immutable.api.ImmutableMessage) Flowable(io.reactivex.Flowable)

Aggregations

ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)36 Message (com.dexels.navajo.document.Message)23 Navajo (com.dexels.navajo.document.Navajo)18 Operand (com.dexels.navajo.document.Operand)17 Optional (java.util.Optional)17 Selection (com.dexels.navajo.document.Selection)12 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)12 TipiLink (com.dexels.navajo.expression.api.TipiLink)12 Access (com.dexels.navajo.script.api.Access)12 MappableTreeNode (com.dexels.navajo.script.api.MappableTreeNode)12 Test (org.junit.Test)12 List (java.util.List)9 Property (com.dexels.navajo.document.Property)7 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)6 HashMap (java.util.HashMap)6 ImmutableFactory (com.dexels.immutable.factory.ImmutableFactory)5 ArrayList (java.util.ArrayList)5 DataItem (com.dexels.navajo.document.stream.DataItem)4 StreamScriptContext (com.dexels.navajo.document.stream.api.StreamScriptContext)4 ReactiveParameters (com.dexels.navajo.reactive.api.ReactiveParameters)4