use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class Dispatcher method generateScheduledMessage.
private final Navajo generateScheduledMessage(Header h, String taskId, boolean rejected) {
try {
Navajo outMessage = NavajoFactory.getInstance().createNavajo();
Header hnew = NavajoFactory.getInstance().createHeader(outMessage, h.getRPCName(), h.getRPCUser(), "", -1);
if (!rejected) {
hnew.setSchedule(taskId);
} else {
Message msg = NavajoFactory.getInstance().createMessage(outMessage, "Warning");
outMessage.addMessage(msg);
Property prop = NavajoFactory.getInstance().createProperty(outMessage, "Status", Property.STRING_PROPERTY, "TimeExpired", 32, "Created by generateScheduledMessage", Property.DIR_OUT);
msg.addProperty(prop);
}
outMessage.addHeader(hnew);
return outMessage;
} catch (Exception e) {
logger.error("Error: ", e);
return null;
}
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class SimpleNode method lazyBiFunction.
public ContextExpression lazyBiFunction(List<String> problems, String expression, BinaryOperator<Operand> func, BiFunction<Optional<String>, Optional<String>, Boolean> acceptTypes, BiFunction<Optional<String>, Optional<String>, Optional<String>> returnTypeResolver, Function<String, FunctionClassification> functionClassifier, Function<String, Optional<Node>> mapResolver) {
ContextExpression expA = jjtGetChild(0).interpretToLambda(problems, expression, functionClassifier, mapResolver);
ContextExpression expB = jjtGetChild(1).interpretToLambda(problems, expression, functionClassifier, mapResolver);
Optional<String> aType = expA.returnType();
Optional<String> bType = expB.returnType();
boolean inputTypesValid = acceptTypes.apply(aType, bType);
if (!inputTypesValid) {
problems.add("Invalid input types in node: " + aType.orElse("unknown") + " and " + bType.orElse("unknown") + " in node type: " + this.getClass());
}
Optional<String> returnType = returnTypeResolver.apply(aType, bType);
return new ContextExpression() {
@Override
public Operand apply(Navajo doc, Message parentMsg, Message parentParamMsg, Selection parentSel, MappableTreeNode mapNode, TipiLink tipiLink, Access access, Optional<ImmutableMessage> immutableMessage, Optional<ImmutableMessage> paramMessage) {
Operand a = expA.apply(doc, parentMsg, parentParamMsg, parentSel, mapNode, tipiLink, access, immutableMessage, paramMessage);
Operand b = expB.apply(doc, parentMsg, parentParamMsg, parentSel, mapNode, tipiLink, access, immutableMessage, paramMessage);
return func.apply(a, b);
}
@Override
public boolean isLiteral() {
return expA.isLiteral() && expB.isLiteral();
}
@Override
public Optional<String> returnType() {
return returnType;
}
@Override
public String expression() {
return expression;
}
};
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class TestGatherEvents method testMethods.
@Test
public void testMethods() throws IOException {
try (InputStream is = TestGatherEvents.class.getResourceAsStream("tml_events.xml")) {
Navajo n = NavajoFactory.getInstance().createNavajo(is);
// List<NavajoStreamEvent> l = NavajoDomStreamer.feed(n).toList().blockingGet();
long l = Single.just(n).compose(StreamDocument.domStreamTransformer()).toObservable().concatMap(e -> e).toFlowable(BackpressureStrategy.BUFFER).compose(StreamDocument.eventsToImmutable(Optional.empty())).doOnNext(e -> ImmutableFactory.createParser().describe(e)).count().blockingGet();
Assert.assertEquals(10, l);
}
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class BaseMessageImpl method copy.
@Override
public final Message copy() {
Navajo empty = NavajoFactory.getInstance().createNavajo();
Message result = copy(empty);
empty.addMessage(result);
return result;
}
use of com.dexels.navajo.document.Navajo in project navajo by Dexels.
the class JSONTMLImpl method parse.
private Navajo parse(JsonParser jp) throws Exception {
Navajo n = NavajoFactory.getInstance().createNavajo();
Message parent = NavajoFactory.getInstance().createMessage(n, (topLevelMessageName != null ? topLevelMessageName : "Request"));
boolean first = true;
while (jp.nextToken() != null) {
if (first) {
n.addMessage(parent);
first = false;
}
parse(n, parent, jp);
}
return n;
}
Aggregations