use of com.dexels.navajo.adapter.messagemap.ResultMessage in project navajo by Dexels.
the class MessageMapTest method test4.
@Test
public void test4() throws Exception {
// message1 array and message2 array test
/* building message 1 array*/
Navajo n = NavajoFactory.getInstance().createNavajo();
Message array = NavajoFactory.getInstance().createMessage(n, "productArray");
n.addMessage(array);
array.setType(Message.MSG_TYPE_ARRAY);
/*Creating the first element of the message array productArray*/
Message c1e1 = NavajoFactory.getInstance().createMessage(n, "productArray");
c1e1.setIndex(0);
c1e1.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
array.addElement(c1e1);
Property c1e1p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property c1e1p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Laptop", 0, "", "out");
Property c1e1p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (0) + "", 0, "", "out");
c1e1.addProperty(c1e1p1);
c1e1.addProperty(c1e1p1a);
c1e1.addProperty(c1e1p2);
/*Creating the second element of the message array productArray */
Message c1e2 = NavajoFactory.getInstance().createMessage(n, "productArray");
c1e2.setIndex(1);
c1e2.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
array.addElement(c1e2);
Property c1e2p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property c1e2p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Desktop", 0, "", "out");
Property c1e2p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (20) + "", 0, "", "out");
c1e2.addProperty(c1e2p1);
c1e2.addProperty(c1e2p1a);
c1e2.addProperty(c1e2p2);
n.write(System.err);
/* building message 2 array*/
Navajo n2 = NavajoFactory.getInstance().createNavajo();
Message array2 = NavajoFactory.getInstance().createMessage(n2, "coreArray");
n2.addMessage(array2);
array2.setType(Message.MSG_TYPE_ARRAY);
/*Creating the first element of the message array coreArray */
Message c2e1 = NavajoFactory.getInstance().createMessage(n2, "coreArray");
c2e1.setIndex(0);
c2e1.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
array2.addElement(c2e1);
Property c2e1p1 = NavajoFactory.getInstance().createProperty(n2, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property c2e1p2 = NavajoFactory.getInstance().createProperty(n2, "Sub", Property.STRING_PROPERTY, "Laptop", 0, "", "out");
Property c2e1p3 = NavajoFactory.getInstance().createProperty(n2, "Core", Property.STRING_PROPERTY, "I", 0, "", "out");
c2e1.addProperty(c2e1p1);
c2e1.addProperty(c2e1p2);
c2e1.addProperty(c2e1p3);
/*Creating the second element of the message array coreArray */
Message c2e2 = NavajoFactory.getInstance().createMessage(n2, "coreArray");
c2e2.setIndex(0);
c2e2.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
array2.addElement(c2e2);
Property c2e2p1 = NavajoFactory.getInstance().createProperty(n2, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property c2e2p2 = NavajoFactory.getInstance().createProperty(n2, "Sub", Property.STRING_PROPERTY, "Laptop", 0, "", "out");
Property c2e2p3 = NavajoFactory.getInstance().createProperty(n2, "Core", Property.STRING_PROPERTY, "A", 0, "", "out");
c2e2.addProperty(c2e2p1);
c2e2.addProperty(c2e2p2);
c2e2.addProperty(c2e2p3);
n2.write(System.err);
Access a = new Access();
a.setOutputDoc(n);
MessageMap mm = new MessageMap();
mm.load(a);
mm.setJoinMessage1("productArray");
/*for the 2nd message*/
a.setOutputDoc(n2);
mm.load(a);
mm.setJoinMessage2("coreArray");
mm.setJoinType("inner");
mm.setJoinCondition("Sub=Sub");
Message resultMessage = NavajoFactory.getInstance().createMessage(n, "ResultingMessage");
resultMessage.setType("array");
n.addMessage(resultMessage);
a.setCurrentOutMessage(resultMessage);
ResultMessage[] result = mm.getResultMessage();
a.setCurrentOutMessage(null);
mm.store();
for (int l = 0; l < result.length; l++) {
assertEquals("Laptop", result[l].getProperty("Sub"));
}
}
use of com.dexels.navajo.adapter.messagemap.ResultMessage in project navajo by Dexels.
the class MessageMapTest method test2.
@Test
public void test2() throws Exception {
Navajo n = NavajoFactory.getInstance().createNavajo();
Message array = NavajoFactory.getInstance().createMessage(n, "Array");
n.addMessage(array);
array.setType(Message.MSG_TYPE_ARRAY);
for (int i = 0; i < 10; i++) {
Message c = NavajoFactory.getInstance().createMessage(n, "Array");
array.addElement(c);
if (i % 2 == 0) {
Property p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Laptop", 0, "", "out");
Property p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (i * 10) + "", 0, "", "out");
String d3 = "2012-01-" + ((i + 1) < 10 ? "0" + (i + 1) : i);
Property p3 = NavajoFactory.getInstance().createProperty(n, "Date", Property.DATE_PROPERTY, d3, 0, "", "out");
Property p4 = NavajoFactory.getInstance().createProperty(n, "Gender", "1", "Geslacht", "");
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Man", "Man", false));
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Vrouw", "Vrouw", true));
c.addProperty(p1);
c.addProperty(p1a);
c.addProperty(p2);
c.addProperty(p3);
c.addProperty(p4);
} else {
Property p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Desktop", 0, "", "out");
Property p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (i * 20) + "", 0, "", "out");
String d3 = "2012-01-" + ((i + 1) < 10 ? "0" + (i + 1) : (i + 1));
Property p3 = NavajoFactory.getInstance().createProperty(n, "Date", Property.DATE_PROPERTY, d3, 0, "", "out");
Property p4 = NavajoFactory.getInstance().createProperty(n, "Gender", "1", "Geslacht", "");
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Man", "Man", false));
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Vrouw", "Vrouw", true));
c.addProperty(p1);
c.addProperty(p1a);
c.addProperty(p2);
c.addProperty(p3);
c.addProperty(p4);
}
}
n.write(System.err);
Access a = new Access();
a.setOutputDoc(n);
MessageMap mm = new MessageMap();
mm.load(a);
// mm.setGroupBy("Product,Sub");
mm.setJoinMessage1("Array");
mm.setJoinType("outer");
// mm.setRemoveSource(true);
Message resultMessage = NavajoFactory.getInstance().createMessage(n, "ResultingMessage");
resultMessage.setType("array");
n.addMessage(resultMessage);
a.setCurrentOutMessage(resultMessage);
ResultMessage[] result = mm.getResultMessage();
a.setCurrentOutMessage(null);
mm.store();
assertEquals("Vrouw", result[0].getProperty("Gender"));
// n.write(System.err);
}
use of com.dexels.navajo.adapter.messagemap.ResultMessage in project navajo by Dexels.
the class MessageMapTest method test.
@Test
public void test() throws Exception {
Navajo n = NavajoFactory.getInstance().createNavajo();
Message array = NavajoFactory.getInstance().createMessage(n, "Array");
n.addMessage(array);
array.setType(Message.MSG_TYPE_ARRAY);
for (int i = 0; i < 10; i++) {
Message c = NavajoFactory.getInstance().createMessage(n, "Array");
array.addElement(c);
if (i % 2 == 0) {
Property p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Laptop", 0, "", "out");
Property p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (i * 10) + "", 0, "", "out");
String d3 = "2012-01-" + ((i + 1) < 10 ? "0" + (i + 1) : i);
Property p3 = NavajoFactory.getInstance().createProperty(n, "Date", Property.DATE_PROPERTY, d3, 0, "", "out");
Property p4 = NavajoFactory.getInstance().createProperty(n, "Gender", "1", "Geslacht", "");
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Man", "Man", false));
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Vrouw", "Vrouw", true));
c.addProperty(p1);
c.addProperty(p1a);
c.addProperty(p2);
c.addProperty(p3);
c.addProperty(p4);
if (i % 4 == 0) {
Property p5 = NavajoFactory.getInstance().createProperty(n, "City", Property.STRING_PROPERTY, "Amsterdam", 0, "", "out");
c.addProperty(p5);
} else {
Property p5 = NavajoFactory.getInstance().createProperty(n, "City", Property.STRING_PROPERTY, "Leiden", 0, "", "out");
c.addProperty(p5);
}
} else {
Property p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Desktop", 0, "", "out");
Property p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (i * 20) + "", 0, "", "out");
String d3 = "2012-01-" + ((i + 1) < 10 ? "0" + (i + 1) : (i + 1));
Property p3 = NavajoFactory.getInstance().createProperty(n, "Date", Property.DATE_PROPERTY, d3, 0, "", "out");
Property p4 = NavajoFactory.getInstance().createProperty(n, "Gender", "1", "Geslacht", "");
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Man", "Man", true));
p4.addSelection(NavajoFactory.getInstance().createSelection(n, "Vrouw", "Vrouw", true));
c.addProperty(p1);
c.addProperty(p1a);
c.addProperty(p2);
c.addProperty(p3);
c.addProperty(p4);
if (i % 4 == 1) {
Property p5 = NavajoFactory.getInstance().createProperty(n, "City", Property.STRING_PROPERTY, "Leiden", 0, "", "out");
c.addProperty(p5);
} else {
// Undo the double selected for the 4x + 3 rows
p4.setSelected("Man");
Property p5 = NavajoFactory.getInstance().createProperty(n, "City", Property.STRING_PROPERTY, "Hoorn", 0, "", "out");
c.addProperty(p5);
}
}
}
n.write(System.err);
Access a = new Access();
a.setOutputDoc(n);
MessageMap mm = new MessageMap();
mm.load(a);
mm.setGroupBy("Product,Sub");
mm.setJoinMessage1("Array");
mm.setJoinType("outer");
// mm.setRemoveSource(true);
Message resultMessage = NavajoFactory.getInstance().createMessage(n, "ResultingMessage");
resultMessage.setType("array");
n.addMessage(resultMessage);
a.setCurrentOutMessage(resultMessage);
ResultMessage[] result = mm.getResultMessage();
// for (int i = 0; i < result.length; i++) {
// result[i].load(a);
// result[i].getMsg().write(System.err);
// System.err.println("Count: " + result[i].getCount("Age"));
// System.err.println("Sum: " + result[i].getSum("Age"));
// System.err.println("Average: " + result[i].getAvg("Age"));
// result[i].store();
// }
a.setCurrentOutMessage(null);
mm.store();
assertEquals(2, result.length);
assertEquals(5, result[0].getCount("Age"));
assertEquals(200.0, result[0].getSum("Age"), 1);
assertEquals(500.0, result[1].getSum("Age"), 1);
assertEquals(40.0, result[0].getAvg("Age"), 1);
assertEquals(100.0, result[1].getAvg("Age"), 1);
assertEquals(80.0, result[0].getMax("Age"));
assertEquals(0.0, result[0].getMin("Age"));
assertEquals(180.0, result[1].getMax("Age"));
assertEquals(20.0, result[1].getMin("Age"));
assertEquals(new SimpleDateFormat("yyyy-MM-dd").parseObject("2012-01-01"), result[0].getMin("Date"));
assertEquals(new SimpleDateFormat("yyyy-MM-dd").parseObject("2012-01-02"), result[1].getMin("Date"));
assertEquals(new SimpleDateFormat("yyyy-MM-dd").parseObject("2012-01-09"), result[0].getMax("Date"));
assertEquals(new SimpleDateFormat("yyyy-MM-dd").parseObject("2012-01-10"), result[1].getMax("Date"));
assertEquals("Amsterdam", result[0].getAny("City"));
assertEquals("Leiden", result[1].getAny("City"));
assertEquals("Amsterdam;Leiden;Amsterdam;Leiden;Amsterdam", result[0].getConcatenated("City"));
assertEquals("Leiden;Hoorn;Leiden;Hoorn;Leiden", result[1].getConcatenated("City"));
assertEquals("Vrouw", result[0].getAny("Gender").toString());
assertEquals("Man,Vrouw", result[1].getAny("Gender").toString());
assertEquals("Vrouw;Vrouw;Vrouw;Vrouw;Vrouw", result[0].getConcatenated("Gender"));
assertEquals("Man;Vrouw;Man;Man;Vrouw;Man;Man;Vrouw", result[1].getConcatenated("Gender"));
}
use of com.dexels.navajo.adapter.messagemap.ResultMessage in project navajo by Dexels.
the class MessageMap method getResultMessage.
public ResultMessage[] getResultMessage() throws UserException {
Message definitionMsg1 = null;
Message definitionMsg2 = null;
List<ResultMessage> resultingMessage = new ArrayList<>();
List<Message> children = this.msg1.getAllMessages();
// Determine definition message, unless groupBy is defined.
if (groupBy == null && this.msg1.getDefinitionMessage() != null) {
definitionMsg1 = this.msg1.getDefinitionMessage();
}
if (groupBy == null && definitionMsg1 != null && this.msg2 != null && this.msg2.getDefinitionMessage() != null) {
definitionMsg2 = this.msg2.getDefinitionMessage();
definitionMsg1.merge(definitionMsg2);
}
for (int i = 0; i < children.size(); i++) {
msg1pointer = children.get(i);
if (msg1pointer.getType().equals(Message.MSG_TYPE_DEFINITION)) {
// Skip definition messages
continue;
}
Object[] joinValues1 = new Object[joinConditions.size()];
for (int p = 0; p < joinConditions.size(); p++) {
JoinCondition jc = joinConditions.get(p);
Property prop = msg1pointer.getProperty(jc.property1);
if (prop == null) {
throw new UserException(-1, "Exception joining messages " + joinMessage1 + " and " + joinMessage2 + ": property not found: " + jc.property1);
}
joinValues1[p] = prop.getValue();
}
// Find c2;
msg2pointer = null;
boolean foundJoinMessage = false;
boolean isSingleMessage = false;
if (this.msg2 != null) {
List<Message> children2 = this.msg2.getAllMessages();
// ==========
if (this.msg2.getType().equals(Message.MSG_TYPE_SIMPLE)) {
// v SIMPLE MESSAGE if
isSingleMessage = true;
} else // ========== // v SIMPLE MESSAGE end if
{
for (int j = 0; j < children2.size(); j++) {
msg2pointer = children2.get(j);
if (msg2pointer.getType().equals(Message.MSG_TYPE_DEFINITION)) {
// Skip definition messages
continue;
}
Object[] joinValues2 = new Object[joinConditions.size()];
for (int p = 0; p < joinConditions.size(); p++) {
JoinCondition jc = joinConditions.get(p);
Property prop = msg2pointer.getProperty(jc.property2);
if (prop == null) {
throw new UserException(-1, "Exception joining messages " + joinMessage1 + " and " + joinMessage2 + ": property not found: " + jc.property2);
}
joinValues2[p] = prop.getValue();
}
// Compare joinValues...
boolean equal = true;
for (int jv = 0; jv < joinConditions.size(); jv++) {
if (joinValues1[jv] != null && joinValues2[jv] != null && !joinValues1[jv].equals(joinValues2[jv])) {
equal = false;
} else if (joinValues1[jv] == null && joinValues2[jv] != null) {
equal = false;
} else if (joinValues1[jv] != null && joinValues2[jv] == null) {
equal = false;
}
}
if (joinExpression != null) {
// Evaluate joinExpression.
try {
Operand ro = Expression.evaluate(joinExpression.toString(), myAccess.getInDoc(), myAccess.getCompiledScript().getCurrentMap(), myAccess.getCurrentInMessage());
equal = (Boolean) ro.value;
} catch (Exception e) {
throw new UserException(-1, "Exception joining messages: " + e.getMessage(), e);
}
}
if (equal) {
Message newMsg = NavajoFactory.getInstance().createMessage(myAccess.getOutputDoc(), "tmp");
// Check for duplicate property names. If found, rename to _1 _2 respectively
// DO NOT, CAN LEAD TO STRANGE BEHAVIOR: renameDuplicates(msg1pointer, msg2pointer);
newMsg.merge(msg2pointer);
newMsg.merge(msg1pointer);
ResultMessage rm = new ResultMessage();
rm.setMessage(definitionMsg1, newMsg, this.suppressProperties);
resultingMessage.add(rm);
foundJoinMessage = true;
}
}
// end for
}
// ==========
}
if (!foundJoinMessage && joinType.equals(OUTER_JOIN) && !isSingleMessage) {
// Append dummy message with empty property values in case no join condition match...
if (msg2pointer != null) {
Message newMsg = NavajoFactory.getInstance().createMessage(myAccess.getOutputDoc(), "tmp");
Message c2c = msg2pointer.copy();
clearPropertyValues(c2c);
newMsg.merge(c2c);
newMsg.merge(msg1pointer);
ResultMessage rm = new ResultMessage();
rm.setMessage(definitionMsg1, newMsg, this.suppressProperties);
resultingMessage.add(rm);
} else {
// Assume empty second array message
Message c1c = msg1pointer.copy();
ResultMessage rm = new ResultMessage();
rm.setMessage(definitionMsg1, c1c, this.suppressProperties);
resultingMessage.add(rm);
}
}
if (!foundJoinMessage && joinType.equals(OUTER_JOIN) && isSingleMessage) {
// if ( msg2pointer != null ) {
if (msg2 != null) {
// msg2 instead of msg2pointer if something goes wrong change back to msg2pointer
Message newMsg = NavajoFactory.getInstance().createMessage(myAccess.getOutputDoc(), "tmp");
Message c1c = msg1pointer.copy();
// clearPropertyValues(c1c);
newMsg.merge(c1c);
// newMsg.merge(msg1pointer);
// msg2 instead of msg2pointer if something goes wrong change back to msg2pointer
newMsg.merge(msg2);
ResultMessage rm = new ResultMessage();
rm.setMessage(definitionMsg1, newMsg, this.suppressProperties);
resultingMessage.add(rm);
} else {
// Assume empty second array message
Message c1c = msg1pointer.copy();
ResultMessage rm = new ResultMessage();
rm.setMessage(definitionMsg1, c1c, this.suppressProperties);
resultingMessage.add(rm);
}
}
}
if (children.isEmpty() && definitionMsg1 != null && msg1 != null) {
// Make sure definition message stays intact
Navajo out = myAccess.getOutputDoc();
Message newMessage = NavajoFactory.getInstance().createMessage(out, msg1.getName(), msg1.getType());
newMessage.addMessage(definitionMsg1.copy(myAccess.getOutputDoc()));
myAccess.getOutputDoc().addMessage(newMessage);
}
if (groupBy != null) {
removeDuplicates = true;
Map<String, PropertyAggregate> aggregates = new HashMap<>();
for (int i = 0; i < resultingMessage.size(); i++) {
Map<String, Object> group = new TreeMap<>();
ResultMessage rm = resultingMessage.get(i);
Message m = rm.getMsg();
List<Property> properties = m.getAllProperties();
for (int j = 0; j < properties.size(); j++) {
Property p = properties.get(j);
if (groupByProperties.contains(p.getName())) {
group.put(p.getName(), p.getTypedValue());
}
}
for (int j = 0; j < properties.size(); j++) {
Property p = properties.get(j);
if (!groupByProperties.contains(p.getName())) {
PropertyAggregate pa = aggregates.get(p.getName());
if (pa == null) {
pa = new PropertyAggregate();
aggregates.put(p.getName(), pa);
}
pa.addProperty(p, group);
m.removeProperty(p);
}
}
}
for (int i = 0; i < resultingMessage.size(); i++) {
resultingMessage.get(i).setAggregates(aggregates);
}
}
if (removeDuplicates) {
for (int i = 0; i < resultingMessage.size(); i++) {
Message m1 = resultingMessage.get(i).getMsg().copy();
resultingMessage.get(i).processSuppressedProperties(m1);
if (!resultingMessage.get(i).isRemove()) {
for (int j = i + 1; j < resultingMessage.size(); j++) {
Message m2 = resultingMessage.get(j).getMsg().copy();
resultingMessage.get(j).processSuppressedProperties(m2);
if (m1.isEqual(m2)) {
resultingMessage.get(j).setRemove(true);
}
}
}
}
}
Iterator<ResultMessage> iter = resultingMessage.iterator();
while (iter.hasNext()) {
ResultMessage c = iter.next();
if (c.isRemove()) {
iter.remove();
}
}
return resultingMessage.toArray(new ResultMessage[] {});
}
use of com.dexels.navajo.adapter.messagemap.ResultMessage in project navajo by Dexels.
the class MessageMapTest method test3.
@Test
public void test3() throws Exception {
// message1 array and message2 simple message test but with one access obj
/* building message 1 array*/
Navajo n = NavajoFactory.getInstance().createNavajo();
Message array = NavajoFactory.getInstance().createMessage(n, "Array");
n.addMessage(array);
array.setType(Message.MSG_TYPE_ARRAY);
for (int i = 0; i < 4; i++) {
Message c = NavajoFactory.getInstance().createMessage(n, "Array");
c.setIndex(i);
c.setType(Message.MSG_TYPE_ARRAY_ELEMENT);
array.addElement(c);
if (i % 2 == 0) {
Property p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Laptop", 0, "", "out");
Property p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (i * 10) + "", 0, "", "out");
c.addProperty(p1);
c.addProperty(p1a);
c.addProperty(p2);
} else {
Property p1 = NavajoFactory.getInstance().createProperty(n, "Product", Property.STRING_PROPERTY, "PC", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "Sub", Property.STRING_PROPERTY, "Desktop", 0, "", "out");
Property p2 = NavajoFactory.getInstance().createProperty(n, "Age", Property.INTEGER_PROPERTY, (i * 20) + "", 0, "", "out");
c.addProperty(p1);
c.addProperty(p1a);
c.addProperty(p2);
}
}
n.write(System.err);
/* building message 2 simple message */
Navajo n2 = NavajoFactory.getInstance().createNavajo();
Message simpleMsg = NavajoFactory.getInstance().createMessage(n, "Simple");
simpleMsg.setType(Message.MSG_TYPE_SIMPLE);
Property p1 = NavajoFactory.getInstance().createProperty(n, "Prop", Property.STRING_PROPERTY, "Test1", 0, "", "out");
Property p1a = NavajoFactory.getInstance().createProperty(n, "SubProp", Property.STRING_PROPERTY, "Test2", 0, "", "out");
simpleMsg.addProperty(p1);
simpleMsg.addProperty(p1a);
n2.addMessage(simpleMsg);
/*end building messages*/
n2.write(System.err);
Access a = new Access();
a.setOutputDoc(n);
MessageMap mm = new MessageMap();
mm.load(a);
mm.setJoinMessage1("Array");
/*for the 2nd message*/
a.setOutputDoc(n2);
mm.load(a);
mm.setJoinMessage2("Simple");
mm.setJoinType("outer");
Message resultMessage = NavajoFactory.getInstance().createMessage(n, "ResultingMessage");
resultMessage.setType("array");
n.addMessage(resultMessage);
a.setCurrentOutMessage(resultMessage);
ResultMessage[] result = mm.getResultMessage();
a.setCurrentOutMessage(null);
mm.store();
for (int l = 0; l < result.length; l++) {
assertEquals("PC", result[l].getProperty("Product"));
assertEquals("Test1", result[l].getProperty("Prop"));
assertEquals("Test2", result[l].getProperty("SubProp"));
}
}
Aggregations