@Test public void testFormatFilterCriteria() throws Exception { FilterCriteria filterCriteria = new FilterCriteria(); List<Object> hostVariableValueList = new ArrayList<Object>(); testformatFilterCriteriaException(null, hostVariableValueList, "filterCriteria"); testformatFilterCriteriaException(filterCriteria, hostVariableValueList, "operation"); filterCriteria.setOperation(FilterCriteria.Operation.EQUAL); testformatFilterCriteriaException(filterCriteria, hostVariableValueList, "field name"); filterCriteria.setFieldName("myField"); filterCriteria.setValue("foo"); Assert.assertTrue("myField =?".equals(generator.formatFilterCriteria(filterCriteria, hostVariableValueList))); Assert.assertTrue(hostVariableValueList.size()==1); Assert.assertTrue("foo".equals(hostVariableValueList.get(0))); hostVariableValueList.clear(); filterCriteria.setOperation(FilterCriteria.Operation.IS_NULL); Assert.assertTrue("myField is null ".equals(generator.formatFilterCriteria(filterCriteria, hostVariableValueList))); Assert.assertTrue(hostVariableValueList.size()==0); hostVariableValueList.clear(); filterCriteria.setOperation(FilterCriteria.Operation.IS_NOT_NULL); Assert.assertTrue("myField is not null ".equals(generator.formatFilterCriteria(filterCriteria, hostVariableValueList))); Assert.assertTrue(hostVariableValueList.size()==0); }
protected String formatFilterCriteria(FilterCriteria filterCriteria, List<Object> hostVariableValueList) { Validate.notNull(filterCriteria, "Null filterCriteria not allowed."); Validate.notNull(filterCriteria.getOperation(), "Null operation not allowed. criteria="+filterCriteria); Validate.notEmpty(filterCriteria.getFieldName(), "Null or blank field name not allowed."); StringBuilder builder = new StringBuilder(); builder.append(filterCriteria.getFieldName()); builder.append(" "); builder.append(this.formatConditionOperation(filterCriteria.getOperation())); if ( !FilterCriteria.Operation.IS_NULL.equals(filterCriteria.getOperation()) && !FilterCriteria.Operation.IS_NOT_NULL.equals(filterCriteria.getOperation())) { hostVariableValueList.add(filterCriteria.getValue()); builder.append("?"); } return builder.toString(); }
DefaultSqlGenerator implements SqlGenerator { protected String formatFilterCriteria(FilterCriteria filterCriteria, List<Object> hostVariableValueList) { Validate.notNull(filterCriteria, "Null filterCriteria not allowed."); Validate.notNull(filterCriteria.getOperation(), "Null operation not allowed. criteria="+filterCriteria); Validate.notEmpty(filterCriteria.getFieldName(), "Null or blank field name not allowed."); StringBuilder builder = new StringBuilder(); builder.append(filterCriteria.getFieldName()); builder.append(" "); builder.append(this.formatConditionOperation(filterCriteria.getOperation())); if ( !FilterCriteria.Operation.IS_NULL.equals(filterCriteria.getOperation()) && !FilterCriteria.Operation.IS_NOT_NULL.equals(filterCriteria.getOperation())) { hostVariableValueList.add(filterCriteria.getValue()); builder.append("?"); } return builder.toString(); } }
DefaultSqlGenerator implements SqlGenerator { protected String formatFilterCriteria(FilterCriteria filterCriteria, List<Object> hostVariableValueList) { Validate.notNull(filterCriteria, "Null filterCriteria not allowed."); Validate.notNull(filterCriteria.getOperation(), "Null operation not allowed. criteria="+filterCriteria); Validate.notEmpty(filterCriteria.getFieldName(), "Null or blank field name not allowed."); StringBuilder builder = new StringBuilder(); builder.append(filterCriteria.getFieldName()); builder.append(" "); builder.append(this.formatConditionOperation(filterCriteria.getOperation())); if ( !FilterCriteria.Operation.IS_NULL.equals(filterCriteria.getOperation()) && !FilterCriteria.Operation.IS_NOT_NULL.equals(filterCriteria.getOperation())) { hostVariableValueList.add(filterCriteria.getValue()); builder.append("?"); } return builder.toString(); } DefaultSqlGenerator(); }
DefaultSqlGenerator implements SqlGenerator { protected String formatFilterCriteria(FilterCriteria filterCriteria, List<Object> hostVariableValueList) { Validate.notNull(filterCriteria, "Null filterCriteria not allowed."); Validate.notNull(filterCriteria.getOperation(), "Null operation not allowed. criteria="+filterCriteria); Validate.notEmpty(filterCriteria.getFieldName(), "Null or blank field name not allowed."); StringBuilder builder = new StringBuilder(); builder.append(filterCriteria.getFieldName()); builder.append(" "); builder.append(this.formatConditionOperation(filterCriteria.getOperation())); if ( !FilterCriteria.Operation.IS_NULL.equals(filterCriteria.getOperation()) && !FilterCriteria.Operation.IS_NOT_NULL.equals(filterCriteria.getOperation())) { hostVariableValueList.add(filterCriteria.getValue()); builder.append("?"); } return builder.toString(); } DefaultSqlGenerator(); SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria,
			String[] fieldNames); }
DefaultSqlGenerator implements SqlGenerator { protected String formatFilterCriteria(FilterCriteria filterCriteria, List<Object> hostVariableValueList) { Validate.notNull(filterCriteria, "Null filterCriteria not allowed."); Validate.notNull(filterCriteria.getOperation(), "Null operation not allowed. criteria="+filterCriteria); Validate.notEmpty(filterCriteria.getFieldName(), "Null or blank field name not allowed."); StringBuilder builder = new StringBuilder(); builder.append(filterCriteria.getFieldName()); builder.append(" "); builder.append(this.formatConditionOperation(filterCriteria.getOperation())); if ( !FilterCriteria.Operation.IS_NULL.equals(filterCriteria.getOperation()) && !FilterCriteria.Operation.IS_NOT_NULL.equals(filterCriteria.getOperation())) { hostVariableValueList.add(filterCriteria.getValue()); builder.append("?"); } return builder.toString(); } DefaultSqlGenerator(); SqlStatement generateSelect(Topic topic, CompositeCriteria searchCriteria,
			String[] fieldNames);  }