@Override public void meet(ValueConstant node) throws RuntimeException { String val = node.getValue().stringValue(); switch (optypes.peek()) { case STRING: case URI: builder.append("'").append(val).append("'"); break; case INT: builder.append(Integer.parseInt(val)); break; case DECIMAL: case DOUBLE: builder.append(Double.parseDouble(val)); break; case BOOL: builder.append(Boolean.parseBoolean(val)); break; case DATE: builder.append("'").append(sqlDateFormat.format(DateUtils.parseDate(val))).append("'"); break; // in this case we should return a node ID and also need to make sure it actually exists case TERM: case NODE: KiWiNode n = parent.getConverter().convert(node.getValue()); builder.append(n.getId()); break; default: throw new IllegalArgumentException("unsupported value type: " + optypes.peek()); } }
@Override public void meet(Exists node) throws RuntimeException { // TODO: need to make sure that variables of the parent are visible in the subquery // - pattern names need to be unique even in subqueries // - variable lookup for expressions in the subquery need to refer to the parent SQLBuilder sq_builder = new SQLBuilder( node.getSubQuery(), parent.getBindings(), parent.getDataset(), parent.getConverter(), parent.getDialect(), "_", Collections.EMPTY_SET, copyVariables(parent.getVariables())); builder.append("EXISTS (").append(sq_builder.build()).append(")"); }