Search in sources :

Example 26 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class ServerAsyncRunner method run.

/**
 * Main thread
 */
@Override
public void run() {
    try {
        prevTime = System.currentTimeMillis();
        while (isIterating()) {
            if (kill) {
                logger.warn("Kill called in ServerAsyncRunner...");
                myResult.getHeader().setCallBackInterrupt("kill");
                setIterating(false);
            }
            if (myPollingInterval > 0) {
                myNavajo.removeHeader();
                myNavajo.addHeader(myResult.getHeader());
                Navajo temp = doSimpleSend(myNavajo, myMethod);
                if (temp.getMessage("ConditionErrors") != null) {
                    logger.warn("Had ConditionErrors in Asyncsend.. ");
                    killServerAsyncSend();
                } else {
                    poll(temp);
                }
            }
        }
    } catch (ClientException ex) {
        logger.debug("oooops");
        myListener.handleException(ex);
        return;
    }
    if (myListener != null) {
        myListener.handleException(new ClientException(-1, -1, "Operation aborted"));
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) ClientException(com.dexels.navajo.client.ClientException)

Example 27 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class SerializationUtilTest method testRemove3.

@Test
public void testRemove3() {
    Navajo n = NavajoFactory.getInstance().createNavajo();
    Message m = NavajoFactory.getInstance().createMessage(n, "TestMessage");
    n.addMessage(m);
    String name = SerializationUtil.serializeNavajo(n, "TestNavajo");
    Assert.assertEquals(true, SerializationUtil.existsNavajo("TestNavajo"));
    SerializationUtil.removeNavajo("Apenoot");
    Assert.assertEquals(false, SerializationUtil.existsNavajo("Apenoot"));
    SerializationUtil.removeNavajo(name);
    Assert.assertEquals(false, SerializationUtil.existsNavajo("TestNavajo"));
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 28 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class DomainObjectMapperTest method testStoreWithMultipleSelectionProperty.

@Test
public void testStoreWithMultipleSelectionProperty() throws Exception {
    // The other way around, with an input Navajo with property that does
    // have an associated attribute.
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    Message m = NavajoFactory.getInstance().createMessage(doc, "MyMessage");
    doc.addMessage(m);
    Property p1 = NavajoFactory.getInstance().createProperty(doc, "Id", "string", "hello", 0, "", "in");
    Property p2 = NavajoFactory.getInstance().createProperty(doc, "Selection", "+", "", "in");
    m.addProperty(p1);
    m.addProperty(p2);
    // Add selections...
    Selection s1 = NavajoFactory.getInstance().createSelection(doc, "aap", "AAP", true);
    Selection s2 = NavajoFactory.getInstance().createSelection(doc, "noot", "NOOT", true);
    Selection s3 = NavajoFactory.getInstance().createSelection(doc, "mies", "MIES", false);
    p2.addSelection(s1);
    p2.addSelection(s2);
    p2.addSelection(s3);
    Access a = new Access();
    a.setInDoc(doc);
    DomainObjectMapper dom2 = new DomainObjectMapper();
    dom2.setCurrentMessageName("MyMessage");
    dom2.load(a);
    dom2.setObjectName("com.dexels.navajo.mapping.bean.Relation");
    boolean exception = false;
    try {
        dom2.store();
    } catch (Exception e) {
        exception = true;
    }
    // Multiple cardinality is not yet supported, hence exception.
    assertTrue(exception);
// Object o = dom2.getMyObject();
// assertNotNull(o);
// assertEquals(Relation.class, o.getClass());
// assertEquals("hello", ((Relation) o).getId());
// assertEquals("NOOT", ((Relation) o).getSelection());
}
Also used : Message(com.dexels.navajo.document.Message) Selection(com.dexels.navajo.document.Selection) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 29 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class DomainObjectMapperTest method testSetInputProperties.

@Test
public void testSetInputProperties() throws Exception {
    TestPOJO tp = new TestPOJO();
    tp.setName("hallo");
    DomainObjectMapper dom = new DomainObjectMapper(tp);
    Access a = new Access();
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    a.setOutputDoc(doc);
    Message m = NavajoFactory.getInstance().createMessage(doc, "Test");
    doc.addMessage(m);
    a.setCurrentOutMessage(m);
    dom.load(a);
    dom.setInputProperties("name;birthdate");
    dom.store();
    assertNotNull(doc.getProperty("/Test/Name"));
    assertEquals("in", doc.getProperty("/Test/Name").getDirection());
    assertEquals("hallo", doc.getProperty("/Test/Name").getValue());
    assertNotNull(doc.getProperty("/Test/Something"));
    assertEquals("out", doc.getProperty("/Test/Something").getDirection());
}
Also used : Message(com.dexels.navajo.document.Message) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Test(org.junit.Test)

Example 30 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class DomainObjectMapperTest method testStoreWithSelectionProperty.

@Test
public void testStoreWithSelectionProperty() throws Exception {
    // The other way around, with an input Navajo with property that does
    // have an associated attribute.
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    Message m = NavajoFactory.getInstance().createMessage(doc, "MyMessage");
    doc.addMessage(m);
    Property p1 = NavajoFactory.getInstance().createProperty(doc, "Id", "string", "hello", 0, "", "in");
    Property p2 = NavajoFactory.getInstance().createProperty(doc, "Selection", "1", "", "in");
    m.addProperty(p1);
    m.addProperty(p2);
    // Add selections...
    Selection s1 = NavajoFactory.getInstance().createSelection(doc, "aap", "AAP", false);
    Selection s2 = NavajoFactory.getInstance().createSelection(doc, "noot", "NOOT", true);
    p2.addSelection(s1);
    p2.addSelection(s2);
    Access a = new Access();
    a.setInDoc(doc);
    DomainObjectMapper dom2 = new DomainObjectMapper();
    dom2.setCurrentMessageName("MyMessage");
    dom2.load(a);
    dom2.setObjectName("com.dexels.navajo.mapping.bean.Relation");
    dom2.store();
    Object o = dom2.getMyObject();
    assertNotNull(o);
    assertEquals(Relation.class, o.getClass());
    assertEquals("hello", ((Relation) o).getId());
    assertEquals("NOOT", ((Relation) o).getSelection());
}
Also used : Message(com.dexels.navajo.document.Message) Selection(com.dexels.navajo.document.Selection) Access(com.dexels.navajo.script.api.Access) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Aggregations

Navajo (com.dexels.navajo.document.Navajo)258 Message (com.dexels.navajo.document.Message)131 Test (org.junit.Test)109 Property (com.dexels.navajo.document.Property)86 NavajoException (com.dexels.navajo.document.NavajoException)31 Access (com.dexels.navajo.script.api.Access)30 IOException (java.io.IOException)28 StringWriter (java.io.StringWriter)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)25 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)22 Selection (com.dexels.navajo.document.Selection)22 Header (com.dexels.navajo.document.Header)20 Operand (com.dexels.navajo.document.Operand)20 InputStream (java.io.InputStream)17 UserException (com.dexels.navajo.script.api.UserException)16 Optional (java.util.Optional)16 FatalException (com.dexels.navajo.script.api.FatalException)14 SystemException (com.dexels.navajo.script.api.SystemException)14 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13