Commit 96328138 authored by Peter Harrison's avatar Peter Harrison

#45 - modified the Model of Filter to use a Map rather than a List for

the conditions. This allows multiple conditions under Oak.
parent 62369710
......@@ -23,6 +23,7 @@ package nz.net.orcon.kanban.model;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.apache.jackrabbit.ocm.manager.enumconverter.EnumTypeConverter;
import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
......@@ -47,7 +48,7 @@ public class Filter extends AbstractNamedModelClass implements Serializable{
private AccessType access;
@Collection(jcrMandatory=false)
private List<Condition> conditions;
private Map<String,Condition> conditions;
public void setExpression(String expression) {
this.expression = expression;
......@@ -57,11 +58,11 @@ public class Filter extends AbstractNamedModelClass implements Serializable{
return expression;
}
public void setConditions(List<Condition> conditions) {
public void setConditions(Map<String,Condition> conditions) {
this.conditions = conditions;
}
public List<Condition> getConditions() {
public Map<String,Condition> getConditions() {
return conditions;
}
......
......@@ -121,7 +121,7 @@ public class ListTools {
}
if( filter!=null){
for( Condition condition : filter.getConditions()){
for( Condition condition : filter.getConditions().values()){
String ex = genEx( condition.getOperation().getExpression(),
condition.getFieldName(),condition.getValue());
......@@ -154,7 +154,7 @@ public class ListTools {
}
if( filter!=null){
for( Condition condition : filter.getConditions()){
for( Condition condition : filter.getConditions().values()){
qmFilter.addJCRExpression( genEx(condition.getOperation().getExpression(),
condition.getFieldName(), condition.getValue()));
}
......
......@@ -28,6 +28,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -194,12 +195,12 @@ public class FilterControllerTest {
}
private Filter getTestFilter(String filterName, String fieldName, Operation operation, String value) {
List<Condition> conditions = new ArrayList<Condition>();
Map<String,Condition> conditions = new HashMap<String,Condition>();
Condition condition = new Condition();
condition.setFieldName(fieldName);
condition.setOperation(operation);
condition.setValue(value);
conditions.add(condition);
conditions.put("a", condition);
Filter filter = new Filter();
filter.setName(filterName);
......
......@@ -145,8 +145,8 @@ public class TestBoardTool {
condition.setFieldName(fieldName);
condition.setValue(value);
condition.setOperation(operation);
List<Condition> conditions = new ArrayList<Condition>();
conditions.add(condition);
Map<String,Condition> conditions = new HashMap<String,Condition>();
conditions.put("a",condition);
Filter filter = new Filter();
filter.setName(name);
filter.setAccess(AccessType.READ);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment