1 6 7 package info.magnolia.cms.gui.controlx.search; 8 9 import info.magnolia.cms.gui.controlx.impl.AbstractControl; 10 import info.magnolia.cms.gui.query.SearchQueryExpression; 11 import info.magnolia.cms.gui.query.StringSearchQueryParameter; 12 13 import org.apache.commons.lang.StringUtils; 14 15 16 21 public class SearchControl extends AbstractControl { 22 23 public static final String RENDER_TYPE = "searchControl"; 24 25 private SearchControlDefinition definition; 26 27 private String value; 28 29 private String constraint; 30 31 public SearchControl() { 32 this.setRenderType(RENDER_TYPE); 33 } 34 35 40 public SearchControl(SearchControlDefinition definition, String value, String condition) { 41 this(); 42 this.definition = definition; 43 this.value = value; 44 this.constraint = condition; 45 } 46 47 50 public String getConstraint() { 51 return constraint; 52 } 53 54 57 public void setConstraint(String condition) { 58 this.constraint = condition; 59 } 60 61 64 public SearchControlDefinition getDefinition() { 65 return definition; 66 } 67 68 71 public void setDefinition(SearchControlDefinition definition) { 72 this.definition = definition; 73 } 74 75 78 public String getValue() { 79 return value; 80 } 81 82 85 public void setValue(String value) { 86 this.value = value; 87 } 88 89 92 public SearchQueryExpression getExpression() { 93 String value = this.getValue().toString(); 94 if (StringUtils.isNotEmpty(value)) { 95 return new StringSearchQueryParameter(this.getDefinition().getColumn(), value, this.getConstraint()); 96 } 97 return null; 98 } 99 100 } 101 | Popular Tags |