Search in sources :

Example 91 with Property

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

the class NavajoContext method resolvePost.

public void resolvePost(String name, String value) {
    if (name.indexOf(':') == -1) {
        return;
    }
    String[] keyVal = name.split(":");
    String navajo = keyVal[0];
    String path = keyVal[1];
    Navajo n = getNavajo(navajo);
    if (n == null) {
        throw new IllegalArgumentException("Missing navajo: " + navajo + " in state. Was the session deleted?");
    }
    Property p = n.getProperty(path);
    if (Property.BOOLEAN_PROPERTY.equals(p.getType())) {
        p.setAnyValue("on".equals(value));
    } else {
        p.setValue(value);
    }
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 92 with Property

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

the class NavajoContext method dumpTopElement.

public void dumpTopElement() {
    Object o = myElementStack.peek();
    if (o instanceof Navajo) {
        Navajo n = (Navajo) o;
        StringWriter sw = new StringWriter();
        try {
            n.write(sw);
            logger.info("Navajo on top: {}", sw);
        } catch (NavajoException e) {
            logger.error("Error: ", e);
        }
    } else if (o instanceof Message) {
        logger.info("Message on top: {}", ((Message) o).getFullMessageName());
    } else if (o instanceof Property) {
        try {
            logger.info("Property on top: {}", ((Property) o).getFullPropertyName());
        } catch (NavajoException e) {
            logger.error("Error: ", e);
        }
    } else {
        if (o != null) {
            logger.info("Other object: {}", o.getClass());
        } else {
            logger.info("Null object on stack!");
        }
    }
}
Also used : StringWriter(java.io.StringWriter) Message(com.dexels.navajo.document.Message) NavajoException(com.dexels.navajo.document.NavajoException) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 93 with Property

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

the class TestMessage method testMergeMessage3.

@Test
public void testMergeMessage3() {
    Message m = NavajoFactory.getInstance().createMessage(testDoc, "MyTop");
    Property p1 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp1", "string", "AAPJES(1)", 0, "", "in", "");
    m.addProperty(p1);
    testDoc.addMessage(m);
    Message m3 = NavajoFactory.getInstance().createMessage(testDoc, "MyTop");
    Property p2 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp2", "string", "AAPJES(2)", 0, "", "in", "");
    m3.addProperty(p2);
    Property p3 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp3", "string", "AAPJES(3)", 0, "", "in", "");
    m3.addProperty(p3);
    Message m4 = NavajoFactory.getInstance().createMessage(testDoc, "MyTopSub");
    Property p4 = NavajoFactory.getInstance().createProperty(testDoc, "MyPropSub1", "string", "AAPJES(3)", 0, "", "in", "");
    m4.addProperty(p4);
    m3.addMessage(m4);
    m.merge(m3);
    assertNotNull(m.getMessage("MyTopSub"));
    assertNotNull(m.getMessage("MyTopSub").getProperty("MyPropSub1"));
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 94 with Property

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

the class TestMessage method testMergeMessage2.

@Test
public void testMergeMessage2() {
    Message m = NavajoFactory.getInstance().createMessage(testDoc, "MyTop");
    Property p1 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp1", "string", "AAPJES(1)", 0, "", "in", "");
    m.addProperty(p1);
    testDoc.addMessage(m);
    Message m3 = NavajoFactory.getInstance().createMessage(testDoc, "MyTop2");
    Property p2 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp2", "string", "AAPJES(2)", 0, "", "in", "");
    m3.addProperty(p2);
    Property p3 = NavajoFactory.getInstance().createProperty(testDoc, "MyProp3", "string", "AAPJES(3)", 0, "", "in", "");
    m3.addProperty(p3);
    m.merge(m3);
    // MyProp3 should be merged althoug m3 has name "MyTop2" and m has name "MyTop".
    assertNotNull(m.getProperty("MyProp3"));
    // message "MyTop2" should not exist at all...
    assertNull(m.getMessage("MyTop2"));
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Example 95 with Property

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

the class TestMessage method testGetProperty.

@Test
public void testGetProperty() {
    Message m = testDoc.getMessage("testmessage");
    Property p = m.getProperty("integerprop");
    Assert.assertNotNull(p);
    Assert.assertEquals("integerprop", p.getName());
    p = m.getProperty("integerpropje");
    Assert.assertNull(p);
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property) Test(org.junit.Test)

Aggregations

Property (com.dexels.navajo.document.Property)253 Message (com.dexels.navajo.document.Message)148 Test (org.junit.Test)88 Navajo (com.dexels.navajo.document.Navajo)84 Selection (com.dexels.navajo.document.Selection)36 NavajoException (com.dexels.navajo.document.NavajoException)30 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)17 ArrayList (java.util.ArrayList)17 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)16 Binary (com.dexels.navajo.document.types.Binary)16 UserException (com.dexels.navajo.script.api.UserException)16 Access (com.dexels.navajo.script.api.Access)15 StringWriter (java.io.StringWriter)13 List (java.util.List)11 Operand (com.dexels.navajo.document.Operand)10 MappableException (com.dexels.navajo.script.api.MappableException)9 IOException (java.io.IOException)9 Writer (java.io.Writer)9 StringTokenizer (java.util.StringTokenizer)9 JSONTML (com.dexels.navajo.document.json.JSONTML)8