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);
}
}
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!");
}
}
}
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"));
}
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"));
}
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);
}
Aggregations