BrightSide Workbench Full Report + Source Code
CentersVM.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2024 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.alliance.www;
20 
21 import java.util.Collections;
22 import java.util.List;
23 import org.turro.alliance.db.AlliancePU;
24 import org.turro.alliance.db.entities.AxCenter;
25 import org.turro.jpa.Dao;
26 import org.turro.sql.SqlClause;
27 import org.turro.string.Strings;
28 import org.turro.util.Cached;
29 import org.zkoss.bind.annotation.Command;
30 import org.zkoss.bind.annotation.NotifyChange;
31 
36 public class CentersVM {
37 
38  /* Search */
39 
40  private String search;
41 
42  public String getSearch() {
43  return search;
44  }
45 
46  public void setSearch(String search) {
47  this.search = search;
48  }
49 
50  @NotifyChange("model")
51  @Command("search")
52  public void search() {
53 
54  }
55 
56  /* Model */
57 
58  public List<AxCenter> getModel() {
59  if(Strings.isBlank(search)) return Collections.EMPTY_LIST;
60  return SqlClause.select("c").from("AxCenter c")
61  .where().partial(search, "c.name", "c.email")
62  .orderBy("c.name")
63  .dao(dao.get())
64  .resultList(AxCenter.class);
65  }
66 
67  /* Dao */
68 
69  private final Cached<Dao> dao = Cached.instance(() -> new AlliancePU());
70 
71 }
List< AxCenter > getModel()
Definition: CentersVM.java:58
void setSearch(String search)
Definition: CentersVM.java:46