|
Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/JdbcValueHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/JdbcValueHandler.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/JdbcValueHandler.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/JdbcValueHandler.java Wed Aug 11 13:22:40 2010 @@ -44,18 +44,18 @@ import org.ofbiz.base.util.Debug; * <code>PreparedStatement</code> and <code>ResultSet</code> objects. * */ -public abstract class JdbcValueHandler { +public abstract class JdbcValueHandler<T> { public static final String module = JdbcValueHandler.class.getName(); - private static final Map<String, JdbcValueHandler> JdbcValueHandlerMap = createJdbcValueHandlerMap(); + private static final Map<String, JdbcValueHandler<?>> JdbcValueHandlerMap = createJdbcValueHandlerMap(); private static final Map<String, Integer> SqlTypeMap = createSqlTypeMap(); - private static Map<String, JdbcValueHandler> createJdbcValueHandlerMap() { + private static Map<String, JdbcValueHandler<?>> createJdbcValueHandlerMap() { /* This Map is used to select the correct JdbcValueHandler for the specified Java type. The JdbcValueHandler instances are initialized with the SQL type recommended by Sun/Oracle. */ - Map<String, JdbcValueHandler> result = FastMap.newInstance(); + Map<String, JdbcValueHandler<?>> result = FastMap.newInstance(); // JDBC 1 result.put("byte[]", new ByteArrayJdbcValueHandler(Types.LONGVARBINARY)); result.put("java.lang.Boolean", new BooleanJdbcValueHandler(Types.BOOLEAN)); @@ -146,8 +146,8 @@ public abstract class JdbcValueHandler { * @param sqlType The SQL type specified in fieldtype*.xml * @return A <code>JdbcValueHandler</code> instance */ - public static JdbcValueHandler getInstance(String javaType, String sqlType) { - JdbcValueHandler handler = JdbcValueHandlerMap.get(javaType); + public static JdbcValueHandler<?> getInstance(String javaType, String sqlType) { + JdbcValueHandler<?> handler = JdbcValueHandlerMap.get(javaType); if (handler != null) { String key = parseSqlType(sqlType); Integer sqlTypeInt = SqlTypeMap.get(key); @@ -230,9 +230,9 @@ public abstract class JdbcValueHandler { * @param obj * @throws SQLException */ - protected abstract void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException; + protected abstract void castAndSetValue(PreparedStatement ps, int parameterIndex, T obj) throws SQLException; - protected JdbcValueHandler create(int sqlType) { + protected JdbcValueHandler<T> create(int sqlType) { if (sqlType == this.getSqlType()) { return this; } @@ -257,7 +257,7 @@ public abstract class JdbcValueHandler { * @return * @throws SQLException */ - public abstract Object getValue(ResultSet rs, int columnIndex) throws SQLException; + public abstract T getValue(ResultSet rs, int columnIndex) throws SQLException; /** * Returns a new instance of the object - initialized with @@ -265,7 +265,9 @@ public abstract class JdbcValueHandler { * @param sqlType * @return */ - protected abstract JdbcValueHandler newInstance(int sqlType); + protected abstract JdbcValueHandler<T> newInstance(int sqlType); + + public abstract Class<T> getJavaClass(); /** Sets a value in a <code>PreparedStatement</code>. The * <code>obj</code> argument is converted to the correct data @@ -276,7 +278,7 @@ public abstract class JdbcValueHandler { * @param obj * @throws SQLException */ - public void setValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { + public void setValue(PreparedStatement ps, int parameterIndex, T obj) throws SQLException { if (obj == null) { ps.setNull(parameterIndex, this.getSqlType()); return; @@ -287,20 +289,24 @@ public abstract class JdbcValueHandler { /** * A <code>java.math.BigDecimal</code> JDBC value handler. */ - protected static class BigDecimalJdbcValueHandler extends JdbcValueHandler { + protected static class BigDecimalJdbcValueHandler extends JdbcValueHandler<java.math.BigDecimal> { protected BigDecimalJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setBigDecimal(parameterIndex, (java.math.BigDecimal) obj); + public Class<java.math.BigDecimal> getJavaClass() { + return java.math.BigDecimal.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, java.math.BigDecimal obj) throws SQLException { + ps.setBigDecimal(parameterIndex, obj); + } + @Override + public java.math.BigDecimal getValue(ResultSet rs, int columnIndex) throws SQLException { return rs.getBigDecimal(columnIndex); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<java.math.BigDecimal> newInstance(int sqlType) { return new BigDecimalJdbcValueHandler(sqlType); } } @@ -308,11 +314,15 @@ public abstract class JdbcValueHandler { /** * A <code>java.sql.Blob</code> JDBC value handler. */ - protected static class BlobJdbcValueHandler extends JdbcValueHandler { + protected static class BlobJdbcValueHandler extends JdbcValueHandler<Object> { protected BlobJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override + public Class<Object> getJavaClass() { + return Object.class; + } + @Override protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { try { // FIXME: This is here for backwards compatibility. Client code @@ -375,7 +385,7 @@ public abstract class JdbcValueHandler { return null; } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Object> newInstance(int sqlType) { return new BlobJdbcValueHandler(sqlType); } } @@ -383,21 +393,25 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Boolean</code> JDBC value handler. */ - protected static class BooleanJdbcValueHandler extends JdbcValueHandler { + protected static class BooleanJdbcValueHandler extends JdbcValueHandler<Boolean> { protected BooleanJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setBoolean(parameterIndex, (Boolean) obj); + public Class<Boolean> getJavaClass() { + return Boolean.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Boolean obj) throws SQLException { + ps.setBoolean(parameterIndex, obj); + } + @Override + public Boolean getValue(ResultSet rs, int columnIndex) throws SQLException { boolean value = rs.getBoolean(columnIndex); return rs.wasNull() ? null : Boolean.valueOf(value); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Boolean> newInstance(int sqlType) { return new BooleanJdbcValueHandler(sqlType); } } @@ -405,21 +419,25 @@ public abstract class JdbcValueHandler { /** * A <code>byte[]</code> JDBC value handler. */ - protected static class ByteArrayJdbcValueHandler extends JdbcValueHandler { + protected static class ByteArrayJdbcValueHandler extends JdbcValueHandler<byte[]> { protected ByteArrayJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setBytes(parameterIndex, (byte[]) obj); + public Class<byte[]> getJavaClass() { + return byte[].class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, byte[] obj) throws SQLException { + ps.setBytes(parameterIndex, obj); + } + @Override + public byte[] getValue(ResultSet rs, int columnIndex) throws SQLException { byte[] value = rs.getBytes(columnIndex); return rs.wasNull() ? null : value; } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<byte[]> newInstance(int sqlType) { return new ByteArrayJdbcValueHandler(sqlType); } } @@ -427,11 +445,15 @@ public abstract class JdbcValueHandler { /** * A <code>java.sql.Clob</code> JDBC value handler. */ - protected static class ClobJdbcValueHandler extends JdbcValueHandler { + protected static class ClobJdbcValueHandler extends JdbcValueHandler<Object> { protected ClobJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override + public Class<Object> getJavaClass() { + return Object.class; + } + @Override protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { try { // FIXME: This is here for backwards compatibility. Client code @@ -478,7 +500,7 @@ public abstract class JdbcValueHandler { } } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Object> newInstance(int sqlType) { return new ClobJdbcValueHandler(sqlType); } } @@ -486,20 +508,24 @@ public abstract class JdbcValueHandler { /** * A <code>java.sql.Date</code> JDBC value handler. */ - protected static class DateJdbcValueHandler extends JdbcValueHandler { + protected static class DateJdbcValueHandler extends JdbcValueHandler<java.sql.Date> { protected DateJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setDate(parameterIndex, (java.sql.Date) obj); + public Class<java.sql.Date> getJavaClass() { + return java.sql.Date.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, java.sql.Date obj) throws SQLException { + ps.setDate(parameterIndex, obj); + } + @Override + public java.sql.Date getValue(ResultSet rs, int columnIndex) throws SQLException { return rs.getDate(columnIndex); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<java.sql.Date> newInstance(int sqlType) { return new DateJdbcValueHandler(sqlType); } } @@ -507,21 +533,25 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Double</code> JDBC value handler. */ - protected static class DoubleJdbcValueHandler extends JdbcValueHandler { + protected static class DoubleJdbcValueHandler extends JdbcValueHandler<Double> { protected DoubleJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setDouble(parameterIndex, (Double) obj); + public Class<Double> getJavaClass() { + return Double.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Double obj) throws SQLException { + ps.setDouble(parameterIndex, obj); + } + @Override + public Double getValue(ResultSet rs, int columnIndex) throws SQLException { double value = rs.getDouble(columnIndex); return rs.wasNull() ? null : Double.valueOf(value); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Double> newInstance(int sqlType) { return new DoubleJdbcValueHandler(sqlType); } } @@ -529,21 +559,25 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Float</code> JDBC value handler. */ - protected static class FloatJdbcValueHandler extends JdbcValueHandler { + protected static class FloatJdbcValueHandler extends JdbcValueHandler<Float> { protected FloatJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setFloat(parameterIndex, (Float) obj); + public Class<Float> getJavaClass() { + return Float.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Float obj) throws SQLException { + ps.setFloat(parameterIndex, obj); + } + @Override + public Float getValue(ResultSet rs, int columnIndex) throws SQLException { float value = rs.getFloat(columnIndex); return rs.wasNull() ? null : Float.valueOf(value); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Float> newInstance(int sqlType) { return new FloatJdbcValueHandler(sqlType); } } @@ -551,21 +585,25 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Integer</code> JDBC value handler. */ - protected static class IntegerJdbcValueHandler extends JdbcValueHandler { + protected static class IntegerJdbcValueHandler extends JdbcValueHandler<Integer> { protected IntegerJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setInt(parameterIndex, (Integer) obj); + public Class<Integer> getJavaClass() { + return Integer.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Integer obj) throws SQLException { + ps.setInt(parameterIndex, obj); + } + @Override + public Integer getValue(ResultSet rs, int columnIndex) throws SQLException { int value = rs.getInt(columnIndex); return rs.wasNull() ? null : Integer.valueOf(value); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Integer> newInstance(int sqlType) { return new IntegerJdbcValueHandler(sqlType); } } @@ -573,21 +611,25 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Long</code> JDBC value handler. */ - protected static class LongJdbcValueHandler extends JdbcValueHandler { + protected static class LongJdbcValueHandler extends JdbcValueHandler<Long> { protected LongJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setLong(parameterIndex, (Long) obj); + public Class<Long> getJavaClass() { + return Long.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Long obj) throws SQLException { + ps.setLong(parameterIndex, obj); + } + @Override + public Long getValue(ResultSet rs, int columnIndex) throws SQLException { long value = rs.getLong(columnIndex); return rs.wasNull() ? null : Long.valueOf(value); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Long> newInstance(int sqlType) { return new LongJdbcValueHandler(sqlType); } } @@ -595,11 +637,15 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Object</code> JDBC value handler. */ - protected static class ObjectJdbcValueHandler extends JdbcValueHandler { + protected static class ObjectJdbcValueHandler extends JdbcValueHandler<Object> { protected ObjectJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override + public Class<Object> getJavaClass() { + return Object.class; + } + @Override protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { ps.setBytes(parameterIndex, serializeObject(obj)); } @@ -630,7 +676,7 @@ public abstract class JdbcValueHandler { } } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Object> newInstance(int sqlType) { return new ObjectJdbcValueHandler(sqlType); } } @@ -638,21 +684,25 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.Short</code> JDBC value handler. */ - protected static class ShortJdbcValueHandler extends JdbcValueHandler { + protected static class ShortJdbcValueHandler extends JdbcValueHandler<Short> { protected ShortJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setShort(parameterIndex, (Short) obj); + public Class<Short> getJavaClass() { + return Short.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Short obj) throws SQLException { + ps.setShort(parameterIndex, obj); + } + @Override + public Short getValue(ResultSet rs, int columnIndex) throws SQLException { short value = rs.getShort(columnIndex); return rs.wasNull() ? null : Short.valueOf(value); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<Short> newInstance(int sqlType) { return new ShortJdbcValueHandler(sqlType); } } @@ -660,20 +710,24 @@ public abstract class JdbcValueHandler { /** * A <code>java.lang.String</code> JDBC value handler. */ - protected static class StringJdbcValueHandler extends JdbcValueHandler { + protected static class StringJdbcValueHandler extends JdbcValueHandler<String> { protected StringJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setString(parameterIndex, (String) obj); + public Class<String> getJavaClass() { + return String.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, String obj) throws SQLException { + ps.setString(parameterIndex, obj); + } + @Override + public String getValue(ResultSet rs, int columnIndex) throws SQLException { return rs.getString(columnIndex); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<String> newInstance(int sqlType) { return new StringJdbcValueHandler(sqlType); } } @@ -681,20 +735,24 @@ public abstract class JdbcValueHandler { /** * A <code>java.sql.Time</code> JDBC value handler. */ - protected static class TimeJdbcValueHandler extends JdbcValueHandler { + protected static class TimeJdbcValueHandler extends JdbcValueHandler<java.sql.Time> { protected TimeJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setTime(parameterIndex, (java.sql.Time) obj); + public Class<java.sql.Time> getJavaClass() { + return java.sql.Time.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, java.sql.Time obj) throws SQLException { + ps.setTime(parameterIndex, obj); + } + @Override + public java.sql.Time getValue(ResultSet rs, int columnIndex) throws SQLException { return rs.getTime(columnIndex); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<java.sql.Time> newInstance(int sqlType) { return new TimeJdbcValueHandler(sqlType); } } @@ -707,26 +765,30 @@ public abstract class JdbcValueHandler { * will be stored as JDBC timestamp escape format strings * (<code>yyyy-mm-dd hh:mm:ss.fffffffff</code>), referenced to UTC.</p> */ - protected static class TimestampJdbcValueHandler extends JdbcValueHandler { + protected static class TimestampJdbcValueHandler extends JdbcValueHandler<java.sql.Timestamp> { protected TimestampJdbcValueHandler(int jdbcType) { super(jdbcType); } @Override - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setTimestamp(parameterIndex, (java.sql.Timestamp) obj); + public Class<java.sql.Timestamp> getJavaClass() { + return java.sql.Timestamp.class; } @Override - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, java.sql.Timestamp obj) throws SQLException { + ps.setTimestamp(parameterIndex, obj); + } + @Override + public java.sql.Timestamp getValue(ResultSet rs, int columnIndex) throws SQLException { return rs.getTimestamp(columnIndex); } @Override - protected JdbcValueHandler newInstance(int sqlType) { + protected JdbcValueHandler<java.sql.Timestamp> newInstance(int sqlType) { if (sqlType == Types.CHAR) { return new TimestampJdbcValueHandler(sqlType) { - protected void castAndSetValue(PreparedStatement ps, int parameterIndex, Object obj) throws SQLException { - ps.setString(parameterIndex, ((java.sql.Timestamp) obj).toString()); + protected void castAndSetValue(PreparedStatement ps, int parameterIndex, java.sql.Timestamp obj) throws SQLException { + ps.setString(parameterIndex, obj.toString()); } - public Object getValue(ResultSet rs, int columnIndex) throws SQLException { + public java.sql.Timestamp getValue(ResultSet rs, int columnIndex) throws SQLException { String str = rs.getString(columnIndex); if (str == null) { return null; Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SQLProcessor.java Wed Aug 11 13:22:40 2010 @@ -35,7 +35,6 @@ import java.sql.Types; import java.util.ArrayList; import java.util.List; -import org.ofbiz.base.conversion.ConversionException; import org.ofbiz.base.util.Debug; import org.ofbiz.entity.GenericDataSourceException; import org.ofbiz.entity.GenericEntityException; @@ -533,7 +532,7 @@ public class SQLProcessor { * * @throws SQLException */ - public void setValue(JdbcValueHandler handler, Object field) throws SQLException { + public <T> void setValue(JdbcValueHandler<T> handler, T field) throws SQLException { handler.setValue(_ps, _ind, field); _ind++; } Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java Wed Aug 11 13:22:40 2010 @@ -735,7 +735,7 @@ public class SqlJdbcUtil { setValue(sqlP, modelField, entity.getEntityName(), fieldValue, modelFieldTypeReader); } - public static void setValue(SQLProcessor sqlP, ModelField modelField, String entityName, Object fieldValue, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException { + public static <T> void setValue(SQLProcessor sqlP, ModelField modelField, String entityName, Object fieldValue, ModelFieldTypeReader modelFieldTypeReader) throws GenericEntityException { ModelFieldType mft = modelFieldTypeReader.getModelFieldType(modelField.getType()); if (mft == null) { @@ -750,10 +750,10 @@ public class SqlJdbcUtil { // ----- Try out the new handler code ----- - JdbcValueHandler handler = mft.getJdbcValueHandler(); + JdbcValueHandler<T> handler = UtilGenerics.cast(mft.getJdbcValueHandler()); if (handler != null) { try { - sqlP.setValue(handler, fieldValue); + sqlP.setValue(handler, handler.getJavaClass().cast(fieldValue)); return; } catch (SQLException e) { throw new GenericDataSourceException("SQL Exception while setting value on field [" + modelField.getName() + "] of entity " + entityName + ": ", e); Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityConditionPlanner.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityConditionPlanner.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityConditionPlanner.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityConditionPlanner.java Wed Aug 11 13:22:40 2010 @@ -23,21 +23,18 @@ import java.util.Map; import javolution.util.FastList; -import org.ofbiz.entity.condition.EntityFieldValue; import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionValue; +import org.ofbiz.entity.condition.EntityFieldValue; import org.ofbiz.entity.condition.EntityOperator; - import org.ofbiz.sql.BooleanCondition; import org.ofbiz.sql.Condition; import org.ofbiz.sql.ConditionList; -import org.ofbiz.sql.ConditionPlan; import org.ofbiz.sql.ConditionPlanner; import org.ofbiz.sql.FieldValue; import org.ofbiz.sql.Joiner; import org.ofbiz.sql.NumberValue; -import org.ofbiz.sql.ParameterizedConditionException; import org.ofbiz.sql.ParameterValue; +import org.ofbiz.sql.ParameterizedConditionException; import org.ofbiz.sql.StringValue; import org.ofbiz.sql.Value; Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntityPlanner.java Wed Aug 11 13:22:40 2010 @@ -24,34 +24,25 @@ import java.util.List; import javolution.util.FastList; -import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.condition.EntityFieldValue; import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionValue; -import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.DynamicViewEntity; +import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.model.ModelViewEntity.ComplexAlias; import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasField; import org.ofbiz.entity.model.ModelViewEntity.ComplexAliasMember; -import org.ofbiz.entity.model.ModelKeyMap; - -import org.ofbiz.sql.BooleanCondition; -import org.ofbiz.sql.Condition; -import org.ofbiz.sql.ConditionList; import org.ofbiz.sql.ConstantValue; import org.ofbiz.sql.FieldAll; import org.ofbiz.sql.FieldDef; import org.ofbiz.sql.FieldValue; import org.ofbiz.sql.FunctionCall; import org.ofbiz.sql.Joined; -import org.ofbiz.sql.Joiner; import org.ofbiz.sql.KeyMap; import org.ofbiz.sql.MathValue; import org.ofbiz.sql.NumberValue; import org.ofbiz.sql.OrderByItem; import org.ofbiz.sql.Planner; -import org.ofbiz.sql.MathValue; import org.ofbiz.sql.Relation; +import org.ofbiz.sql.SelectGroup; import org.ofbiz.sql.SQLDelete; import org.ofbiz.sql.SQLInsert; import org.ofbiz.sql.SQLSelect; @@ -61,6 +52,7 @@ import org.ofbiz.sql.StaticValue; import org.ofbiz.sql.StringValue; import org.ofbiz.sql.Table; import org.ofbiz.sql.TableName; +import org.ofbiz.sql.Unioned; import org.ofbiz.sql.Value; public class EntityPlanner extends Planner<EntityPlanner, EntityCondition, EntityDeletePlan, EntityInsertPlan, EntitySelectPlan, EntityUpdatePlan, EntityViewPlan> { @@ -78,20 +70,25 @@ public class EntityPlanner extends Plann public EntitySelectPlan planSelect(SQLSelect selectStatement) { DynamicViewEntity dve = new DynamicViewEntity(); - Table table = selectStatement.getTable(); + Unioned unioned = selectStatement.getUnioned(); + if (unioned.getOperator() != null || unioned.getNext() != null) { + throw new IllegalArgumentException("union views not yet supported"); + } + SelectGroup selectGroup = unioned.getGroup(); + Table table = selectGroup.getTable(); addMember(dve, table.getTableName()); addJoined(dve, table.getTableName().getAlias(), table.getJoined()); - for (FieldAll fieldAll: selectStatement.getFieldAlls()) { + for (FieldAll fieldAll: selectGroup.getFieldAlls()) { dve.addAliasAll(fieldAll.getAlias(), null); } for (Relation relation: selectStatement.getRelations().values()) { dve.addRelation(relation.getType(), relation.getTitle(), relation.getEntityName(), buildKeyMaps(relation)); } - List<String> groupBy = selectStatement.getGroupBy(); + List<String> groupBy = selectGroup.getGroupBy(); if (groupBy == null) { groupBy = Collections.emptyList(); } - for (FieldDef fieldDef: selectStatement.getFieldDefs()) { + for (FieldDef fieldDef: selectGroup.getFieldDefs()) { addFieldDef(dve, groupBy, fieldDef.getAlias(), fieldDef); } List<String> orderBy; @@ -103,7 +100,7 @@ public class EntityPlanner extends Plann orderBy.add(orderByItem.toString()); } } - return new EntitySelectPlan(dve, plan(selectStatement.getWhereCondition()), plan(selectStatement.getHavingCondition()), orderBy); + return new EntitySelectPlan(dve, plan(selectGroup.getWhereCondition()), plan(selectGroup.getHavingCondition()), orderBy); } public EntityUpdatePlan planUpdate(SQLUpdate updateStatement) { Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntitySelectPlan.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntitySelectPlan.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntitySelectPlan.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/EntitySelectPlan.java Wed Aug 11 13:22:40 2010 @@ -19,29 +19,19 @@ package org.ofbiz.entity.sql; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.concurrent.Callable; -import javolution.util.FastList; -import javolution.util.FastMap; - -import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityOperator; -import org.ofbiz.entity.model.DynamicViewEntity; - import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; import org.ofbiz.entity.model.DynamicViewEntity; -import org.ofbiz.entity.model.ModelKeyMap; import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.entity.util.EntityListIterator; - -import org.ofbiz.sql.SelectPlan; import org.ofbiz.sql.ConditionPlan; import org.ofbiz.sql.ParameterizedConditionException; +import org.ofbiz.sql.SelectPlan; public final class EntitySelectPlan extends SelectPlan<EntitySelectPlan, EntityCondition> { private final DynamicViewEntity dve; Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/sql/SQLUtil.java Wed Aug 11 13:22:40 2010 @@ -19,14 +19,12 @@ package org.ofbiz.entity.sql; import java.io.StringReader; -import java.util.List; import org.ofbiz.entity.condition.EntityCondition; - +import org.ofbiz.sql.OrderByItem; import org.ofbiz.sql.Parser; import org.ofbiz.sql.ParseException; -import org.ofbiz.sql.SQLPlan; -import org.ofbiz.sql.SQLStatement; +import org.ofbiz.sql.Parser; public class SQLUtil { private static final EntityPlanner planner = new EntityPlanner(); @@ -38,6 +36,10 @@ public class SQLUtil { public static EntitySelectPlan parseSelect(String sql) throws ParseException { return planner.planSelect(updateParserFlags(new Parser(new StringReader(sql))).SelectStatement()); } + + public static OrderByItem parseOrderByItem(String sql) throws ParseException { + return updateParserFlags(new Parser(new StringReader(sql))).OrderByItem(); + } /* public static EntityCondition parseCondition(String condition) throws ParseException { return new Parser(new StringReader(condition)).EntityCondition(); Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntitySaxReader.java Wed Aug 11 13:22:40 2010 @@ -218,7 +218,19 @@ public class EntitySaxReader implements return 0; } Debug.logImportant("Beginning import from URL: " + location.toExternalForm(), module); - return this.parse(location.openStream(), location.toString()); + InputStream is = null; + long numberRead = 0; + try { + is = location.openStream(); + numberRead = this.parse(is, location.toString()); + } finally { + if (is != null) { + try { + is.close(); + } catch(Exception e) {} + } + } + return numberRead; } public long parse(InputStream is, String docDescription) throws SAXException, java.io.IOException { Modified: ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntityTypeUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntityTypeUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntityTypeUtil.java (original) +++ ofbiz/branches/jquery/framework/entity/src/org/ofbiz/entity/util/EntityTypeUtil.java Wed Aug 11 13:22:40 2010 @@ -23,6 +23,8 @@ import java.util.Collection; import java.util.List; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -115,4 +117,38 @@ public class EntityTypeUtil { return isType(getParentType(thisType), targetType); } } + + /** + * A generic method to be used on Type enities, e.g. ProductType. Recurse to the root level in the type hierarchy + * and checks if the specified type childType has parentType as its parent somewhere in the hierarchy. + * + * @param delegator The Delegator object. + * @param entityName Name of the Type entity on which check is performed. + * @param primaryKey Primary Key field of the Type entity. + * @param childType Type value for which the check is performed. + * @param parentTypeField Field in Type entity which stores the parent type. + * @param parentType Value of the parent type against which check is performed. + * @return boolean value based on the check results. + */ + public static boolean hasParentType(Delegator delegator, String entityName, String primaryKey, String childType, String parentTypeField, String parentType) { + GenericValue childTypeValue = null; + try { + childTypeValue = delegator.findOne(entityName, UtilMisc.toMap(primaryKey, childType), true); + } catch (GenericEntityException e) { + Debug.logError("Error finding "+entityName+" record for type "+childType, module); + } + if (childTypeValue != null) { + if (parentType.equals(childTypeValue.getString(primaryKey))) return true; + + if (childTypeValue.getString(parentTypeField) != null) { + if (parentType.equals(childTypeValue.getString(parentTypeField))) { + return true; + } else { + return hasParentType(delegator, entityName, primaryKey, childTypeValue.getString(parentTypeField), parentTypeField, parentType); + } + } + } + + return false; + } } Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/EntityWatchServices.java Wed Aug 11 13:22:40 2010 @@ -18,27 +18,14 @@ *******************************************************************************/ package org.ofbiz.entityext; -import org.ofbiz.service.ServiceUtil; -import org.ofbiz.service.DispatchContext; -import org.ofbiz.service.LocalDispatcher; -import org.ofbiz.service.GenericServiceException; -import org.ofbiz.security.Security; -import org.ofbiz.entity.Delegator; -import org.ofbiz.entity.GenericEntityException; -import org.ofbiz.entity.GenericValue; -import org.ofbiz.entity.jdbc.DatabaseUtil; -import org.ofbiz.entity.model.ModelEntity; -import org.ofbiz.entity.model.ModelField; -import org.ofbiz.base.util.GeneralException; +import java.util.Map; + import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.UtilURL; -import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; - -import java.util.Map; -import java.net.URI; -import java.net.URL; -import java.net.URISyntaxException; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ServiceUtil; public class EntityWatchServices { Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java Wed Aug 11 13:22:40 2010 @@ -18,13 +18,13 @@ *******************************************************************************/ package org.ofbiz.entityext.data; -import java.net.URL; +import java.io.File; import java.net.MalformedURLException; +import java.net.URL; import java.text.NumberFormat; import java.util.List; import java.util.Map; import java.util.TreeSet; -import java.io.File; import javolution.util.FastList; @@ -37,7 +37,6 @@ import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.DelegatorFactory; -import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.datasource.GenericHelperInfo; import org.ofbiz.entity.jdbc.DatabaseUtil; Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/DelegatorEcaHandler.java Wed Aug 11 13:22:40 2010 @@ -25,8 +25,6 @@ import java.util.TreeSet; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilValidate; - -import static org.ofbiz.base.util.UtilGenerics.checkList; import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaCondition.java Wed Aug 11 13:22:40 2010 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.entityext.eca; -import java.util.Iterator; import java.util.List; import javolution.util.FastList; Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaUtil.java Wed Aug 11 13:22:40 2010 @@ -18,12 +18,9 @@ *******************************************************************************/ package org.ofbiz.entityext.eca; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; +import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.Collection; import javolution.util.FastList; import javolution.util.FastMap; @@ -35,10 +32,10 @@ import org.ofbiz.base.config.ResourceHan import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.cache.UtilCache; +import org.ofbiz.entity.Delegator; import org.ofbiz.entity.config.DelegatorInfo; import org.ofbiz.entity.config.EntityConfigUtil; import org.ofbiz.entity.config.EntityEcaReaderInfo; -import org.ofbiz.entity.Delegator; import org.w3c.dom.Element; /** Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncContext.java Wed Aug 11 13:22:40 2010 @@ -25,6 +25,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; + import javax.xml.parsers.ParserConfigurationException; import javolution.util.FastList; @@ -41,11 +42,8 @@ import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.condition.EntityCondition; -import org.ofbiz.entity.condition.EntityConditionList; -import org.ofbiz.entity.condition.EntityExpr; import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.entity.model.ModelEntity; -import org.ofbiz.entity.model.ModelViewEntity; import org.ofbiz.entity.serialize.SerializeException; import org.ofbiz.entity.serialize.XmlSerializer; import org.ofbiz.entity.transaction.GenericTransactionException; @@ -58,7 +56,6 @@ import org.ofbiz.service.GenericServiceE import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; import org.ofbiz.service.ServiceUtil; - import org.xml.sax.SAXException; /** Modified: ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java (original) +++ ofbiz/branches/jquery/framework/entityext/src/org/ofbiz/entityext/synchronization/EntitySyncServices.java Wed Aug 11 13:22:40 2010 @@ -25,10 +25,8 @@ import java.net.URL; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Date; -import java.util.Iterator; import java.util.List; import java.util.Map; Modified: ofbiz/branches/jquery/framework/example/webapp/example/WEB-INF/actions/includes/FindExampleFeatures.groovy URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/example/webapp/example/WEB-INF/actions/includes/FindExampleFeatures.groovy?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/example/webapp/example/WEB-INF/actions/includes/FindExampleFeatures.groovy (original) +++ ofbiz/branches/jquery/framework/example/webapp/example/WEB-INF/actions/includes/FindExampleFeatures.groovy Wed Aug 11 13:22:40 2010 @@ -41,4 +41,4 @@ if (andExprs) { //context.autocompleteOptions = autocompleteOptions; request.setAttribute("autocompleteOptions", autocompleteOptions); } -return "success"; \ No newline at end of file +return "success"; Modified: ofbiz/branches/jquery/framework/example/widget/example/BirtScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/example/widget/example/BirtScreens.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/example/widget/example/BirtScreens.xml (original) +++ ofbiz/branches/jquery/framework/example/widget/example/BirtScreens.xml Wed Aug 11 13:22:40 2010 @@ -87,4 +87,4 @@ under the License. </widgets> </section> </screen> -</screens> \ No newline at end of file +</screens> Modified: ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupForms.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupForms.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupForms.xml (original) +++ ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupForms.xml Wed Aug 11 13:22:40 2010 @@ -103,4 +103,4 @@ under the License. </field> </form> -</forms> \ No newline at end of file +</forms> Modified: ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupScreens.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupScreens.xml (original) +++ ofbiz/branches/jquery/framework/example/widget/example/FormWidgetExampleLookupScreens.xml Wed Aug 11 13:22:40 2010 @@ -143,4 +143,4 @@ under the License. </section> </screen> -</screens> \ No newline at end of file +</screens> Modified: ofbiz/branches/jquery/framework/images/webapp/images/selectall.js URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/images/webapp/images/selectall.js?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/images/webapp/images/selectall.js (original) +++ ofbiz/branches/jquery/framework/images/webapp/images/selectall.js Wed Aug 11 13:22:40 2010 @@ -345,7 +345,7 @@ function ajaxSubmitFormUpdateAreas(form, * form of: areaId, target, target parameters [, areaId, target, target parameters...]. */ function ajaxAutoCompleter(areaCsvString, showDescription) { - var areaArray = areaCsvString.replace('&','&').split(","); + var areaArray = areaCsvString.replace(/&/g,'&').split(","); var numAreas = parseInt(areaArray.length / 3); for (var i = 0; i < numAreas * 3; i = i + 3) { @@ -579,7 +579,7 @@ function expandAll(expanded) { groupbody=divs1[j]; } } - if(groupbody.style.visible != expanded) { + if($(groupbody).visible() != expanded) { toggleCollapsiblePanel(links[0], groupbody.id, 'expand', 'collapse'); } } Modified: ofbiz/branches/jquery/framework/minilang/src/org/ofbiz/minilang/method/otherops/Log.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/minilang/src/org/ofbiz/minilang/method/otherops/Log.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/minilang/src/org/ofbiz/minilang/method/otherops/Log.java (original) +++ ofbiz/branches/jquery/framework/minilang/src/org/ofbiz/minilang/method/otherops/Log.java Wed Aug 11 13:22:40 2010 @@ -44,12 +44,14 @@ public class Log extends MethodOperation String levelStr; String message; + Object startLine; List<MethodString> methodStrings = null; public Log(Element element, SimpleMethod simpleMethod) { super(element, simpleMethod); this.message = element.getAttribute("message"); this.levelStr = element.getAttribute("level"); + this.startLine = element.getUserData("startLine"); List<? extends Element> methodStringElements = UtilXml.childElementList(element); if (methodStringElements.size() > 0) { @@ -97,6 +99,10 @@ public class Log extends MethodOperation buf.append(methodLocation); buf.append("#"); buf.append(this.simpleMethod.getMethodName()); + if (this.startLine != null) { + buf.append(" line "); + buf.append(this.startLine); + } buf.append("] "); if (message != null) buf.append(message); Modified: ofbiz/branches/jquery/framework/service/dtd/services.xsd URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/service/dtd/services.xsd?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/service/dtd/services.xsd (original) +++ ofbiz/branches/jquery/framework/service/dtd/services.xsd Wed Aug 11 13:22:40 2010 @@ -314,6 +314,7 @@ under the License. <xs:complexType> <xs:sequence> <xs:element minOccurs="0" maxOccurs="unbounded" ref="type-validate"/> + <xs:element minOccurs="0" ref="description" /> </xs:sequence> <xs:attributeGroup ref="attlist.attribute"/> </xs:complexType> Modified: ofbiz/branches/jquery/framework/service/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/service/servicedef/services.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/service/servicedef/services.xml (original) +++ ofbiz/branches/jquery/framework/service/servicedef/services.xml Wed Aug 11 13:22:40 2010 @@ -65,12 +65,25 @@ under the License. <!-- Service Engine Interfaces --> <service name="permissionInterface" engine="interface"> <description>Interface to describe base parameters for Permission Services</description> - <attribute name="mainAction" type="String" mode="IN" optional="true"/> + <attribute name="mainAction" type="String" mode="IN" optional="true"> + <description>The action requiring permission. Must be one of ADMIN, CREATE, UPDATE, DELETE, VIEW.</description> + </attribute> + <attribute name="primaryPermission" type="String" mode="IN" optional="true"> + <description>The permission to check - typically the name of an application or entity.</description> + </attribute> + <attribute name="altPermission" type="String" mode="IN" optional="true"> + <description>Optional alternate permission to check. If the primary permission check fails, + the alternate permission will be checked.</description> + </attribute> <attribute name="resourceDescription" type="String" mode="IN" optional="true"> - <!-- Note that this will be filled in either with what the user specifies in the service definition, or will default to the service name. --> + <description>The name of the resource being accessed - defaults to service name.</description> + </attribute> + <attribute name="hasPermission" type="Boolean" mode="OUT" optional="false"> + <description>Contains true if the requested permission has been granted.</description> + </attribute> + <attribute name="failMessage" type="String" mode="OUT" optional="true"> + <description>Contains an explanation if the permission was denied.</description> </attribute> - <attribute name="hasPermission" type="Boolean" mode="OUT" optional="false"/> - <attribute name="failMessage" type="String" mode="OUT" optional="true"/> </service> <service name="authenticationInterface" engine="interface"> @@ -84,7 +97,7 @@ under the License. </service> <service name="serviceStreamInterface" engine="interface"> - <description>Inteface to describe services call with streams</description> + <description>Interface to describe services call with streams</description> <attribute name="inputStream" type="java.io.InputStream" mode="IN"/> <attribute name="outputStream" type="java.io.OutputStream" mode="IN"/> <attribute name="contentType" type="String" mode="OUT"/> Modified: ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelParam.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelParam.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelParam.java (original) +++ ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelParam.java Wed Aug 11 13:22:40 2010 @@ -43,6 +43,9 @@ public class ModelParam implements Seria /** Parameter name */ public String name; + /** The description of this parameter */ + public String description; + /** Paramater type */ public String type; @@ -88,6 +91,7 @@ public class ModelParam implements Seria public ModelParam(ModelParam param) { this.name = param.name; + this.description = param.description; this.type = param.type; this.mode = param.mode; this.formLabel = param.formLabel; Modified: ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelPermission.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelPermission.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelPermission.java (original) +++ ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelPermission.java Wed Aug 11 13:22:40 2010 @@ -159,4 +159,4 @@ public class ModelPermission implements } return ((Boolean) resp.get("hasPermission")).booleanValue(); } -} \ No newline at end of file +} Modified: ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelServiceReader.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelServiceReader.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelServiceReader.java (original) +++ ofbiz/branches/jquery/framework/service/src/org/ofbiz/service/ModelServiceReader.java Wed Aug 11 13:22:40 2010 @@ -23,7 +23,6 @@ import java.io.Serializable; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URL; -import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; @@ -518,6 +517,7 @@ public class ModelServiceReader implemen ModelParam param = new ModelParam(); param.name = UtilXml.checkEmpty(attribute.getAttribute("name")).intern(); + param.description = getCDATADef(attribute, "description"); param.type = UtilXml.checkEmpty(attribute.getAttribute("type")).intern(); param.mode = UtilXml.checkEmpty(attribute.getAttribute("mode")).intern(); param.entityName = UtilXml.checkEmpty(attribute.getAttribute("entity-name")).intern(); Modified: ofbiz/branches/jquery/framework/sql/build.xml URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/build.xml?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/build.xml (original) +++ ofbiz/branches/jquery/framework/sql/build.xml Wed Aug 11 13:22:40 2010 @@ -46,6 +46,9 @@ under the License. <pathelement location="src"/> </path> <filelist id="test.classes" dir="${src.dir}"> + <file name="org/ofbiz/sql/test/ValuesTest.java"/> + <file name="org/ofbiz/sql/test/ConditionsTest.java"/> + <file name="org/ofbiz/sql/test/SelectTest.java"/> <file name="org/ofbiz/sql/test/SQLTest.java"/> </filelist> Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BetweenCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BetweenCondition.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BetweenCondition.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BetweenCondition.java Wed Aug 11 13:22:40 2010 @@ -18,6 +18,9 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class BetweenCondition extends Condition { private final Value left; private final Value r1; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BooleanCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BooleanCondition.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BooleanCondition.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/BooleanCondition.java Wed Aug 11 13:22:40 2010 @@ -18,6 +18,9 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class BooleanCondition extends Condition { private final Value left; private final String op; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Condition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Condition.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Condition.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Condition.java Wed Aug 11 13:22:40 2010 @@ -26,5 +26,19 @@ public abstract class Condition extends void visit(ListCondition condition); } + public static class BaseVisitor implements Visitor { + public void visit(BetweenCondition condition) { + } + + public void visit(BooleanCondition condition) { + } + + public void visit(ConditionList condition) { + } + + public void visit(ListCondition condition) { + } + } + public abstract void accept(Visitor visitor); } Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ConditionList.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ConditionList.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ConditionList.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ConditionList.java Wed Aug 11 13:22:40 2010 @@ -21,8 +21,10 @@ package org.ofbiz.sql; import java.util.Iterator; import java.util.List; +import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.util.StringUtil; +@SourceMonitored public final class ConditionList extends Condition implements Iterable<Condition> { private final Joiner joiner; private final List<Condition> conditions; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/CountAllFunction.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/CountAllFunction.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/CountAllFunction.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/CountAllFunction.java Wed Aug 11 13:22:40 2010 @@ -18,7 +18,16 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class CountAllFunction extends StaticValue { + private final String tableName; + + public CountAllFunction(String tableName) { + this.tableName = tableName; + } + public void accept(Visitor visitor) { visitor.visit(this); } @@ -27,8 +36,25 @@ public final class CountAllFunction exte return "COUNT"; } + public String getTableName() { + return tableName; + } + + public boolean equals(Object o) { + if (o instanceof CountAllFunction) { + CountAllFunction other = (CountAllFunction) o; + return equalsHelper(tableName, other.tableName); + } else { + return false; + } + } + public StringBuilder appendTo(StringBuilder sb) { - sb.append("COUNT(*)"); + sb.append("COUNT("); + if (tableName != null) { + sb.append(tableName).append('.'); + } + sb.append("*)"); return sb; } } Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldAll.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldAll.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldAll.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldAll.java Wed Aug 11 13:22:40 2010 @@ -21,8 +21,10 @@ package org.ofbiz.sql; import java.util.Iterator; import java.util.Set; +import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.util.StringUtil; +@SourceMonitored public final class FieldAll extends Atom implements Iterable<String> { private final String alias; private final Set<String> exclude; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldDef.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldDef.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldDef.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldDef.java Wed Aug 11 13:22:40 2010 @@ -18,12 +18,15 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class FieldDef extends Atom { private final String alias; private final StaticValue value; public FieldDef(StaticValue value, String alias) { - this.alias = alias == null ? value.getDefaultName() : alias; + this.alias = alias; this.value = value; } @@ -31,6 +34,10 @@ public final class FieldDef extends Atom return alias; } + public String getDefaultName() { + return alias == null ? value.getDefaultName() : alias; + } + public StaticValue getValue() { return value; } @@ -38,7 +45,7 @@ public final class FieldDef extends Atom public boolean equals(Object o) { if (o instanceof FieldDef) { FieldDef other = (FieldDef) o; - return alias.equals(other.alias) && value.equals(other.value); + return equalsHelper(alias, other.alias) && value.equals(other.value); } else { return false; } @@ -46,7 +53,7 @@ public final class FieldDef extends Atom public StringBuilder appendTo(StringBuilder sb) { value.appendTo(sb); - if (!equalsHelper(value.getDefaultName(), alias)) { + if (alias != null) { sb.append(" AS ").append(alias); } return sb; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldValue.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldValue.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FieldValue.java Wed Aug 11 13:22:40 2010 @@ -18,6 +18,9 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class FieldValue extends StaticValue { private final String fieldName; private final String tableName; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FunctionCall.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FunctionCall.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FunctionCall.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/FunctionCall.java Wed Aug 11 13:22:40 2010 @@ -21,8 +21,10 @@ package org.ofbiz.sql; import java.util.Iterator; import java.util.List; +import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.util.StringUtil; +@SourceMonitored public final class FunctionCall extends StaticValue implements Iterable<Value> { private final String name; private final List<Value> values; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Joined.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Joined.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Joined.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/Joined.java Wed Aug 11 13:22:40 2010 @@ -76,8 +76,10 @@ public final class Joined extends Atom i tableName.appendTo(sb); sb.append(" ON "); for (int i = 0; i < keyMaps.size(); i++) { + KeyMap keyMap = keyMaps.get(i); if (i != 0) sb.append(" AND "); - keyMaps.get(i).appendTo(leftAlias, tableName.getAlias(), sb); + sb.append(' ').append(leftAlias).append('.').append(keyMap.getLeftFieldName()); + sb.append(" = ").append(tableName.getAlias()).append('.').append(keyMap.getRightFieldName()); } if (joined != null) { joined.appendTo(tableName.getAlias(), sb); Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/KeyMap.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/KeyMap.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/KeyMap.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/KeyMap.java Wed Aug 11 13:22:40 2010 @@ -18,7 +18,7 @@ */ package org.ofbiz.sql; -public final class KeyMap extends Atom { +public final class KeyMap { private final String leftFieldName; private final String rightFieldName; @@ -43,15 +43,4 @@ public final class KeyMap extends Atom { return false; } } - - public StringBuilder appendTo(StringBuilder sb) { - return appendTo("left", "right", sb); - } - - public StringBuilder appendTo(String leftAlias, String rightAlias, StringBuilder sb) { - sb.append(leftAlias).append('.').append(leftFieldName); - sb.append(" = "); - sb.append(rightAlias).append('.').append(rightFieldName); - return sb; - } } Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ListCondition.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ListCondition.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ListCondition.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ListCondition.java Wed Aug 11 13:22:40 2010 @@ -20,8 +20,10 @@ package org.ofbiz.sql; import java.util.List; +import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.util.StringUtil; +@SourceMonitored public final class ListCondition extends Condition { private final Value left; private final String op; Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/MathValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/MathValue.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/MathValue.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/MathValue.java Wed Aug 11 13:22:40 2010 @@ -21,8 +21,10 @@ package org.ofbiz.sql; import java.util.Iterator; import java.util.List; +import org.ofbiz.base.lang.SourceMonitored; import org.ofbiz.base.util.StringUtil; +@SourceMonitored public final class MathValue extends StaticValue implements Iterable<ConstantValue> { private final String op; private final List<ConstantValue> values; @@ -59,7 +61,7 @@ public final class MathValue extends Sta public StringBuilder appendTo(StringBuilder sb) { sb.append('('); - StringUtil.appendTo(sb, values, " ", null, op); + StringUtil.appendTo(sb, values, null, null, " ", op, " "); sb.append(')'); return sb; } Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/NumberValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/NumberValue.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/NumberValue.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/NumberValue.java Wed Aug 11 13:22:40 2010 @@ -18,9 +18,20 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class NumberValue<N extends Number> extends ConstantValue { private final N number; + public static NumberValue<Long> valueOf(long v) { + return new NumberValue<Long>(v); + } + + public static NumberValue<Double> valueOf(double v) { + return new NumberValue<Double>(v); + } + public NumberValue(N number) { this.number = number; } Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/OrderByItem.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/OrderByItem.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/OrderByItem.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/OrderByItem.java Wed Aug 11 13:22:40 2010 @@ -18,44 +18,46 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class OrderByItem extends Atom { public enum Order { DEFAULT, ASCENDING, DESCENDING }; + public enum Nulls { DEFAULT, FIRST, LAST }; private final Order order; - private final String functionName; - private final String fieldName; + private final Nulls nulls; + private final ConstantValue value; - public OrderByItem(Order order, String functionName, String fieldName) { + public OrderByItem(Order order, Nulls nulls, ConstantValue value) { this.order = order; - this.functionName = functionName; - this.fieldName = fieldName; + this.nulls = nulls; + this.value = value; } public final Order getOrder() { return order; } - public final String getFunctionName() { - return functionName; + public final Nulls getNulls() { + return nulls; } - public final String getFieldName() { - return fieldName; + public final ConstantValue getValue() { + return value; } public boolean equals(Object o) { if (o instanceof OrderByItem) { OrderByItem other = (OrderByItem) o; - return order.equals(other.order) && equalsHelper(functionName, other.functionName) && fieldName.equals(other.fieldName); + return order.equals(other.order) && nulls.equals(other.nulls) && value.equals(other.value); } else { return false; } } public StringBuilder appendTo(StringBuilder sb) { - if (functionName != null) sb.append(functionName).append('('); - sb.append(fieldName); - if (functionName != null) sb.append(')'); + value.appendTo(sb); switch (order) { case ASCENDING: sb.append(" ASC"); @@ -64,6 +66,14 @@ public final class OrderByItem extends A sb.append(" DESC"); break; } + switch (nulls) { + case FIRST: + sb.append(" NULLS FIRST"); + break; + case LAST: + sb.append(" NULLS LAST"); + break; + } return sb; } } Modified: ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ParameterValue.java URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ParameterValue.java?rev=984399&r1=984398&r2=984399&view=diff ============================================================================== --- ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ParameterValue.java (original) +++ ofbiz/branches/jquery/framework/sql/src/org/ofbiz/sql/ParameterValue.java Wed Aug 11 13:22:40 2010 @@ -18,6 +18,9 @@ */ package org.ofbiz.sql; +import org.ofbiz.base.lang.SourceMonitored; + +@SourceMonitored public final class ParameterValue extends Value { private final String name; |
| Free forum by Nabble | Edit this page |
