19 package org.turro.alliance.client.model;
21 import java.util.ArrayList;
22 import java.util.List;
23 import org.turro.alliance.db.AlliancePU;
24 import org.turro.alliance.service.AxConstants;
25 import org.turro.alliance.service.AxServer;
26 import org.turro.dossier.entity.Dossier;
27 import org.turro.elephant.util.Toasts;
28 import org.turro.i18n.I_;
29 import org.turro.jpa.Dao;
30 import org.turro.json.Jsons;
31 import org.turro.member.db.entities.AxProjectCategory;
32 import org.turro.sql.SqlClause;
33 import org.turro.ws.WsServer;
34 import org.turro.ws.service.member.Servers;
35 import org.zkoss.bind.annotation.BindingParam;
36 import org.zkoss.bind.annotation.Command;
37 import org.zkoss.bind.annotation.ExecutionArgParam;
38 import org.zkoss.bind.annotation.Init;
39 import org.zkoss.bind.annotation.NotifyChange;
40 import org.zkoss.zk.ui.Executions;
51 public void init(@ExecutionArgParam(
"dossier")
Dossier dossier) {
52 if(dossier !=
null) this.dossier = dossier;
53 if(this.dossier ==
null) {
54 this.dossier = (
Dossier) Executions.getCurrent().getAttribute(
"dossier");
63 this.needsSave = needsSave;
66 @NotifyChange(
"model")
69 if(server !=
null && !inModel(server)) {
80 @NotifyChange(
"model")
84 model.stream().filter(pc -> pc.isEmpty())
86 model.removeIf(pc -> pc.isEmpty());
93 @NotifyChange(
"model")
96 deletions.add(category);
97 model.removeIf(pc -> pc.getServerDomain().equals(category.getServerDomain()));
103 private boolean needsSave;
105 private List<AxProjectCategory> model;
106 private List<AxProjectCategory> deletions =
new ArrayList<>();
110 model = SqlClause.select(
"pc").from(
"AxProjectCategory pc")
111 .where().equal(
"pc.projectId", String.valueOf(dossier.
getId()))
118 private boolean inModel(
WsServer server) {
119 return model.stream().anyMatch(apc -> apc.getServerDomain().equals(server.
getServerDomain()));
131 this.server = server;
List< AxProjectCategory > getModel()
void init(@ExecutionArgParam("dossier") Dossier dossier)
void setNeedsSave(boolean needsSave)
Jsons getCategories(AxProjectCategory pc)
void setServer(WsServer server)
void delete(@BindingParam("category") AxProjectCategory category)
static final String SERVER_SERVICE
static Toasts message(String message)
static String get(String msg)
void deleteEntity(IDaoEntity entity)
void deleteCollection(Collection objs)
void saveEntities(Collection<? extends IDaoEntity > entities)
void setServerDomain(String serverDomain)
void setDossier(Dossier dossier)
static WsServer from(String serverDomain, String service)