use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class JsonTmlConverterImpl method toNode.
/* (non-Javadoc)
* @see com.dexels.navajo.document.json.impl.JsonTmlConferter#toNode(com.dexels.navajo.document.Message, java.lang.String)
*/
@Override
public ObjectNode toNode(Message m, final String primaryKeys) {
ObjectNode result = createTopLevel(primaryKeys);
ObjectNode columnValuesList = objectMapper.createObjectNode();
result.set("Columns", columnValuesList);
List<Property> allProperties = m.getAllProperties();
if (allProperties != null) {
for (Property p : allProperties) {
ObjectNode o = objectMapper.createObjectNode();
o.put("Type", p.getType());
o.put("Value", p.getValue());
columnValuesList.set(p.getName(), o);
}
}
for (Message submessage : m.getAllMessages()) {
String name = submessage.getName();
if (Message.MSG_TYPE_ARRAY.equals((submessage.getType()))) {
ArrayNode node = objectMapper.createArrayNode();
for (Message element : submessage.getAllMessages()) {
node.add(toNode(element, primaryKeys));
}
ObjectNode submessages = ensureSub("SubMessage", result);
submessages.set(name, node);
} else {
ObjectNode submsg = ensureSub("SubMessage", result);
submsg.set(name, toNode(submessage, primaryKeys));
}
}
return result;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoDomStreamer method emitBinaryProperties.
private static void emitBinaryProperties(Message m, List<NavajoStreamEvent> list) {
for (Property p : m.getAllProperties()) {
if (Property.BINARY_PROPERTY.equals(p.getType())) {
list.add(Events.binaryStarted(p.getName(), p.getLength(), Optional.ofNullable(p.getDescription()), Optional.ofNullable(p.getDirection()), Optional.ofNullable(p.getSubType())));
Binary b = (Binary) p.getTypedValue();
if (b != null) {
try {
b.writeBase64(new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
list.add(Events.binaryContent(new String(cbuf, off, len)));
}
@Override
public void flush() throws IOException {
}
@Override
public void close() throws IOException {
}
});
} catch (IOException e) {
logger.error("Error: ", e);
}
}
list.add(Events.binaryDone());
}
}
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoDomStreamer method messageProperties.
private static List<Prop> messageProperties(Message msg) {
List<Property> all = msg.getAllProperties();
final List<Prop> result = new ArrayList<>();
for (Property property : all) {
result.add(create(property));
}
return Collections.unmodifiableList(result);
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoStreamCollector method createTmlProperty.
private Property createTmlProperty(Prop p) {
Property result;
if (Property.SELECTION_PROPERTY.equals(p.type())) {
result = NavajoFactory.getInstance().createProperty(assemble, p.name(), p.cardinality().orElse(null), p.description(), p.direction().orElse(null));
for (Select s : p.selections()) {
Selection sel = NavajoFactory.getInstance().createSelection(assemble, s.name(), s.value(), s.selected());
result.addSelection(sel);
}
} else {
result = NavajoFactory.getInstance().createProperty(assemble, p.name(), p.type() == null ? Property.STRING_PROPERTY : p.type(), null, p.length(), p.description(), p.direction().orElse(null));
if (p.value() != null) {
result.setAnyValue(p.value());
}
if (p.type() != null) {
result.setType(p.type());
}
}
return result;
}
use of com.dexels.navajo.document.Property in project navajo by Dexels.
the class NavajoStreamCollector method createBinaryProperty.
private Property createBinaryProperty(String name, Binary value) {
Property result = this.binaryProperties.get(name);
// Property result = NavajoFactory.getInstance().createProperty(assemble, name, Property.BINARY_PROPERTY, null,0,"", Property.DIR_IN);
if (result == null) {
logger.warn("Missing binary property with name " + name);
} else {
result.setAnyValue(value);
return result;
}
Property res = NavajoFactory.getInstance().createProperty(assemble, name, Property.BINARY_PROPERTY, null, 0, "", Property.DIR_IN);
return res;
}
Aggregations