diff --git a/src/main/java/info/bukova/isspst/data/Building.java b/src/main/java/info/bukova/isspst/data/Building.java index e3be3304..7730055e 100644 --- a/src/main/java/info/bukova/isspst/data/Building.java +++ b/src/main/java/info/bukova/isspst/data/Building.java @@ -3,38 +3,33 @@ package info.bukova.isspst.data; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Table; -import javax.validation.constraints.NotNull; import org.hibernate.validator.constraints.NotBlank; -import org.hibernate.validator.constraints.NotEmpty; @Entity -@Table(name="BUILDING") +@Table(name = "BUILDING") public class Building extends BaseData implements DataModel { - - @Column(name="CODE", unique=true) + @Column(name = "CODE", unique = true) private String code; - - @Column(name="NAME") + + @Column(name = "NAME") private String name; - - @Column(name="DESCRIPTION") + + @Column(name = "DESCRIPTION") private String description; - /** * @return the code */ - @NotBlank(message = "${labels.BuildingsFormCodeConstr}") - @NotNull(message = "${labels.BuildingsFormCodeConstr}") - @NotEmpty(message = "${labels.BuildingsFormCodeConstr}") + @NotBlank(message = "{BuildingsFormCodeConstr}") public String getCode() { return code; } /** - * @param code the code to set + * @param code + * the code to set */ public void setCode(String code) { this.code = code; @@ -48,7 +43,8 @@ public class Building extends BaseData implements DataModel { } /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; @@ -62,7 +58,8 @@ public class Building extends BaseData implements DataModel { } /** - * @param description the description to set + * @param description + * the description to set */ public void setDescription(String description) { this.description = description; diff --git a/src/main/java/info/bukova/isspst/filters/BuildingFilter.java b/src/main/java/info/bukova/isspst/filters/BuildingFilter.java new file mode 100644 index 00000000..787c6a22 --- /dev/null +++ b/src/main/java/info/bukova/isspst/filters/BuildingFilter.java @@ -0,0 +1,56 @@ +package info.bukova.isspst.filters; + +import static info.bukova.isspst.StringUtils.nullStr; +import info.bukova.isspst.data.Building; + +import org.hamcrest.Description; +import org.hamcrest.Factory; +import org.hamcrest.Matcher; +import org.hamcrest.TypeSafeMatcher; + +public class BuildingFilter implements Filter { + + private Building condBuilding; + + public BuildingFilter(Building condBuilding) { + this.condBuilding = condBuilding; + } + + private static class BuildingMatcher extends TypeSafeMatcher { + + private Building condBuilding; + + public BuildingMatcher(Building cond) { + this.condBuilding = cond; + } + + @Override + public void describeTo(Description desc) { + desc.appendText("buildings matches"); + } + + @Override + public boolean matchesSafely(Building item) { + return nullStr(item.getCode()).toLowerCase().contains(nullStr(condBuilding.getCode()).toLowerCase()) + && nullStr(item.getName()).toLowerCase().contains(nullStr(condBuilding.getName()).toLowerCase()) + && nullStr(item.getDescription()).toLowerCase().contains(nullStr(condBuilding.getDescription()).toLowerCase()); + } + + @Factory + public static Matcher matchBuilding(Building building) { + return new BuildingMatcher(building); + } + } + + @Override + public BuildingMatcher matcher() { + return new BuildingMatcher(condBuilding); + } + + @Override + public String queryString() { + // TODO query string + return ""; + } + +} diff --git a/src/main/resources/ValidationMessages.properties b/src/main/resources/ValidationMessages.properties new file mode 100644 index 00000000..ebe76fac --- /dev/null +++ b/src/main/resources/ValidationMessages.properties @@ -0,0 +1 @@ +BuildingsFormCodeConstr=Zadejte k\u00f3d budovy... \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/zk-label.properties b/src/main/webapp/WEB-INF/zk-label.properties index a072d70c..e8f09376 100644 --- a/src/main/webapp/WEB-INF/zk-label.properties +++ b/src/main/webapp/WEB-INF/zk-label.properties @@ -2,7 +2,6 @@ AgendaBuildings=Budovy BuildingsFormCode=Kód -BuildingsFormCodeConstr=Zadejte kód budovy... BuildingsFormName=Název BuildingsFormDescription=Popis