use of com.github.fabriciofx.cactoos.jdbc.statement.StatementSelect in project cactoos-jdbc by fabriciofx.
the class ContactSql method about.
@Override
public String about() throws Exception {
final String contact = new ResultSetAsValue<String>(new StatementSelect(this.session, new QuerySimple("SELECT name FROM contact WHERE id = :id", new ParamUuid("id", this.id)))).value();
final String phones = new ResultSetAsXmlEach(new StatementSelect(this.session, new QuerySimple(new Joined(" ", "SELECT number, carrier FROM phone WHERE", "contact_id = :contact_id"), new ParamUuid("contact_id", this.id))), "phone").value();
final String xml;
if (phones.isEmpty()) {
xml = "<contact><name>%s</name></contact>";
} else {
xml = "<contact><name>%s</name><phones>%s</phones></contact>";
}
return new FormattedText(xml, contact, phones).asString();
}
Aggregations