Fixed a bug in StringProperty.in(String[]) that makes hiding emergent tags work

pull/14/head
Sam Bosley 13 years ago
parent 28d05d6325
commit 6060b21757

@ -5,7 +5,14 @@
*/
package com.todoroo.andlib.data;
import static com.todoroo.andlib.sql.SqlConstants.COMMA;
import static com.todoroo.andlib.sql.SqlConstants.LEFT_PARENTHESIS;
import static com.todoroo.andlib.sql.SqlConstants.RIGHT_PARENTHESIS;
import static com.todoroo.andlib.sql.SqlConstants.SPACE;
import com.todoroo.andlib.sql.Criterion;
import com.todoroo.andlib.sql.Field;
import com.todoroo.andlib.sql.Operator;
/**
* Property represents a typed column in a database.
@ -150,6 +157,21 @@ public abstract class Property<TYPE> extends Field implements Cloneable {
PropertyVisitor<RETURN, PARAMETER> visitor, PARAMETER data) {
return visitor.visitString(this, data);
}
public Criterion in(final String[] value) {
final Field field = this;
return new Criterion(Operator.in) {
@Override
protected void populate(StringBuilder sb) {
sb.append(field).append(SPACE).append(Operator.in).append(SPACE).append(LEFT_PARENTHESIS).append(SPACE);
for (String s : value) {
sb.append("\"").append(s.toString()).append("\"").append(COMMA);
}
sb.deleteCharAt(sb.length() - 1).append(RIGHT_PARENTHESIS);
}
};
}
}
/**

@ -11,7 +11,7 @@ import static com.todoroo.andlib.sql.SqlConstants.SPACE;
public abstract class Criterion {
protected final Operator operator;
Criterion(Operator operator) {
public Criterion(Operator operator) {
this.operator = operator;
}

@ -2,24 +2,24 @@ package com.todoroo.andlib.sql;
@SuppressWarnings("nls")
public final class SqlConstants {
static final String SELECT = "SELECT";
static final String DISTINCT = "DISTINCT";
static final String SPACE = " ";
static final String AS = "AS";
static final String COMMA = ",";
static final String FROM = "FROM";
static final String ON = "ON";
static final String JOIN = "JOIN";
static final String ALL = "*";
static final String LEFT_PARENTHESIS = "(";
static final String RIGHT_PARENTHESIS = ")";
static final String AND = "AND";
static final String BETWEEN = "BETWEEN";
static final String LIKE = "LIKE";
static final String OR = "OR";
static final String ORDER_BY = "ORDER BY";
static final String GROUP_BY = "GROUP BY";
static final String WHERE = "WHERE";
public static final String SELECT = "SELECT";
public static final String DISTINCT = "DISTINCT";
public static final String SPACE = " ";
public static final String AS = "AS";
public static final String COMMA = ",";
public static final String FROM = "FROM";
public static final String ON = "ON";
public static final String JOIN = "JOIN";
public static final String ALL = "*";
public static final String LEFT_PARENTHESIS = "(";
public static final String RIGHT_PARENTHESIS = ")";
public static final String AND = "AND";
public static final String BETWEEN = "BETWEEN";
public static final String LIKE = "LIKE";
public static final String OR = "OR";
public static final String ORDER_BY = "ORDER BY";
public static final String GROUP_BY = "GROUP BY";
public static final String WHERE = "WHERE";
public static final String EXISTS = "EXISTS";
public static final String NOT = "NOT";
public static final String LIMIT = "LIMIT";

@ -325,7 +325,7 @@ public final class TagService {
tagData.readFromCursor(cursor);
String tagName = tagData.getValue(TagData.NAME).trim();
Tag tag = new Tag(tagData);
if(tagData.getValue(TagData.DELETION_DATE) > 0) {
if(tagData.getValue(TagData.DELETION_DATE) > 0 || tagData.getFlag(TagData.FLAGS, TagData.FLAG_EMERGENT)) {
tags.remove(tagName);
continue;
}

Loading…
Cancel
Save