public void appendTo(SQLBuffer buf, FilterValue target, FilterValue[] args, ClassMapping type, JDBCStore store) { if (!args[0].isConstant()) throw new UserException(_loc.get("const-only", TAG)); if (!target.isPath()) throw new UserException(_loc.get("path-only", TAG)); // alias the column using the target's context, so that the // correct relation path to the target is used ClassMapping mapping = target.getClassMapping(); String colName = args[0].getValue().toString(); buf.append(target.getColumnAlias(colName, mapping.getTable())); }
private void appendXmlExist(SQLBuffer buf, FilterValue lhs) { buf.append(lhs.getColumnAlias( lhs.getFieldMapping().getColumns()[0])). append(".exist('"). append("/*["); lhs.appendTo(buf); }
cbFilter1 = new JComboBox(model); cbFilter1.setBounds(176, 70, 90, 20); cbFilter1.setSelectedIndex(5); // EDITED pnlOUT1.add(cbFilter1); cbFilter1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JComboBox comboBox = (JComboBox)e.getSource(); FilterValue item = (FilterValue)comboBox.getSelectedItem(); System.out.println( item.getValue() + " : " + item.getLabel() ); } });
/** * Append SQL for the given numeric value to the buffer, casting as needed. */ protected void appendNumericCast(SQLBuffer buf, FilterValue val) { if (val.isConstant()) appendCast(buf, val, Types.NUMERIC); else val.appendTo(buf); }
private void appendXmlValue(SQLBuffer buf, FilterValue val) { Class<?> rc = Filters.wrap(val.getType()); int type = getJDBCType(JavaTypes.getTypeCode(rc), false); boolean isXmlAttribute = (val.getXmlMapping() == null) ? false : val.getXmlMapping().isXmlAttribute(); buf.append(val.getColumnAlias(val.getFieldMapping().getColumns()[0])) .append(".value(").append("'(/*/"); val.appendTo(buf); if (!isXmlAttribute) buf.append("/text()"); buf.append(")[1]','").append(getTypeName(type)); appendLength(buf, type); buf.append("')"); }
boolean lhsxml = lhs.getXPath() != null; boolean rhsxml = rhs.getXPath() != null; if (lhsxml || rhsxml) { appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); Class lc = Filters.wrap(lhs.getType()); Class rc = Filters.wrap(rhs.getType()); if (lc == rc && lc == Boolean.class && lhs.isConstant() && rhs.isConstant()) { String lvalue = Boolean.TRUE.equals(lhs.getValue()) ? "1" : "0"; String rvalue = Boolean.TRUE.equals(rhs.getValue()) ? "1" : "0"; buf.append(lvalue).append(op).append(rvalue); return; || (lhs.isConstant() && rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c; castlhs = castlhs && lhs.requiresCast(); castrhs = castrhs && rhs.requiresCast(); appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else
public void appendTo(SQLBuffer buf, FilterValue target, FilterValue[] args, ClassMapping type, JDBCStore store) { if (!args[0].isConstant()) throw new UserException(_loc.get("const-only", TAG)); Object val = args[0].getValue(); target.appendTo(buf); if (val == null) buf.append(" IS ").appendValue(null); else buf.append(" LIKE ").appendValue("%" + val + "%"); } }
boolean castlhs = false; boolean castrhs = false; Class lc = Filters.wrap(lhs.getType()); Class rc = Filters.wrap(rhs.getType()); int type = 0; if (requiresCastForMathFunctions && (lc != rc || (lhs.isConstant() || rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c; appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else rhs.appendTo(buf);
public void appendTo(SQLBuffer buf, FilterValue target, FilterValue[] args, ClassMapping type, JDBCStore store) { if (!args[0].isConstant()) throw new UserException(_loc.get("const-only", TAG)); buf.append(args[0].getValue().toString()); }
boolean lhsxml = lhs.getXPath() != null; boolean rhsxml = rhs.getXPath() != null; if (lhsxml || rhsxml) { appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); Class lc = Filters.wrap(lhs.getType()); Class rc = Filters.wrap(rhs.getType()); int type = 0; if (requiresCastForComparisons && (lc != rc || (lhs.isConstant() && rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c; appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else rhs.appendTo(buf);
private void appendXmlVar(SQLBuffer buf, FilterValue val) { buf.append(val.getColumnAlias( val.getFieldMapping().getColumns()[0])). append(" AS "). append("\"").append(val.getColumnAlias( val.getFieldMapping().getColumns()[0])). append("\""); }
val.appendTo(buf); buf.append(mid); buf.append(getTypeName(type)); buf.append(post); } else { val.appendTo(buf); String sqlString = buf.getSQL(false); if (sqlString.endsWith("?")) { if (String.class.equals(val.getType())) typeName = typeName + "(" + characterColumnSize + ")"; String str = "CAST(? AS " + typeName + ")";
/* Could do the same for label, using val.getLabel() * and passing a String in parameter */ public void selectByValue(int value){ FilterValue row = null; for(FilterValue val : model){ //Searching for the corresponding FilterValue if(val.getValue() == value){ row = val; } } cbFilter1.setSelectedItem(row); //Select the corresponding row }
@Override public void substring(SQLBuffer buf, FilterValue str, FilterValue start, FilterValue length) { buf.append("SUBSTR(CAST(("); str.appendTo(buf); buf.append(") AS VARCHAR(").append(Integer.toString(varcharCastLength)) .append(")), "); if (start.getValue() instanceof Number) { buf.append(Long.toString(toLong(start))); } else { buf.append("CAST(("); start.appendTo(buf); buf.append(") AS INTEGER)"); } if (length != null) { buf.append(", "); if (length.getValue() instanceof Number) { buf.append(Long.toString(toLong(length))); } else { buf.append("CAST(("); length.appendTo(buf); buf.append(") AS INTEGER)"); } } buf.append(")"); } }
private void appendXmlValue(SQLBuffer buf, FilterValue val) { Class<?> rc = Filters.wrap(val.getType()); int type = getJDBCType(JavaTypes.getTypeCode(rc), false); boolean isXmlAttribute = (val.getXmlMapping() == null) ? false : val.getXmlMapping().isXmlAttribute(); buf.append(val.getColumnAlias(val.getFieldMapping().getColumns()[0])) .append(".value(").append("'(/*/"); val.appendTo(buf); if (!isXmlAttribute) buf.append("/text()"); buf.append(")[1]','").append(getTypeName(type)); appendLength(buf, type); buf.append("')"); }
boolean lhsxml = lhs.getXPath() != null; boolean rhsxml = rhs.getXPath() != null; if (lhsxml || rhsxml) { appendXmlComparison(buf, op, lhs, rhs, lhsxml, rhsxml); Class lc = Filters.wrap(lhs.getType()); Class rc = Filters.wrap(rhs.getType()); if (lc == rc && lc == Boolean.class && lhs.isConstant() && rhs.isConstant()) { String lvalue = Boolean.TRUE.equals(lhs.getValue()) ? "1" : "0"; String rvalue = Boolean.TRUE.equals(rhs.getValue()) ? "1" : "0"; buf.append(lvalue).append(op).append(rvalue); return; || (lhs.isConstant() && rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c; castlhs = castlhs && lhs.requiresCast(); castrhs = castrhs && rhs.requiresCast(); appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else
public void appendTo(SQLBuffer buf, FilterValue target, FilterValue[] args, ClassMapping type, JDBCStore store) { if (!args[0].isConstant()) throw new UserException(_loc.get("const-only", TAG)); Object val = args[0].getValue(); target.appendTo(buf); if (val == null) buf.append(" IS ").appendValue(null); else buf.append(" LIKE ").appendValue("%" + val + "%"); } }
boolean castlhs = false; boolean castrhs = false; Class lc = Filters.wrap(lhs.getType()); Class rc = Filters.wrap(rhs.getType()); int type = 0; if (requiresCastForMathFunctions && (lc != rc || (lhs.isConstant() || rhs.isConstant()))) { Class c = Filters.promote(lc, rc); type = getJDBCType(JavaTypes.getTypeCode(c), false); if (type != Types.VARBINARY && type != Types.BLOB) { castlhs = (lhs.isConstant() && rhs.isConstant()) || lc != c; castrhs = (lhs.isConstant() && rhs.isConstant()) || rc != c; appendCast(buf, lhs, type); else lhs.appendTo(buf); appendCast(buf, rhs, type); else rhs.appendTo(buf);
/** * Append SQL for the given numeric value to the buffer, casting as needed. */ protected void appendNumericCast(SQLBuffer buf, FilterValue val) { if (val.isConstant()) appendCast(buf, val, Types.NUMERIC); else val.appendTo(buf); }